Subversion Repositories wimsdev

Rev

Rev 3278 | Rev 8185 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
  2.  *
  3.  *  This program is free software; you can redistribute it and/or modify
  4.  *  it under the terms of the GNU General Public License as published by
  5.  *  the Free Software Foundation; either version 2 of the License, or
  6.  *  (at your option) any later version.
  7.  *
  8.  *  This program is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  *  GNU General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with this program; if not, write to the Free Software
  15.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18. /* WWW multipurpose server, header definitions */
  19.  
  20. #include "config.h"
  21. #include "includes.h"
  22. #include "wimsdef.h"
  23. /* #include "wimsshm.h" */
  24.  
  25.         /* limit of query_string. */
  26. #define QUERY_STRING_LIMIT 204799
  27.         /* maximal length of deposited file */
  28. #define MAX_DEPOSITLEN (8*1024*1024)
  29.         /* maximal number of registered variables */
  30. #define MAX_VAR_NUM 512
  31.         /* length limit for public_html/bin executable names */
  32. #define MAX_EXEC_NAME 31
  33.         /* max level of nested fors */
  34. #define MAX_FOR_LEVEL 12
  35.         /* max nested read; to avoid infinite loop */
  36. #define MAX_READNEST 20
  37.         /* number of cached working files */
  38. #define MAX_MCACHE 32
  39.         /* max languages on a site, hard limit */
  40. #define MAX_LANGUAGES 32
  41.         /* max sort items. */
  42. #define MAX_SORT_ITEM 5000
  43.         /* max randperm() items. Should be compatible to MAX_LINELEN. */
  44. #define MAX_RANDPERM 2000
  45.         /* Number of session random numbers */
  46. #define MAX_SESRANDOM 64
  47.   /* Limit of output length. This can be configured. */
  48. #define OUTPUT_LENGTH_LIMIT (1024*1024)
  49.   /* limit of items in value lists */
  50. #define MAX_VALUE_LIST 2048
  51.         /* file to hold last output */
  52. #define lastout "last.html"
  53.         /* temporary log file */
  54. #define TEMP_LOG_FILE "../log/temp.log"
  55.         /* Access policy configuration file */
  56. #define ACCESS_CONF "../log/wims.conf.access"
  57.         /* Should not be changed */
  58. #define SESSION_BASE "sessions"
  59. #define S2_BASE "s2"
  60.  
  61.         /* Prefix char for exec functions */
  62. #define exec_prefix_char '!'
  63.         /* Prefix char for calc functions */
  64. #define calc_prefix_char '!'
  65.         /* Prefix char for goto labels */
  66. #define label_prefix_char ':'
  67.         /* Prefix for tags in data files */
  68. #define tag_prefix_char ':'
  69.         /* Tag string for randfile */
  70. #define tag_string "\n:"
  71.         /* Prefix char for comment lines */
  72. #define comment_prefix_char '#'
  73.   /* prefix to user variable names */
  74. #define var_prefix      "w_"
  75.   /* (user) prefix for mathematical fonts */
  76. #define mathfont_prefix "m_"
  77.   /* prefix for internal variables */
  78. #define wims_prefix "wims_"
  79. #define wpflen strlen(wims_prefix)
  80.   /* name of variable definition file */
  81. #define default_var_def "var.def"
  82.         /* Not configured */
  83. #define error_data_string "wims_error_data"
  84.   /* Name of files containing error messages. */
  85. #define user_error_msg_file "msg/user_error.phtml"
  86. #define module_error_msg_file "msg/module_error.msg"
  87.   /* directory containing log files */
  88. #define log_dir "../log"
  89. #define class_base "../log/classes"
  90.   /* What should indicate that a file name given by the user
  91.    * would allow him to go upstairs in the directory tree?
  92.    * We shouldn't use "../", otherwise the user may just specify
  93.    * ".." as name and go upstairs one step. */
  94. #define parent_dir_string ".."
  95.   /* This one is stronger. */
  96. #define PARENT_DIR_STRING "/../"
  97.   /* kernel daemon socket file. Should match that of wimslogd. */
  98. #define ksockfile "../tmp/log/.wimslogd"
  99.   /* this directory should not exist. Do not change the definition! */
  100. #define sysmask_trigger_dir "sysmask/stat/trigger"
  101.  
  102. typedef struct {
  103.     int lineno; /* line number */
  104. /*    long fpt; */ /* position in the file */
  105.     char varname[MAX_NAMELEN+1];
  106.     double varval;
  107.     double varend;
  108.     char *list_pt, *bufpt;
  109.     double step;
  110.     int from;   /* from ... to ... if 0, list if 1 */
  111. } FOR_STACK;
  112.  
  113. typedef struct {
  114.     char *address;
  115.     short int execcode, varcode;
  116.     int isstart; /* bit 0: start line; bit 1: exec; bit 2: label. bit 3: hard comment. bit 4: soft comment */
  117.     unsigned int llen;
  118. } LINE_STRUCT;
  119.  
  120. typedef struct {
  121.     char name[MAX_FNAME+1];
  122.     int  l;
  123.     int linepointer;
  124.         /* nocache bits: 0. !nocache; 1. hard nocache; 2. isfromcache; 3. isbase; */
  125.     short int for_idx, nocache;
  126.     int linecnt;
  127.     char *textbuf;
  128.     LINE_STRUCT *lines;
  129.     FOR_STACK *for_stack;
  130. } WORKING_FILE;
  131.  
  132. struct {
  133.     char *name;
  134.     char *font;
  135. } charname[]={
  136.     {"en","iso-8859-1"},
  137.       {"fr","iso-8859-1"},
  138.       {"es","iso-8859-1"},
  139.       {"cn","gb2312"},
  140.       {"de","iso-8859-1"},
  141.       {"it","iso-8859-1"},
  142.       {"nl","iso-8859-1"},
  143.       {"si","iso-8859-2"},
  144.       {"ar","iso-8859-6"},
  145.       {"tw","big5"},
  146.       {"pt","iso-8859-1"},
  147.       {"ca","iso-8859-1"},
  148.       {"pt","iso-8859-1"},
  149.       {"ru","iso-8859-5"},
  150.       {"ty","iso-8859-13"}
  151. };
  152.  
  153. #define charname_no (sizeof(charname)/sizeof(charname[0]))
  154.  
  155. /* left to right   or   right to left   writing */
  156. struct {
  157.     char *name;
  158.     char *dirn;
  159. } dirnname[]={
  160.     {"en","ltr"},
  161.       {"fr","ltr"},
  162.       {"es","ltr"},
  163.       {"cn","ltr"},
  164.       {"de","ltr"},
  165.       {"it","ltr"},
  166.       {"nl","ltr"},
  167.       {"si","ltr"},
  168.       {"ar","rtl"},  
  169.       {"tw","ltr"},
  170.       {"pt","ltr"},
  171.       {"ca","ltr"},
  172.       {"pt","ltr"},
  173.       {"ru","ltr"},
  174.       {"ty","ltr"}
  175.      
  176. };
  177.  
  178. #define dirnname_no (sizeof(dirnname)/sizeof(dirnname[0]))
  179.  
  180.         /* var.c */
  181. char *getvar(char *name);
  182. int setvar(char *vname, char *vval);
  183. void debug_output(void);
  184. void exportall(void);
  185.  
  186.         /* config.c */
  187. void setsesdir(char *p);
  188.  
  189.         /* variables.c */
  190. void var_proc(char *fname,int cache);
  191. void phtml_put(char *fname,int cache);
  192. void phtml_put_base(char *fname,int cache);
  193.  
  194.         /* evalue.c */
  195. double evalue(char *p);
  196. char *substit(char *p);
  197.  
  198.         /* calc.c */
  199. void calc_tolower(char *p);
  200. void calc_toupper(char *p);
  201.  
  202.         /* log.c */
  203. void user_log(char *p);
  204. void write_logs(void);
  205. void mail_log(char *p);
  206. void flushlog(void);
  207.  
  208.         /* insmmath.c */
  209. void insmath(char *p);
  210.  
  211.         /* mathfonts.c */
  212. void fix_tex_size(void);
  213.  
  214.         /* exam.c */
  215. void calc_examdep(char *p);
  216.  
  217.         /* test.c */
  218. void exec_test(char *p);
  219.  
  220.         /* var.c */
  221. int force_setvar(char *vname,char *vvalue);
  222.  
  223.         /* variables.c */
  224. int var_def_check(char *name);
  225.  
  226. #if !HAVE_SETENV
  227. int setenv(const char *name, const char *value, int overwrite);
  228. void unsetenv(const char *name);
  229. #endif
  230.