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 #ifndef UTILS_H
30 #define UTILS_H
31
32 #ifdef _WIN32
33 #include <winsock2.h>
34 #include <io.h>
35 #endif
36
37 #include <sys/types.h>
38 #include <libxml/tree.h>
39 #include <cx/string.h>
40 #include <cx/buffer.h>
41 #include <sys/stat.h>
42 #include <inttypes.h>
43
44 #include <curl/curl.h>
45 #include "webdav.h"
46
47 #ifdef _WIN32
48 #ifndef mode_t
49 #define mode_t int
50 #endif
51 #endif
52
53 #ifndef S_IRWXG
54
55 #define S_IRWXU 0700
56 #define S_IRWXG 070
57 #define S_IRGRP 040
58 #define S_IWGRP 020
59 #define S_IXGRP 010
60 #define S_IRWXO 07
61 #define S_IROTH 04
62 #define S_IWOTH 02
63 #define S_IXOTH 01
64 #endif
65
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69
70 time_t util_parse_creationdate(
char *str);
71 time_t util_parse_lastmodified(
char *str);
72
73 int util_mkdir(
char *path,
mode_t mode);
74
75 char* util_url_base(
const char *url);
76 cxstring util_url_base_s(cxstring url);
77 const char* util_url_path(
const char *url);
78 cxstring util_url_path_s(cxstring url);
79 char* util_url_decode(DavSession *sn,
const char *url);
80 const char* util_resource_name(
const char *url);
81 const char* util_resource_name_c(
const char *url,
char pathseparator);
82 const char* util_path_file_name(
const char *url);
83
84 char* util_concat_path(
const char *url_base,
const char *path);
85 cxmutstr util_concat_path_s(cxstring url_base, cxstring path);
86 cxmutstr util_concat_path_ext(cxstring url_base, cxstring path,
char separator);
87 cxmutstr util_concat_sys_path(cxstring base, cxstring path);
88 char* util_get_url(DavSession *sn,
const char *href);
89 void util_set_url(DavSession *sn,
const char *href);
90
91
92
93
94 int util_path_isrelated(
const char *path1,
const char *path2);
95
96 int util_path_isabsolut(
const char *path);
97
98 char* util_path_normalize(
const char *path);
99 char* util_create_relative_path(
const char *abspath,
const char *base);
100
101 void util_capture_header(
CURL *handle, CxMap* map);
102
103 char* util_path_to_url(DavSession *sn,
const char *path);
104 char* util_parent_path(
const char *path);
105 char* util_sys_parent_path(
const char *path);
106
107 char* util_size_str(DavBool iscollection,
uint64_t contentlength);
108 char* util_size_str2(DavBool iscollection,
uint64_t contentlength,
uint64_t dimension,
int precision);
109 char* util_date_str(
time_t tm);
110
111 int util_getboolean(
const char *v);
112 int util_strtouint(
const char *str,
uint64_t *value);
113 int util_strtoint(
const char *str,
int64_t *value);
114 int util_szstrtouint(
const char *str,
uint64_t *value);
115
116 int util_uint_mul(
uint64_t a,
uint64_t b,
uint64_t *result);
117
118 char* util_xml_get_text(
const xmlNode *elm);
119
120 char* util_base64decode(
const char *in);
121 char* util_base64decode_len(
const char *in,
int *outlen);
122 char* util_base64encode(
const char *in,
size_t len);
123
124 char* util_encrypt_str(DavSession *sn,
const char *str,
const char *key);
125 char* util_encrypt_str_k(DavSession *sn,
const char *str, DavKey *key);
126 char* util_decrypt_str(DavSession *sn,
const char *str,
const char *key);
127 char* util_decrypt_str_k(DavSession *sn,
const char *str, DavKey *key);
128
129 char* util_random_str();
130
131
132
133 cxmutstr util_readline(
FILE *stream);
134 char* util_password_input(
char *prompt);
135
136 int util_exec_command(
char *command, CxBuffer *outbuf);
137
138 char* util_hexstr(
const unsigned char *data,
size_t len);
139
140 void util_remove_trailing_pathseparator(
char *path);
141
142 char* util_file_hash(
const char *path);
143
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif
150
151