Skip to content
Snippets Groups Projects
opt.h 636 B
#ifndef OPT_H
#define OPT_H

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define W_FLAG 1 << 0
#define F_FLAG 1 << 1
#define S_FLAG 1 << 2

typedef struct _opt {
    char flag;
    char **extra;
    int extra_count;
    char *digest_method; // default SHA1
} opt;

/**
 * @brief Verify passed options, and returns the corresponding flag.
 *
 * -w : 0x1
 * -f : 0x2
 * -s : 0x4
 *
 * other : error
 *
 * @param argc
 * @param argv
 * @return opt
 */
opt *verify_options(int argc, char *argv[]);

/**
 * @brief Discard the given options
 *
 * @param o
 */
void discard_options(opt *o);

#endif // OPT_H