This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-certstore/src/components/json/parse_flags.c
fengweihao 2a844d3205 1.添加扫描框架maat,根据json文件初始化keyring链
2.添加源证书时签发流程
2018-09-06 19:51:23 +08:00

51 lines
981 B
C

#include "config.h"
#include <stdio.h>
#include <string.h>
#include "json.h"
#include "parse_flags.h"
#if !defined(HAVE_STRCASECMP) && defined(_MSC_VER)
# define strcasecmp _stricmp
#elif !defined(HAVE_STRCASECMP)
# error You do not have strcasecmp on your system.
#endif /* HAVE_STRNCASECMP */
static struct {
const char *arg;
int flag;
} format_args[] = {
{ "plain", JSON_C_TO_STRING_PLAIN },
{ "spaced", JSON_C_TO_STRING_SPACED },
{ "pretty", JSON_C_TO_STRING_PRETTY },
};
#ifndef NELEM
#define NELEM(x) (sizeof(x) / sizeof(&x[0]))
#endif
int parse_flags(int argc, char **argv)
{
int arg_idx;
int sflags = 0;
for (arg_idx = 1; arg_idx < argc ; arg_idx++)
{
int jj;
for (jj = 0; jj < (int)NELEM(format_args); jj++)
{
if (strcasecmp(argv[arg_idx], format_args[jj].arg) == 0)
{
sflags |= format_args[jj].flag;
break;
}
}
if (jj == NELEM(format_args))
{
printf("Unknown arg: %s\n", argv[arg_idx]);
exit(1);
}
}
return sflags;
}