Subversion Repositories wimsdev

Rev

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

Rev 8120 Rev 8149
Line 48... Line 48...
48
void check_parm(char *p);
48
void check_parm(char *p);
49
void output(char *p);
49
void output(char *p);
50
void about(void);
50
void about(void);
51
char *dynsetup(char *p, char *end);
51
char *dynsetup(char *p, char *end);
52
 
52
 
53
/*
-
 
54
void *xmalloc(size_t n)
-
 
55
{
-
 
56
    void *p;
-
 
57
    p=malloc(n);
-
 
58
    if(p==NULL) {
-
 
59
      fprintf(stderr, "%s: Malloc failure.\n",progname);
-
 
60
      exit(1);
-
 
61
    }
-
 
62
    return p;
-
 
63
}
-
 
64
*/
-
 
65
/* strip trailing spaces; return string end. */
53
/* strip trailing spaces; return string end. */
66
char *strip_trailing_spaces2(char *p)
54
char *strip_trailing_spaces2(char *p)
67
{
55
{
68
    char *pp;
56
    char *pp;
69
    if(*p==0) return p;
57
    if(*p==0) return p;
70
    for(pp=p+strlen(p)-1; pp>=p && isspace(*pp); *(pp--)=0);
58
    for(pp=p+strlen(p)-1; pp>=p && isspace(*pp); *(pp--)=0);
71
    return pp;
59
    return pp;
72
}
60
}
73
 
61
 
74
/* Points to the end of the word */
-
 
75
/*
-
 
76
char *find_word_end(char *p)
-
 
77
{
62
 
78
    int i;
-
 
79
    for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++);
-
 
80
    return p;
-
 
81
}
-
 
82
*/
-
 
83
/* Strips leading spaces */
-
 
84
/*
-
 
85
char *find_word_start(char *p)
-
 
86
{
-
 
87
    int i;
-
 
88
    for(i=0; isspace(*p) && i<MAX_LINELEN; p++,i++);
-
 
89
    return p;
-
 
90
}
-
 
91
*/
-
 
92
/* Find first occurrence of word */
63
/* Find first occurrence of word */
93
char *wordchr2(char *p, char *w)
64
char *wordchr2(char *p, char *w)
94
{
65
{
95
    char *r;
66
    char *r;
96
 
67
 
Line 99... Line 70...
99
      ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) );
70
      ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) );
100
      r=strstr(r+1,w));
71
      r=strstr(r+1,w));
101
    return r;
72
    return r;
102
}
73
}
103
 
74
 
104
/* Returns the pointer or NULL. */
-
 
105
/*
-
 
106
char *varchr(char *p, char *v)
-
 
107
{
-
 
108
        char *pp; int n=strlen(v);
-
 
109
        for(pp=strstr(p,v); pp!=NULL; pp=strstr(pp+1,v)) {
-
 
110
          if((pp==p || (!isalnum(*(pp-1)) && *(pp-1)!='_')) &&
-
 
111
             ((!isalnum(*(pp+n)) && *(pp+n)!='_') || *(pp+n)==0)) break;
-
 
112
        }
-
 
113
        return pp;
-
 
114
}
-
 
115
*/
-
 
116
/* find matching parenthesis */
75
/* find matching parenthesis */
117
char *find_matching2(char *p, char c)
76
char *find_matching2(char *p, char c)
118
{
77
{
119
    char *pp;
78
    char *pp;
120
    int parenth, brak, brace;
79
    int parenth, brak, brace;
Line 135... Line 94...
135
      }
94
      }
136
    }
95
    }
137
    if(*pp!=c) return NULL;
96
    if(*pp!=c) return NULL;
138
    return pp;
97
    return pp;
139
}
98
}
140
 
-
 
141
/* searches a list. Returns index if found, (-1-index of insertion) if nomatch.
-
 
142
 * Uses binary search, list must be sorted. */
-
 
143
 
-
 
144
/*
-
 
145
int search_list(void *list, int items, size_t item_size, const char *str)
-
 
146
{
-
 
147
 int i = 0;
-
 
148
 while (items > 0)
-
 
149
   {
-
 
150
     int m = items / 2, j = i + m;
-
 
151
     int k = strcmp(*(char **)(list + j * item_size), str);
-
 
152
     if (k == 0) return j;
-
 
153
     if (k > 0) items = m; else {i = j + 1; items -= (m + 1);}
-
 
154
   }
-
 
155
 return ~i;
-
 
156
}
-
 
157
*/
-
 
158
 
99
 
159
/* Read/write to a file with variable parms to print filename */
100
/* Read/write to a file with variable parms to print filename */
160
void accessfile(char *content, char *type, char *s,...)
101
void accessfile(char *content, char *type, char *s,...)
161
{
102
{
162
    va_list vp;
103
    va_list vp;