138 ret = cmd_lock(args); |
138 ret = cmd_lock(args); |
139 } else if(!strcasecmp(cmd, "unlock")) { |
139 } else if(!strcasecmp(cmd, "unlock")) { |
140 ret = cmd_unlock(args); |
140 ret = cmd_unlock(args); |
141 } else if(!strcasecmp(cmd, "info")) { |
141 } else if(!strcasecmp(cmd, "info")) { |
142 ret = cmd_info(args); |
142 ret = cmd_info(args); |
|
143 } else if(!strcasecmp(cmd, "checkout")) { |
|
144 ret = cmd_checkout(args); |
|
145 } else if(!strcasecmp(cmd, "checkin")) { |
|
146 ret = cmd_checkin(args); |
|
147 } else if(!strcasecmp(cmd, "uncheckout")) { |
|
148 ret = cmd_uncheckout(args); |
|
149 } else if(!strcasecmp(cmd, "versioncontrol")) { |
|
150 ret = cmd_versioncontrol(args); |
|
151 } else if(!strcasecmp(cmd, "list-versions") || !strcasecmp(cmd, "lsv")) { |
|
152 ret = cmd_list_versions(args); |
143 } else if(!strcasecmp(cmd, "add-repository") |
153 } else if(!strcasecmp(cmd, "add-repository") |
144 || !strcasecmp(cmd, "add-repo")) { |
154 || !strcasecmp(cmd, "add-repo")) { |
145 ret = cmd_add_repository(args); |
155 ret = cmd_add_repository(args); |
146 } else if(!strcasecmp(cmd, "remove-repository") |
156 } else if(!strcasecmp(cmd, "remove-repository") |
147 || !strcasecmp(cmd, "remove-repo") |
157 || !strcasecmp(cmd, "remove-repo") |
270 fprintf(stderr, " -x xml property content\n"); |
279 fprintf(stderr, " -x xml property content\n"); |
271 fprintf(stderr, " -N disable authentication prompt (all commands)\n"); |
280 fprintf(stderr, " -N disable authentication prompt (all commands)\n"); |
272 fprintf(stderr, " -i disable cert verification (all commands)\n"); |
281 fprintf(stderr, " -i disable cert verification (all commands)\n"); |
273 fprintf(stderr, " -v verbose output (all commands)\n"); |
282 fprintf(stderr, " -v verbose output (all commands)\n"); |
274 fprintf(stderr, "\n"); |
283 fprintf(stderr, "\n"); |
|
284 fprintf(stderr, "Advanced commands:\n"); |
|
285 fprintf(stderr, " versioncontrol, list-versions, checkout, checkin, uncheckout\n\n"); |
275 fprintf(stderr, "Config commands:\n"); |
286 fprintf(stderr, "Config commands:\n"); |
276 fprintf(stderr, " add-repository\n"); |
287 fprintf(stderr, " add-repository\n"); |
277 fprintf(stderr, " remove-repository\n"); |
288 fprintf(stderr, " remove-repository\n"); |
278 fprintf(stderr, " list-repositories\n"); |
289 fprintf(stderr, " list-repositories\n"); |
279 fprintf(stderr, " repository-url\n"); |
290 fprintf(stderr, " repository-url\n"); |
1958 } else { |
1969 } else { |
1959 print_resource_error(sn, res->path); |
1970 print_resource_error(sn, res->path); |
1960 } |
1971 } |
1961 |
1972 |
1962 return -1; |
1973 return -1; |
|
1974 } |
|
1975 |
|
1976 int cmd_checkout(CmdArgs *a) { |
|
1977 if(a->argc < 1) { |
|
1978 fprintf(stderr, "Too few arguments\n"); |
|
1979 fprintf(stderr, "Usage: dav %s\n", "checkout [-pc] <url>"); |
|
1980 return -1; |
|
1981 } |
|
1982 |
|
1983 char *url = a->argv[0]; |
|
1984 char *path = NULL; |
|
1985 Repository *repo = url2repo(url, &path); |
|
1986 DavSession *sn = connect_to_repo(repo, path, a); |
|
1987 |
|
1988 if(set_session_config(sn, a)) { |
|
1989 return -1; |
|
1990 } |
|
1991 set_session_lock(sn, a); |
|
1992 |
|
1993 int ret = 0; |
|
1994 DavResource *res = dav_resource_new(sn, path); |
|
1995 if(dav_checkout(res)) { |
|
1996 print_resource_error(sn, res->path); |
|
1997 ret = 1; |
|
1998 } |
|
1999 |
|
2000 return ret; |
|
2001 } |
|
2002 |
|
2003 int cmd_checkin(CmdArgs *a) { |
|
2004 if(a->argc < 1) { |
|
2005 fprintf(stderr, "Too few arguments\n"); |
|
2006 fprintf(stderr, "Usage: dav %s\n", "checkin [-pc] <url>"); |
|
2007 return -1; |
|
2008 } |
|
2009 |
|
2010 char *url = a->argv[0]; |
|
2011 char *path = NULL; |
|
2012 Repository *repo = url2repo(url, &path); |
|
2013 DavSession *sn = connect_to_repo(repo, path, a); |
|
2014 |
|
2015 if(set_session_config(sn, a)) { |
|
2016 return -1; |
|
2017 } |
|
2018 set_session_lock(sn, a); |
|
2019 |
|
2020 int ret = 0; |
|
2021 DavResource *res = dav_resource_new(sn, path); |
|
2022 if(dav_checkin(res)) { |
|
2023 print_resource_error(sn, res->path); |
|
2024 ret = 1; |
|
2025 } |
|
2026 |
|
2027 return ret; |
|
2028 } |
|
2029 |
|
2030 int cmd_uncheckout(CmdArgs *a) { |
|
2031 if(a->argc < 1) { |
|
2032 fprintf(stderr, "Too few arguments\n"); |
|
2033 fprintf(stderr, "Usage: dav %s\n", "uncheckout [-pc] <url>"); |
|
2034 return -1; |
|
2035 } |
|
2036 |
|
2037 char *url = a->argv[0]; |
|
2038 char *path = NULL; |
|
2039 Repository *repo = url2repo(url, &path); |
|
2040 DavSession *sn = connect_to_repo(repo, path, a); |
|
2041 |
|
2042 if(set_session_config(sn, a)) { |
|
2043 return -1; |
|
2044 } |
|
2045 set_session_lock(sn, a); |
|
2046 |
|
2047 int ret = 0; |
|
2048 DavResource *res = dav_resource_new(sn, path); |
|
2049 if(dav_uncheckout(res)) { |
|
2050 print_resource_error(sn, res->path); |
|
2051 ret = 1; |
|
2052 } |
|
2053 |
|
2054 return ret; |
|
2055 } |
|
2056 int cmd_versioncontrol(CmdArgs *a) { |
|
2057 if(a->argc < 1) { |
|
2058 fprintf(stderr, "Too few arguments\n"); |
|
2059 fprintf(stderr, "Usage: dav %s\n", "versioncontrol [-pc] <url>"); |
|
2060 return -1; |
|
2061 } |
|
2062 |
|
2063 char *url = a->argv[0]; |
|
2064 char *path = NULL; |
|
2065 Repository *repo = url2repo(url, &path); |
|
2066 DavSession *sn = connect_to_repo(repo, path, a); |
|
2067 |
|
2068 if(set_session_config(sn, a)) { |
|
2069 return -1; |
|
2070 } |
|
2071 set_session_lock(sn, a); |
|
2072 |
|
2073 int ret = 0; |
|
2074 DavResource *res = dav_resource_new(sn, path); |
|
2075 if(dav_versioncontrol(res)) { |
|
2076 print_resource_error(sn, res->path); |
|
2077 ret = 1; |
|
2078 } |
|
2079 |
|
2080 return ret; |
|
2081 } |
|
2082 |
|
2083 int cmd_list_versions(CmdArgs *a) { |
|
2084 if(a->argc < 1) { |
|
2085 fprintf(stderr, "Too few arguments\n"); |
|
2086 fprintf(stderr, "Usage: dav %s\n", "list-versions [-pc] <url>"); |
|
2087 return -1; |
|
2088 } |
|
2089 |
|
2090 char *url = a->argv[0]; |
|
2091 char *path = NULL; |
|
2092 Repository *repo = url2repo(url, &path); |
|
2093 DavSession *sn = connect_to_repo(repo, path, a); |
|
2094 |
|
2095 if(set_session_config(sn, a)) { |
|
2096 return -1; |
|
2097 } |
|
2098 |
|
2099 DavResource *res = dav_resource_new(sn, path); |
|
2100 |
|
2101 int ret = 0; |
|
2102 DavResource *list = dav_versiontree(res, NULL); |
|
2103 if(list) { |
|
2104 char* longlist = cmd_getoption(a, "list"); |
|
2105 |
|
2106 DavResource *v = list; |
|
2107 int addnl = 0; |
|
2108 while(v) { |
|
2109 char *vname = dav_get_string_property(v, "D:version-name"); |
|
2110 |
|
2111 if(longlist) { |
|
2112 if(addnl) { |
|
2113 putchar('\n'); |
|
2114 } |
|
2115 printf("name: %s\n", vname); |
|
2116 printf("href: %s\n", v->href); |
|
2117 addnl = 1; |
|
2118 } else { |
|
2119 printf("%s\n", vname); |
|
2120 } |
|
2121 v = v->next; |
|
2122 } |
|
2123 } else if(sn->error != DAV_OK) { |
|
2124 print_resource_error(sn, path); |
|
2125 ret = 1; |
|
2126 } |
|
2127 |
|
2128 return ret; |
1963 } |
2129 } |
1964 |
2130 |
1965 |
2131 |
1966 char* stdin2str() { |
2132 char* stdin2str() { |
1967 UcxBuffer *buf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); |
2133 UcxBuffer *buf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); |