gecko/media/mtransport/third_party/nrappkit/upstream.diff

392 lines
11 KiB
Diff

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
+