int pirs_extract_all(pirs_t * pirs, const char *basepath, pirs_extract_callback callback) { pirs_object *obj = pirs_get_filetable(pirs); pirs_object *dirs = pirs_get_directories(pirs); int i, j; for (i = j = 0; i < obj->table->nent / obj->table->width; i++) { const char *filetype, *filename, *data; const char *pirs_dir, *output_dir; unsigned long size; unsigned long offset; pirs_chunk *chunks; filename = (const char *) obj->table->entries[i * obj->table->width]->content; filetype = (const char *) obj->table->entries[i * obj->table->width + 1]->content; if (strcmp(filetype, "File") != 0) continue; pirs_dir = pirs_resolve_directory(dirs->table, (unsigned long) obj->table->entries[i * obj->table->width + 4]->content); if (strcmp (pirs_dir, "/") == 0) output_dir = strdup (basepath); else output_dir = str_concatenate(basepath, pirs_dir, 0); offset = obj->table->entries[i * obj->table->width + 3]->content; size = (unsigned long) obj->table->entries[i * obj->table->width + 5]->content; data = pirs->buf + offset; chunks = pirs_extract_chunks(pirs, data, offset, size); callback(pirs, output_dir, filename, chunks); free(output_dir); j++; } return j; }
/* * jenkins_get_status() - Get json describing jenkins status. * * @jenkins_url: The url of the jenkins server in the form of * http://<domainname>[:<port>]. /api/json will be added. * * Gets the json data containing the status of the server and all plans on the * server as a zero terminated string. If not retrievable, returns NULL. */ char* jenkins_get_status(char* jenkins_url) { CURL *curl; CURLcode res = 0; JENKINS_JSON json = { NULL, 0 }; char *url = str_concatenate(jenkins_url, "/api/json"); curl = curl_easy_init(); if(!curl) return NULL; curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, jenkins_curl_write_function); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &json); res = curl_easy_perform(curl); curl_easy_cleanup(curl); free(url); return json.json; }