Back to index

wims  3.65+svn20090927
wims.h
Go to the documentation of this file.
00001 /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
00002  *
00003  *  This program is free software; you can redistribute it and/or modify
00004  *  it under the terms of the GNU General Public License as published by
00005  *  the Free Software Foundation; either version 2 of the License, or
00006  *  (at your option) any later version.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  */
00017 
00018 /* WWW multipurpose server, header definitions */
00019 
00020 #include "config.h"
00021 #include "includes.h"
00022 #include "wimsdef.h"
00023 /* #include "wimsshm.h" */
00024 
00025         /* limit of query_string. */
00026 #define QUERY_STRING_LIMIT 204799
00027        /* maximal length of deposited file */
00028 #define MAX_DEPOSITLEN (8*1024*1024)
00029        /* maximal number of registered variables */
00030 #define MAX_VAR_NUM 512
00031        /* length limit for public_html/bin executable names */
00032 #define MAX_EXEC_NAME 31
00033        /* max level of nested fors */
00034 #define MAX_FOR_LEVEL 12
00035        /* max nested read; to avoid infinite loop */
00036 #define MAX_READNEST 20
00037        /* number of cached working files */
00038 #define MAX_MCACHE 32
00039        /* max languages on a site, hard limit */
00040 #define MAX_LANGUAGES 32
00041        /* max sort items. */
00042 #define MAX_SORT_ITEM 5000
00043        /* max randperm() items. Should be compatible to MAX_LINELEN. */
00044 #define MAX_RANDPERM 2000
00045        /* Number of session random numbers */
00046 #define MAX_SESRANDOM 64
00047   /* Limit of output length. This can be configured. */
00048 #define OUTPUT_LENGTH_LIMIT 600000
00049   /* limit of items in value lists */
00050 #define MAX_VALUE_LIST 2048
00051        /* file to hold last output */
00052 #define lastout      "last.html"
00053        /* temporary log file */
00054 #define TEMP_LOG_FILE "../log/temp.log"
00055        /* Access policy configuration file */
00056 #define ACCESS_CONF "../log/wims.conf.access"
00057        /* Should not be changed */
00058 #define SESSION_BASE "sessions"
00059 #define S2_BASE "s2"
00060 
00061        /* Prefix char for exec functions */
00062 #define exec_prefix_char '!'
00063        /* Prefix char for calc functions */
00064 #define calc_prefix_char '!'
00065        /* Prefix char for goto labels */
00066 #define label_prefix_char ':'
00067        /* Prefix for tags in data files */
00068 #define tag_prefix_char ':'
00069        /* Tag string for randfile */
00070 #define tag_string "\n:"
00071        /* Prefix char for comment lines */
00072 #define comment_prefix_char '#'
00073   /* prefix to user variable names */
00074 #define var_prefix   "w_"
00075   /* (user) prefix for mathematical fonts */
00076 #define mathfont_prefix     "m_"
00077   /* prefix for internal variables */
00078 #define wims_prefix "wims_"
00079 #define wpflen strlen(wims_prefix)
00080   /* name of variable definition file */
00081 #define default_var_def "var.def"
00082        /* Not configured */
00083 #define error_data_string "wims_error_data"
00084   /* Name of files containing error messages. */
00085 #define user_error_msg_file "msg/user_error.phtml"
00086 #define module_error_msg_file "msg/module_error.msg"
00087   /* directory containing log files */
00088 #define log_dir "../log"
00089 #define class_base "../log/classes"
00090   /* What should indicate that a file name given by the user 
00091    * would allow him to go upstairs in the directory tree?
00092    * We shouldn't use "../", otherwise the user may just specify
00093    * ".." as name and go upstairs one step. */
00094 #define parent_dir_string ".."
00095   /* This one is stronger. */
00096 #define PARENT_DIR_STRING "/../"
00097   /* kernel daemon socket file. Should match that of wimslogd. */
00098 #define ksockfile "../tmp/log/.wimslogd"
00099   /* this directory should not exist. Do not change the definition! */
00100 #define sysmask_trigger_dir "sysmask/stat/trigger"
00101 
00102 typedef struct {
00103     int lineno; /* line number */
00104 /*    long fpt;      */ /* position in the file */
00105     char varname[MAX_NAMELEN+1];
00106     double varval;
00107     double varend;
00108     char *list_pt, *bufpt;
00109     double step;
00110     int from; /* from ... to ... if 0, list if 1 */
00111 } FOR_STACK;
00112 
00113 typedef struct {
00114     char *address;
00115     short int execcode, varcode;
00116     int isstart; /* bit 0: start line; bit 1: exec; bit 2: label. bit 3: hard comment. bit 4: soft comment */
00117     unsigned int llen;
00118 } LINE_STRUCT;
00119 
00120 typedef struct {
00121     char name[MAX_FNAME+1];
00122     int  l;
00123     int linepointer;
00124        /* nocache bits: 0. !nocache; 1. hard nocache; 2. isfromcache; 3. isbase; */
00125     short int for_idx, nocache;
00126     int linecnt;
00127     char *textbuf;
00128     LINE_STRUCT *lines;
00129     FOR_STACK *for_stack;
00130 } WORKING_FILE;
00131 
00132 struct {
00133     char *name;
00134     char *font;
00135 } charname[]={
00136     {"en","iso-8859-1"},
00137       {"fr","iso-8859-1"},
00138       {"es","iso-8859-1"},
00139       {"cn","gb2312"},
00140       {"de","iso-8859-1"},
00141       {"it","iso-8859-1"},
00142       {"nl","iso-8859-1"},
00143       {"si","iso-8859-2"},
00144       {"tw","big5"},
00145       {"pt","iso-8859-1"},
00146       {"ca","iso-8859-1"},
00147       {"ru","iso-8859-5"}
00148 };
00149 
00150 #define charname_no (sizeof(charname)/sizeof(charname[0]))
00151 
00152        /* var.c */
00153 char *getvar(char *name);
00154 int setvar(char *vname, char *vval);
00155 void debug_output(void);
00156 void exportall(void);
00157 
00158        /* config.c */
00159 void setsesdir(char *p);
00160 
00161        /* variables.c */
00162 void var_proc(char *fname,int cache);
00163 void phtml_put(char *fname,int cache);
00164 void phtml_put_base(char *fname,int cache);
00165 
00166        /* evalue.c */
00167 double evalue(char *p);
00168 char *substit(char *p);
00169 
00170        /* calc.c */
00171 void calc_tolower(char *p);
00172 void calc_toupper(char *p);
00173 
00174        /* log.c */
00175 void user_log(char *p);
00176 void write_logs(void);
00177 void mail_log(char *p);
00178 void flushlog(void);
00179 
00180        /* insmmath.c */
00181 void insmath(char *p);
00182 
00183        /* mathfonts.c */
00184 void fix_tex_size(void);
00185 
00186        /* exam.c */
00187 void calc_examdep(char *p);
00188 
00189        /* test.c */
00190 void exec_test(char *p);
00191 
00192        /* var.c */
00193 int force_setvar(char *vname,char *vvalue);
00194 
00195        /* variables.c */
00196 int var_def_check(char *name);
00197 
00198 #if !HAVE_SETENV
00199 int setenv(const char *name, const char *value, int overwrite);
00200 void unsetenv(const char *name);
00201 #endif