bool ApkFile::open(const std::string &path) { unzFile uf = unzOpen(path.c_str()); if (!uf) { LOGE("%s: Failed to open archive", path.c_str()); return false; } auto close_uf = util::finally([&]{ unzClose(uf); }); if (unzLocateFile(uf, "AndroidManifest.xml", nullptr) != UNZ_OK) { LOGE("%s: package does not contain AndroidManifest.xml", path.c_str()); return false; } std::vector<unsigned char> data; if (!read_to_memory(uf, &data)) { LOGE("%s: Failed to extract AndroidManifest.xml", path.c_str()); return false; } // Load AndroidManifest.xml and check package name return parse_manifest(data.data(), data.size()); }
static void complete_query_requisites_on_target(void *data, Target *target, gchar *target_key, ProcReact_Future *future, ProcReact_Status status) { QueryRequisitesData *query_requisites_data = (QueryRequisitesData*)data; if(status != PROCREACT_STATUS_OK || future->result == NULL) g_printerr("[target: %s]: Cannot query the requisites of the profile!\n", target_key); else { ProfileManifestTarget *profile_manifest_target = (ProfileManifestTarget*)g_malloc(sizeof(ProfileManifestTarget)); char **result = (char**)future->result; gint result_length = g_strv_length(result); profile_manifest_target->target_key = target_key; if(result_length > 0) { profile_manifest_target->derivation = result[result_length - 1]; result[result_length - 1] = NULL; } else profile_manifest_target->derivation = NULL; parse_manifest(profile_manifest_target); g_ptr_array_add(query_requisites_data->profile_manifest_target_array, profile_manifest_target); procreact_free_string_array(future->result); } }
bool rp9_parse_file(struct uae_prefs *p, const char *filename) { bool bResult = false; struct zfile *zf; unzFile uz; unz_file_info file_info; char *manifest; add_HDF_DHnum = 0; clip_no_hires = false; zf = zfile_fopen(filename, _T("rb")); if(zf != NULL) { uz = unzOpen(zf); if (uz != NULL) { if (unzLocateFile (uz, RP9_MANIFEST, 1) == UNZ_OK) { if (unzGetCurrentFileInfo (uz, &file_info, NULL, 0, NULL, 0, NULL, 0) == UNZ_OK) { manifest = (char *)malloc(file_info.uncompressed_size + 1); if(manifest != NULL) { if (unzOpenCurrentFile (uz) == UNZ_OK) { int readsize = unzReadCurrentFile(uz, manifest, file_info.uncompressed_size); unzCloseCurrentFile(uz); if(readsize == file_info.uncompressed_size) { manifest[readsize] = '\0'; bResult = parse_manifest(p, uz, manifest); if(bResult) { // Fixup some prefs... if(p->m68k_speed >= 0) p->cachesize = 0; // Use JIT only if max. speed selected p->input_joymouse_multiplier = 5; // Most games need slower mouse movement... } } } free(manifest); } } } unzClose (uz); } zfile_fclose(zf); } return bResult; }
int main (int argc, char** argv) { if (argc < 2) { std::cerr << "usage: ./picodeps <inputfile>" << std::endl; exit(1); } std::ifstream f { argv[1] }; if (!f.is_open()) { std::cerr << "failed to open file: " << argv[1] << std::endl; exit(1); } auto dependencies = parse_manifest(f); for (auto dependency : dependencies) { dependency->download(); dependency->install(); } }
int add_this_kernel(Options *op) { Package *p; PrecompiledFileInfo *fileInfos; /* parse the manifest */ if ((p = parse_manifest(op)) == NULL) goto failed; /* make sure we have the development tools */ if (!check_development_tools(op, p)) goto failed; /* find the kernel header files */ if (!determine_kernel_source_path(op, p)) goto failed; /* build the precompiled files */ if (p->num_kernel_modules != build_kernel_interfaces(op, p, &fileInfos)) goto failed; /* pack the precompiled files */ if (!pack_precompiled_files(op, p, p->num_kernel_modules, fileInfos)) goto failed; free_package(p); return TRUE; failed: ui_error(op, "Unable to add a precompiled kernel interface for the " "running kernel."); free_package(p); return FALSE; } /* add_this_kernel() */
Manifest *create_manifest(const gchar *manifest_file, const unsigned int flags, const gchar *container_filter, const gchar *component_filter) { xmlDocPtr doc; xmlNodePtr node_root; Manifest *manifest; /* Parse the XML document */ if((doc = xmlParseFile(manifest_file)) == NULL) { g_printerr("Error with parsing the manifest XML file!\n"); xmlCleanupParser(); return NULL; } /* Retrieve root element */ node_root = xmlDocGetRootElement(doc); if(node_root == NULL) { g_printerr("The manifest XML file is empty!\n"); xmlFreeDoc(doc); xmlCleanupParser(); return NULL; } /* Parse manifest */ manifest = parse_manifest(node_root, flags, container_filter, component_filter); /* Cleanup */ xmlFreeDoc(doc); xmlCleanupParser(); /* Return manifest */ return manifest; }
/* * The SelectVersion() routine ensures that an appropriate version of * the JRE is running. The specification for the appropriate version * is obtained from either the manifest of a jar file (preferred) or * from command line options. */ static void SelectVersion(int argc, char **argv, char **main_class) { char *arg; char **new_argv; char **new_argp; char *operand; char *version = NULL; char *jre = NULL; int jarflag = 0; int restrict_search = -1; /* -1 implies not known */ manifest_info info; char env_entry[MAXNAMELEN + 24] = ENV_ENTRY "="; char *env_in; int res; /* * If the version has already been selected, set *main_class * with the value passed through the environment (if any) and * simply return. */ if ((env_in = getenv(ENV_ENTRY)) != NULL) { if (*env_in != '\0') *main_class = strdup(env_in); return; } /* * Scan through the arguments for options relevant to multiple JRE * support. For reference, the command line syntax is defined as: * * SYNOPSIS * java [options] class [argument...] * * java [options] -jar file.jar [argument...] * * As the scan is performed, make a copy of the argument list with * the version specification options (new to 1.5) removed, so that * a version less than 1.5 can be exec'd. */ new_argv = MemAlloc((argc + 1) * sizeof(char*)); new_argv[0] = argv[0]; new_argp = &new_argv[1]; argc--; argv++; while ((arg = *argv) != 0 && *arg == '-') { if (strncmp(arg, "-version:", 9) == 0) { version = arg + 9; } else if (strcmp(arg, "-jre-restrict-search") == 0) { restrict_search = 1; } else if (strcmp(arg, "-no-jre-restrict-search") == 0) { restrict_search = 0; } else { if (strcmp(arg, "-jar") == 0) jarflag = 1; /* deal with "unfortunate" classpath syntax */ if (strcmp(arg, "-classpath") == 0 || strcmp(arg, "-cp") == 0) { if (argc >= 1) { *new_argp++ = arg; argc--; argv++; arg = *argv; } } *new_argp++ = arg; } argc--; argv++; } if (argc <= 0) { /* No operand? Possibly legit with -[full]version */ operand = NULL; } else { argc--; *new_argp++ = operand = *argv++; } while (argc-- > 0) /* Copy over [argument...] */ *new_argp++ = *argv++; *new_argp = NULL; /* * If there is a jar file, read the manifest. If the jarfile can't be * read, the manifest can't be read from the jar file, or the manifest * is corrupt, issue the appropriate error messages and exit. * * Even if there isn't a jar file, construct a manifest_info structure * containing the command line information. Its a convenient way to carry * this data around. */ if (jarflag && operand) { if ((res = parse_manifest(operand, &info)) != 0) { if (res == -1) ReportErrorMessage2("Unable to access jarfile %s", operand, JNI_TRUE); else ReportErrorMessage2("Invalid or corrupt jarfile %s", operand, JNI_TRUE); exit(1); } } else { info.manifest_version = NULL; info.main_class = NULL; info.jre_version = NULL; info.jre_restrict_search = 0; } /* * The JRE-Version and JRE-Restrict-Search values (if any) from the * manifest are overwritten by any specified on the command line. */ if (version != NULL) info.jre_version = version; if (restrict_search != -1) info.jre_restrict_search = restrict_search; /* * "Valid" returns (other than unrecoverable errors) follow. Set * main_class as a side-effect of this routine. */ if (info.main_class != NULL) *main_class = strdup(info.main_class); /* * If no version selection information is found either on the command * line or in the manifest, simply return. */ if (info.jre_version == NULL) { free_manifest(); free(new_argv); return; } /* * Check for correct syntax of the version specification (JSR 56). */ if (!valid_version_string(info.jre_version)) { ReportErrorMessage2("Syntax error in version specification \"%s\"", info.jre_version, JNI_TRUE); exit(1); } /* * Find the appropriate JVM on the system. Just to be as forgiving as * possible, if the standard algorithms don't locate an appropriate * jre, check to see if the one running will satisfy the requirements. * This can happen on systems which haven't been set-up for multiple * JRE support. */ jre = LocateJRE(&info); if (_launcher_debug) printf("JRE-Version = %s, JRE-Restrict-Search = %s Selected = %s\n", (info.jre_version?info.jre_version:"null"), (info.jre_restrict_search?"true":"false"), (jre?jre:"null")); if (jre == NULL) { if (acceptable_release(FULL_VERSION, info.jre_version)) { free_manifest(); free(new_argv); return; } else { ReportErrorMessage2( "Unable to locate JRE meeting specification \"%s\"", info.jre_version, JNI_TRUE); exit(1); } } /* * If I'm not the chosen one, exec the chosen one. Returning from * ExecJRE indicates that I am indeed the chosen one. * * The private environment variable _JAVA_VERSION_SET is used to * prevent the chosen one from re-reading the manifest file and * using the values found within to override the (potential) command * line flags stripped from argv (because the target may not * understand them). Passing the MainClass value is an optimization * to avoid locating, expanding and parsing the manifest extra * times. */ if (info.main_class != NULL) { if (strlen(info.main_class) <= MAXNAMELEN) { (void)strcat(env_entry, info.main_class); } else { ReportErrorMessage("Error: main-class: attribute exceeds system limits\n", JNI_TRUE); exit(1); } } (void)putenv(env_entry); ExecJRE(jre, new_argv); free_manifest(); free(new_argv); return; }
int install_from_cwd(Options *op) { Package *p; CommandList *c; int ret; int ran_pre_install_hook = FALSE; HookScriptStatus res; static const char* edit_your_xf86config = "Please update your XF86Config or xorg.conf file as " "appropriate; see the file /usr/share/doc/" "NVIDIA_GLX-1.0/README.txt for details."; /* * validate the manifest file in the cwd, and process it, building * a Package struct */ if ((p = parse_manifest(op)) == NULL) goto failed; if (!op->x_files_packaged) { edit_your_xf86config = ""; } ui_set_title(op, "%s (%s)", p->description, p->version); /* * warn the user if "legacy" GPUs are installed in this system * and if no supported GPU is found, at all. */ check_for_nvidia_graphics_devices(op, p); /* check that we are not running any X server */ if (!check_for_running_x(op)) goto failed; /* make sure the kernel module is unloaded */ if (!check_for_unloaded_kernel_module(op)) goto failed; /* ask the user to accept the license */ if (!get_license_acceptance(op)) goto exit_install; ui_log(op, "Installing NVIDIA driver version %s.", p->version); /* * determine the current NVIDIA version (if any); ask the user if * they really want to overwrite the existing installation */ if (!check_for_existing_driver(op, p)) goto exit_install; /* * check to see if an alternate method of installation is already installed * or is available, but not installed; ask the user if they really want to * install anyway despite the presence/availability of an alternate install. */ if (!check_for_alternate_install(op)) goto exit_install; /* run the distro preinstall hook */ res = run_distro_hook(op, "pre-install"); if (res == HOOK_SCRIPT_FAIL) { if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES, NUM_CONTINUE_ABORT_CHOICES, CONTINUE_CHOICE, /* Default choice */ "The distribution-provided pre-install " "script failed! Are you sure you want " "to continue?") == ABORT_CHOICE) { goto failed; } } else if (res == HOOK_SCRIPT_SUCCESS) { if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES, NUM_CONTINUE_ABORT_CHOICES, CONTINUE_CHOICE, /* Default choice */ "The distribution-provided pre-install script " "completed successfully. If this is the first " "time you have run the installer, this script " "may have helped disable Nouveau, but a reboot " "may be required first. " "Would you like to continue, or would you " "prefer to abort installation to reboot the " "system?") == ABORT_CHOICE) { goto exit_install; } ran_pre_install_hook = TRUE; } /* fail if the nouveau driver is currently in use */ if (!check_for_nouveau(op)) goto failed; /* ask if we should install the UVM kernel module */ should_install_uvm(op, p); /* attempt to build the kernel modules for the target kernel */ if (!op->no_kernel_module) { if (!install_kernel_modules(op, p)) { goto failed; } } else { ui_warn(op, "You specified the '--no-kernel-module' command line " "option, nvidia-installer will not install a kernel " "module as part of this driver installation, and it will " "not remove existing NVIDIA kernel modules not part of " "an earlier NVIDIA driver installation. Please ensure " "that an NVIDIA kernel module matching this driver version " "is installed seperately."); /* no_kernel_module should imply no DKMS */ if (op->dkms) { ui_warn(op, "You have specified both the '--no-kernel-module' " "and the '--dkms' command line options. The '--dkms' " "option will be ignored."); op->dkms = FALSE; } } /* * if we are only installing the kernel module, then remove * everything else from the package; otherwise do some * OpenGL-specific stuff */ if (op->kernel_module_only) { remove_non_kernel_module_files_from_package(op, p); } else { /* ask for the XFree86 and OpenGL installation prefixes. */ if (!get_prefixes(op)) goto failed; /* ask if we should install the OpenGL header files */ should_install_opengl_headers(op, p); /* * select the appropriate TLS class, modifying the package as * necessary. */ select_tls_class(op, p); /* * if the package contains any libGL.la or .desktop files, * process them (perform some search and replacing so * that they reflect the correct installation path, etc) * and add them to the package list (files to be installed). */ process_libGL_la_files(op, p); process_dot_desktop_files(op, p); #if defined(NV_X86_64) /* * ask if we should install the 32bit compatibility files on * this machine. */ should_install_compat32_files(op, p); #endif /* NV_X86_64 */ } if (op->no_opengl_files) { remove_opengl_files_from_package(op, p); } /* * now that we have the installation prefixes, build the * destination for each file to be installed */ if (!set_destinations(op, p)) goto failed; /* * if we are installing OpenGL libraries, ensure that a symlink gets * installed to /usr/lib/libGL.so.1. add_libgl_abi_symlink() sets its own * destination, so it must be called after set_destinations(). */ if (!op->kernel_module_only && !op->no_opengl_files) { add_libgl_abi_symlink(op, p); } /* * uninstall the existing driver; this needs to be done before * building the command list. * * XXX if we uninstall now, then build the command list, and * then ask the user if they really want to execute the * command list, if the user decides not to execute the * command list, they'll be left with no driver installed. */ if (!op->kernel_module_only) { if (!run_existing_uninstaller(op)) goto failed; } if (!check_libglvnd_files(op, p)) { goto failed; } /* build a list of operations to execute to do the install */ if ((c = build_command_list(op, p)) == NULL) goto failed; /* call the ui to get approval for the list of commands */ if (!ui_approve_command_list(op, c, "%s", p->description)) { goto exit_install; } /* initialize the backup log file */ if (!op->kernel_module_only) { if (!init_backup(op, p)) goto failed; } /* execute the command list */ if (!do_install(op, p, c)) goto failed; /* Register, build, and install the module with DKMS, if requested */ if (op->dkms && !dkms_install_module(op, p->version, get_kernel_name(op))) goto failed; /* * Leave the RM loaded in case an X server with OutputClass-based driver * matching is being used. */ if (!op->no_kernel_module || op->dkms) { if (!load_kernel_module(op, p->kernel_modules[0].module_name)) { goto failed; } } /* run the distro postinstall script */ run_distro_hook(op, "post-install"); /* * check that everything is installed properly (post-install * sanity check) */ check_installed_files_from_package(op, p); if (!check_runtime_configuration(op, p)) goto failed; /* done */ if (op->kernel_module_only || op->no_nvidia_xconfig_question) { ui_message(op, "Installation of the kernel module for the %s " "(version %s) is now complete.", p->description, p->version); } else { /* ask the user if they would like to run nvidia-xconfig */ const char *msg = "Would you like to run the nvidia-xconfig utility " "to automatically update your X configuration file " "so that the NVIDIA X driver will be used when you " "restart X? Any pre-existing X configuration " "file will be backed up."; ret = run_nvidia_xconfig(op, FALSE, msg, op->run_nvidia_xconfig); if (ret) { ui_message(op, "Your X configuration file has been successfully " "updated. Installation of the %s (version: %s) is now " "complete.", p->description, p->version); } else { ui_message(op, "Installation of the %s (version: %s) is now " "complete. %s", p->description, p->version, edit_your_xf86config); } } free_package(p); return TRUE; failed: /* * something bad happened during installation; print an error * message and return FALSE */ if (op->logging) { ui_error(op, "Installation has failed. Please see the file '%s' " "for details. You may find suggestions on fixing " "installation problems in the README available on the " "Linux driver download page at www.nvidia.com.", op->log_file_name); } else { ui_error(op, "Installation has failed. You may find suggestions " "on fixing installation problems in the README available " "on the Linux driver download page at www.nvidia.com."); } if (ran_pre_install_hook) run_distro_hook(op, "failed-install"); /* fall through into exit_install... */ exit_install: /* * we are exiting installation; this can happen for reasons that * do not merit the error message (e.g., the user declined the * license agreement) */ free_package(p); return FALSE; } /* install_from_cwd() */
int benthos_dc_manifest_parse(plugin_manifest_t * ptr, const char * path) { int rv; struct plugin_manifest_t_ * manifest; struct stat finfo; xmlDoc * doc; xmlNode * root; iconv_t conv; if (! ptr || ! path) return EINVAL; /* Create the Encoding Converter */ conv = iconv_open("ISO-8859-1", "UTF-8"); if (conv == (iconv_t)(-1)) return errno; /* Create the Manifest Object */ manifest = new struct plugin_manifest_t_; if (! manifest) { iconv_close(conv); return ENOMEM; } /* Check that the File Exists */ rv = stat(path, & finfo); if (rv != 0) { delete manifest; iconv_close(conv); return errno; } if (! S_ISREG(finfo.st_mode)) { delete manifest; iconv_close(conv); return ENOENT; } /* Load the Manifest File */ doc = xmlReadFile(path, 0, 0); if (doc == NULL) { delete manifest; xmlCleanupParser(); iconv_close(conv); return MANFIEST_ERR_MALFORMED; } /* Load the Root Node */ root = xmlDocGetRootElement(doc); if ((root == NULL) || (root->type != XML_ELEMENT_NODE)) { delete manifest; xmlFreeDoc(doc); xmlCleanupParser(); iconv_close(conv); return MANIFEST_ERR_NOROOT; } /* Check the Root Node */ if (xmlStrcmp(root->name, BAD_CAST("plugin")) != 0) { delete manifest; xmlFreeDoc(doc); xmlCleanupParser(); iconv_close(conv); return MANIFEST_ERR_NOTPLUGIN; } /* Parse the Manifest Entry */ rv = parse_manifest(manifest, root, conv); if (rv != 0) { delete manifest; xmlFreeDoc(doc); xmlCleanupParser(); iconv_close(conv); return rv; } /* Set Manifest Pointer */ (* ptr) = manifest; /* Cleanup */ xmlFreeDoc(doc); xmlCleanupParser(); iconv_close(conv); return 0; }