config.h 583 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#ifndef TRAFT_CONFIG_H
#define TRAFT_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

#include <getopt.h>
#include <stdint.h>
#include "common.h"

typedef struct {
  char     host[HOST_LEN];
  uint16_t port;
} Addr;

typedef struct {
  Addr me;
  char baseDir[BASE_DIR_LEN];
} RaftServerConfig;

void addrToString(const char *host, uint16_t port, char *addr, int len);
void parseAddr(const char *addr, char *host, int len, uint16_t *port);
int  parseConf(int argc, char **argv, RaftServerConfig *pConf);
void printConf(RaftServerConfig *pConf);

#ifdef __cplusplus
}
#endif

#endif