* NEEDSWORK: remote_ls() ignores info/refs on the remote side. But it * should _only_ heed the information from that file, instead of trying to * determine the refs from the remote file system (badly: it does not even * know about packed-refs). */
| 1127 | * know about packed-refs). |
| 1128 | */ |
| 1129 | static void remote_ls(const char *path, int flags, |
| 1130 | void (*userFunc)(struct remote_ls_ctx *ls), |
| 1131 | void *userData) |
| 1132 | { |
| 1133 | char *url = xstrfmt("%s%s", repo->url, path); |
| 1134 | struct active_request_slot *slot; |
| 1135 | struct slot_results results; |
| 1136 | struct strbuf in_buffer = STRBUF_INIT; |
| 1137 | struct buffer out_buffer = { STRBUF_INIT, 0 }; |
| 1138 | struct curl_slist *dav_headers = http_copy_default_headers(); |
| 1139 | struct xml_ctx ctx; |
| 1140 | struct remote_ls_ctx ls; |
| 1141 | |
| 1142 | ls.flags = flags; |
| 1143 | ls.path = xstrdup(path); |
| 1144 | ls.dentry_name = NULL; |
| 1145 | ls.dentry_flags = 0; |
| 1146 | ls.userData = userData; |
| 1147 | ls.userFunc = userFunc; |
| 1148 | |
| 1149 | strbuf_addstr(&out_buffer.buf, PROPFIND_ALL_REQUEST); |
| 1150 | |
| 1151 | dav_headers = curl_slist_append(dav_headers, "Depth: 1"); |
| 1152 | dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml"); |
| 1153 | |
| 1154 | slot = get_active_slot(); |
| 1155 | slot->results = &results; |
| 1156 | curl_setup_http(slot->curl, url, DAV_PROPFIND, |
| 1157 | &out_buffer, fwrite_buffer); |
| 1158 | curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers); |
| 1159 | curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &in_buffer); |
| 1160 | |
| 1161 | if (start_active_slot(slot)) { |
| 1162 | run_active_slot(slot); |
| 1163 | if (results.curl_result == CURLE_OK) { |
| 1164 | XML_Parser parser = XML_ParserCreate(NULL); |
| 1165 | enum XML_Status result; |
| 1166 | ctx.name = xcalloc(10, 1); |
| 1167 | ctx.len = 0; |
| 1168 | ctx.cdata = NULL; |
| 1169 | ctx.userFunc = handle_remote_ls_ctx; |
| 1170 | ctx.userData = &ls; |
| 1171 | XML_SetUserData(parser, &ctx); |
| 1172 | XML_SetElementHandler(parser, xml_start_tag, |
| 1173 | xml_end_tag); |
| 1174 | XML_SetCharacterDataHandler(parser, xml_cdata); |
| 1175 | result = XML_Parse(parser, in_buffer.buf, |
| 1176 | in_buffer.len, 1); |
| 1177 | free(ctx.name); |
| 1178 | free(ctx.cdata); |
| 1179 | |
| 1180 | if (result != XML_STATUS_OK) { |
| 1181 | fprintf(stderr, "XML error: %s\n", |
| 1182 | XML_ErrorString( |
| 1183 | XML_GetErrorCode(parser))); |
| 1184 | } |
| 1185 | XML_ParserFree(parser); |
| 1186 | } |
no test coverage detected