struct install_status_t ntran_copy (struct install_item *ins) { static char src_name [INSTALL_MAX_PATHLEN]; static char dst_name [INSTALL_MAX_PATHLEN]; static char dst_tmp [INSTALL_MAX_PATHLEN]; struct install_status_t status = INSTALL_STATUS_INIT; if (!ins->src) { status.message = "source file undefined"; return status; } if (!ins->dir) { status.message = "directory undefined"; return status; } if (!ins->dst) ins->dst = ins->src; if (str_ends (ins->src, ".vlb")) { if (!libname (ins->src, src_name)) { status.message = "could not build library name"; return status; } ins->src = src_name; } if (str_ends (ins->dst, ".vlb")) { if (!libname (ins->dst, dst_name)) { status.message = "could not build library name"; return status; } ins->dst = dst_name; } if (!base_name (ins->dst, &ins->dst)) { status.message = "invalid destination path"; return status; } if (snprintf (dst_tmp, sizeof (dst_tmp), "%s/%s", ins->dir, ins->dst) < 0) { status.status = INSTALL_STATUS_ERROR; status.message = "could not format destination path"; return status; } ins->dst = dst_tmp; status.status = INSTALL_STATUS_OK; return status; }
static inline QCString makeLibName(const char *name) { QCString libname(name); // only append ".so" if there is no extension int pos = libname.findRev('/'); if(pos < 0) pos = 0; if(libname.find('.', pos) < 0) libname += ".so"; return libname; }
static inline QCString makeLibName( const char* name ) { QCString libname(name); // only append ".la" if there is no extension // this allows to load non-libtool libraries as well // (mhk, 20000228) int pos = libname.findRev('/'); if (pos < 0) pos = 0; if (libname.find('.', pos) < 0) libname += ".la"; return libname; }
// Factory functions PVMFNodeInterface* Mp4NodesCoreLibraryLoader::CreateMp4ParserNode(int32 aPriority) { OsclSharedLibrary* mp4SharedLibrary = NULL; OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(MP4_LIB_NAME); // Need to load the library for the node mp4SharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname)); OsclLibStatus result = mp4SharedLibrary->LoadLib(); if (OsclLibSuccess != result) { return NULL; } mp4SharedLibrary->AddRef(); // Query for create function OsclAny* interfacePtr = NULL; mp4SharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr); NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr); OsclAny* createFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFMP4FFParserNodeUuid, PV_CREATE_NODE_INTERFACE); LPFN_NODE_CREATE_FUNC nodeCreateFunc = OSCL_DYNAMIC_CAST(PVMFNodeInterface * (*)(int32), createFuncTemp); if (NULL != nodeCreateFunc) { PVMFNodeInterface* node = NULL; // call the real node factory function node = (*(nodeCreateFunc))(aPriority); if (NULL == node) { mp4SharedLibrary->RemoveRef(); if (OsclLibSuccess == mp4SharedLibrary->Close()) { // Close will unload the library if refcount is 0 OSCL_DELETE(mp4SharedLibrary); } return NULL; } node->SetSharedLibraryPtr(mp4SharedLibrary); return node; } return NULL; }
// Factory functions ProtocolContainer* ProtocolEngineNodeProgressiveDownloadContainerLoader::CreateProgressiveDownloadContainer(PVMFProtocolEngineNode* aNode) { OsclSharedLibrary* aSharedLibrary = NULL; OSCL_StackString<LIB_NAME_MAX_LENGTH> libname(PDL_PLUGIN_LIB_NAME); // Need to load the library for the node aSharedLibrary = OSCL_NEW(OsclSharedLibrary, ()); OsclLibStatus result = aSharedLibrary->LoadLib(libname); if (OsclLibSuccess != result) return NULL; aSharedLibrary->AddRef(); // Query for create function OsclAny* interfacePtr = NULL; aSharedLibrary->QueryInterface(PENODE_SHARED_LIBRARY_INTERFACE, (OsclAny*&)interfacePtr); if (NULL == interfacePtr) return NULL; ProtocolEngineNodeSharedLibraryInterface* libIntPtr = OSCL_DYNAMIC_CAST(ProtocolEngineNodeSharedLibraryInterface*, interfacePtr); OsclAny* createFuncTemp = libIntPtr->QueryLibInterface(PENODE_CREATE_LIB_INTERFACE); if (!createFuncTemp) return NULL; LPFN_LIB_CREATE_FUNC libCreateFunc = OSCL_DYNAMIC_CAST(ProtocolContainer * (*)(PVMFProtocolEngineNode *), createFuncTemp); if (NULL != libCreateFunc) { // call the real node factory function ProtocolContainer *aProtocolContainer = (*(libCreateFunc))(aNode); if (NULL != aProtocolContainer) { aProtocolContainer->SetSharedLibraryPtr(aSharedLibrary); return aProtocolContainer; } } aSharedLibrary->RemoveRef(); if (OsclLibSuccess == aSharedLibrary->Close()) { // Close will unload the library if refcount is 0 OSCL_DELETE(aSharedLibrary); } return NULL; }
struct install_status_t ntran_liblink (struct install_item *ins) { static char dst_tmp [INSTALL_MAX_PATHLEN]; static char src_name [INSTALL_MAX_PATHLEN]; static char src_tmp [INSTALL_MAX_PATHLEN]; struct install_status_t status = INSTALL_STATUS_INIT; if (!ins->src) { status.message = "source file undefined"; return status; } if (!ins->dir) { status.message = "directory undefined"; return status; } if (!ins->dst) { status.message = "destination file undefined"; return status; } if (str_ends (ins->src, ".vlb")) { if (!libname (ins->src, src_tmp)) { status.message = "could not build library name"; return status; } ins->src = src_tmp; if (!base_name (ins->src, &ins->src)) { status.message = "invalid source path"; return status; } memcpy (src_name, ins->src, INSTALL_MAX_PATHLEN); ins->src = src_name; } /* build name of library */ if (!base_name (ins->dst, &ins->dst)) { status.message = "invalid destination path"; return status; } if (snprintf (dst_tmp, INSTALL_MAX_PATHLEN, "%s%s", ins->dst, inst_dlib_suffix) < 0) { status.status = INSTALL_STATUS_ERROR; status.message = "could not format destination path"; return status; } ins->dst = dst_tmp; status.status = INSTALL_STATUS_OK; return status; }
int _setargv(int *argc, char ***argv) { register int nargc; /* New arguments counter */ char **nargv; /* New arguments pointers */ register int i, j; int asize; /* argv array size */ char *arg; char lib[256]; _errnum = 0; nargc = 0; /* Initialise counter, size counter */ asize = *argc; /* and new argument vector to the */ /* current argv array size */ if ((nargv = (char **) calloc((size_t) *argc, sizeof (void *))) != NULL) { /* For each initial argument */ for (i = 0; i < *argc; i++) { arg = (*argv)[i]; #ifdef DEBUG fprintf(stderr, "checking arg: %s", arg); #endif if (i == 0 || *arg == '-' || ! ismember(arg)) { /* if it begins with a dash or doesn't include * a library name simply add it to the new array */ if (! (asize = allocarg(nargc, asize, &nargv, arg))) return 0; /* Not enough memory */ nargc++; } else { short insert; strcpy(lib, libname(arg)); /* add library name if necessary */ for (j = 2, insert = 1; i < nargc; i++) { if (ismember(nargv[i]) && ! strcmp(lib, libname(nargv[i]))) { insert = 0; break; } } if (insert) { #ifdef DEBUG fprintf(stderr, "inserting lib %s ", lib); #endif if (! (asize = allocarg(nargc, asize, &nargv, lib))) return 0; /* Not enough memory */ nargc++; } /* add file name */ #ifdef DEBUG fprintf(stderr, "inserting file %s", arg); #endif if (! (asize = allocarg(nargc, asize, &nargv, arg))) return 0; /* Not enough memory */ nargc++; } #ifdef DEBUG fprintf(stderr, "\n"); #endif } /* Update caller's parameters */ *argc = nargc; *argv = nargv; /* and sign on success */ return nargc; } /* If it is not possible to allocate initial array, sign on error */ _errnum = ENOMEM; return 0; }
static struct install_status_t ntran_copy (struct install_item *item) { static char src_name [INSTALL_MAX_PATHLEN]; static char dst_name [INSTALL_MAX_PATHLEN]; static char dst_tmp [INSTALL_MAX_PATHLEN]; struct install_status_t status = INSTALL_STATUS_INIT; assert (item != NULL); if (item->src == NULL) { install_status_assign (&status, INSTALL_STATUS_ERROR, "source file undefined"); return status; } if (item->dir == NULL) { install_status_assign (&status, INSTALL_STATUS_ERROR, "directory undefined"); return status; } if (item->dst == NULL) item->dst = item->src; /* If source or destination file are virtual library files, build * real library names. */ if (str_ends (item->src, ".vlb") != 0) { if (libname (item->src, src_name) == 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "could not build library name"); return status; } item->src = src_name; } if (str_ends (item->dst, ".vlb") != 0) { if (libname (item->dst, dst_name) == 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "could not build library name"); return status; } item->dst = dst_name; } assert (item->src != NULL); assert (item->dst != NULL); if (base_name (item->dst, &item->dst) == 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "invalid destination path"); return status; } assert (item->dst != NULL); /* Build file names, possibly prefixed with fake root */ if (inst_fake_root != NULL) { if (snprintf (dst_tmp, sizeof (dst_tmp), "%s/%s/%s", inst_fake_root, item->dir, item->dst) < 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "could not format destination path"); return status; } } else { if (snprintf (dst_tmp, sizeof (dst_tmp), "%s/%s", item->dir, item->dst) < 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "could not format destination path"); return status; } } item->dst = dst_tmp; install_status_assign (&status, INSTALL_STATUS_OK, NULL); return status; }
static struct install_status_t ntran_liblink (struct install_item *item) { static char dir_name [INSTALL_MAX_PATHLEN]; static char dst_tmp [INSTALL_MAX_PATHLEN]; static char src_name [INSTALL_MAX_PATHLEN]; static char src_tmp [INSTALL_MAX_PATHLEN]; struct install_status_t status = INSTALL_STATUS_INIT; assert (item != NULL); if (item->src == NULL) { install_status_assign (&status, INSTALL_STATUS_ERROR, "source file undefined"); return status; } if (item->dir == NULL) { install_status_assign (&status, INSTALL_STATUS_ERROR, "directory undefined"); return status; } if (item->dst == NULL) { install_status_assign (&status, INSTALL_STATUS_ERROR, "destination file undefined"); return status; } /* Modify path if fake root was specified */ if (inst_fake_root != NULL) { if (snprintf (dir_name, INSTALL_MAX_PATHLEN, "%s/%s", inst_fake_root, item->dir) < 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "could not format destination path"); return status; } item->dir = dir_name; } /* If source or destination file are virtual library files, build * real library names. */ if (str_ends (item->src, ".vlb") != 0) { if (libname (item->src, src_tmp) == 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "could not build library name"); return status; } item->src = src_tmp; if (base_name (item->src, &item->src) == 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "invalid source path"); return status; } memcpy (src_name, item->src, INSTALL_MAX_PATHLEN); item->src = src_name; } /* Build library name */ if (base_name (item->dst, &item->dst) == 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "invalid destination path"); return status; } assert (item->dst != NULL); if (snprintf (dst_tmp, INSTALL_MAX_PATHLEN, "%s%s", item->dst, inst_dlib_suffix) < 0) { install_status_assign (&status, INSTALL_STATUS_ERROR, "could not format destination path"); return status; } item->dst = dst_tmp; install_status_assign (&status, INSTALL_STATUS_OK, NULL); return status; }
static bool do_change_version(atrt_config& config, SqlResultSet& command, AtrtClient& atrtdb){ /** * TODO make option to restart "not" initial */ uint process_id= command.columnAsInt("process_id"); const char* process_args= command.column("process_args"); g_logger.info("Change version for process: %d, args: %s", process_id, process_args); // Get the process if (process_id > config.m_processes.size()){ g_logger.critical("Invalid process id %d", process_id); return false; } atrt_process& proc= *config.m_processes[process_id]; const char* new_prefix= g_prefix1 ? g_prefix1 : g_prefix; const char* old_prefix= g_prefix; const char *start= strstr(proc.m_proc.m_path.c_str(), old_prefix); if (!start){ /* Process path does not contain old prefix. * Perhaps it contains the new prefix - e.g. is already * upgraded? */ if (strstr(proc.m_proc.m_path.c_str(), new_prefix)) { /* Process is already upgraded, *assume* that this * is ok * Alternatives could be - error, or downgrade. */ g_logger.info("Process already upgraded"); return true; } g_logger.critical("Could not find '%s' in '%s'", old_prefix, proc.m_proc.m_path.c_str()); return false; } // Save current proc state if (proc.m_save.m_saved == false) { proc.m_save.m_proc= proc.m_proc; proc.m_save.m_saved= true; } g_logger.info("stopping process..."); if (!stop_process(proc)) return false; BaseString newEnv = set_env_var(proc.m_proc.m_env, BaseString("MYSQL_BASE_DIR"), BaseString(new_prefix)); proc.m_proc.m_env.assign(newEnv); ssize_t pos = proc.m_proc.m_path.lastIndexOf('/') + 1; BaseString exename(proc.m_proc.m_path.substr(pos)); char * exe = find_bin_path(new_prefix, exename.c_str()); proc.m_proc.m_path = exe; if (exe) { free(exe); } if (process_args && strlen(process_args)) { /* Beware too long args */ proc.m_proc.m_args.append(" "); proc.m_proc.m_args.append(process_args); } { /** * In 5.5...binaries aren't compiled with rpath * So we need an explicit LD_LIBRARY_PATH * So when upgrading..we need to change LD_LIBRARY_PATH * So I hate 5.5... */ #if defined(__MACH__) ssize_t p0 = proc.m_proc.m_env.indexOf(" DYLD_LIBRARY_PATH="); #else ssize_t p0 = proc.m_proc.m_env.indexOf(" LD_LIBRARY_PATH="); #endif ssize_t p1 = proc.m_proc.m_env.indexOf(' ', p0 + 1); BaseString part0 = proc.m_proc.m_env.substr(0, p0); BaseString part1 = proc.m_proc.m_env.substr(p1); proc.m_proc.m_env.assfmt("%s%s", part0.c_str(), part1.c_str()); BaseString lib(g_libmysqlclient_so_path); ssize_t pos = lib.lastIndexOf('/') + 1; BaseString libname(lib.substr(pos)); char * exe = find_bin_path(new_prefix, libname.c_str()); char * dir = dirname(exe); #if defined(__MACH__) proc.m_proc.m_env.appfmt(" DYLD_LIBRARY_PATH=%s", dir); #else proc.m_proc.m_env.appfmt(" LD_LIBRARY_PATH=%s", dir); #endif free(exe); free(dir); } ndbout << proc << endl; g_logger.info("starting process..."); if (!start_process(proc)) return false; return true; }