| 166 } |
166 } |
| 167 else |
167 else |
| 168 return strerror( errornum ); |
168 return strerror( errornum ); |
| 169 } |
169 } |
| 170 |
170 |
| |
171 /* From glibc 2.2.5 */ |
| |
172 char* wgaim_strsep(char **stringp, const char *delim) { |
| |
173 char *begin, *end; |
| |
174 |
| |
175 begin = *stringp; |
| |
176 if (begin == NULL) |
| |
177 return NULL; |
| |
178 |
| |
179 /* A frequent case is when the delimiter string contains only one |
| |
180 character. Here we don't need to call the expensive `strpbrk' |
| |
181 function and instead work using `strchr'. */ |
| |
182 if (delim[0] == '\0' || delim[1] == '\0') { |
| |
183 char ch = delim[0]; |
| |
184 |
| |
185 if (ch == '\0') |
| |
186 end = NULL; |
| |
187 else { |
| |
188 if (*begin == ch) |
| |
189 end = begin; |
| |
190 else if (*begin == '\0') |
| |
191 end = NULL; |
| |
192 else |
| |
193 end = strchr (begin + 1, ch); |
| |
194 } |
| |
195 } |
| |
196 else |
| |
197 /* Find the end of the token. */ |
| |
198 end = strpbrk (begin, delim); |
| |
199 |
| |
200 if (end) { |
| |
201 /* Terminate the token and set *STRINGP past NUL character. */ |
| |
202 *end++ = '\0'; |
| |
203 *stringp = end; |
| |
204 } |
| |
205 else |
| |
206 /* No more delimiters; this is the last token. */ |
| |
207 *stringp = NULL; |
| |
208 |
| |
209 return begin; |
| |
210 } |
| |
211 |
| 171 /* unistd.h */ |
212 /* unistd.h */ |
| 172 |
213 |
| 173 /* |
214 /* |
| 174 * We need to figure out whether fd is a file or socket handle. |
215 * We need to figure out whether fd is a file or socket handle. |
| 175 */ |
216 */ |