Xcall.c

Go to the documentation of this file.
00001 /* C code produced by gperf version 3.0.1 */
00002 /* Command-line: gperf -C -t -k '2,3,4,$' Xcall.gperf  */
00003 
00004 /* #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ */
00005 /*       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ */
00006 /*       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ */
00007 /*       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ */
00008 /*       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ */
00009 /*       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ */
00010 /*       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ */
00011 /*       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ */
00012 /*       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ */
00013 /*       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ */
00014 /*       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ */
00015 /*       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ */
00016 /*       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ */
00017 /*       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ */
00018 /*       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ */
00019 /*       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ */
00020 /*       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ */
00021 /*       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ */
00022 /*       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ */
00023 /*       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ */
00024 /*       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ */
00025 /*       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ */
00026 /*       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) */
00027 /* /\* The character set is not based on ISO-646.  *\/ */
00028 /* error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." */
00029 /* #endif */
00030 
00031 
00032 /* #line 1 "Xcall.gperf" */
00033 /*------------------------------------------------------------------------
00034    *  Graphic library for 2D and 3D plotting 
00035    *  Copyright (C) 1998-2001 Chancelier Jean-Philippe
00036    * jpc@cermics.enpc.fr 
00037    *  Copyright (C) 1998-2006 INRIA (Serge Steer, Fabrice Leray, Jean-Baptiste Silvy, Allan Cornet, Pierre Marechal)
00038    --------------------------------------------------------------------------*/
00039 #include <string.h>
00040 #include <stdio.h>
00041 
00042 #ifdef MAC
00043 #include "../machine.h"
00044 #include "periMac.h"
00045 #else 
00046 #include "math_graphics.h"
00047 #ifdef _MSC_VER
00048 #include "periWin.h"
00049 #else
00050 #include "periX11.h"
00051 #endif
00052 #endif 
00053 
00054 #include "periPos.h"
00055 #include "periFig.h"
00056 #include "periGif.h"
00057 #include "Xcall1.h"
00058 #include "sciprint.h"
00059 #include "DestroyObjects.h"
00060 
00061 /* should be removed when scilab will be full ansi C */
00062 
00063 #ifndef __STDC__ 
00064 #define const 
00065 #endif 
00066 
00067 int WindowsPrintScreen = 0;
00068 int Printer_XRes = 0;
00069 int Printer_YRes = 0;
00070 
00071 /*---------------------------------------------------------------
00072  * The basic graphic driver is X11 
00073  *    The name is X11 due to historical reasons 
00074  *    but according to architecture X11 can be an Xwindow driver 
00075  *    a driver for Macintosh 
00076  *    or a Windows driver 
00077  * Other drivers are Postscript Fig ( xfig ) and Rec ( Rec= X11 + Recording capabilities) 
00078  *    xfig is only meaningfull when using Unix machine 
00079  * ----------------------------------------------------------------*/
00080 
00081 /* How to use the hash table by jb Silvy 04/2006 */
00082 /* The hash table (asso_values array) has been created using the gperf software. */
00083 /* Normally, each a new function is added in Xcall, gperf shoud be run to obtain a new hastable */
00084 /* But here I present a way to avoid using gperf :). */
00085 /* When dr is called, the programm will compute the hash value of the called function (xset, */
00086 /* xarc,...). The function hash compute this. The obtained number will then give the function to */
00087 /* call in the driver. This number is the index of the function to be called in the wordlist array. */
00088 /* As you can see, there are empty baskets. They can be used to add new functions (that's the point :) )*/
00089 /* So if you want to add a new functions, you need to find a name which fits one basket. */
00090 /* So it is not possible to choose any name, there can be only one name per basket. */
00091 /* However, I think it is easier than running gperf each time ;). */
00092 
00093 static void C2F(vide)(char *v1,integer * v2,integer * v3,integer * v4,integer * v5,integer * v6,
00094                       integer *v7,double * dv1,double * dv2,double * dv3,double * dv4) {}
00095 const struct funreplace * xcall_in_word_set (register const char *str, register unsigned int len);
00096 static void C2F(all)(char x0[],char x1[],integer *x2,integer *x3,integer *x4,integer *x5, integer *x6, integer *x7,double *dx1,double *dx2,double *dx3,double *dx4, integer lx0, integer lx1);
00097 
00098 
00099 typedef void (*func)();
00100 typedef void (function)() ;
00101 /* #line 51 "Xcall.gperf" */
00102 struct funreplace { char *name; func action[4]; };
00103 
00104 #define MIN_WORD_LENGTH 4
00105 #define MAX_WORD_LENGTH 9
00106 #define MIN_HASH_VALUE 9
00107 #define MAX_HASH_VALUE 86
00108 /* maximum key range = 78, duplicates = 0 */
00109 
00110 #ifdef __GNUC__
00111 __inline
00112 #else
00113 #ifdef __cplusplus
00114 inline
00115 #endif
00116 #endif
00117 
00118 static unsigned int hash (register const char *str, register unsigned int len)
00119 {
00120   static const unsigned char asso_values[] =
00121     {
00122       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00123       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00124       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00125       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00126       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00127       60, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00128       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00129       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00130       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00131       87, 87, 87, 87, 87, 87, 87,  5, 87,  0, /* 99 */
00132       15,  5, 45, 15, 25,  0, 87, 45, 25, 15,
00133       20,  0, 10, 87,  0,  0,  5, 20, 87, 55,
00134       25, 10, 87, 87, 87, 87, 87, 87, 87, 87,
00135       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00136       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00137       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00138       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00139       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00140       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00141       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00142       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00143       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00144       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00145       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00146       87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
00147       87, 87, 87, 87, 87, 87
00148     };
00149   
00150   return len + asso_values[(unsigned char)str[3]] + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[len - 1]];
00151 }
00152 
00153 #ifdef __GNUC__
00154 __inline
00155 #endif
00156 const struct funreplace * xcall_in_word_set (register const char *str, register unsigned int len)
00157 {
00158   static const struct funreplace wordlist[] =
00159     {
00160       {""}, /* index 0 */
00161       {""}, 
00162       {""}, 
00163       {""}, 
00164       {""}, 
00165       {""}, 
00166       {""}, 
00167       {""}, 
00168       {""},
00169       {"xarc",    {C2F(drawarc),C2F(drawarcPos),C2F(drawarcXfig),C2F(drawarcGif)}},
00170       {"xarcs",    {C2F(drawarcs),C2F(drawarcsPos),C2F(drawarcsXfig),C2F(drawarcsGif)}}, /* 10 */
00171       {"xrects",    {C2F(drawrectangles),C2F(drawrectanglesPos),C2F(drawrectanglesXfig),C2F(drawrectanglesGif)}},
00172       {""}, 
00173       {""}, 
00174       {""},
00175       {"xrect",    {C2F(drawrectangle),C2F(drawrectanglePos),C2F(drawrectangleXfig),C2F(drawrectangleGif)}},
00176       {"xsetdr",    {C2F(SetDriver),C2F(SetDriver),C2F(SetDriver),C2F(SetDriver)}},
00177       {""}, 
00178       {""},
00179       {"xset",    {C2F(MissileGCset),C2F(scilabgcsetPos),C2F(scilabgcsetXfig),C2F(scilabgcsetGif)}},
00180       {"xarea",    {C2F(fillpolyline),C2F(fillpolylinePos),C2F(fillpolylineXfig),C2F(fillpolylineGif)}}, /* 20 */
00181       {"xstart",    {CleanPlots,CleanPlots,CleanPlots,CleanPlots}},
00182       {""}, 
00183       {""},
00184       {""},
00185       {"xsegs",    {C2F(drawsegments),C2F(drawsegmentsPos),C2F(drawsegmentsXfig),C2F(drawsegmentsGif)}},
00186       {"xmarks",    {C2F(drawpolymark),C2F(drawpolymarkPos),C2F(drawpolymarkXfig),C2F(drawpolymarkGif)}},
00187       {"xstring",    {C2F(displaystring),C2F(displaystringPos),C2F(displaystringXfig),C2F(displaystringGif)}},
00188       {""},
00189       {""},
00190       {"xinit",    {C2F(initgraphic),C2F(initgraphicPos),C2F(initgraphicXfig),C2F(initgraphicGif)}}, /* 30 */
00191       {"xgetdr",    {GetDriver1,GetDriver1,GetDriver1,GetDriver1}},
00192       {""},
00193       {""},
00194       {"xget",    {C2F(MissileGCget),C2F(scilabgcgetPos),C2F(scilabgcgetXfig),C2F(scilabgcgetGif)}},
00195       {"xaxis",    {C2F(drawaxis),C2F(drawaxisPos),C2F(drawaxisXfig),C2F(drawaxisGif)}},
00196       {"xclear",    {C2F(clearwindow),C2F(clearwindowPos),C2F(clearwindowXfig),C2F(clearwindowGif)}},
00197       {""},
00198       {"xstringl",    {C2F(boundingbox),C2F(boundingboxPos),C2F(boundingboxXfig),C2F(boundingboxGif),}},
00199       {"xgetmouse",    {C2F(xgetmouse),C2F(xgetmousePos),C2F(xgetmouseXfig),C2F(xgetmouseGif)}},
00200       {"xclea",    {C2F(cleararea),C2F(clearareaPos),C2F(clearareaXfig),C2F(clearareaGif)}}, /* 40 */
00201       {"xpolys",    {C2F(drawpolylines),C2F(drawpolylinesPos),C2F(drawpolylinesXfig),C2F(drawpolylinesGif)}},
00202       {"xselect",    {C2F(xselgraphic),C2F(xselgraphicPos),C2F(xselgraphicXfig),C2F(xselgraphicGif)}},
00203       {""},
00204       {"xclickany",    {C2F(xclick_any),C2F(xclick_anyPos),C2F(xclick_anyXfig),C2F(xclick_anyGif)}},
00205       {""},
00206       {""},
00207       {""}, 
00208       {""},
00209       {""},
00210       {"xname",    {C2F(setpopupname),C2F(vide),C2F(vide),C2F(vide)}}, /* 50 */
00211       {"xlines",    {C2F(drawClippedPolyline),C2F(drawpolylinePos),C2F(drawClippedPolylineXfig),C2F(drawpolylineGif)}},
00212       {"xliness",    {C2F(fillpolylines),C2F(fillpolylinesPos),C2F(fillpolylinesXfig),C2F(fillpolylinesGif)}},
00213       {"xuclines",    {C2F(drawpolyline),C2F(drawpolylinePos),C2F(drawpolylineXfig),C2F(drawpolylineGif)}}, 
00214       {""},
00215       {"xfarc",    {C2F(fillarc),C2F(fillarcPos),C2F(fillarcXfig),C2F(fillarcGif)}},
00216       {"xfarcs",    {C2F(fillarcs),C2F(fillarcsPos),C2F(fillarcsXfig),C2F(fillarcsGif)}},
00217       {""}, 
00218       {""},
00219       {"xend",    {C2F(xend),C2F(xendPos),C2F(xendXfig),C2F(xendGif)}},
00220       {""}, /* 60 */
00221       {"xfrect",    {C2F(fillrectangle),C2F(fillrectanglePos),C2F(fillrectangleXfig),C2F(fillrectangleGif)}},
00222       {""}, 
00223       {""}, 
00224       {""}, 
00225       {""},
00226       {"xarrow",    {C2F(drawarrows),C2F(drawarrowsPos),C2F(drawarrowsXfig),C2F(drawarrowsGif)}},
00227       {""}, 
00228       {""}, 
00229       {""},
00230       {"xinfo",    {C2F(xinfo),C2F(vide),C2F(vide),C2F(vide)}}, /* 70 */
00231       {"xgfont",    {C2F(queryfamily),C2F(queryfamilyPos),C2F(queryfamilyXfig),C2F(queryfamilyGif)}},
00232       {""}, 
00233       {"xfontmxs", {C2F(getFontMaxSize),C2F(getFontMaxSizePos),C2F(getFontMaxSizeXfig),C2F(getFontMaxSizeGif)}},
00234       {"xnum",    {C2F(displaynumbers),C2F(displaynumbersPos),C2F(displaynumbersXfig),C2F(displaynumbersGif)}},
00235       {""},
00236       {"xclick",    {C2F(xclick),C2F(xclickPos),C2F(xclickXfig),C2F(xclickGif)}},
00237       {""}, 
00238       {""}, 
00239       {""},
00240       {""}, /* 80 */
00241       {"xlfont",    {C2F(loadfamily),C2F(loadfamilyPos),C2F(loadfamilyXfig),C2F(loadfamilyGif)}},
00242       {""}, 
00243       {""}, 
00244       {""}, 
00245       {""},
00246       {"xinit2",    {C2F(initgraphic),C2F(initgraphicfromscreenPos),C2F(initgraphicfromscreenXfig),C2F(initgraphicfromscreenGif)}} /* 86 */
00247     };
00248 
00249   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
00250     {
00251       register int key = hash (str, len);
00252 
00253       if (key <= MAX_HASH_VALUE && key >= 0)
00254         {
00255           register const char *s = wordlist[key].name;
00256 
00257           if (*str == *s && !strcmp (str + 1, s + 1))
00258             return &wordlist[key];
00259         }
00260     }
00261   return 0;
00262 }
00263 /*#line 94 "Xcall.gperf"*/
00264 
00265 
00266 static char DriverName[]= "Rec";
00267 static int  DriverId = 0;
00268 
00269 void C2F(SetDriver)(char *x0, integer *v2,integer * v3,integer * v4, integer *v5,integer * v6,
00270                     integer * v7,double * dv1,double * dv2,double * dv3,double * dv4)
00271 {
00272   switch (x0[0])
00273     {
00274     case 'I':
00276       strcpy(DriverName,"Int"); /* internal : for Win32 */
00277       DriverId = 0;
00278       break;
00279     case 'G':
00280       if (x0[1] == 'I') {
00281           strcpy(DriverName,"GIF");
00282           DriverId = 3;
00283           break;
00284       }
00285     case 'X':
00286     case 'W':
00287       strcpy(DriverName,"X11");
00288       DriverId = 0;
00289       break;
00290     case 'P'  :
00291       if (x0[1] == 'P') {
00292         strcpy(DriverName,"PPM");
00293         DriverId = 3;
00294         break;
00295       }
00296       else {
00297         strcpy(DriverName,"Pos");
00298         DriverId = 1;
00299       }
00300       break;
00301     case 'F'  :
00302       strcpy(DriverName,"Fig");
00303       DriverId = 2;
00304       break;
00305     case 'R'  :
00306       strcpy(DriverName,"Rec");
00307       DriverId = 0;
00308       break;
00309     default:
00310       sciprint("\n Wrong driver name I'll use X11");
00311       strcpy(DriverName,"X11");
00312       DriverId = 0;
00313       break;
00314     }
00315 }
00316 
00317 void GetDriver1(char *str, integer *v2,integer * v3,integer * v4, integer *v5,integer * v6,
00318                     integer * v7,double * dv1,double * dv2,double * dv3,double * dv4)
00319 {
00320   strcpy(str,DriverName);
00321 }
00322 
00323 char GetDriver() {return(DriverName[0]);}
00324 
00325 int GetDriverId() { return DriverId;}
00326 
00327 /* The following function can be called by fortran so we 
00328    use the Sun C-fortran interface conventions 
00329    dr has 2 last extra parametres to deal with the size of
00330    x0 and x1 */
00331 
00332 int C2F(dr)(char x0[],char x1[],integer *x2,integer *x3,integer *x4,integer *x5,integer *x6, integer *x7,double *dx1,double *dx2,double *dx3,double *dx4,
00333             integer lx0, integer lx1)
00334 { 
00335 #ifdef _MSC_VER
00336   if ( DriverId == 0 && DriverName[0] != 'I' ) 
00337     {
00338       SetWinhdc();
00339       C2F(all)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4,lx0,lx1);
00340       ReleaseWinHdc();
00341     }
00342   else 
00343     {
00344       C2F(all)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4,lx0,lx1);
00345     }
00346 #else
00347       C2F(all)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4,lx0,lx1);
00348 #endif
00349   return 0;
00350 }
00351 
00352 static void C2F(all)(char x0[],char x1[],integer *x2,integer *x3,integer *x4,integer *x5,
00353                      integer *x6,
00354                      integer *x7,double *dx1,double *dx2,double *dx3,double *dx4, integer lx0, integer lx1)
00355 { 
00356   const struct funreplace *fr;
00357   fr=xcall_in_word_set(x0,strlen(x0));
00358   if ( fr != NULL ) 
00359     {
00360       (*(fr->action[DriverId]))(x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4,lx0,lx1);
00361     }
00362   else 
00363     {
00364       sciprint("\n Unknow X operator <%s>\r\n",x0);
00365     }
00366 }
00367 
00368 
00369 /*----------------------------------END---------------------------*/
00370 extern int GetScreenDPI(int *ixres, int *iyres) ;
00371 /*---------------------------------------------------------------------------------------------------*/
00372 int GetDPIFromDriver(int DPI[2])
00373 {
00374   int driver = GetDriverId(); /* return the first letter of the driver name (see XCall.c) */
00375   int succeed = 0;
00376   int ixres, iyres;
00377 
00378   switch(driver)
00379   {
00380   case 0: 
00381     if(WindowsPrintScreen == 1)
00382     {
00383       ixres = Printer_XRes;
00384       iyres = Printer_YRes;
00385       succeed = 1;
00386     }
00387     else
00388     {
00389       succeed = GetScreenDPI(&ixres,&iyres);
00390       if(succeed == -1){
00391         ixres = (int)72.; /* default value*/
00392         iyres = (int)72.; /* default value*/
00393       }
00394     }
00395     break;
00396   case 1: /* Pos */
00397     /*       printf("DRIVERS POS enabled -- -- -- --\n"); */
00398     /* when using Pos driver, the output file is 6000x4240 pixels */
00399     /* computed DPI: height : 6000/(30cm/2.54) = 508 ; width: 4240/(21.20/2.54) = 508 */
00400     ixres = (int)(524.*1.5);
00401     iyres = (int)(524.*1.5);
00402     break;
00403   case 2: /* Fig. */
00404     /*       printf("DRIVERS FIG enabled -- -- -- --\n"); */
00405     /* when using Pos driver, the output file is 6000x4240 pixels */
00406     /* computed DPI: height : 9600/(8inches) = 1200 ; width: 6784/(5.7inches) = 1190 */
00407     ixres = (int)1200.;
00408     iyres = (int)1190.;
00409     break;
00410   case 3: /* Gif & PPM driver */ /* NOT SURE: may be 72. avery time... */
00411   default:
00412     succeed = GetScreenDPI(&ixres,&iyres);
00413     if(succeed == -1){
00414       ixres = (int)72.; /* default value*/      
00415       iyres = (int)72.; /* default value*/
00416     }
00417     break;
00418   }
00419 
00420   DPI[0] = ixres;
00421   DPI[1] = iyres;
00422 
00423   return 0;
00424 }
00425 /*---------------------------------------------------------------------------------------------------*/
00426 

Generated on Sun Mar 4 15:03:54 2007 for Scilab [trunk] by  doxygen 1.5.1