ems/ems_c/argparse.h

34 lines
1.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*****************************************************************************
* @copyright 2024-2024, . POWER SUPPLY CO., LTD.
* @file argparse.h
* @brief 命令行参数解析头文件
* @author Gary
* @date 2024/09/20
*****************************************************************************/
#ifndef ARGPARSE_H
#define ARGPARSE_H
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#define RESTART_NEVER 0
#define RESTART_ALWAYS ((size_t) -2)
#define RESTART_ONFAILURE ((size_t) -1)
// 命令行参数配置结构体
typedef struct {
bool daemonized; // 是否以守护进程方式运行
size_t restart; // 重启策略
bool stop; // 是否停止运行
} cli_args_t;
/*****************************************************************************
* @brief 初始化命令行参数解析
* @param[in] argc命令行参数个数
* @param[in] argv命令行参数字符数组
* @param[out] args命令行解析后装入的结构体
*****************************************************************************/
void cliArgsInit(int argc, char *argv[], cli_args_t *args);
#endif // ARGPARSE_H