34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
|
/*****************************************************************************
|
|||
|
* @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
|