dav/main.c

branch
feature/dav-edit
changeset 715
f4da6141e233
parent 712
c62af832a0e2
child 716
5c2e4da00b04
equal deleted inserted replaced
714:10a5d6ce0906 715:f4da6141e233
33 #include <stdbool.h> 33 #include <stdbool.h>
34 #include <errno.h> 34 #include <errno.h>
35 #include <unistd.h> 35 #include <unistd.h>
36 #include <time.h> 36 #include <time.h>
37 #include <sys/types.h> 37 #include <sys/types.h>
38 #ifndef _WIN32
38 #include <sys/wait.h> 39 #include <sys/wait.h>
40 #endif
39 #include <ucx/string.h> 41 #include <ucx/string.h>
40 #include <ucx/utils.h> 42 #include <ucx/utils.h>
41 #include <dirent.h> 43 #include <dirent.h>
42 44
43 #include <libidav/utils.h> 45 #include <libidav/utils.h>
1163 1165
1164 return 0; 1166 return 0;
1165 } 1167 }
1166 1168
1167 int cmd_edit(CmdArgs *a) { 1169 int cmd_edit(CmdArgs *a) {
1170 #ifdef _WIN32
1171 fprintf(stderr, "This feature is not supported on your platform.\n");
1172 return -1;
1173 #else
1168 if(a->argc != 1) { 1174 if(a->argc != 1) {
1169 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few":"many"); 1175 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few":"many");
1170 fprintf(stderr, "Usage: dav %s\n", find_usage_str("edit")); 1176 fprintf(stderr, "Usage: dav %s\n", find_usage_str("edit"));
1171 return -1; 1177 return -1;
1172 } 1178 }
1261 char* editor = getenv("EDITOR"); 1267 char* editor = getenv("EDITOR");
1262 if(!editor) editor = default_editor; 1268 if(!editor) editor = default_editor;
1263 char* viargs[3] = {editor, outfile, NULL}; 1269 char* viargs[3] = {editor, outfile, NULL};
1264 1270
1265 int ret = 0; 1271 int ret = 0;
1266 // TODO: solution for windows
1267 pid_t pid = fork(); 1272 pid_t pid = fork();
1268 if(pid < 0) { 1273 if(pid < 0) {
1269 perror("Cannot create process for editor"); 1274 perror("Cannot create process for editor");
1270 ret = 1; 1275 ret = 1;
1271 } else if(pid == 0) { 1276 } else if(pid == 0) {
1313 close(tmp_fd); 1318 close(tmp_fd);
1314 unlink(outfile); 1319 unlink(outfile);
1315 free(path); 1320 free(path);
1316 1321
1317 return ret; 1322 return ret;
1323 #endif
1318 } 1324 }
1319 1325
1320 int get_resource(Repository *repo, GetResource *getres, CmdArgs *a, void *unused) { 1326 int get_resource(Repository *repo, GetResource *getres, CmdArgs *a, void *unused) {
1321 DavResource *res = getres->res; 1327 DavResource *res = getres->res;
1322 char *out = getres->path; 1328 char *out = getres->path;

mercurial