Functions |
| int | glencode_set_param (PARAM *p) |
| int | pvlock (PARAM *p) |
| int | pvunlock (PARAM *p) |
| int | pvsystem (const char *command) |
| void | pvGetLocalTime (pvTime *pvtime) |
| int | pvIsAccessAllowed (const char *adr, int trace) |
| int | pvSendVersion (PARAM *p) |
| int | pvXYAllocate (PARAM *p, int n) |
| int | getIntegers (const char *text, IntegerArray *ia) |
| int | getFloats (const char *text, FloatArray *fa) |
| const char * | getTextFromText (const char *text) |
| int | pvSetXY (PARAM *p, int i, float x, float y) |
| int * | pvGetSocketPointer (PARAM *p) |
| int | pvInitInternal (PARAM *p) |
| int | pvInit (int ac, char **av, PARAM *p) |
| int | pvAccept (PARAM *p) |
| int | pvCreateThread (PARAM *p, int s) |
| int | pvGetInitialMask (PARAM *p) |
| int | pvMain (PARAM *p) |
| int | pvSetCleanup (PARAM *p, int(*cleanup)(void *), void *app_data) |
| char * | pvGetEvent (PARAM *p) |
| int | pvPollEvent (PARAM *p, char *event) |
| int | pvWait (PARAM *p, const char *pattern) |
| int | pvGlUpdate (PARAM *p, int id) |
| int | pvSleep (int milliseconds) |
| int | pvWarning (PARAM *p, const char *text) |
| int | pvMainFatal (PARAM *p, const char *text) |
| int | pvThreadFatal (PARAM *p, const char *text) |
| int | pvScreenHint (PARAM *p, int w, int h) |
| int | pvSetMouseShape (PARAM *p, int shape) |
| int | pvSetWhatsThis (PARAM *p, int id, const char *text) |
| int | pvWhatsThisPrintf (PARAM *p, int id, const char *format,...) |
| int | pvClientCommand (PARAM *p, const char *command, const char *filename) |
| int | pvZoomMask (PARAM *p, int percent) |
| int | pvSetManualUrl (PARAM *p, const char *url) |
These routines are used for initialisation. And also some global usable routines are available.
| int pvInit |
( |
int |
ac, |
|
|
char ** |
av, |
|
|
PARAM * |
p |
|
) |
| |
(Test) pvInit must be called in main(). It interprets the command line switches that it knows.
Afterwards you can interpret your command line switches. It is possible to set p.user to data
of your choice. This data will be available in the worker threads. (Caution: the worker threads are
only allowed to read the p.user data because it is shared among all clients)
Then there must be a while(1) in which new clients are accepted. For each client a new thread
is created.
int main(int ac, char **av)
{
PARAM p;
int s; pvInit(ac,av,&p);
here you may interpret ac,av and set p.user to your data
while(1)
{
s = pvAccept(&p);
if(s != -1) pvCreateThread(&p,s);
}
return 0;
}
| int pvIsAccessAllowed |
( |
const char * |
adr, |
|
|
int |
trace |
|
) |
| |
Test if access is allowed by files "allow.ipv4" and "deny.ipv4" in your local directory
adr := dottet ip address
trace = 1 print messages on stdout
trace = 0 do not print messages on stdout
return = 1 access allowed
return = 0 access is not allowed
Example allow.ipv4:
1.0.0.127/32 # allow localhost
192.168.1.0/24 # allow 192.168.1.0 - 192.168.1.255
# insert more areas here
Example deny.ipv4:
# deny a individual address
192.168.2.14/32
# insert more areas here
The number behind the / is the number of significant bits of the ip address.
Every pvserver will evaluate "allow.ipv4 and "deny.ipv4" when client connects.
pvMain is your main worker thread. It could look as follows.
The main worker thread is never closed. It will be closed automatically when the client disconnects.
int pvMain(PARAM *p)
{
int ret;here you can initialize your worker thread
pvSetCleanup(p,your_exit_handler,your_app_data); // if cleanup is necessary
pvResize(p,0,970,600); // this will resize your working area
ret = showMask1(p);
while(1)
{
switch(ret)
{
case 1:
ret = showMask1(p);
break;
case 2:
ret = showMask2(p);
break;
case 3:
ret = showMask3(p);
break;
default:
return 0;
}
}
}
| int pvPollEvent |
( |
PARAM * |
p, |
|
|
char * |
event |
|
) |
| |
This function will return the next event as soon as it is available.
The maximum wait time is p->sleep in milliseconds (default 100).
You can specify a different wait time on the commandline (-sleep=1000)
Example:
int showMask1(PARAM *p)
{
DATA d;
char event[MAX_EVENT_LENGTH];
int i;
char text[MAX_EVENT_LENGTH]; defineMask1(p);
readData1(&d); // from shared memory or out of database
showData1(p,&d);
while(1)
{
pvPollEvent(p,event);
switch(pvParseEvent(event, &i, text))
{
case NULL_EVENT:
readData1(&d); // from shared memory or out of database
showData1(p,&d);
break;
case BUTTON_EVENT:
...
break;
case TEXT_EVENT:
...
break;
default:
printf("UNKNOWN_EVENT id=\%d \%s\\n",i,text);
break;
}
}
}