File: missing.c

package info (click to toggle)
clearsilver 0.10.5-1%2Bsqueeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,440 kB
  • ctags: 3,139
  • sloc: ansic: 24,586; python: 4,233; sh: 2,945; cs: 1,429; ruby: 819; java: 735; makefile: 600; perl: 118; lisp: 34; sql: 21
file content (91 lines) | stat: -rw-r--r-- 1,951 bytes parent folder | download | duplicates (8)
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
/* Missing Functions 
 * 
 * The functions included here are provided as replacements for system
 * library functions that are missing (or broken).
 *
 * Yes, configure usually tries to get you to have a single file for
 * each function, but pppbbbttthhhhh.
 *
 * To my knowledge, each of these replacement functions are available as
 * free code... if not, I'll have to steal them from somewhere else that
 * is free (hmm, FreeBSD libc?)
 */

#include "cs_config.h"

#ifndef HAVE_STRTOK_R
#include <string.h>

/* from glibc */
/* Parse S into tokens separated by characters in DELIM.
   If S is NULL, the saved pointer in SAVE_PTR is used as
   the next starting point.  For example:
     char s[] = "-abc-=-def";
     char *sp;
     x = strtok_r(s, "-", &sp);  // x = "abc", sp = "=-def"
     x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
     x = strtok_r(NULL, "=", &sp);   // x = NULL 
          // s = "abc\0-def\0"
*/

char * strtok_r (char *s,const char * delim, char **save_ptr)
{
  char *token;

  if (s == NULL)
    s = *save_ptr;

  /* Scan leading delimiters.  */
  s += strspn (s, delim);
  if (*s == '\0')
  {
    *save_ptr = s;
    return NULL;
  }

  /* Find the end of the token.  */
  token = s;
  s = strpbrk (token, delim);
  if (s == NULL)
    /* This token finishes the string.  */
    /**save_ptr = __rawmemchr (token, '\0');*/
    *save_ptr = strchr (token, '\0');
  else
  {
    /* Terminate the token and make
     * *SAVE_PTR point past it.  */
    *s = '\0';
    *save_ptr = s + 1;
  }
  return token;
}
#endif

#include <time.h>

#ifndef HAVE_LOCALTIME_R

struct tm *localtime_r (const time_t *timep, struct tm *ttm)
{
  ttm = localtime(timep);
  return ttm;
}
#endif

#ifndef HAVE_GMTIME_R
struct tm *gmtime_r(const time_t *timep, struct tm *ttm)
{
  ttm = gmtime(timep);
  return ttm;
}

#endif

#ifndef HAVE_MKSTEMP
#include <fcntl.h>

int mkstemp(char *path) 
{
  return open(mktemp(path),O_RDWR);
}
#endif