Changeset 169 for trunk/src/slib.c
- Timestamp:
- Apr 13, 2008, 9:59:55 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/slib.c
r167 r169 108 108 int sl_trace_use (const char * dummy) 109 109 { 110 if (dummy) 111 slib_do_trace = 1; 112 else 113 slib_do_trace = 1; 110 (void) dummy; 111 slib_do_trace = 1; 114 112 return 0; 115 113 } … … 156 154 fprintf(trace_fp, "[%2d] %s \t - File %c%s%c at line %d\n", 157 155 trace_level, str, 0x22, file, 0x22, line); 156 fflush(trace_fp); 158 157 } 159 158 else … … 191 190 fprintf(trace_fp, _("[%2d] %s \t - File %c%s%c at line %d\n"), 192 191 trace_level, str, 0x22, file, 0x22, line); 192 fflush(trace_fp); 193 193 } 194 194 else … … 1007 1007 } 1008 1008 1009 #include <ctype.h> 1010 int sl_strcasecmp(const char * one, const char * two) 1011 { 1012 #ifdef SL_FAIL_ON_ERROR 1013 SL_REQUIRE (one != NULL, _("one != NULL")); 1014 SL_REQUIRE (two != NULL, _("two != NULL")); 1015 #endif 1016 1017 if (one && two) 1018 { 1019 do { 1020 if (*one && *two) 1021 { 1022 if (tolower(*one) == tolower(*two)) 1023 { 1024 ++one; ++two; 1025 } 1026 else if (tolower(*one) < tolower(*two)) 1027 return -1; 1028 else 1029 return 1; 1030 } 1031 else if (*one == '\0' && *two == '\0') 1032 return 0; 1033 else if (*one == '\0') 1034 return -1; 1035 else 1036 return 1; 1037 } while (1 == 1); 1038 } 1039 else if (one == NULL && two != NULL) 1040 return -1; 1041 else if (one != NULL && two == NULL) 1042 return 1; 1043 else 1044 return -7; /* default to not equal */ 1045 } 1009 1046 1010 1047 int sl_strcmp(const char * a, const char * b) … … 1022 1059 return (1); 1023 1060 else 1024 return (-7); /* arbitrary*/1061 return (-7); /* default to not equal */ 1025 1062 } 1026 1063 … … 1040 1077 return (1); 1041 1078 else 1042 return (-7); /* arbitrary*/1079 return (-7); /* default to not equal */ 1043 1080 } 1044 1081 … … 2232 2269 if (is_nonblocking == SL_FALSE) 2233 2270 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2271 TPT(( 0, FIL__, __LINE__, _("msg=<read error>"))); 2234 2272 return (SL_EREAD); 2235 2273 } … … 2247 2285 if (is_nonblocking == SL_FALSE) 2248 2286 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2287 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2249 2288 return (SL_TIMEOUT); 2250 2289 } … … 2253 2292 if (is_nonblocking == SL_FALSE) 2254 2293 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2294 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2255 2295 return (SL_EREAD); 2256 2296 } … … 2260 2300 if (is_nonblocking == SL_FALSE) 2261 2301 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2302 TPT(( 0, FIL__, __LINE__, _("msg=<terminated>"))); 2262 2303 return (SL_EREAD); 2263 2304 } … … 2270 2311 if (is_nonblocking == SL_FALSE) 2271 2312 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2313 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2272 2314 return (SL_TIMEOUT); 2273 2315 } … … 2282 2324 int timeout, int is_nonblocking) 2283 2325 { 2284 int fd ;2326 int fd, retval; 2285 2327 2328 SL_ENTER(_("sl_read_timeout")); 2329 2286 2330 if (buf_in == NULL || SL_ISERROR(fd = get_the_fd(ticket))) 2287 2331 { … … 2289 2333 { 2290 2334 TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>"))); 2291 return (SL_ENULL);2335 SL_IRETURN((SL_ENULL), _("sl_read_timeout")); 2292 2336 } 2293 2337 if (SL_ISERROR(fd = get_the_fd(ticket))) 2294 2338 { 2295 2339 TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd)); 2296 return (fd);2340 SL_IRETURN((fd), _("sl_read_timeout")); 2297 2341 } 2298 2342 } 2299 2343 2300 return sl_read_timeout_fd (fd, buf_in, count, timeout, is_nonblocking); 2344 retval = sl_read_timeout_fd (fd, buf_in, count, timeout, is_nonblocking); 2345 SL_IRETURN((retval), _("sl_read_timeout")); 2301 2346 } 2302 2347 … … 2310 2355 char * buf; 2311 2356 2357 SL_ENTER(_("sl_read")); 2358 2312 2359 if (count < 1) 2313 2360 { 2314 2361 TPT(( 0, FIL__, __LINE__, _("msg=<range error>"))); 2315 return(SL_ERANGE);2362 SL_IRETURN((SL_ERANGE), _("sl_read")); 2316 2363 } 2317 2364 if (buf_in == NULL) 2318 2365 { 2319 2366 TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>"))); 2320 return (SL_ENULL);2367 SL_IRETURN((SL_ENULL), _("sl_read")); 2321 2368 } 2322 2369 … … 2324 2371 { 2325 2372 TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd)); 2326 return (fd);2373 SL_IRETURN((fd), _("sl_read")); 2327 2374 } 2328 2375 … … 2345 2392 { 2346 2393 TPT(( 0, FIL__, __LINE__, _("msg=<read error> errno=<%d>\n"), errno)); 2347 return (SL_EREAD);2348 } 2349 return (bytes);2394 SL_IRETURN((SL_EREAD), _("sl_read")); 2395 } 2396 SL_IRETURN((bytes), _("sl_read")); 2350 2397 } 2351 2398 … … 2357 2404 char * buf; 2358 2405 2406 SL_ENTER(_("sl_read_fast")); 2407 2359 2408 if (count < 1) 2360 2409 { 2361 2410 TPT(( 0, FIL__, __LINE__, _("msg=<range error>"))); 2362 return(SL_ERANGE);2411 SL_IRETURN((SL_ERANGE), _("sl_read_fast")); 2363 2412 } 2364 2413 if (buf_in == NULL) 2365 2414 { 2366 2415 TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>"))); 2367 return (SL_ENULL);2416 SL_IRETURN((SL_ENULL), _("sl_read_fast")); 2368 2417 } 2369 2418 … … 2371 2420 { 2372 2421 TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd)); 2373 return (fd);2422 SL_IRETURN((fd), _("sl_read_fast")); 2374 2423 } 2375 2424 … … 2381 2430 if (byteread >= 0) 2382 2431 { 2383 return (byteread);2432 SL_IRETURN((byteread), _("sl_read_fast")); 2384 2433 } 2385 2434 } while ( byteread == -1 && (errno == EINTR || errno == EAGAIN)); … … 2389 2438 { 2390 2439 TPT(( 0, FIL__, __LINE__, _("msg=<read error> errno=<%d>\n"), errno)); 2391 return (SL_EREAD);2392 } 2393 return (0);2440 SL_IRETURN((SL_EREAD), _("sl_read_fast")); 2441 } 2442 SL_IRETURN((0), _("sl_read_fast")); 2394 2443 } 2395 2444
Note:
See TracChangeset
for help on using the changeset viewer.