Subversion Repositories wimsdev

Rev

Rev 2710 | Rev 8121 | 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. };
  151.  
  152. #define charname_no (sizeof(charname)/sizeof(charname[0]))
  153.  
  154. /* left to right   or   right to left   writing */
  155. struct {
  156.     char *name;
  157.     char *dirn;
  158. } dirnname[]={
  159.     {"en","ltr"},
  160.       {"fr","ltr"},
  161.       {"es","ltr"},
  162.       {"cn","ltr"},
  163.       {"de","ltr"},
  164.       {"it","ltr"},
  165.       {"nl","ltr"},
  166.       {"si","ltr"},
  167.       {"ar","rtl"},  
  168.       {"tw","ltr"},
  169.       {"pt","ltr"},
  170.       {"ca","ltr"},
  171.       {"pt","ltr"},
  172.       {"ru","ltr"}
  173. };
  174.  
  175. #define dirnname_no (sizeof(dirnname)/sizeof(dirnname[0]))
  176.  
  177.         /* var.c */
  178. char *getvar(char *name);
  179. int setvar(char *vname, char *vval);
  180. void debug_output(void);
  181. void exportall(void);
  182.  
  183.         /* config.c */
  184. void setsesdir(char *p);
  185.  
  186.         /* variables.c */
  187. void var_proc(char *fname,int cache);
  188. void phtml_put(char *fname,int cache);
  189. void phtml_put_base(char *fname,int cache);
  190.  
  191.         /* evalue.c */
  192. double evalue(char *p);
  193. char *substit(char *p);
  194.  
  195.         /* calc.c */
  196. void calc_tolower(char *p);
  197. void calc_toupper(char *p);
  198.  
  199.         /* log.c */
  200. void user_log(char *p);
  201. void write_logs(void);
  202. void mail_log(char *p);
  203. void flushlog(void);
  204.  
  205.         /* insmmath.c */
  206. void insmath(char *p);
  207.  
  208.         /* mathfonts.c */
  209. void fix_tex_size(void);
  210.  
  211.         /* exam.c */
  212. void calc_examdep(char *p);
  213.  
  214.         /* test.c */
  215. void exec_test(char *p);
  216.  
  217.         /* var.c */
  218. int force_setvar(char *vname,char *vvalue);
  219.  
  220.         /* variables.c */
  221. int var_def_check(char *name);
  222.  
  223. #if !HAVE_SETENV
  224. int setenv(const char *name, const char *value, int overwrite);
  225. void unsetenv(const char *name);
  226. #endif
  227.