diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2013-09-05 11:24:46 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2013-09-05 11:24:46 +0200 |
commit | dd740d494969c92654fd7a1d077cacccce86f7ed (patch) | |
tree | 74c64f67f4ae873a258dcc0721fbffe600a6dd80 /tools | |
parent | 70b9f79a2b2e6e03b33c82397595a09f850ba473 (diff) | |
download | nanomsg-dd740d494969c92654fd7a1d077cacccce86f7ed.tar.gz |
nanocat now builds with MSVC2010
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/nanocat.c | 4 | ||||
-rw-r--r-- | tools/options.c | 26 |
2 files changed, 23 insertions, 7 deletions
diff --git a/tools/nanocat.c b/tools/nanocat.c index 52a1cea..5a0fece 100644 --- a/tools/nanocat.c +++ b/tools/nanocat.c @@ -29,8 +29,8 @@ #include "../src/reqrep.h" #include "options.h" -#include "../src/utils/sleep.h" -#include "../src/utils/clock.h" +#include "../src/utils/sleep.c" +#include "../src/utils/clock.c" #include <stdio.h> #include <string.h> diff --git a/tools/options.c b/tools/options.c index ecdfbc5..cec9308 100644 --- a/tools/options.c +++ b/tools/options.c @@ -20,6 +20,10 @@ IN THE SOFTWARE. */ +#include "options.h" + +#include "../src/utils/err.c" + #include <string.h> #include <stdio.h> #include <stdlib.h> @@ -27,8 +31,6 @@ #include <errno.h> #include <ctype.h> -#include "options.h" - struct nn_parse_context { /* Initial state */ struct nn_commandline *def; @@ -64,7 +66,7 @@ static int nn_has_arg (struct nn_option *opt) case NN_OPT_READ_FILE: return 1; } - abort (); + nn_assert (0); } static void nn_print_usage (struct nn_parse_context *ctx, FILE *stream) @@ -409,12 +411,17 @@ static void nn_process_option (struct nn_parse_context *ctx, blob->length = strlen (argument); return; case NN_OPT_FLOAT: - *(float *)(((char *)ctx->target) + opt->offset) = strtof (argument, - &endptr); +#if defined NN_HAVE_WINDOWS + *(float *)(((char *)ctx->target) + opt->offset) = + (float) atof (argument); +#else + *(float *)(((char *)ctx->target) + opt->offset) = + strtof (argument, &endptr); if (endptr == argument || *endptr != 0) { nn_option_error ("requires float point argument", ctx, opt_index); } +#endif return; case NN_OPT_LIST_APPEND: nn_append_string (ctx, opt, argument); @@ -422,7 +429,12 @@ static void nn_process_option (struct nn_parse_context *ctx, case NN_OPT_LIST_APPEND_FMT: data_buf = strlen (argument) + strlen (opt->pointer); data = malloc (data_buf); +#if defined NN_HAVE_WINDOWS + data_len = _snprintf_s (data, data_buf, data_buf, opt->pointer, + argument); +#else data_len = snprintf (data, data_buf, opt->pointer, argument); +#endif assert (data_len < data_buf); nn_append_string (ctx, opt, data); return; @@ -430,8 +442,12 @@ static void nn_process_option (struct nn_parse_context *ctx, if (!strcmp (argument, "-")) { file = stdin; } else { +#if defined NN_HAVE_WINDOWS + if (fopen_s (&file, argument, "r") != 0) { +#else file = fopen (argument, "r"); if (!file) { +#endif fprintf (stderr, "Error opening file ``%s'': %s\n", argument, strerror (errno)); exit (2); |