int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte **data) { char *arg_language = NULL; const char *arg_type = resType; char *arg_name = resName; int ressize = 0; _arg_raw = false; /* translate --type option from resource type string to integer */ arg_type = res_type_string_to_id(arg_type); WinLibrary fi; /* initiate stuff */ fi.memory = NULL; fi.file = NULL; if (_fileName.empty()) { // We are running for the first time _fileName = _vm->generateFilename(-3); } /* get file size */ fi.file = SearchMan.createReadStreamForMember(_fileName); if (!fi.file) { error("Cannot open file %s", _fileName.c_str()); } fi.total_size = fi.file->size(); if (fi.total_size == -1) { error("Cannot get size of file %s", _fileName.c_str()); goto cleanup; } if (fi.total_size == 0) { error("%s: file has a size of 0", _fileName.c_str()); goto cleanup; } /* read all of file */ fi.memory = (byte *)malloc(fi.total_size); if (fi.file->read(fi.memory, fi.total_size) == 0) { error("Cannot read from file %s", _fileName.c_str()); goto cleanup; } /* identify file and find resource table */ if (!read_library(&fi)) { /* error reported by read_library */ goto cleanup; } /* errors will be printed by the callback */ ressize = do_resources(&fi, arg_type, arg_name, arg_language, data); /* free stuff and close file */ cleanup: delete fi.file; free(fi.memory); return ressize; }
dav_error * dav_svn__merge_response(ap_filter_t *output, const dav_svn_repos *repos, svn_revnum_t new_rev, char *post_commit_err, apr_xml_elem *prop_elem, svn_boolean_t disable_merge_response, apr_pool_t *pool) { apr_bucket_brigade *bb; svn_fs_root_t *root; svn_error_t *serr; const char *vcc; const char *rev; svn_string_t *creationdate, *creator_displayname; const char *post_commit_err_elem = NULL, *post_commit_header_info = NULL; serr = svn_fs_revision_root(&root, repos->fs, new_rev, pool); if (serr != NULL) { return dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, "Could not open the FS root for the " "revision just committed.", repos->pool); } bb = apr_brigade_create(pool, output->c->bucket_alloc); /* prep some strings */ /* the HREF for the baseline is actually the VCC */ vcc = dav_svn__build_uri(repos, DAV_SVN__BUILD_URI_VCC, SVN_IGNORED_REVNUM, NULL, 0 /* add_href */, pool); /* the version-name of the baseline is the revision number */ rev = apr_psprintf(pool, "%ld", new_rev); /* get the post-commit hook stderr, if any */ if (post_commit_err) { post_commit_header_info = apr_psprintf(pool, " xmlns:S=\"%s\"", SVN_XML_NAMESPACE); post_commit_err_elem = apr_psprintf(pool, "<S:post-commit-err>%s" "</S:post-commit-err>", post_commit_err); } else { post_commit_header_info = "" ; post_commit_err_elem = "" ; } /* get the creationdate and creator-displayname of the new revision, too. */ serr = svn_fs_revision_prop(&creationdate, repos->fs, new_rev, SVN_PROP_REVISION_DATE, pool); if (serr != NULL) { return dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, "Could not get date of newest revision", repos->pool); } serr = svn_fs_revision_prop(&creator_displayname, repos->fs, new_rev, SVN_PROP_REVISION_AUTHOR, pool); if (serr != NULL) { return dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, "Could not get author of newest revision", repos->pool); } (void) ap_fputstrs(output, bb, DAV_XML_HEADER DEBUG_CR "<D:merge-response xmlns:D=\"DAV:\"", post_commit_header_info, ">" DEBUG_CR "<D:updated-set>" DEBUG_CR /* generate a response for the new baseline */ "<D:response>" DEBUG_CR "<D:href>", apr_xml_quote_string(pool, vcc, 1), "</D:href>" DEBUG_CR "<D:propstat><D:prop>" DEBUG_CR /* ### this is wrong. it's a VCC, not a baseline. but ### we need to tell the client to look at *this* ### resource for the version-name. */ "<D:resourcetype><D:baseline/></D:resourcetype>" DEBUG_CR, post_commit_err_elem, DEBUG_CR "<D:version-name>", rev, "</D:version-name>" DEBUG_CR, NULL); if (creationdate) { (void) ap_fputstrs(output, bb, "<D:creationdate>", apr_xml_quote_string(pool, creationdate->data, 1), "</D:creationdate>" DEBUG_CR, NULL); } if (creator_displayname) { (void) ap_fputstrs(output, bb, "<D:creator-displayname>", apr_xml_quote_string(pool, creator_displayname->data, 1), "</D:creator-displayname>" DEBUG_CR, NULL); } (void) ap_fputstrs(output, bb, "</D:prop>" DEBUG_CR "<D:status>HTTP/1.1 200 OK</D:status>" DEBUG_CR "</D:propstat>" DEBUG_CR "</D:response>" DEBUG_CR, NULL); /* ONLY have dir_delta drive the editor if the caller asked us to generate a full MERGE response. svn clients can ask us to suppress this walk by sending specific request headers. */ if (! disable_merge_response) { /* Now we need to generate responses for all the resources which changed. This is done through a delta of the two roots. Note that a directory is not marked when open_dir is seen (since it typically is used just for changing members in that directory); instead, we want for a property change (the only reason the client would need to fetch a new directory). ### we probably should say something about the dirs, so that ### we can pass back the new version URL */ /* and go make me proud, boy! */ serr = do_resources(repos, root, new_rev, output, bb, pool); if (serr != NULL) { return dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, "Error constructing resource list.", repos->pool); } } /* wrap up the merge response */ (void) ap_fputs(output, bb, "</D:updated-set>" DEBUG_CR "</D:merge-response>" DEBUG_CR); /* send whatever is left in the brigade */ (void) ap_pass_brigade(output, bb); return SVN_NO_ERROR; }