/[hydra]/hydra/src/strutil.c
ViewVC logotype

Annotation of /hydra/src/strutil.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Sat Oct 5 09:39:36 2002 UTC (21 years, 5 months ago) by nmav
Branch: MAIN
CVS Tags: hydra_0_1_6_without_hic, hydra_0_0_8, hydra_0_0_9, hydra_0_0_7, hydra_0_1_3, hydra_0_1_2, hydra_0_1_1, hydra_0_1_0, hydra_0_1_7, hydra_0_1_6, hydra_0_1_4, hydra_0_1_8, hydra_0_0_10, HEAD
Branch point for: hydra_0_1_0_patches
Changes since 1.2: +8 -0 lines
File MIME type: text/plain
More SSL additions.

1 nmav 1.1
2 nmav 1.2 #include <string.h>
3 nmav 1.1 #include "compat.h"
4    
5     /*
6     * Name: strstr and strdup
7     *
8     * These are the standard library utilities. We define them here for
9     * systems that don't have them.
10     */
11    
12     #ifndef HAVE_STRSTR
13     char *strstr(char *s1, char *s2)
14     { /* from libiberty */
15     char *p;
16     int len = strlen(s2);
17    
18     if (*s2 == '\0') /* everything matches empty string */
19     return s1;
20     for (p = s1; (p = strchr(p, *s2)) != NULL; p = strchr(p + 1, *s2)) {
21     if (strncmp(p, s2, len) == 0)
22     return (p);
23     }
24     return NULL;
25     }
26     #endif
27    
28     #ifndef HAVE_STRDUP
29     char *strdup(char *s)
30     {
31     char *retval;
32    
33     retval = (char *) malloc(strlen(s) + 1);
34     if (retval == NULL) {
35     perror("Hydra: out of memory in strdup");
36     exit(1);
37     }
38     return strcpy(retval, s);
39     }
40     #endif
41 nmav 1.2
42     #ifndef HAVE_ALPHASORT
43    
44     int alphasort(const struct dirent **a, const struct dirent **b)
45     {
46     return (strcmp((*a)->d_name, (*b)->d_name));
47     }
48    
49     #endif /* HAVE_ALPHASORT */
50 nmav 1.3
51     #ifndef HAVE_GMTIME_R
52     struct tm *gmtime_r(const time_t *timep, struct tm *result)
53     {
54     memcpy( result, gmtime( timep), sizeof( struct tm));
55     return result;
56     }
57     #endif

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26