diff --git a/src/sf_nio.c b/src/sf_nio.c index 40e791f..07ba482 100644 --- a/src/sf_nio.c +++ b/src/sf_nio.c @@ -224,7 +224,7 @@ static int client_sock_read(int sock, short event, void *arg) } else { logWarning("file: "__FILE__", line: %d, " - "client ip: %s, req_count: %ld, recv timeout", + "client ip: %s, req_count: %"PRId64", recv timeout", __LINE__, pTask->client_ip, pTask->req_count); } diff --git a/src/sf_util.c b/src/sf_util.c index 35dd6aa..73c0072 100644 --- a/src/sf_util.c +++ b/src/sf_util.c @@ -5,6 +5,7 @@ #include #include +#include #include #include "sf_util.h" @@ -72,3 +73,30 @@ int sf_printbuffer(char* buffer,int32_t len) return(0); } +void sf_usage(const char *program) +{ + fprintf(stderr, "Usage: %s [--without-daemon | --no-daemon] " + "[start | stop | restart]\n", program); +} + +void sf_parse_daemon_mode_and_action(int argc, char *argv[], + bool *daemon_mode, char **action) +{ + int i; + + *daemon_mode = true; + for (i=2; i 2) { + *action = argv[argc - 1]; + } else { + *action = NULL; + } +} diff --git a/src/sf_util.h b/src/sf_util.h index 4876e38..341d10e 100644 --- a/src/sf_util.h +++ b/src/sf_util.h @@ -48,6 +48,12 @@ int64_t getticks() ; void log_plus(const int priority, const char* file, int line, const char* fmt, ...); int sf_printbuffer(char* buffer,int32_t len); + +void sf_usage(const char *program); + +void sf_parse_daemon_mode_and_action(int argc, char *argv[], + bool *daemon_mode, char **action); + #ifdef __cplusplus } #endif