Commit cbf028f3 authored by Ophélie Gagnard's avatar Ophélie Gagnard

src/main.*: Improve arguments handling.

parent db8dcfd0
This diff is collapsed.
...@@ -281,6 +281,11 @@ cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *f ...@@ -281,6 +281,11 @@ cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *f
#cdef char ip_address[100] #cdef char ip_address[100]
#cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r") #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r")
if child_pid == 0: # CHILD if child_pid == 0: # CHILD
fprintf(stdout, "path_to_scan: %s\n", path_to_scan)
fprintf(stdout, "fb_exec_path: %s\n", fb_exec_path)
fprintf(stdout, "fb_lib_path: %s\n", fb_lib_path)
fprintf(stdout, "fb_conf_path: %s\n", fb_conf_path)
fprintf(stdout, "log_path: %s\n", log_path)
err = execlp(fb_exec_path, program_name, <char*>"-e", fb_lib_path, <char*>"-c", fb_conf_path, 0) err = execlp(fb_exec_path, program_name, <char*>"-e", fb_lib_path, <char*>"-c", fb_conf_path, 0)
fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err)
else: # PARENT else: # PARENT
...@@ -363,13 +368,15 @@ cdef public int main(int argc, char* argv[]) nogil: ...@@ -363,13 +368,15 @@ cdef public int main(int argc, char* argv[]) nogil:
cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so" cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so"
cdef char* fb_conf_path = "/etc/flb.conf" cdef char* fb_conf_path = "/etc/flb.conf"
cdef char* log_path = "/var/log/metadata_collect.log" cdef char* log_path = "/var/log/metadata_collect.log"
if argc == 2: if argc >= 2:
path_to_scan = <char*>argv[1]
elif argc == 6:
path_to_scan = <char*>argv[1] path_to_scan = <char*>argv[1]
if argc >= 3:
fb_exec_path = <char*>argv[2] fb_exec_path = <char*>argv[2]
if argc >= 4:
fb_lib_path = <char*>argv[3] fb_lib_path = <char*>argv[3]
if argc >= 5:
fb_conf_path = <char*>argv[4] fb_conf_path = <char*>argv[4]
if argc >=6:
log_path = <char*>argv[5] log_path = <char*>argv[5]
return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path) return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment