Subversion Repositories wimsdev

Rev

Rev 8082 | Rev 8103 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8082 Rev 8100
Line 14... Line 14...
14
 *  along with this program; if not, write to the Free Software
14
 *  along with this program; if not, write to the Free Software
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 */
16
 */
17
 
17
 
18
/* dvi 2 gif driver, tex standard */
18
/* dvi 2 gif driver, tex standard */
19
#include "../Lib/basicstr.c"
19
#include "../Lib/libwims.h"
20
 
20
 
21
void error(char *s)
21
void error(char *s)
22
{
22
{
23
    fprintf(stderr,"%s: %s\n",progname, s);
23
    fprintf(stderr,"%s: %s\n",progname, s);
24
    exit(1);
24
    exit(1);
25
}
25
}
26
 
26
 
-
 
27
/*
27
void *xmalloc(size_t n)
28
void *xmalloc(size_t n)
28
{
29
{
29
    void *p;
30
    void *p;
30
    p=malloc(n);
31
    p=malloc(n);
31
    if(p==NULL) error("Malloc failure.");
32
    if(p==NULL) error("Malloc failure.");
32
    return p;
33
    return p;
33
}
34
}
34
 
35
*/
35
unsigned long int texint(void *bp, int l)
36
unsigned long int texint(void *bp, int l)
36
{
37
{
37
    unsigned long int o, t;
38
    unsigned long int o, t;
38
    unsigned char c, *p;
39
    unsigned char c, *p;
39
    int i;
40
    int i;
Line 43... Line 44...
43
    }
44
    }
44
    return o;
45
    return o;
45
}
46
}
46
 
47
 
47
long int texintsigned(void *bp, int l)
48
long int texintsigned(void *bp, int l)
48
{
49
{
49
    long int o, t;
50
    long int o, t;
50
    signed char c, *p;
51
    signed char c, *p;
51
    int i;
52
    int i;
52
    if(l<=0) return 0;
53
    if(l<=0) return 0;
53
    p=bp; o=*p;
54
    p=bp; o=*p;
Line 56... Line 57...
56
    }
57
    }
57
    return o;
58
    return o;
58
}
59
}
59
 
60
 
60
        /* Strips leading spaces */
61
        /* Strips leading spaces */
-
 
62
/*
61
char *find_word_start(char *p)
63
char *find_word_start(char *p)
62
{
64
{
63
    int i;
65
    int i;
64
    for(i=0; isspace(*p); p++,i++);
66
    for(i=0; isspace(*p); p++,i++);
65
    return p;
67
    return p;
66
}
68
}
67
 
69
*/
68
        /* Points to the end of the word */
70
/* Points to the end of the word */
-
 
71
/*
69
char *find_word_end(char *p)
72
char *find_word_end(char *p)
70
{
73
{
71
    int i;
74
    int i;
72
    for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++);
75
    for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++);
73
    return p;
76
    return p;
74
}
77
}
-
 
78
*/
75
 
79
 
76
/* searches a list. Returns index if found, (-1-index of insertion) if nomatch.
80
/* searches a list. Returns index if found, (-1-index of insertion) if nomatch.
77
 * Uses binary search, list must be sorted. */
81
 * Uses binary search, list must be sorted. */
78
 
82
 
-
 
83
/*
79
int search_list(void *list, int items, size_t item_size, const char *str)
84
int search_list(void *list, int items, size_t item_size, const char *str)
80
{
85
{
81
 int i = 0;
86
 int i = 0;
82
 while (items > 0)
87
 while (items > 0)
83
   {
88
   {
Line 86... Line 91...
86
     if (k == 0) return j;
91
     if (k == 0) return j;
87
     if (k > 0) items = m; else {i = j + 1; items -= (m + 1);}
92
     if (k > 0) items = m; else {i = j + 1; items -= (m + 1);}
88
   }
93
   }
89
 return ~i;
94
 return ~i;
90
}
95
}
91
 
96
*/
92
        /* get the content of a file, and store in buf. */
97
        /* get the content of a file, and store in buf. */
93
int getfile(char *fname, unsigned char **buf)
98
int getfile(char *fname, unsigned char **buf)
94
{
99
{
95
    FILE *f;
100
    FILE *f;
96
    long l, l2;
101
    long l, l2;
Line 153... Line 158...
153
    t=execredirected("sh",NULL,NULL,NULL,parmbuf);
158
    t=execredirected("sh",NULL,NULL,NULL,parmbuf);
154
    sync(); return t;
159
    sync(); return t;
155
}
160
}
156
 
161
 
157
        /* recursively generate a directory structure */
162
        /* recursively generate a directory structure */
-
 
163
/*
158
void mkdirs(char *s)
164
void mkdirs(char *s)
159
{
165
{
160
    struct stat st;
166
    struct stat st;
161
    char *buf;
167
    char *buf;
162
    if(stat(s,&st)==-1) {
168
    if(stat(s,&st)==-1) {
Line 166... Line 172...
166
            mkdirs(buf); free(buf);
172
            mkdirs(buf); free(buf);
167
        }
173
        }
168
        mkdir(s,-1);
174
        mkdir(s,-1);
169
    }
175
    }
170
}
176
}
-
 
177
*/
171
 
178