win32: first test, if olsr_cfg can be included/DLL'ed stand alone
authorSven-Ola Tuecke <sven-ola@gmx.de>
Tue, 13 Jan 2009 08:43:28 +0000 (09:43 +0100)
committerSven-Ola Tuecke <sven-ola@gmx.de>
Tue, 13 Jan 2009 08:43:28 +0000 (09:43 +0100)
.hgignore
gui/win32/mk.sh [new file with mode: 0644]
gui/win32/win32verify.c [new file with mode: 0644]
make/Makefile.vxworks [new file with mode: 0644]
src/ipcalc.c
src/main.c
src/olsr_cfg.c

index 37b2272..ad1d049 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -28,6 +28,7 @@ olsrd.exports
 *.aps
 *.sbr
 *.plg
+gui/win32/win32verify
 gui/win32/Main/Debug/
 gui/win32/Main/Release/
 gui/win32/Shim/Debug/
diff --git a/gui/win32/mk.sh b/gui/win32/mk.sh
new file mode 100644 (file)
index 0000000..20c9154
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+SRCS="olsr_cfg olsr_cfg_gen olsr_ip_acl olsr_ip_prefix_list ipcalc builddata common/autobuf"
+OBJS=
+
+for i in $SRCS; do
+  gcc -Werror -Wall -I../../src -O0 -ggdb -c ../../src/$i.c
+  OBJS="$OBJS ${i##*/}.o"
+done
+gcc -Werror -Wall -I../../src -O0 -ggdb -o win32verify win32verify.c $OBJS
diff --git a/gui/win32/win32verify.c b/gui/win32/win32verify.c
new file mode 100644 (file)
index 0000000..b46a7f5
--- /dev/null
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "olsr.h"
+#include "olsr_cfg.h"
+#include "olsr_cfg_gen.h"
+
+bool disp_pack_out = false;
+const char *LOG_SEVERITY_NAMES[] = {};
+const char *LOG_SOURCE_NAMES[] = {};
+
+FILE *debug_handle = NULL;
+struct olsr_config *olsr_cnf = NULL;
+
+void *olsr_malloc(size_t size, const char *id __attribute__ ((unused)))
+{
+  return calloc(1, size);
+}
+
+char *olsr_strdup(const char *s)
+{
+  char *ret = olsr_malloc(1 + strlen(s), "olsr_strdup");
+  strcpy(ret, s);
+  return ret;
+}
+
+char *olsr_strndup(const char *s, size_t n)
+{
+  size_t len = n < strlen(s) ? n : strlen(s);
+  char *ret = olsr_malloc(1 + len, "olsr_strndup");
+  strncpy(ret, s, len);
+  ret[len] = 0;
+  return ret;
+}
+
+void parser_set_disp_pack_in(bool val __attribute__ ((unused)))
+{
+}
+
+int main(int argc, char *argv[])
+{
+  int i, ret = 0;
+  for (i = 1; i < argc; i++) {
+    struct olsr_config *cfg_tmp;
+    printf("Verifying argv[%d]=%s\n", i, argv[i]);
+    cfg_tmp = olsr_parse_cfg(0, NULL, argv[i]);
+    if (NULL != cfg_tmp) {
+      printf("%s verified: %s\n", argv[i], olsr_sanity_check_cfg(cfg_tmp) ? "yes" : "no");
+      printf("DebugLevel=%d\n", cfg_tmp->debug_level);
+      olsr_free_cfg(cfg_tmp);
+    }
+    else {
+      fprintf(stderr, "%s not verified\n", argv[i]);
+      ret = 1;
+    }
+  }
+  return ret;
+}
diff --git a/make/Makefile.vxworks b/make/Makefile.vxworks
new file mode 100644 (file)
index 0000000..1af289b
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# VXWORKS SPECIFIC CONFIGURATION. Note, that this is used to
+# test compile with 'make OS=vxworks VXWORKS=vxworksdir'.
+# To compile as vxworks kernel task, you may want to grab
+# the mercurial branch: http://gredler.at/hg/olsrd-vxworks
+#
+
+SRCS +=                $(wildcard src/bsd/*.c src/unix/*.c)
+HDRS +=                $(wildcard src/bsd/*.h src/unix/*.h)
+
+LIBS =
+
+VXWORKS = /usr/src/cross/vxworks-6.6
+
+CPPFLAGS +=    -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
+CPPFLAGS +=    -Dx_WRS_KERNEL -DCPU=_VX_PENTIUM -I$(VXWORKS)/target/h/wrn/coreip
+
+ifdef OLSRD_PLUGIN
+CFLAGS +=      -fPIC
+LDFLAGS +=     -fPIC
+endif
+
+PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
+INSTALL_LIB =  install -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
+               /sbin/ldconfig
+
+OS_LIB_PTHREAD = -pthread
+OS_CFLAG_PTHREAD = -pthread
+OS_LIB_DYNLOAD =
+
+# Local Variables:
+# mode: makefile
+# End:
index cfdb6e0..38a01a9 100644 (file)
 
 const struct in6_addr in6addr_v4mapped_loopback = IN6ADDR_V4MAPPED_LOOPBACK_INIT;
 
-/* Global stuff externed in olsr_cfg.h */
-FILE *debug_handle;                    /* Where to send debug(defaults to stdout) */
-struct olsr_config *olsr_cnf;          /* The global configuration */
-
 int
 prefix_to_netmask(uint8_t *a, int len, uint8_t prefixlen)
 {
index 51e3e93..5b8690f 100644 (file)
@@ -85,6 +85,10 @@ static void olsr_shutdown(void);
 static void signal_reconfigure(int);
 #endif
 
+/* Global stuff externed in olsr_cfg.h */
+FILE *debug_handle;                    /* Where to send debug(defaults to stdout) */
+struct olsr_config *olsr_cnf;          /* The global configuration */
+
 volatile enum app_state app_state = STATE_RUNNING;
 
 static char copyright_string[] __attribute__ ((unused)) =
index dd6008f..ef47842 100644 (file)
@@ -1087,7 +1087,7 @@ olsr_parse_cfg(int argc, char *argv[], const char *conf_file_name)
   }
 
   /* If no arguments, revert to default behaviour */
-  if (1 == opt_argc) {
+  if (1 >= opt_argc) {
     char *argv0_tmp = opt_argv[0];
     free(opt_argv);
     opt_argv = olsr_malloc(3 * sizeof(opt_argv[0]), "default argv");