-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutil.h
More file actions
56 lines (47 loc) · 1.41 KB
/
util.h
File metadata and controls
56 lines (47 loc) · 1.41 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
// Copyright David Tannenbaum 2014 (Commands.com).
// Distributed under the http://creativecommons.org/licenses/by-nc-sa/4.0/
// (See accompanying file LICENSE.txt or copy at http://creativecommons.org/licenses/by-nc-sa/4.0/)
#ifndef UTIL_H
#define UTIL_H
#define MAX_JSON_FILE_SIZE 1000000 // 1 MB
// common URLs
#define authUrl "https://commands.com/user/login"
#define keyUrl "https://commands.com/command"
#define gotoKeyUrl "https://commands.com"
typedef enum {
POST_NAME,
POST_JSON,
AUTHKEY_NAME,
KEY_NAME,
SHELL_NAME,
SHELL_NAME2,
TEMP_NAME
} NAMETYPE;
// common shared filenames
char postFile[256];
char jsonFile[256];
char authKeyJsonFile[256];
char keyJsonFile[256];
char shellFile[256];
char shellFile2[256];
char tempFile[256];
// exported functions
int getAuthKey(char *username, char *password, char *authkey, char *key);
int buildJsonResult(char *authkey, char *key);
int getKeyVal(char *key);
int postJsonFile(char *postfile);
int genGlobalFilenames();
char *fName(NAMETYPE name);
void scratchname (char *name,char *suffix);
void my_cp(char *from, char *to);
void my_diff(char *source, char *dest, char *appendfile);
void my_append(char *source, char *appendfile);
// return data from the server
struct return_string {
char *ptr;
size_t len;
};
// utility functions
size_t accumulate(void *ptr, size_t size, size_t nmemb, struct return_string *s);
void init_string(struct return_string *s);
#endif