-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsharedfunctions.h
More file actions
75 lines (67 loc) · 2.24 KB
/
Copy pathsharedfunctions.h
File metadata and controls
75 lines (67 loc) · 2.24 KB
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
#ifndef SHAREDFUNC
#define SHAREDFUNC
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <openssl/sha.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
// Contains various utility functions that both client and server may want/need to use
typedef struct FileContents{
char* content;
size_t size;
int fd;
} FileContents;
typedef struct _Manifest {
int version;
char** entries;
int entrycount;
} Manifest;
typedef struct _Commit {
int filesize;
int entries;
char* filecontent;
int uid;
} Commit;
typedef struct _Update {
int uptodate;
int filesize;
int entries;
char* filecontent;
int uid;
} Update;
typedef enum modtag {Add, Modify, Delete} ModTag;
int checkForLocalProj(char* projname);
char* bin2hex(const unsigned char *bin, size_t len);
int hexchr2bin(const char hex, char* out);
char* hashtohex(unsigned char* hash);
unsigned char* hashdata(unsigned char* data, size_t datalen);
FileContents* readfile(char* name);
void freefile(FileContents* file);
char* strrmove(char* str, const char* sub);
int isNum(char* value, int len);
int digitCount(int num);
int strshift(char* word, int populatedbytes, size_t buffsize, int offset);
int projectVersion(char* project, FileContents* (*readfile)(char*));
int createcompressedarchive(char* filepath, int pathlen);
int createcompressedfile(char* filepath, int pathlen, char* archivename, int archivenamelen);
int getManifestVersion(FileContents* manifest);
char* getcompressedfile(char* filepath, int* deflated_size, int (*opencmnd)(const char*, int), ssize_t (*readcmnd)(int, char*, size_t));
int recreatefile(char* filepath, char* contents, int size);
int uncompressfile(char* compressedpath);
Manifest* parseManifest(FileContents* filecontent);
char** getManifestFiles(Manifest* manifest);
char** getManifestHashcodes(Manifest* manifest);
int* getManifestFileVersion(Manifest* manifest);
Commit* parseCommit(FileContents* filecontent);
char** getCommitFilePaths(Commit* commit);
ModTag* getModificationTags(Commit* commit);
int* getCommitVersions(Commit* commit);
char** getCommitHashes(Commit* commit);
void freeManifest(Manifest* manifest);
void freeCommit(Commit* commit);
#endif