summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2015-05-25 17:55:41 +0200
committerAndreas Baumann <abaumann@yahoo.com>2015-05-25 17:55:41 +0200
commit66079abd1083a00f165b8fc62eec885f872b903c (patch)
tree59ea7cba7e00a5c8e793a8e870961b922a900ea8
parent1c0c08414529cc10c45cd34a1a5188970c98a892 (diff)
downloadbiruda-66079abd1083a00f165b8fc62eec885f872b903c.tar.gz
biruda-66079abd1083a00f165b8fc62eec885f872b903c.tar.bz2
various fixes on Windows
-rw-r--r--src/NMakefile11
-rw-r--r--src/biruda.c4
-rw-r--r--src/cli.c27
-rw-r--r--src/cli.h6
-rw-r--r--src/worker.c22
5 files changed, 44 insertions, 26 deletions
diff --git a/src/NMakefile b/src/NMakefile
index 7379af8..e7fb64a 100644
--- a/src/NMakefile
+++ b/src/NMakefile
@@ -46,7 +46,7 @@ biruda.exe: biruda.obj biruda_cmdline.obj master.obj coordinator.obj worker.obj
$(LINK) $(LINKFLAGS) $(LIBS) /out:$@ $**
biruda_cmdline.obj: biruda_cmdline.c
-biruda.obj: biruda.c biruda_cmdline.h master.h coordinator.h worker.h port.h system.h cli.h
+biruda.obj: biruda.c biruda_cmdline.h master.h coordinator.h worker.h port.h system.h cli.h biruda_conf.c
master.obj: master.c master.h port.h
coordinator.obj: coordinator.c coordinator.h port.h system.h
worker.obj: worker.c worker.h
@@ -64,12 +64,21 @@ workertest.exe: workertest.obj
workertest.obj: workertest.c
+3rdParty\xxd\xxd.exe: 3rdParty\xxd\xxd.c
+ $(CC) /nologo /c /Fo3rdParty\xxd\xxd.obj 3rdParty\xxd\xxd.c
+ $(LINK) /out:3rdParty\xxd\xxd.exe 3rdParty\xxd\xxd.obj
+
+biruda_conf.c: biruda.conf 3rdParty\xxd\xxd.exe
+ 3rdParty\xxd\xxd.exe -i biruda.conf > biruda_conf.c
+
clean:
@-erase *.obj 2>NUL
@-erase *.dll 2>NUL
@-erase gspawn-win32-helper-console.exe 2>NUL
@-erase biruda.exe workertest.exe 2>NUL
@-erase biruda_cmdline.h biruda_cmdline.c 2>NUL
+ @-erase 3rdParty\xxd\xxd.exe 3rdParty\xxd\xxd.obj 2>NUL
+ @-rm biruda_conf.c
run: all
@-copy $(CONFUSE_DIR)\bin\libConfuse.dll .
diff --git a/src/biruda.c b/src/biruda.c
index c46b580..e150627 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -387,7 +387,6 @@ int main( int argc, char *argv[] )
}
}
int ret;
-#ifndef _WIN32
unsigned int port = DEFAULT_WEBSERVER_PORT;
if( args_info.config_file_given ) {
cfg_t *webserver_cfg = cfg_getnsec( cfg, "webserver", 0 );
@@ -405,10 +404,11 @@ int main( int argc, char *argv[] )
port = atoi( args_info.inputs[1] );
}
+#ifndef _WIN32
ret = start_interactive( ( in == stdin ) ? !args_info.no_colors_given : false, host, port, in );
#else
if( args_info.filename_given ) {
- ret = start_interactive( false, in );
+ ret = start_interactive( false, host, port, in );
} else {
fprintf( stderr, "FATAL: No CLI mode implemented for Windows currently!\n" );
ret = -1;
diff --git a/src/cli.c b/src/cli.c
index 66bc5b6..0ec95b1 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1,18 +1,16 @@
#include "cli.h"
-#ifdef _WIN32
-int start_interactive( bool colors, const char *host, unsigned short port, FILE *in )
-{
- fprintf( stderr, "ERROR: Not implemented on Windows!\n" );
- return EXIT_FAILURE;
-}
-
-#else
+#ifndef _WIN32
#include <strings.h>
+#endif
#include <ctype.h>
#include <stdarg.h>
+#ifndef _WIN32
#include "linenoise.h"
+#endif
+#ifndef _WIN32
#include "http_lib.h"
+#endif
#include "json-c/json.h"
#include <stdlib.h>
@@ -24,6 +22,9 @@ int start_interactive( bool colors, const char *host, unsigned short port, FILE
#include "coordinator.h"
#include "worker.h"
#include "system.h"
+
+#ifndef _WIN32
+
typedef enum {
COMMAND, // command parsing
START_WORKER, // worker command expecting a worker parameter
@@ -256,6 +257,16 @@ static void stop_worker( const char *worker_name )
}
}
+#endif
+
+#ifdef _WIN32
+int start_interactive( bool colors, const char *host, unsigned short port, FILE *in )
+{
+ fprintf( stderr, "ERROR: Not implemented on Windows!\n" );
+ return EXIT_FAILURE;
+}
+
+#else
int start_interactive( bool colors, const char *host, unsigned short port, FILE *in )
{
char history_filename[1024];
diff --git a/src/cli.h b/src/cli.h
index 2907b6a..c94973e 100644
--- a/src/cli.h
+++ b/src/cli.h
@@ -5,12 +5,8 @@
#include <stdio.h>
-#ifndef _WIN32
-
int start_interactive( bool colors, const char *host, unsigned short port, FILE *in );
-#endif
+void print_guessed_env( bool human_readable );
#endif
-
-void print_guessed_env( bool human_readable );
diff --git a/src/worker.c b/src/worker.c
index 17c7f5e..7529394 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -11,7 +11,9 @@
#include <stdio.h>
#include <string.h>
+#ifndef _WIN32
#include <strings.h>
+#endif
#include <stdlib.h>
#include <ctype.h>
@@ -263,11 +265,11 @@ static char *expand_system_variables( const char *s )
size_t r_size = strlen( s ) * 2;
char *r = (char *)malloc( r_size );
char *d = r;
- enum { COPYING, DOLLAR, OPEN_BRACE, VARIABLE, CLOSE_BRACE, ERROR } state = COPYING;
+ enum { COPYING, DOLLAR, OPEN_BRACE, VARIABLE, CLOSE_BRACE, _ERROR } state = COPYING;
const char *var = NULL;
const char *p = s;
- while( state != ERROR && *p != '\0' && d - r < r_size - 1 ) {
+ while( state != _ERROR && *p != '\0' && d - r < r_size - 1 ) {
switch( state ) {
case COPYING:
if( *p == '$' ) {
@@ -286,14 +288,14 @@ static char *expand_system_variables( const char *s )
p++;
} else {
fprintf( stderr, "ERROR: Unexpected '{' at position %d in '%s'\n", (int)( p - s ), s );
- state = ERROR;
+ state = _ERROR;
}
break;
case OPEN_BRACE:
if( *p == '}' ) {
fprintf( stderr, "ERROR: Empty variable declaration '${}' at position %d in '%s'\n", (int)( p - s ), s );
- state = ERROR;
+ state = _ERROR;
p++;
} else if( isalpha( *p ) ) {
// ok, part of variable name
@@ -302,7 +304,7 @@ static char *expand_system_variables( const char *s )
p++;
} else {
fprintf( stderr, "ERROR: Illegal character '%c' at position %d in variable in '%s'\n", *p, (int)( p - s ), s );
- state = ERROR;
+ state = _ERROR;
}
break;
@@ -314,7 +316,7 @@ static char *expand_system_variables( const char *s )
p++;
} else {
fprintf( stderr, "ERROR: Illegal character '%c' at position %d in variable in '%s'\n", *p, (int)( p - s ), s );
- state = ERROR;
+ state = _ERROR;
}
break;
@@ -346,12 +348,12 @@ static char *expand_system_variables( const char *s )
state = COPYING;
} else {
fprintf( stderr, "ERROR: Unknown variable '${%*s}' at position %d in '%s'\n", (int)( p-var ), var, (int)( p - s ), s );
- state = ERROR;
+ state = _ERROR;
}
p++;
break;
- case ERROR:
+ case _ERROR:
default:
break;
}
@@ -360,7 +362,7 @@ static char *expand_system_variables( const char *s )
if( d - r >= r_size - 1 ) {
fprintf( stderr, "ERROR: out of memory while substituting variables in '%s'\n", s );
- state = ERROR;
+ state = _ERROR;
}
switch( state ) {
@@ -378,7 +380,7 @@ static char *expand_system_variables( const char *s )
fprintf( stderr, "ERROR: illegal state while parsing command '%s'\n", s );
break;
- case ERROR:
+ case _ERROR:
return NULL;
}