Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
10 reyssat 1
/*    Copyright (C) 2002-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
#ifndef SYMTEXT_H
19
#define SYMTEXT_H 1
20
 
21
#include <stdio.h>
22
#include <stdlib.h>
23
#include <stdarg.h>
24
#include <ctype.h>
25
#include <unistd.h>
26
#include <math.h>
27
#include <string.h>
28
#include <sys/stat.h>
29
#include <sys/types.h>
30
#include <fcntl.h>
31
#include <errno.h>
32
#include <signal.h>
33
#include <time.h>
34
 
8161 bpr 35
#include "../../Lib/libwims.h"
10 reyssat 36
 
37
        /* Maximum of blocks. Limited to sizeof(short). */
38
#define MAX_BLOCKS      8192
39
        /* Maximum of pools. Limited to sizeof(short). */
40
#define MAX_POOLS       10240
41
        /* Maximum of variable names. */
42
#define MAX_NAMELEN     63
43
        /* Maximum of (complete) file names. */
44
#define MAX_FNAME       199
45
        /* Maximum of dictionaries, including reserved ones. */
46
#define MAX_DICS        15
47
        /* Maximum of lists in permdata. Very limited. */
48
#define MAX_PERMLIST    4
49
        /* Size of list buffer */
50
#define MAX_LISTS       65536
51
        /* Limit of the length of builtin command names */
52
#define MAX_BINAME      10
53
        /* Limit to nesting levels */
54
#define MAX_LEVELS      16384
55
        /* How many picks at most */
56
#define MAX_PICKS       64
57
        /* limit of entries in a dictionary */
58
#define MAX_DICENTRIES 512*1024
59
        /* limit of any single dictionary size */
60
#define MAX_DICSIZE     10240*1024
61
 
62
        /* int or short */
63
#define listtype        short int
64
        /* default dictionary directory */
65
#define defaultdir      "scripts"
66
 
67
#define char_punct      ".,;:?!\""
68
#define char_math       "+-*/=|%<>()_"
69
#define char_parenth    "()[]{}"
70
#define char_cs         "_&$#`\\@~"
71
#define char_quote      "`'\""
72
 
73
typedef struct block {
74
    char *string;               /* string for compare */
75
    int (*fn) (struct block *blk, char *start, int level);
76
    listtype nextblock, sublock;        /* subblocks are always consecutive */
77
    listtype len, lcnt, lind1, lind2, lstart, pool, mpool, mend;
78
    listtype *listlen;
79
    listtype *lists[MAX_PERMLIST];      /* permutation lists */
80
} block;
81
 
82
typedef struct poolstruct {
83
    listtype block, lastpool, ind1, ind2, dirty, len;
84
    char *string;
85
    listtype *tag;              /* level tags for recursion */
86
} poolstruct;
87
 
8161 bpr 88
/* from translate.c */
89
extern struct entry {
90
    unsigned char *original, *replace;
91
    int olen,earlier;
92
} entry[];
93
 
94
int search_dic(struct entry *list, int items, size_t item_size, const char *str);
95
 
96
extern struct dic {
97
    char name[MAX_FNAME+1];
98
    char unknown[256];
99
    char *buf;
100
    int unknown_type;
101
    int start;
102
    int len;
103
} dic[MAX_DICS];
104
enum {
105
    unk_delete, unk_leave, unk_replace
106
};
107
int transdic, macrodic;
108
int diccnt;
109
struct dic *prepare_dic(char *fname);
110
int getdic(char *dicname);
111
 
112
/*from symtext.c */
113
 
114
extern char styledir[], defbuf[];
115
char *mkfname(char buf[], char *s,...);
116
extern int debug;
117
int nextpool, nexttag;
118
extern poolstruct poolbuf[MAX_POOLS];
119
extern block blockbuf[MAX_BLOCKS];
120
#define OUTSIZE 4096
121
extern char *outptr, *wptr, outbuf[OUTSIZE];
122
extern listtype tagbuf[MAX_BLOCKS];
123
extern int nextblock, nextlist;
124
extern char wbuf[MAX_LINELEN+1];
125
extern listtype listbuf[MAX_LISTS];
126
extern int options;
127
#define op_nocase    (1<<0)
128
#define op_deaccent  (1<<1)
129
#define op_reaccent  (1<<2)
130
#define op_nopunct   (1<<3)
131
#define op_nomath    (1<<4)
132
#define op_noparenth (1<<5)
133
#define op_nocs      (1<<6)
134
#define op_noquote   (1<<7)
135
#define op_matchall  (1<<8)
136
#define op_alphaonly (1<<9)
137
#define op_alnumonly (1<<10)
138
void error(char *msg,...);
139
void _getdef(char buf[], char *name, char value[]);
140
/* from match.c */
141
int mt_string(struct block *blk, char *start, int level);
142
int mt_permpick(struct block *blk, char *start, int level);
143
int mt_m(struct block *blk, char *start, int level);
144
int mt_neg(struct block *blk, char *start, int level);
145
int mt_dic(struct block *blk, char *start, int level);
146
int mt_w(struct block *blk, char *start, int level);
147
int mt_wild(struct block *blk, char *start, int level);
148
int mt_out(struct block *blk, char *start, int level);
149
int mt_nomatch(struct block *blk, char *start, int level);
150
 
151
/* from suffix.c */
152
extern int suffixcnt;
153
void suffix_translate(char *p);
154
void _translate(char *p, int i);
155
void suffix_dic(char *sdicname);
156
 
157
/* from compile.c */
158
void strfold(char *p);
159
extern struct builtin {
160
    char *name;
161
    void (*fn) (char *p, struct block *blk, int next);
162
} builtin[];
163
void compile(char *p);
164
 
165
extern int builtincnt, Mcnt;
166
extern char Mbuf[MAX_LINELEN+1];
167
extern char *Mnext;
168
 
169
/* from match.c */
170
int match(char *p);
10 reyssat 171
#endif
172
 
8161 bpr 173
 
174