|
|
#include "libxode.h"
Go to the source code of this file.
Functions | |
xode_pool | xode_spool_getpool (const xode_spool s) |
int | xode_spool_getlen (const xode_spool s) |
void | xode_spool_free (xode_spool s) |
xode_spool | xode_spool_newfrompool (xode_pool p) |
xode_spool | xode_spool_new (void) |
void | xode_spool_add (xode_spool s, char *str) |
void | xode_spooler (xode_spool s,...) |
char * | xode_spool_tostr (xode_spool s) |
char * | xode_spool_str (xode_pool p,...) |
char * | xode_strunescape (xode_pool p, char *buf) |
char * | xode_strescape (xode_pool p, char *buf) |
|
Definition at line 60 of file str.c. References xode_spool_node::c, xode_spool_struct::first, xode_spool_struct::last, xode_spool_struct::len, xode_spool_node::next, xode_spool_struct::p, xode_pool_malloc(), xode_pool_strdup(), and xode_spool. Referenced by _xode_to_prettystr(), jid_full(), spools(), xode_spool_str(), and xode_spooler(). 00061 { 00062 struct xode_spool_node *sn; 00063 int len; 00064 00065 if(str == NULL) 00066 return; 00067 00068 len = strlen(str); 00069 if(len == 0) 00070 return; 00071 00072 sn = xode_pool_malloc(s->p, sizeof(struct xode_spool_node)); 00073 sn->c = xode_pool_strdup(s->p, str); 00074 sn->next = NULL; 00075 00076 s->len += len; 00077 if(s->last != NULL) 00078 s->last->next = sn; 00079 s->last = sn; 00080 if(s->first == NULL) 00081 s->first = sn; 00082 }
|
|
Definition at line 38 of file str.c. References xode_pool_free(), xode_spool, and xode_spool_getpool(). 00039 { 00040 xode_pool_free(xode_spool_getpool(s)); 00041 }
|
|
Definition at line 30 of file str.c. References xode_spool_struct::len, and xode_spool. 00031 { 00032 if(s == NULL) 00033 return 0; 00034 00035 return s->len; 00036 }
|
|
Definition at line 22 of file str.c. References xode_spool_struct::p, xode_pool, and xode_spool. Referenced by xode_spool_free(). 00023 { 00024 if(s == NULL) 00025 return NULL; 00026 00027 return s->p; 00028 }
|
|
Definition at line 55 of file str.c. References xode_pool_heap(), xode_spool, and xode_spool_newfrompool(). 00056 { 00057 return xode_spool_newfrompool(xode_pool_heap(512)); 00058 }
|
|
Definition at line 43 of file str.c. References xode_spool_struct::first, xode_spool_struct::last, xode_spool_struct::len, xode_spool_struct::p, xode_pool, xode_pool_malloc(), and xode_spool. Referenced by jid_full(), spools(), xode_spool_new(), xode_spool_str(), and xode_to_prettystr(). 00044 { 00045 xode_spool s; 00046 00047 s = xode_pool_malloc(p, sizeof(struct xode_spool_struct)); 00048 s->p = p; 00049 s->len = 0; 00050 s->last = NULL; 00051 s->first = NULL; 00052 return s; 00053 }
|
|
Definition at line 130 of file str.c. References xode_pool, xode_spool, xode_spool_add(), xode_spool_newfrompool(), and xode_spool_tostr(). 00131 { 00132 va_list ap; 00133 xode_spool s; 00134 char *arg = NULL; 00135 00136 if(p == NULL) 00137 return NULL; 00138 00139 s = xode_spool_newfrompool(p); 00140 00141 va_start(ap, p); 00142 00143 /* loop till we hit our end flag, the first arg */ 00144 while(1) 00145 { 00146 arg = va_arg(ap,char *); 00147 if((int)arg == (int)p) 00148 break; 00149 else 00150 xode_spool_add(s, arg); 00151 } 00152 00153 va_end(ap); 00154 00155 return xode_spool_tostr(s); 00156 }
|
|
Definition at line 107 of file str.c. References xode_spool_node::c, xode_spool_struct::first, xode_spool_struct::len, xode_spool_node::next, NULL, xode_spool_struct::p, xode_pool_malloc(), and xode_spool. Referenced by jid_full(), xode_spool_str(), xode_to_prettystr(), and xode_to_str(). 00108 { 00109 char *ret,*tmp; 00110 struct xode_spool_node *next; 00111 00112 if(s == NULL || s->len == 0 || s->first == NULL) 00113 return NULL; 00114 00115 ret = xode_pool_malloc(s->p, s->len + 1); 00116 *ret = '\0'; 00117 00118 next = s->first; 00119 tmp = ret; 00120 while(next != NULL) 00121 { 00122 tmp = strcat(tmp,next->c); 00123 next = next->next; 00124 } 00125 00126 return ret; 00127 }
|
|
Definition at line 84 of file str.c. References xode_spool, and xode_spool_add(). Referenced by _xode_to_prettystr(), and jid_full(). 00085 { 00086 va_list ap; 00087 char *arg = NULL; 00088 00089 if(s == NULL) 00090 return; 00091 00092 va_start(ap, s); 00093 00094 /* loop till we hit our end flag, the first arg */ 00095 while(1) 00096 { 00097 arg = va_arg(ap,char *); 00098 if((int)arg == (int)s || arg == NULL) 00099 break; 00100 else 00101 xode_spool_add(s, arg); 00102 } 00103 00104 va_end(ap); 00105 }
|
|
Definition at line 203 of file str.c. References NULL, xode_pool, and xode_pool_malloc(). 00204 { 00205 int i,j,oldlen,newlen; 00206 char *temp; 00207 00208 if (p == NULL || buf == NULL) return(NULL); 00209 00210 oldlen = newlen = strlen(buf); 00211 for(i=0;i<oldlen;i++) 00212 { 00213 switch(buf[i]) 00214 { 00215 case '&': 00216 newlen+=5; 00217 break; 00218 case '\'': 00219 newlen+=6; 00220 break; 00221 case '\"': 00222 newlen+=6; 00223 break; 00224 case '<': 00225 newlen+=4; 00226 break; 00227 case '>': 00228 newlen+=4; 00229 break; 00230 } 00231 } 00232 00233 if(oldlen == newlen) return buf; 00234 00235 temp = xode_pool_malloc(p,newlen+1); 00236 00237 if (temp==NULL) return(NULL); 00238 00239 for(i=j=0;i<oldlen;i++) 00240 { 00241 switch(buf[i]) 00242 { 00243 case '&': 00244 memcpy(&temp[j],"&",5); 00245 j += 5; 00246 break; 00247 case '\'': 00248 memcpy(&temp[j],"'",6); 00249 j += 6; 00250 break; 00251 case '\"': 00252 memcpy(&temp[j],""",6); 00253 j += 6; 00254 break; 00255 case '<': 00256 memcpy(&temp[j],"<",4); 00257 j += 4; 00258 break; 00259 case '>': 00260 memcpy(&temp[j],">",4); 00261 j += 4; 00262 break; 00263 default: 00264 temp[j++] = buf[i]; 00265 } 00266 } 00267 temp[j] = '\0'; 00268 return temp; 00269 }
|
|
Definition at line 159 of file str.c. References NULL, xode_pool, and xode_pool_malloc(). 00160 { 00161 int i,j=0; 00162 char *temp; 00163 00164 if (p == NULL || buf == NULL) return(NULL); 00165 00166 if (strchr(buf,'&') == NULL) return(buf); 00167 00168 temp = xode_pool_malloc(p,strlen(buf)+1); 00169 00170 if (temp == NULL) return(NULL); 00171 00172 for(i=0;i<strlen(buf);i++) 00173 { 00174 if (buf[i]=='&') 00175 { 00176 if (strncmp(&buf[i],"&",5)==0) 00177 { 00178 temp[j] = '&'; 00179 i += 4; 00180 } else if (strncmp(&buf[i],""",6)==0) { 00181 temp[j] = '\"'; 00182 i += 5; 00183 } else if (strncmp(&buf[i],"'",6)==0) { 00184 temp[j] = '\''; 00185 i += 5; 00186 } else if (strncmp(&buf[i],"<",4)==0) { 00187 temp[j] = '<'; 00188 i += 3; 00189 } else if (strncmp(&buf[i],">",4)==0) { 00190 temp[j] = '>'; 00191 i += 3; 00192 } 00193 } else { 00194 temp[j]=buf[i]; 00195 } 00196 j++; 00197 } 00198 temp[j]='\0'; 00199 return(temp); 00200 }
|
Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |