Subversion Repositories wimsdev

Rev

Rev 1540 | 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 600000
  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.       {"tw","big5"}
  145. };
  146.  
  147. #define charname_no (sizeof(charname)/sizeof(charname[0]))
  148.  
  149.         /* var.c */
  150. char *getvar(char *name);
  151. int setvar(char *vname, char *vval);
  152. void debug_output(void);
  153. void exportall(void);
  154.  
  155.         /* config.c */
  156. void setsesdir(char *p);
  157.  
  158.         /* variables.c */
  159. void var_proc(char *fname,int cache);
  160. void phtml_put(char *fname,int cache);
  161. void phtml_put_base(char *fname,int cache);
  162.  
  163.         /* evalue.c */
  164. double evalue(char *p);
  165. char *substit(char *p);
  166.  
  167.         /* calc.c */
  168. void calc_tolower(char *p);
  169. void calc_toupper(char *p);
  170.  
  171.         /* log.c */
  172. void user_log(char *p);
  173. void write_logs(void);
  174. void mail_log(char *p);
  175. void flushlog(void);
  176.  
  177.         /* insmmath.c */
  178. void insmath(char *p);
  179.  
  180.         /* mathfonts.c */
  181. void fix_tex_size(void);
  182.  
  183.         /* exam.c */
  184. void calc_examdep(char *p);
  185.  
  186.         /* test.c */
  187. void exec_test(char *p);
  188.  
  189.         /* var.c */
  190. int force_setvar(char *vname,char *vvalue);
  191.  
  192.         /* variables.c */
  193. int var_def_check(char *name);
  194.  
  195. #if !HAVE_SETENV
  196. int setenv(const char *name, const char *value, int overwrite);
  197. void unsetenv(const char *name);
  198. #endif
  199.