/[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 216 by twoaday, Sun May 14 18:40:36 2006 UTC revision 217 by twoaday, Mon May 22 14:21:39 2006 UTC
# Line 55  strsep (char **stringp, const char *deli Line 55  strsep (char **stringp, const char *deli
55      }      }
56      else /* Find the end of the token.  */      else /* Find the end of the token.  */
57          end = strpbrk (begin, delim);          end = strpbrk (begin, delim);
58      if ( end ){      if (end) {
59          /* Terminate the token and set *STRINGP past NUL character.  */          /* Terminate the token and set *STRINGP past NUL character.  */
60          *end++ = '\0';          *end++ = '\0';
61          *stringp = end;          *stringp = end;
# Line 132  substr (const char *str, unsigned int be Line 132  substr (const char *str, unsigned int be
132      p[pos] = '\0';      p[pos] = '\0';
133      return p;      return p;
134  }  }
135    
136    
137    /* Remove %AB sequences from the input buffer @in
138       and store the raw data in @out. */
139    void
140    unhexify_buffer (const char *in, char **out)
141    {
142        char temp[3];
143        size_t pos, i=0;
144    
145        *out = (char*)calloc (1, strlen (in)+1);
146        if (!*out)
147            abort ();
148        for (pos = 0; pos < strlen (in); pos++) {
149            if (in[pos] == '%' && in[pos+1] == '%')
150                (*out)[i++] = '%';
151            else if (in[pos] == '%') {
152                temp[0] = in[++pos];
153                temp[1] = in[++pos];
154                temp[2] = 0;
155                (*out)[i++] = (char)strtoul (temp, NULL, 16);
156            }
157            else
158                (*out)[i++] = in[pos];
159        }
160        (*out)[i] = 0;
161    }

Legend:
Removed from v.216  
changed lines
  Added in v.217

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26