File: string_ext.c

package info (click to toggle)
ssmtp 2.33-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 220 kB
  • ctags: 102
  • sloc: ansic: 1,249; makefile: 86; sh: 74
file content (108 lines) | stat: -rw-r--r-- 1,440 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
   ** strings.c -- Local strings routines.
 */
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
#include "string_ext.h"

#ifdef NOSTRDUP
char *
strdup (p)
     char *p;
{
  char *q, *malloc (), *strcpy ();

  if ((q = malloc ((unsigned) strlen (p) + 1)) == NULL)
    {
      return NULL;
    }
  else
    {
      return strcpy (q, p);
    }
}
#endif

#ifdef NOSTRNCASECMP
int
strncasecmp (p, q, n)
     char *p, *q;
     int n;
{
  int i;
  char c, d;

  for (i = 0; i < n; i++, p++, q++)
    {
      if (*p != *q)
	{
	  if (isascii (c = *p) && isascii (d = *q))
	    {
	      if (tolower (c) != tolower (d))
		{
		  return c - d;
		}
	    }
	  else
	    {
	      return c - d;
	    }
	}
    }
  return 0;
}
#endif

#ifdef NOSTRTOK
char *
strtok (input, seperators)
     char *input, *seperators;
{
  static char *at;
  char *p, *q, *strchr ();

  if (input != NULL)
    {
      at = input;
    }
  for (p = at; *p; p++)
    {
      if (strchr (seperators, *p) != NULL)
	{
	  /* Found one. */
	  *p = '\0';
	  q = at;
	  at = p + 1;
	  return q;
	}
    }
  if (p == at)
    {
      return NULL;
    }
  else
    {
      return at;
    }
  /*@NOTREACHED@ */
}
#endif

#ifdef NOSTRSTR
char *
strstr (string, substr)
     char *string, *substr;
{
  char *p, *strchr ();

  for (p = strchr (string, *substr); p && *p; p++)
    {
      if (strncmp (p, substr, strlen (substr)) == 0)
	{
	  return p;
	}
    }
  return NULL;
}
#endif