add function sf_usage and sf_parse_daemon_mode_and_action
parent
b27ecc4c1e
commit
a64f3ffab4
|
|
@ -224,7 +224,7 @@ static int client_sock_read(int sock, short event, void *arg)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logWarning("file: "__FILE__", line: %d, "
|
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);
|
__LINE__, pTask->client_ip, pTask->req_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "sf_util.h"
|
#include "sf_util.h"
|
||||||
|
|
||||||
|
|
@ -72,3 +73,30 @@ int sf_printbuffer(char* buffer,int32_t len)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sf_usage(const char *program)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: %s <config_file> [--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<argc; i++) {
|
||||||
|
if (strcmp(argv[i], "--without-daemon") == 0 ||
|
||||||
|
strcmp(argv[i], "--no-daemon") == 0)
|
||||||
|
{
|
||||||
|
*daemon_mode = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc - (*daemon_mode ? 0 : 1) > 2) {
|
||||||
|
*action = argv[argc - 1];
|
||||||
|
} else {
|
||||||
|
*action = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,12 @@ int64_t getticks() ;
|
||||||
void log_plus(const int priority, const char* file, int line, const char* fmt, ...);
|
void log_plus(const int priority, const char* file, int line, const char* fmt, ...);
|
||||||
|
|
||||||
int sf_printbuffer(char* buffer,int32_t len);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue