Rev 8896 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 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 | */ |
||
7678 | bpr | 17 | /* line input / output / translation routines |
8067 | bpr | 18 | * and error routines |
19 | */ |
||
10 | reyssat | 20 | |
8195 | bpr | 21 | /*#include <stdarg.h>*/ |
8135 | bpr | 22 | #include "../Lib/libwims.h" |
23 | #include "msg2wims.h" |
||
10 | reyssat | 24 | |
8195 | bpr | 25 | void msg_error(char *p) |
10 | reyssat | 26 | { |
12247 | bpr | 27 | fprintf(stderr,"%s\n",p); |
10 | reyssat | 28 | } |
29 | |||
30 | void bailout(int i1, int i2, char *msg) |
||
31 | { |
||
12247 | bpr | 32 | if(*msg) msg_error(msg); |
33 | printf("%d %d",i1,i2); exit(0); |
||
10 | reyssat | 34 | } |
35 | |||
7678 | bpr | 36 | /* find html tag end */ |
10 | reyssat | 37 | char *find_tag_end(char *p) |
38 | { |
||
12247 | bpr | 39 | char *pp; |
7678 | bpr | 40 | |
12247 | bpr | 41 | p++; if(*p=='!') { |
42 | if(*(p+1)=='-' && *(p+2)=='-') { |
||
43 | pp=strstr(p,"-->"); if(pp==NULL) return p+strlen(p); |
||
44 | else return p+2; |
||
10 | reyssat | 45 | } |
12247 | bpr | 46 | } |
47 | /* else */ { |
||
48 | pp=strchr(p,'>'); |
||
49 | if(pp==NULL) return p+strlen(p); |
||
50 | else return pp; |
||
51 | } |
||
7678 | bpr | 52 | /* Now the following is not executed. */ |
10 | reyssat | 53 | /* for(pp=p;*pp;pp++) { |
7678 | bpr | 54 | switch(*pp) { |
55 | case '>': return pp; |
||
56 | case '"': { |
||
57 | pp=strchr(++pp,'"'); if(pp==NULL) return p+strlen(p); |
||
58 | break; |
||
59 | } |
||
60 | default: break; |
||
61 | } |
||
10 | reyssat | 62 | } |
63 | return pp; |
||
64 | */ |
||
65 | } |
||
66 | |||
8067 | bpr | 67 | /* modify a string. Bufferlen must be at least MAX_LINELEN */ |
10 | reyssat | 68 | void string_modify2(char *start, char *bad_beg, char *bad_end, char *good,...) |
69 | { |
||
12247 | bpr | 70 | char buf[MAX_LINELEN+1]; |
71 | va_list vp; |
||
7678 | bpr | 72 | |
12247 | bpr | 73 | va_start(vp,good); |
74 | vsnprintf(buf,sizeof(buf),good,vp); va_end(vp); |
||
75 | if(strlen(start)-(bad_end-bad_beg)+strlen(buf)>=MAX_LINELEN) |
||
76 | bailout(inlen,0,"string too long"); |
||
77 | strcat(buf,bad_end); |
||
78 | ovlstrcpy(bad_beg,buf); |
||
10 | reyssat | 79 | } |
80 | |||
7678 | bpr | 81 | /* strcmp() to be used within qsort(). */ |
10 | reyssat | 82 | int _scmp(const void *p1, const void *p2) |
83 | { |
||
12247 | bpr | 84 | const char **s1,**s2; |
7678 | bpr | 85 | |
12247 | bpr | 86 | s1=(const char **) p1; s2=(const char **) p2; |
87 | return strcmp(*s1,*s2); |
||
10 | reyssat | 88 | } |
89 | |||
90 | char *substit(char *p) |
||
91 | { |
||
12247 | bpr | 92 | char *pp; |
93 | while((pp=strchr(p,'$'))!=NULL) *pp=' '; |
||
94 | return p; |
||
10 | reyssat | 95 | } |