summaryrefslogtreecommitdiffstats
path: root/media/mtransport/third_party/nrappkit/upstream.diff
blob: df296677f19d2127b24ad8ba1a529cf9f3e63561 (plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
diff --git a/media/mtransport/third_party/nrappkit/src/event/async_wait.h b/media/mtransport/third_party/nrappkit/src/event/async_wait.h
--- a/media/mtransport/third_party/nrappkit/src/event/async_wait.h
+++ b/media/mtransport/third_party/nrappkit/src/event/async_wait.h
@@ -38,21 +38,21 @@
 
 
 #ifndef _async_wait_h
 #define _async_wait_h
 
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 #include <csi_platform.h>
 
-typedef void (*NR_async_cb)(int resource,int how,void *arg);
+typedef void (*NR_async_cb)(NR_SOCKET resource,int how,void *arg);
 
 #define NR_ASYNC_WAIT_READ 0
 #define NR_ASYNC_WAIT_WRITE 1
 
 
 int NR_async_wait_init(void);
 int NR_async_wait(NR_SOCKET sock, int how, NR_async_cb cb,void *cb_arg,
                             char *function,int line);
 int NR_async_cancel(NR_SOCKET sock,int how);
 int NR_async_schedule(NR_async_cb cb,void *arg,char *function,int line);
diff --git a/media/mtransport/third_party/nrappkit/src/log/r_log.c b/media/mtransport/third_party/nrappkit/src/log/r_log.c
--- a/media/mtransport/third_party/nrappkit/src/log/r_log.c
+++ b/media/mtransport/third_party/nrappkit/src/log/r_log.c
@@ -33,28 +33,41 @@
    POSSIBILITY OF SUCH DAMAGE.
 
 
    ekr@rtfm.com  Mon Dec  3 15:24:38 2001
  */
 
 
 static char *RCSSTRING __UNUSED__ ="$Id: r_log.c,v 1.10 2008/11/25 22:25:18 adamcain Exp $";
 
 
+#ifdef LINUX
+#define _BSD_SOURCE
+#endif
+
 #include "r_log.h"
 #include "hex.h"
+
 #include <string.h>
+#include <errno.h>
+#ifndef _MSC_VER
+#include <strings.h>
+#include <syslog.h>
+#endif
 #include <registry.h>
 #include <time.h>
+
+
 #include "nr_common.h"
 #include "nr_reg_keys.h"
 
+
 #define LOGGING_DEFAULT_LEVEL  5
 
 int NR_LOG_LOGGING = 0;
 
 static char *log_level_strings[]={
      "EMERG",
      "ALERT",
      "CRIT",
      "ERR",
      "WARNING",
diff --git a/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h b/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h
--- a/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h
+++ b/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h
@@ -37,17 +37,21 @@
  */
 
 
 #ifndef _platform_h
 #define _platform_h
 
 #include <unistd.h>
 
 #define STDIO_BYTES_BUFFERED(fp) (fp->_r)
 
+#ifdef NR_SOCKET_IS_VOID_PTR
+typedef void* NR_SOCKET;
+#else
 typedef int NR_SOCKET;
 #define NR_SOCKET_READ(sock,buf,count)   read((sock),(buf),(count))
 #define NR_SOCKET_WRITE(sock,buf,count)  write((sock),(buf),(count))
 #define NR_SOCKET_CLOSE(sock)            close(sock)
+#endif
 
 #endif
 
diff --git a/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h b/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h
--- a/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h
+++ b/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h
@@ -35,17 +35,21 @@
 
    ekr@rtfm.com  Mon Dec 13 17:26:51 2004
  */
 
 
 #ifndef _platform_h
 #define _platform_h
 
 #include <linux_funcs.h>
 
+#ifdef NR_SOCKET_IS_VOID_PTR
+typedef void* NR_SOCKET;
+#else
 typedef int NR_SOCKET;
 #define NR_SOCKET_READ(sock,buf,count)   read((sock),(buf),(count))
 #define NR_SOCKET_WRITE(sock,buf,count)  write((sock),(buf),(count))
 #define NR_SOCKET_CLOSE(sock)            close(sock)
+#endif
 
 #endif
 
diff --git a/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h b/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h
--- a/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h
+++ b/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h
@@ -44,45 +44,51 @@
 #define _WIN32_WINNT 0x0400  // This prevents weird "'TryEnterCriticalSection': identifier not found"
                              // compiler errors when poco/win32_mutex.h is included
 #endif
 
 #define UINT8 UBLAH_IGNORE_ME_PLEASE
 #define INT8 BLAH_IGNORE_ME_PLEASE
 #include <winsock2.h>
 #undef UINT8
 #undef INT8
 #include <r_types.h>
+#include <errno.h>
 
 #define strcasecmp _stricmp
 #define strncasecmp _strnicmp
-#define snprintf _snprintf
 
 #define strcasestr stristr
 
 /* Hack version of strlcpy (in util/util.c) */
 size_t strlcat(char *dst, const char *src, size_t siz);
 
 /* Hack version of getopt() (in util/getopt.c) */
 int getopt(int argc, char *argv[], char *opstring);
 extern char *optarg;
 extern int optind;
 extern int opterr;
 
 /* Hack version of gettimeofday() (in util/util.c) */
 int gettimeofday(struct timeval *tv, void *tz);
 
+#ifdef NR_SOCKET_IS_VOID_PTR
+typedef void* NR_SOCKET;
+#else
 typedef SOCKET NR_SOCKET;
 #define NR_SOCKET_READ(sock,buf,count)   recv((sock),(buf),(count),0)
 #define NR_SOCKET_WRITE(sock,buf,count)  send((sock),(buf),(count),0)
 #define NR_SOCKET_CLOSE(sock)            closesocket(sock)
+#endif
 
+#ifndef EHOSTUNREACH
 #define EHOSTUNREACH    WSAEHOSTUNREACH
+#endif
 
 #define LOG_EMERG       0
 #define LOG_ALERT       1
 #define LOG_CRIT        2
 #define LOG_ERR         3
 #define LOG_WARNING     4
 #define LOG_NOTICE      5
 #define LOG_INFO        6
 #define LOG_DEBUG       7
 
diff --git a/media/mtransport/third_party/nrappkit/src/registry/registry.c b/media/mtransport/third_party/nrappkit/src/registry/registry.c
--- a/media/mtransport/third_party/nrappkit/src/registry/registry.c
+++ b/media/mtransport/third_party/nrappkit/src/registry/registry.c
@@ -37,21 +37,22 @@
  *    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  *    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  *    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *    POSSIBILITY OF SUCH DAMAGE.
  *
  *
  */
 
 #include <assert.h>
 #include <string.h>
-#ifndef WIN32
+#ifndef _MSC_VER
+#include <strings.h>
 #include <sys/param.h>
 #include <netinet/in.h>
 #endif
 #ifdef OPENSSL
 #include <openssl/ssl.h>
 #endif
 #include <ctype.h>
 #include "registry.h"
 #include "registry_int.h"
 #include "registry_vtbl.h"
diff --git a/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c b/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c
--- a/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c
+++ b/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c
@@ -58,20 +58,21 @@
  * the crc computation is finished.  The crc should be complemented
  * before transmission.
  * The variable corresponding to the macro argument "crc" should
  * be an unsigned long and should be preset to all ones for Ethernet
  * use.  An error-free packet will leave 0xDEBB20E3 in the crc.
  *			Spencer Garrett <srg@quick.com>
  */
 
 
 #include <sys/types.h>
+#include <r_types.h>
 
 static char *RCSSTRING __UNUSED__ ="$Id: r_crc32.c,v 1.4 2008/11/26 03:22:02 adamcain Exp $";
 
 #ifdef WIN32
 #define u_int32_t  UINT4
 #endif
 
 #define CRC(crc, ch)	 (crc = (crc >> 8) ^ crctab[(crc ^ (ch)) & 0xff])
 
 /* generated using the AUTODIN II polynomial
diff --git a/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h b/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h
--- a/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h
+++ b/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h
@@ -118,20 +118,20 @@
 #ifndef MIN
 #define MIN(a,b) ((a)>(b))?(b):(a)
 #endif
 
 #ifndef MAX
 #define MAX(a,b) ((b)>(a))?(b):(a)
 #endif
 
 #ifdef DEBUG
 #define DBG(a) debug a
-int debug(int class,char *format,...);
+int debug(int cls, char *format,...);
 #else
 #define DBG(a)
 #endif
 
 #define UNIMPLEMENTED do { fprintf(stderr,"%s:%d Function %s unimplemented\n",__FILE__,__LINE__,__FUNCTION__); abort(); } while(0)
 
 #include "r_memory.h"
 
 #endif
diff --git a/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h b/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h
--- a/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h
+++ b/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h
@@ -77,35 +77,25 @@
    $Id: r_time.h,v 1.4 2007/06/26 22:37:57 adamcain Exp $
 
 
    ekr@rtfm.com  Thu Mar  4 08:45:41 1999
  */
 
 
 #ifndef _r_time_h
 #define _r_time_h
 
+#include <csi_platform.h>
 
-#ifdef WIN32
-#  include <time.h>
-#else
-/* Cribbed from the autoconf doc */
-# if TIME_WITH_SYS_TIME
-#  include <sys/time.h>
-#  include <time.h>
-# else
-#  if HAVE_SYS_TIME_H
-#   include <sys/time.h>
-#  else
-#   include <time.h>
-#  endif
-# endif
+#ifndef WIN32
+#include <sys/time.h>
+#include <time.h>
 #endif
 
 int r_timeval_diff(struct timeval *t1,struct timeval *t0, struct timeval *diff);
 int r_timeval_add(struct timeval *t1,struct timeval *t2, struct timeval *sum);
 int r_timeval_cmp(struct timeval *t1,struct timeval *t2);
 
 UINT8 r_timeval2int(struct timeval *tv);
 int r_int2timeval(UINT8 t,struct timeval *tv);
 UINT8 r_gettimeint(void);
 
diff --git a/media/mtransport/third_party/nrappkit/src/util/util.c b/media/mtransport/third_party/nrappkit/src/util/util.c
--- a/media/mtransport/third_party/nrappkit/src/util/util.c
+++ b/media/mtransport/third_party/nrappkit/src/util/util.c
@@ -292,20 +292,22 @@ int nr_sha1_file(char *filename,UCHAR *o
 
     return(_status);
   }
 
 #endif
 
 #ifdef WIN32
   // TODO
 #else
 
+#if 0
+
 #include <fts.h>
 
 int nr_rm_tree(char *path)
   {
     FTS *fts=0;
     FTSENT *p;
     int failed=0;
     int _status;
     char *argv[2];
 
@@ -337,20 +339,21 @@ int nr_rm_tree(char *path)
     }
 
     if(failed)
       ABORT(R_FAILED);
 
     _status=0;
   abort:
     if(fts) fts_close(fts);
     return(_status);
   }
+#endif
 
 int nr_write_pid_file(char *pid_filename)
   {
     FILE *fp;
     int _status;
 
     if(!pid_filename)
       ABORT(R_BAD_ARGS);
 
     unlink(pid_filename);
@@ -739,12 +742,24 @@ int gettimeofday(struct timeval *tv, voi
      * since the Epoch */
     SystemTimeToFileTime(&st, &ft);
     u.HighPart = ft.dwHighDateTime;
     u.LowPart = ft.dwLowDateTime;
 
     tv->tv_sec = (long) (u.QuadPart / 10000000L);
     tv->tv_usec = (long) (st.wMilliseconds * 1000);;
 
     return 0;
   }
+
+int snprintf(char *buffer, size_t n, const char *format, ...)
+{
+  va_list argp;
+  int ret;
+  va_start(argp, format);
+  ret = _vscprintf(format, argp);
+  vsnprintf_s(buffer, n, _TRUNCATE, format, argp);
+  va_end(argp);
+  return ret;
+}
+
 #endif
 
diff --git a/media/mtransport/third_party/nrappkit/src/util/util.h b/media/mtransport/third_party/nrappkit/src/util/util.h
--- a/media/mtransport/third_party/nrappkit/src/util/util.h
+++ b/media/mtransport/third_party/nrappkit/src/util/util.h
@@ -57,12 +57,17 @@ int nr_drop_privileges(char *username);
 int nr_hex_ascii_dump(Data *data);
 int nr_fwrite_all(FILE *fp,UCHAR *buf,int len);
 int nr_sha1_file(char *filename,UCHAR *out);
 int nr_bin2hex(UCHAR *in,int len,UCHAR *out);
 int nr_rm_tree(char *path);
 int nr_write_pid_file(char *pid_filename);
 
 int nr_reg_uint4_fetch_and_check(NR_registry key, UINT4 min, UINT4 max, int log_fac, int die, UINT4 *val);
 int nr_reg_uint8_fetch_and_check(NR_registry key, UINT8 min, UINT8 max, int log_fac, int die, UINT8 *val);
 
+#ifdef WIN32
+int snprintf(char *buffer, size_t n, const char *format, ...);
+const char *inet_ntop(int af, const void *src, char *dst, size_t size);
 #endif
 
+#endif
+