void Delivery::on_activation() { // change delivery_status to initial state // check conditions and acquire needed GPS info delivery_status = DELIV_PREFLIGHT; memset(&gripper, 0 ,sizeof(gripper)); load_package(); _first_run = true; _rtl_state = RTL_STATE_CLIMB; }
static int load_db_packages(struct pm_ctx *pmctx, struct pkgdir *pkgdir, const char *rootdir) { struct pkgdb *db; struct pkgdb_it it; const struct pm_dbrec *dbrec; char dbfull_path[PATH_MAX]; int n; snprintf(dbfull_path, sizeof(dbfull_path), "%s%s", *(rootdir + 1) == '\0' ? "" : rootdir, pkgdir->idxpath != NULL ? pkgdir->idxpath : ""); db = pkgdb_open(pmctx, rootdir, pkgdir->idxpath, O_RDONLY, NULL); if (db == NULL) return 0; msg(3, _("Loading db packages%s%s%s..."), *dbfull_path ? " [":"", dbfull_path, *dbfull_path ? "]":""); pkgdb_it_init(db, &it, PMTAG_RECNO, NULL); n = 0; while ((dbrec = pkgdb_it_get(&it))) { if (dbrec->hdr) { if (load_package(dbrec->recno, dbrec->hdr, pkgdir)) n++; } if (n % 100 == 0) msg(3, "_."); if (sigint_reached()) { n = 0; break; } } msgn(3, "_done"); pkgdb_it_destroy(&it); pkgdb_free(db); if (n == 0) n_array_clean(pkgdir->pkgs); return n_array_size(pkgdir->pkgs); }
PyMODINIT_FUNC init_PyCrypto(void) { char cryptoPath[MAXPATHLEN+1]; strcpy(cryptoPath, Py_GetProgramFullPath()); strcat(cryptoPath, "/pylib/otherlibs/Crypto"); PyObject* m = load_package("Crypto", cryptoPath); if(!PyImport_ImportModule("Crypto.Util")) Py_FatalError("failed to load Crypto.Util"); importFromStaticallyLinked("Crypto.Util._counter", init_counter); importFromStaticallyLinked("Crypto.Util.strxor", initstrxor); if(!PyImport_ImportModule("Crypto.Cipher")) Py_FatalError("failed to load Crypto.Cipher"); importFromStaticallyLinked("Crypto.Cipher._AES", init_AES); }
int remove(const std::string& package_name, const po::variables_map& config_file) { std::cout << translate("remove_attempt") << " " << package_name << '\n'; std::string installed_pkgs = config_var("installed_packages", config_file); std::string installed_version = package_version(package_name, installed_pkgs); if(installed_version == "") { std::cout << translate("pkg_not_installed") << '\n'; return 0; } std::string local = config_var("local", config_file); std::string pkg_file = local + package_name + "_" + installed_version + ".tar"; package* pkg = load_package(local + package_name + "_" + installed_version + ".tar"); if(pkg) { // wypisanie informacji o pakiecie std::cout << translate("removing") << ": " << std::endl << " " << translate("name") << ": " << pkg->name << std::endl << " " << translate("version") << ": " << pkg->version << std::endl << " " << translate("licence") << ": " << pkg->licence << std::endl << " " << translate("description") << ": " << pkg->description << std::endl; // wypisanie plików, które zostaną usunięte for(std::vector<std::pair<std::string, std::string> >::iterator ins = pkg->files.begin(); ins != pkg->files.end(); ++ins) { std::cout << translate("removing") << " " << (*ins).first << " "+ translate("from") << " " << (*ins).second << std::endl; } // usunięcie pakietu - operacje dyskowe remove_package(pkg, config_file); delete pkg; } return 0; }
tn_array *metadata_load_primary(struct pkgdir *pkgdir, const char *path) { xmlDocPtr doc; xmlNode *root = NULL, *node; tn_array *pkgs; pkgs = n_array_new(1024, NULL, NULL); doc = xmlReadFile(path, NULL, XML_PARSE_NONET); if (doc == NULL) { logn(LOGERR, "%s: parser error", path); return NULL; } if ((root = xmlDocGetRootElement(doc)) == NULL) { xmlFreeDoc(doc); return NULL; } for (node = root->children; node; node = node->next) { char *type; if (node->type != XML_ELEMENT_NODE || strcmp((char *) node->name, "package") != 0) continue; if ((type = (char *) xmlGetProp(node, (const xmlChar *) "type")) && strcmp(type, "rpm") == 0) { struct pkg *pkg; if ((pkg = load_package(pkgdir->na, pkgdir->pkgroups, node))) n_array_push(pkgs, pkg); MEMINF("%s", pkg ? pkg_snprintf_s(pkg) : "null"); } x_xmlFree(type); } xmlFreeDoc(doc); MEMINF("XMLFREE_END"); return pkgs; }
/* * According to PEP 302, load_module has a number of responsibilities: * Note that load_package hands off to another module loader for handling __init__, * which will happily overwrite supplied values where it sees fit. * ) Module must be added to sys.modules before loading, and if there is * already one there, use it. * - load_package: We call PyImport_AddModule * - load_compiled_module: We call PyImport_ExecCodeModuleEx * - load_source_module: We call PyImport_ExecCodeModuleEx * ) __file__ must be set * - load_package: We set it to the given file name * - load_compiled_module: We pass it to PyImport_ExecCodeModuleEx * - load_source_module: We pass it to PyImport_ExecCodeModuleEx * ) __name__ must be set (PyImport_AddModule handles this) * - load_package: We call PyImport_AddModule * - load_compiled_module: We call PyImport_ExecCodeModuleEx * - load_source_module: We call PyImport_ExecCodeModuleEx * ) __path__ must be a list, if it's a package * - load_package: We do this by hand, it gets sent back to getImporter * ) __loader__ should be set to the loader * - load_package: We do this * - load_compiled_module: We do this * - load_source_module: We do this */ PyObject* PyResMgrImportLoader::load_module( const std::string& name ) { // TRACE_MSG( "PyResMgrImportLoader(%s)::load_module: %s\n", path_.c_str(), // name.c_str() ); MF_ASSERT( modules_[ name ].first != NOT_FOUND ); switch( modules_[ name ].first ) { case PKG_DIRECTORY: return load_package( name, modules_[ name ].second ); case PY_OBJECT: return load_compiled_module( name, modules_[ name ].second->asBinary() ); case PY_SOURCE: return load_source_module( name, modules_[ name ].second->asBinary(), pDirectory_ ); case NOT_FOUND: case C_EXTENSION: break; } Py_Return; }
static struct pkg *load_from_file(int dirfd, const char *filename, const char *arch) { _cleanup_close_ int pkgfd = openat(dirfd, filename, O_RDONLY); if (pkgfd < 0) { err(EXIT_FAILURE, "failed to open %s", filename); } struct pkg *pkg = malloc(sizeof(pkg_t)); zero(pkg, sizeof(pkg_t)); if (load_package(pkg, pkgfd) < 0) goto error; if (arch && pkg->arch && !match_arch(pkg, arch)) goto error; pkg->filename = strdup(filename); return pkg; error: package_free(pkg); return NULL; }