-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
79 lines (54 loc) · 1.54 KB
/
utils.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef __UTILS_H__
#define __UTILS_H__
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <dirent.h>
#include <regex.h>
#include "bstrlib.h"
#include "utf8util.h"
#include "buniutil.h"
#include "bstraux.h"
#include "bsafe.h"
#include "bstrlibext.h"
#include "base64.h"
#define HASHEDPW_PATH "../credentials"
#define HASHEDPW_SUFFIX ".hashedpw"
#define MAIL_PATH "../mail"
#define CERT_PATH "../ca/intermediate/certs"
#define CERT_SUFFIX ".cert.pem"
#define CSR_PATH "../ca/intermediate/csr"
#define CSR_SUFFIX ".req.pem"
#define FARAMAIL_PORT 4200
#define BOROMAIL_PORT 6969
#define MAX_CERT_SIZE 2048
#define IMCNF "imopenssl.cnf"
#define GB 1000000000
#define MB 1000000
#define ARG_REGEX "^[a-z0-9\\+\\-_\\./]+$"
#define p(...) \
if (DEBUG) \
{ \
printf(__VA_ARGS__); \
}
struct Node
{
bstring str;
struct Node *next;
};
struct Node *createList();
int freeList(struct Node *list);
int inList(struct Node *list, bstring str);
int prependList(struct Node **list, bstring str);
int appendList(struct Node **list, bstring str);
bstring printList(struct Node *list, const char *delim);
int recipExists(bstring recip);
int getMessageFilename(bstring recip, bstring filename);
void encodeMessage(bstring message);
void decodeMessage(bstring message);
int serializeData(bstring key, bstring value, bstring result, int encode);
int deserializeData(bstring key, bstring value, bstring result, int decode);
int validArg(char *datastr);
#endif