/[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 213 by twoaday, Mon Mar 27 10:05:14 2006 UTC revision 214 by twoaday, Sun May 14 18:40:36 2006 UTC
# Line 23  Line 23 
23  #endif  #endif
24    
25  #include <string.h>  #include <string.h>
26    #include <stdlib.h>
27  #include <stdio.h>  #include <stdio.h>
28  #include <ctype.h>  #include <ctype.h>
29    
# Line 94  stristr (const char *buf, const char *su Line 95  stristr (const char *buf, const char *su
95  int  int
96  check_email_address (const char *email)  check_email_address (const char *email)
97  {  {
98      const char *allowed = "@._-%+";      const char *allowed = "@._-%+;";
99      size_t i;      size_t i;
100    
101      if (!strchr (email, '@'))      if (!strchr (email, '@'))
# Line 108  check_email_address (const char *email) Line 109  check_email_address (const char *email)
109      }      }
110      return 0;      return 0;
111  }  }
112    
113    
114    /* Return a substring of @str from the position @begin
115       to position @end. */
116    char*
117    substr (const char *str, unsigned int begin, unsigned int end)
118    {    
119        char *p;
120        size_t i, pos;
121    
122        if (end > strlen (str) || begin > strlen (str) || (end-begin) < 0)
123            return NULL;
124    
125        /*p = new char[end-begin+1]; XXX: fixme*/
126        p = (char*)calloc (1, end-begin+1);
127        if (!p)
128            abort ();
129    
130        for (i = begin, pos=0; i < end; i++)
131            p[pos++] = str[i];
132        p[pos] = '\0';
133        return p;
134    }

Legend:
Removed from v.213  
changed lines
  Added in v.214

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26