00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "rsync.h"
00030
00031
00032 #ifndef HAVE_STRDUP
00033 char *strdup(char *s)
00034 {
00035 int l = strlen(s) + 1;
00036 char *ret = (char *)malloc(l);
00037 if (ret)
00038 strcpy(ret,s);
00039 return ret;
00040 }
00041 #endif
00042
00043 #ifndef HAVE_GETCWD
00044 char *getcwd(char *buf, int size)
00045 {
00046 return getwd(buf);
00047 }
00048 #endif
00049
00050
00051 #ifndef HAVE_WAITPID
00052 pid_t waitpid(pid_t pid, int *statptr, int options)
00053 {
00054 #ifdef HAVE_WAIT4
00055 return wait4(pid, statptr, options, NULL);
00056 #else
00057
00058
00059
00060
00061 int tmp_pid, dummystat;;
00062 if (kill(pid, 0) == -1) {
00063 errno = ECHILD;
00064 return -1;
00065 }
00066 if (statptr == NULL)
00067 statptr = &dummystat;
00068 while (((tmp_pid = wait3(statptr, options, 0)) != pid) &&
00069 (tmp_pid != -1) && (tmp_pid != 0) && (pid != -1))
00070 ;
00071 return tmp_pid;
00072 #endif
00073 }
00074 #endif
00075
00076
00077 #ifndef HAVE_MEMMOVE
00078 void *memmove(void *dest, const void *src, size_t n)
00079 {
00080 bcopy((char *) src, (char *) dest, n);
00081 return dest;
00082 }
00083 #endif
00084
00085 #ifndef HAVE_STRPBRK
00086
00087
00088
00089
00090
00091 char *strpbrk(const char *s, const char *accept)
00092 {
00093 while (*s != '\0') {
00094 const char *a = accept;
00095 while (*a != '\0') {
00096 if (*a++ == *s) return (char *)s;
00097 }
00098 ++s;
00099 }
00100
00101 return NULL;
00102 }
00103 #endif
00104
00105
00106 #ifndef HAVE_STRLCPY
00107
00108
00109
00110
00111
00112
00113
00114
00115 size_t strlcpy(char *d, const char *s, size_t bufsize)
00116 {
00117 size_t len = strlen(s);
00118 size_t ret = len;
00119 if (bufsize > 0) {
00120 if (len >= bufsize)
00121 len = bufsize-1;
00122 memcpy(d, s, len);
00123 d[len] = 0;
00124 }
00125 return ret;
00126 }
00127 #endif
00128
00129 #ifndef HAVE_STRLCAT
00130
00131
00132
00133
00134
00135
00136
00137 size_t strlcat(char *d, const char *s, size_t bufsize)
00138 {
00139 size_t len1 = strlen(d);
00140 size_t len2 = strlen(s);
00141 size_t ret = len1 + len2;
00142
00143 if (len1 < bufsize - 1) {
00144 if (len2 >= bufsize - len1)
00145 len2 = bufsize - len1 - 1;
00146 memcpy(d+len1, s, len2);
00147 d[len1+len2] = 0;
00148 }
00149 return ret;
00150 }
00151 #endif
00152
00153
00154 int sys_gettimeofday(struct timeval *tv)
00155 {
00156 #ifdef HAVE_GETTIMEOFDAY_TZ
00157 return gettimeofday(tv, NULL);
00158 #else
00159 return gettimeofday(tv);
00160 #endif
00161 }