ProcessViewBrowser-ServerProgramming
Functions
Initialisation and global routines

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)

Detailed Description

These routines are used for initialisation. And also some global usable routines are available.


Function Documentation

int getFloats ( const char *  text,
FloatArray fa 
)
Get integer array from string for script language
int getIntegers ( const char *  text,
IntegerArray ia 
)
Get integer array from string for script language
const char* getTextFromText ( const char *  text)
Get text in parentesis from text for script language
int glencode_set_param ( PARAM p)
int pvAccept ( PARAM p)
see pvInit
int pvClientCommand ( PARAM p,
const char *  command,
const char *  filename 
)
Run command on client.
command := pdf | img | svg | txt | csv | html | audio | video
See view.pdf, view.img, view.svg ... within pvbrowser options.
int pvCreateThread ( PARAM p,
int  s 
)
see pvInit
char* pvGetEvent ( PARAM p)
If it is necessary to cleanup your application when the main worker thread terminates
you can set an exit handler that receives the data in app_data.
Call this function in pvMain. See also pvMain.
int pvGetInitialMask ( PARAM p)
Get the initial mask the user wants to see
p->initial_mask is a string identifying the initial mask 
void pvGetLocalTime ( pvTime pvtime)
Get local time
int* pvGetSocketPointer ( PARAM p)
Get a pointer to the socket for script language
int pvGlUpdate ( PARAM p,
int  id 
)
update OpenGL widget
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 pvInitInternal ( PARAM p)
see pvInit
Init for script languages
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.
int pvlock ( PARAM p)
If you access variables that are global to the server or
if you want to use malloc() and free()
you must surround the operations with
pvlock() and pvunlock()
because these operations are not thread save.
int pvMain ( PARAM p)
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 pvMainFatal ( PARAM p,
const char *  text 
)
Output a fatal message and terminate the whole server.
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;
     }
   }
 }
int pvScreenHint ( PARAM p,
int  w,
int  h 
)
Output a screenHint for calculating the zoom factor
Optimal screen width=w height=h .
int pvSendVersion ( PARAM p)
Send version of pvserver to client
int pvSetCleanup ( PARAM p,
int(*)(void *)  cleanup,
void *  app_data 
)
If it is necessary to cleanup your application when the main worker thread terminates
you can set an exit handler that receives the data in app_data.
Call this function in pvMain. See also pvMain.
int pvSetManualUrl ( PARAM p,
const char *  url 
)
Set the URL which will be used for Help->Manual within pvbrowser.
default: index.html
You could also set the URL of a webserver which hosts your documentation.
Example:
pvSetManualUrl(p,"http://your.server.org");
int pvSetMouseShape ( PARAM p,
int  shape 
)
Set mouse shape
MouseShape.
int pvSetWhatsThis ( PARAM p,
int  id,
const char *  text 
)
Set whatsThis text
Allowed Widgets: all Widgets
int pvSetXY ( PARAM p,
int  i,
float  x,
float  y 
)
Set x,y array for script language
int pvSleep ( int  milliseconds)
Sleep for milliseconds.
int pvsystem ( const char *  command)
Same as system(command); but portable
int pvThreadFatal ( PARAM p,
const char *  text 
)
Output a fatal message and terminate the worker thread.
int pvunlock ( PARAM p)
If you access variables that are global to the server or
if you want to use malloc() and free()
you must surround the operations with
pvlock() and pvunlock()
because these operations are not thread save.
int pvWait ( PARAM p,
const char *  pattern 
)
waits for an event.
int pvWarning ( PARAM p,
const char *  text 
)
Output a warning message.
int pvWhatsThisPrintf ( PARAM p,
int  id,
const char *  format,
  ... 
)
printf whatsThis text
Allowed Widgets: all Widgets
int pvXYAllocate ( PARAM p,
int  n 
)
Allocate x,y array for script language
int pvZoomMask ( PARAM p,
int  percent 
)
Zoom the whole mask.
Zoom factor in percent.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines