+static int get_names_args(poptContext *pc)
+{
+ char *str, *strlist, *strctx;
+ int ret = 0;
+
+ opt_payload_field_names = 0;
+ opt_context_field_names = 0;
+ strlist = (char *) poptGetOptArg(*pc);
+ if (!strlist) {
+ return -EINVAL;
+ }
+ str = strtok_r(strlist, ",", &strctx);
+ do {
+ if (!strcmp(str, "all"))
+ opt_all_field_names = 1;
+ else if (!strcmp(str, "scope"))
+ opt_scope_field_names = 1;
+ else if (!strcmp(str, "context") || !strcmp(str, "ctx"))
+ opt_context_field_names = 1;
+ else if (!strcmp(str, "header"))
+ opt_header_field_names = 1;
+ else if (!strcmp(str, "payload") || !strcmp(str, "args") || !strcmp(str, "arg"))
+ opt_payload_field_names = 1;
+ else if (!strcmp(str, "none")) {
+ opt_all_field_names = 0;
+ opt_scope_field_names = 0;
+ opt_context_field_names = 0;
+ opt_header_field_names = 0;
+ opt_payload_field_names = 0;
+ } else {
+ fprintf(stderr, "[error] unknown field name type %s\n", str);
+ free(strlist);
+ ret = -EINVAL;
+ goto end;
+ }
+ } while ((str = strtok_r(NULL, ",", &strctx)));
+end:
+ free(strlist);
+ return ret;
+}
+
+static int get_fields_args(poptContext *pc)
+{
+ char *str, *strlist, *strctx;
+ int ret = 0;
+
+ strlist = (char *) poptGetOptArg(*pc);
+ if (!strlist) {
+ return -EINVAL;
+ }
+ str = strtok_r(strlist, ",", &strctx);
+ do {
+ opt_trace_default_fields = 0;
+ if (!strcmp(str, "all"))
+ opt_all_fields = 1;
+ else if (!strcmp(str, "trace"))
+ opt_trace_field = 1;
+ else if (!strcmp(str, "trace:hostname"))
+ opt_trace_hostname_field = 1;
+ else if (!strcmp(str, "trace:domain"))
+ opt_trace_domain_field = 1;
+ else if (!strcmp(str, "trace:procname"))
+ opt_trace_procname_field = 1;
+ else if (!strcmp(str, "trace:vpid"))
+ opt_trace_vpid_field = 1;
+ else if (!strcmp(str, "loglevel"))
+ opt_loglevel_field = 1;
+ else if (!strcmp(str, "emf"))
+ opt_emf_field = 1;
+ else if (!strcmp(str, "callsite"))
+ opt_callsite_field = 1;
+ else {
+ fprintf(stderr, "[error] unknown field type %s\n", str);
+ ret = -EINVAL;
+ goto end;
+ }
+ } while ((str = strtok_r(NULL, ",", &strctx)));
+end:
+ free(strlist);
+ return ret;
+}
+