/[winpt]/trunk/Src/wptUtil.cpp
ViewVC logotype

Diff of /trunk/Src/wptUtil.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 224 by twoaday, Mon May 22 14:21:39 2006 UTC revision 225 by twoaday, Tue Jun 6 13:37:59 2006 UTC
# Line 101  check_email_address (const char *email) Line 101  check_email_address (const char *email)
101      if (!strchr (email, '@'))      if (!strchr (email, '@'))
102          return -1;          return -1;
103      for (i=0; i < strlen (email); i++) {      for (i=0; i < strlen (email); i++) {
104          if (isdigit (email[i]) || isalpha (email[i])          if (isxdigit (email[i]) || isalpha (email[i])
105              || strchr (allowed, email[i]))              || strchr (allowed, email[i]))
106              continue;              continue;
107          else          else
# Line 122  substr (const char *str, unsigned int be Line 122  substr (const char *str, unsigned int be
122      if (end > strlen (str) || begin > strlen (str) || (end-begin) < 0)      if (end > strlen (str) || begin > strlen (str) || (end-begin) < 0)
123          return NULL;          return NULL;
124    
125      /*p = new char[end-begin+1]; XXX: fixme*/      p = new char[end-begin+1];
     p = (char*)calloc (1, end-begin+1);  
126      if (!p)      if (!p)
127          abort ();          abort ();
128    
# Line 137  substr (const char *str, unsigned int be Line 136  substr (const char *str, unsigned int be
136  /* Remove %AB sequences from the input buffer @in  /* Remove %AB sequences from the input buffer @in
137     and store the raw data in @out. */     and store the raw data in @out. */
138  void  void
139  unhexify_buffer (const char *in, char **out)  unhexify_buffer (const char *in, char **r_out)
140  {  {
141      char temp[3];      char temp[3], *out;
142      size_t pos, i=0;      size_t len, pos, i=0;
143    
144      *out = (char*)calloc (1, strlen (in)+1);      len = strlen (in);
145      if (!*out)      out = new char[len+1];
146        if (!out)
147          abort ();          abort ();
148      for (pos = 0; pos < strlen (in); pos++) {      memset (out, 0, len+1);
149        for (pos = 0; pos < len; pos++) {
150          if (in[pos] == '%' && in[pos+1] == '%')          if (in[pos] == '%' && in[pos+1] == '%')
151              (*out)[i++] = '%';              out[i++] = '%';
152          else if (in[pos] == '%') {          else if (in[pos] == '%') {
153              temp[0] = in[++pos];              temp[0] = in[++pos];
154              temp[1] = in[++pos];              temp[1] = in[++pos];
155              temp[2] = 0;              temp[2] = 0;
156              (*out)[i++] = (char)strtoul (temp, NULL, 16);              out[i++] = (char)strtoul (temp, NULL, 16);
157          }          }
158          else          else
159              (*out)[i++] = in[pos];              out[i++] = in[pos];
160      }      }
161      (*out)[i] = 0;      out[i] = 0;
162        *r_out = out;
163  }  }

Legend:
Removed from v.224  
changed lines
  Added in v.225

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26