这篇教程C++ wordfree函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wordfree函数的典型用法代码示例。如果您正苦于以下问题:C++ wordfree函数的具体用法?C++ wordfree怎么用?C++ wordfree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wordfree函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: wordexpconst char *az_get_app_data_directory(void) { static char path_buffer[PATH_MAX]; if (path_buffer[0] == '/0') { // First, do tilde-expansion so we get a path in the user's homedir. wordexp_t words; wordexp("~/.azimuth-game", &words, 0); if (words.we_wordc < 1) { wordfree(&words); return NULL; } strncpy(path_buffer, words.we_wordv[0], sizeof(path_buffer) - 1); wordfree(&words); struct stat stat_buffer; // Try to stat the desired path. if (stat(path_buffer, &stat_buffer) == 0) { // If the path exists but isn't a directory, we fail. if (!S_ISDIR(stat_buffer.st_mode)) { path_buffer[0] = '/0'; return NULL; } } // If the directory doesn't exist, try to create it. If we can't create // it, or if stat failed for some other reason, we fail. else if (errno != ENOENT || mkdir(path_buffer, 0700) != 0) { path_buffer[0] = '/0'; return NULL; } } return path_buffer;}
开发者ID:andrewrk,项目名称:azimuth,代码行数:30,
示例2: read_repopathsstatic intread_repopaths(char **md_repo, char **md_primary_xml, char **md_filelists, char **md_repo_updates, char **md_primary_updates_xml, char **md_filelists_updates){ wordexp_t word_vector; *md_repo = *md_primary_xml = *md_filelists = *md_repo_updates = / *md_primary_updates_xml = *md_filelists_updates = NULL; if (wordexp(CFG_FILE, &word_vector, 0)) return 1; if (word_vector.we_wordc < 1) { wordfree(&word_vector); return 1; } const char *cfgpath = word_vector.we_wordv[0]; FILE *f = fopen(cfgpath, "r"); if (!f) { wordfree(&word_vector); return 1; } size_t size = 0; if ((getline(md_repo, &size, f) < 0) || (getline(md_primary_xml, &size, f) < 0) || (getline(md_filelists, &size, f) < 0) || (getline(md_repo_updates, &size, f) < 0) || (getline(md_primary_updates_xml, &size, f) < 0) || (getline(md_filelists_updates, &size, f) < 0)) { free(*md_repo); free(*md_primary_xml); free(*md_filelists); free(*md_repo_updates); free(*md_primary_updates_xml); free(*md_filelists_updates); fclose(f); wordfree(&word_vector); return 1; } fclose(f); wordfree(&word_vector); rtrim(*md_repo); rtrim(*md_primary_xml); rtrim(*md_filelists); rtrim(*md_repo_updates); rtrim(*md_primary_updates_xml); rtrim(*md_filelists_updates); return 0;}
开发者ID:MichaelMraka,项目名称:libhif,代码行数:49,
示例3: glob_for_cachedirstatic intglob_for_cachedir(char *path){ int ret = 1; if (!str_endswith(path, "XXXXXX")) return ret; wordexp_t word_vector; char *p = solv_strdup(path); const int len = strlen(p); struct stat s; ret = 2; p[len-6] = '*'; p[len-5] = '/0'; if (wordexp(p, &word_vector, 0)) { solv_free(p); return ret; } for (int i = 0; i < word_vector.we_wordc; ++i) { char *entry = word_vector.we_wordv[i]; if (stat(entry, &s)) continue; if (S_ISDIR(s.st_mode) && s.st_uid == getuid()) { assert(strlen(path) == strlen(entry)); strcpy(path, entry); ret = 0; break; } } wordfree(&word_vector); solv_free(p); return ret;}
开发者ID:iamcourtney,项目名称:hawkey,代码行数:35,
示例4: ExpandEnvironmentStringsstd::string DataDirLocater::SubstEnvVars(const std::string& in) const{ std::string out;#ifdef _WIN32 const size_t maxSize = 32 * 1024; char out_c[maxSize]; ExpandEnvironmentStrings(in.c_str(), out_c, maxSize); // expands %HOME% etc. out = out_c;#else std::string previous = in; for (int i = 0; i < 10; ++i) { // repeat substitution till we got a pure absolute path wordexp_t pwordexp; int r = wordexp(previous.c_str(), &pwordexp, WRDE_NOCMD); // expands $FOO, ${FOO}, ${FOO-DEF} ~/, etc. if (r == EXIT_SUCCESS) { if (pwordexp.we_wordc > 0) { out = pwordexp.we_wordv[0];; for (unsigned int w = 1; w < pwordexp.we_wordc; ++w) { out += " "; out += pwordexp.we_wordv[w]; } } wordfree(&pwordexp); } else { out = in; } if (previous == out) { break; } previous.swap(out); }#endif return out;}
开发者ID:nixtux,项目名称:spring,代码行数:34,
示例5: do_wordexpstatic char*do_wordexp (const char *path){#ifdef HAVE_WORDEXP_H wordexp_t wexp; char *dir; if (!path) { /* g_debug ("%s: path is empty", __FUNCTION__); */ return NULL; } if (wordexp (path, &wexp, 0) != 0) { /* g_debug ("%s: expansion failed for %s", __FUNCTION__, path); */ return NULL; } /* we just pick the first one */ dir = g_strdup (wexp.we_wordv[0]); /* strangely, below seems to lead to a crash on MacOS (BSD); so we have to allow for a tiny leak here on that platform... maybe instead of __APPLE__ it should be __BSD__?*/#ifndef __APPLE__ wordfree (&wexp);#endif /*__APPLE__*/ return dir;# else /*!HAVE_WORDEXP_H*//* E.g. OpenBSD does not have wordexp.h, so we ignore it */ return path ? g_strdup (path) : NULL;#endif /*HAVE_WORDEXP_H*/}
开发者ID:chrisklaiber,项目名称:mu,代码行数:34,
示例6: _ifparser_sourcestatic void_ifparser_source (const char *path, const char *en_dir, int quiet){ char *abs_path; wordexp_t we; uint i; if (g_path_is_absolute (path)) abs_path = g_strdup (path); else abs_path = g_build_filename (en_dir, path, NULL); if (!quiet) nm_log_info (LOGD_SETTINGS, " interface-parser: source line includes interfaces file(s) %s/n", abs_path); /* ifupdown uses WRDE_NOCMD for wordexp. */ if (wordexp (abs_path, &we, WRDE_NOCMD)) { if (!quiet) nm_log_warn (LOGD_SETTINGS, "word expansion for %s failed/n", abs_path); } else { for (i = 0; i < we.we_wordc; i++) _recursive_ifparser (we.we_wordv[i], quiet); wordfree (&we); } g_free (abs_path);}
开发者ID:aelarabawy,项目名称:NetworkManager,代码行数:26,
示例7: xdg_open_selection_cbstatic voidxdg_open_selection_cb (GtkClipboard *clipboard, const char *string, gpointer data){ char *command; wordexp_t result; gboolean spawn; GError *spawn_error = NULL; command = g_strconcat ("xdg-open ", string, NULL); switch (wordexp (command, &result, WRDE_NOCMD)) { case 0: break; case WRDE_BADCHAR: fprintf (stderr, "'%s' contains an invalid character/n", string); goto finalize; case WRDE_CMDSUB: fprintf (stderr, "'%s' uses command substitution, which is not allowed/n", string); goto finalize; case WRDE_NOSPACE: fprintf (stderr, "Could not allocate enough memory when parsing '%s'/n", string); goto finalize; case WRDE_SYNTAX: fprintf (stderr, "Syntax error in '%s'/n", string); goto finalize; } spawn = g_spawn_async (NULL, result.we_wordv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &spawn_error); if (!spawn) { fprintf (stderr, "%s/n", spawn_error->message); g_error_free (spawn_error); } finalize: wordfree (&result);}
开发者ID:Donskoy-tabak,项目名称:tinyterm,代码行数:34,
示例8: expandPathstd::string expandPath(const char* file){ if (!file) return ""; std::string f; size_t size = strlen(file); f.reserve(size); for (size_t x=0; x<size; x++) { if (file[x] == ' ') f.push_back('//'); f.push_back(file[x]); } wordexp_t exp_result; memset(&exp_result, 0, sizeof(wordexp_t)); int res = wordexp(f.c_str(), &exp_result, 0); if (res != 0) return ""; std::string r; if (exp_result.we_wordv[0]) r = exp_result.we_wordv[0]; wordfree(&exp_result); return r;}
开发者ID:leayle2a,项目名称:desura-app,代码行数:35,
示例9: getenvchar *swaynag_get_config_path(void) { static const char *config_paths[] = { "$HOME/.swaynag/config", "$XDG_CONFIG_HOME/swaynag/config", SYSCONFDIR "/swaynag/config", }; char *config_home = getenv("XDG_CONFIG_HOME"); if (!config_home || config_home[0] == '/0') { config_paths[1] = "$HOME/.config/swaynag/config"; } wordexp_t p; for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) { if (wordexp(config_paths[i], &p, 0) == 0) { char *path = strdup(p.we_wordv[0]); wordfree(&p); if (file_exists(path)) { return path; } free(path); } } return NULL;}
开发者ID:thejan2009,项目名称:sway,代码行数:26,
示例10: word_expansionchar * word_expansion(char * line){ //on traite les caractères spéciaux char * new_line = replace_char(line, "|"); char * new_line_2 = replace_char(new_line, "<"); char * new_line_3 = replace_char(new_line_2, ">"); char * new_line_4 = replace_char(new_line_3, "&"); wordexp_t result; wordexp(new_line_4, &result, 0); free(new_line_4); int cmd_offset = 0; //on calcule la longueur de la nouvelle commande for(int i=0; i<result.we_wordc; i++) { cmd_offset += strlen(result.we_wordv[i]); cmd_offset++; //derrière chaque commande, il y a un espace } //cmd_offset--; char * max_cmd = malloc(sizeof(char)*cmd_offset); //initialisation à '/0' for(int i=0; i<cmd_offset; i++) max_cmd[i] = '/0'; int tmp_cmd_offset = 0; //on fait la recopie for(int i=0; tmp_cmd_offset<cmd_offset; i++) { strcat(max_cmd, result.we_wordv[i]); tmp_cmd_offset += (int)strlen(result.we_wordv[i]); max_cmd[tmp_cmd_offset++] = ' '; } max_cmd[cmd_offset] = '/0'; wordfree(&result); return max_cmd;}
开发者ID:Obikate,项目名称:sepc_hahnleif_ortizso,代码行数:35,
示例11: assertg_vector<g_string> PinCmd::getFullCmdArgs(uint32_t procIdx, const char** inputFile) { assert(procIdx < procInfo.size()); //must be one of the topmost processes g_vector<g_string> res = getPinCmdArgs(procIdx); g_string cmd = procInfo[procIdx].cmd; /* Loader injection: Turns out that Pin mingles with the simulated binary, which decides the loader used, * even when PIN_VM_LIBRARY_PATH is used. This kill the invariance on libzsim.so's loaded address, because * loaders in different children have different sizes. So, if specified, we prefix the program with the * given loader. This is optional because it won't work with statically linked binaries. * * BTW, thinking of running pin under a specific loaderto fix this instead? Nope, it gets into an infinite loop. */ if (procInfo[procIdx].loader != "") { cmd = procInfo[procIdx].loader + " " + cmd; info("Injected loader on process%d, command line: %s", procIdx, cmd.c_str()); warn("Loader injection makes Pin unaware of symbol routines, so things like routine patching" "will not work! You can homogeneize the loaders instead by editing the .interp ELF section"); } //Parse command -- use glibc's wordexp to parse things like quotes, handle argument expansion, etc correctly wordexp_t p; wordexp(cmd.c_str(), &p, 0); for (uint32_t i = 0; i < p.we_wordc; i++) { res.push_back(g_string(p.we_wordv[i])); } wordfree(&p); //Input redirect *inputFile = (procInfo[procIdx].input == "")? nullptr : procInfo[procIdx].input.c_str(); return res;}
开发者ID:flylucas,项目名称:zsim,代码行数:32,
示例12: wordexpstd::string ConfigurationManager::retrieveAsPath(std::string namespaceName, std::string identifier, std::string defaultValue){ std::string result = defaultValue; EntriesMap::const_iterator iter = entries->find(std::make_pair(namespaceName, identifier)); if(iter != entries->end()) { wordexp_t expansion; int expansionResult = 0; expansionResult = wordexp(iter->second.c_str(), &expansion, WRDE_NOCMD); if(expansionResult == 0 && expansion.we_wordc > 0) { result.clear(); for(int i=0;i<expansion.we_wordc;i++) { result += expansion.we_wordv[i]; } } wordfree(&expansion); if(result[0] != '/') // relative path, need to prefix with workingDir { result = workingDir + result; } } return result;}
开发者ID:profmaad,项目名称:yonderboy,代码行数:31,
示例13: mame_expand_stringstatic voidmame_expand_string (gchar **p_string){#if HAVE_WORDEXP_H wordexp_t words; g_return_if_fail (p_string != NULL); g_return_if_fail (*p_string != NULL); /* MAME configurations often use shell variables like $HOME * in its search and output paths, so we need to expand them. */ if (wordexp (*p_string, &words, WRDE_NOCMD) == 0) { GString *buffer; gsize ii; buffer = g_string_sized_new (strlen (*p_string)); for (ii = 0; ii < words.we_wordc; ii++) { if (ii > 0) g_string_append_c (buffer, ' '); g_string_append (buffer, words.we_wordv[ii]); } g_free (*p_string); *p_string = g_string_free (buffer, FALSE); wordfree (&words); }#endif}
开发者ID:GNOME,项目名称:gnome-video-arcade,代码行数:31,
示例14: Processvoid Process(const char * i_lpszType, const char ** i_lpszCol_Names){ XDATASET cFile; XDATASET cCombined; wordexp_t cResults; char lpszSearchFile[64]; char lpszOutputFile[64]; unsigned int uiColors[8][2] = { {2,4}, // u - v {2,3}, // u - b {3,4}, // b - v {7,5}, // uvm2 - uvw1 {6,5}, // uvw2 - uvw1 {7,4}, // uvm2 - v {6,4}, // uw2 - v {5,4} // uw1 - v }; sprintf(lpszSearchFile,"*%s*photometry.csv",i_lpszType); sprintf(lpszOutputFile,"%s_photometry.csv",i_lpszType); if (wordexp(lpszSearchFile,&cResults,WRDE_NOCMD|WRDE_UNDEF) == 0) { if (cResults.we_wordc > 0) { printf("Count %i/n",cResults.we_wordc); unsigned int uiCount = cResults.we_wordc; for (unsigned int uiI = 0; uiI < cResults.we_wordc; uiI++) if (strcmp(cResults.we_wordv[uiI],lpszOutputFile) == 0) uiCount--; if (uiCount > 0) cCombined.Allocate(17,uiCount); uiCount = 0; for (unsigned int uiI = 0; uiI < cResults.we_wordc; uiI++) { if (strcmp(cResults.we_wordv[uiI],lpszOutputFile) != 0) { printf("Reading %s/n",cResults.we_wordv[uiI]); cFile.ReadDataFile(cResults.we_wordv[uiI],false,false,',',1); for(unsigned int uiJ = 0; uiJ < 9; uiJ++) cCombined.SetElement(uiJ,uiCount,cFile.GetElement(uiJ,0)); for (unsigned int uiJ = 0; uiJ < 8; uiJ++) cCombined.SetElement(9 + uiJ,uiCount,cFile.GetElement(uiColors[uiJ][0],0) - cFile.GetElement(uiColors[uiJ][1],0)); uiCount++; } } if (uiCount > 0) cCombined.SaveDataFileCSV(lpszOutputFile,i_lpszCol_Names); wordfree(&cResults); } }}
开发者ID:astrobit,项目名称:analysis_tools,代码行数:57,
示例15: expansion_demostatic void expansion_demo(char const *str){ printf("Before expansion: %s/n", str); wordexp_t exp; wordexp(str, &exp, 0); printf("After expansion: %s/n", exp.we_wordv[0]); wordfree(&exp);}
开发者ID:jleffler,项目名称:soq,代码行数:9,
示例16: wordexpchar *expand_path(char *path){ wordexp_t exp_result; wordexp(path, &exp_result, 0); char *expanded = strdup(exp_result.we_wordv[0]); wordfree(&exp_result); return expanded;}
开发者ID:demute,项目名称:iPKCS11,代码行数:9,
示例17: get_config_pathstatic char* get_config_path(const char **paths, ssize_t len){ wordexp_t p; char *path; int i; for (i = 0; i < (int)(len / sizeof(char *)); ++i) { if (wordexp(paths[i], &p, 0) == 0) { path = p.we_wordv[0]; if (file_exists(path)) { path = strdup(path); wordfree(&p); return path; } wordfree(&p); } } return NULL;}
开发者ID:Hummer12007,项目名称:nav,代码行数:19,
示例18: expandString/** * Expands environment variables within strings. * @param inStr string to be expanded * @return string with all environment variables expanded */std::string expandString(std::string inStr) { std::string outStr; wordexp_t p; char **w; wordexp(inStr.c_str(), &p, 0); outStr = p.we_wordv[0]; wordfree(&p); return outStr;}
开发者ID:steinj,项目名称:acre,代码行数:16,
示例19: drop_oauth_expandfilenamegchar* drop_oauth_expandfilename(gchar *filename){ wordexp_t result_t; gchar *result = NULL; if(wordexp(filename, &result_t, 0) == 0) result = g_strjoinv(" ", result_t.we_wordv); else result = g_strdup(filename); wordfree(&result_t); return result;}
开发者ID:mohan43u,项目名称:gdrop,代码行数:11,
示例20: OT_ASSERT// static// Changes ~/blah to /Users/au/blah//void OTLog::TransformFilePath(const char * szInput, OTString & strOutput){ OT_ASSERT(NULL != szInput); #ifndef _WIN32 // if UNIX (NOT windows) wordexp_t exp_result; if (wordexp(szInput, &exp_result, 0)) { OTLog::Error("OTLog::TransformFilePath: Error calling wordexp() to expand path./n"); wordfree(&exp_result); strOutput.Set(szInput); return; } // ---------------------------- std::string str_Output(""); // wordexp tokenizes by space (as well as expands, which is why I'm using it.) // Therefore we need to iterate through the tokens, and create a single string // with spaces between the tokens. // for (int i = 0; exp_result.we_wordv[i] != NULL; i++) { str_Output += exp_result.we_wordv[i]; if (exp_result.we_wordv[i+1] != NULL) str_Output += " "; } wordfree(&exp_result); if (str_Output.size() > 0) strOutput.Set(str_Output.c_str()); else strOutput.Set(szInput);#else strOutput.Set(szInput);#endif }
开发者ID:DocMerlin,项目名称:Open-Transactions,代码行数:43,
示例21: glob_for_repofilesHyRepoglob_for_repofiles(Pool *pool, const char *repo_name, const char *path){ HyRepo repo = hy_repo_create(repo_name); const char *tmpl; wordexp_t word_vector; tmpl = pool_tmpjoin(pool, path, "/repomd.xml", NULL); if (wordexp(tmpl, &word_vector, 0) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_MD_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*primary.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_PRIMARY_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*filelists.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_FILELISTS_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*prestodelta.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_PRESTO_FN, word_vector.we_wordv[0]); tmpl = pool_tmpjoin(pool, path, "/*updateinfo.xml.gz", NULL); if (wordexp(tmpl, &word_vector, WRDE_REUSE) || word_vector.we_wordc < 1) goto fail; hy_repo_set_string(repo, HY_REPO_UPDATEINFO_FN, word_vector.we_wordv[0]); wordfree(&word_vector); return repo; fail: wordfree(&word_vector); hy_repo_free(repo); return NULL;}
开发者ID:gbraad,项目名称:libhif,代码行数:40,
示例22: wordexpbool Path::resolve(ResolveMode mode, const Path &cwd, bool *changed){ if (changed) *changed = false; if (startsWith('~')) { wordexp_t exp_result; wordexp(constData(), &exp_result, 0); operator=(exp_result.we_wordv[0]); wordfree(&exp_result); } if (*this == ".") clear(); if (mode == MakeAbsolute) { if (isAbsolute()) return true; const Path copy = (cwd.isEmpty() ? Path::pwd() : cwd.ensureTrailingSlash()) + *this; if (copy.exists()) { if (changed) *changed = true; operator=(copy); return true; } return false; } if (!cwd.isEmpty() && !isAbsolute()) { Path copy = cwd + '/' + *this; if (copy.resolve(RealPath, Path(), changed)) { operator=(copy); return true; } } { char buffer[PATH_MAX + 2]; if (realpath(constData(), buffer)) { if (isDir()) { const int len = strlen(buffer); assert(buffer[len] != '/'); buffer[len] = '/'; buffer[len + 1] = '/0'; } if (changed && strcmp(buffer, constData())) *changed = true; String::operator=(buffer); return true; } } return false;}
开发者ID:emdeesee,项目名称:rct,代码行数:51,
示例23: ShellExpandFilenameExpr void ShellExpandFilenameExpr ( const std::string& aFilenameExpr , const boost::filesystem::path& aParentPath , std::vector< boost::filesystem::path >& aFiles ) { try { // boost::lock_guard<boost::mutex> lLock ( gUtilityMutex ); //struct which will store the shell expansions of the expression wordexp_t lShellExpansion; wordexp ( aFilenameExpr.c_str() , &lShellExpansion , 0 ); for ( std::size_t i = 0 ; i != lShellExpansion.we_wordc ; i++ ) { boost::filesystem::path lPath ( lShellExpansion.we_wordv[i] ); log ( Debug() , "lPath was " , Quote ( lPath.c_str() ) ); log ( Debug() , "aParentPath is " , Quote ( aParentPath.c_str() ) ); lPath = boost::filesystem::absolute ( lPath , aParentPath ); log ( Debug() , "lPath now " , Quote ( lPath.c_str() ) ); if ( boost::filesystem::exists ( lPath ) ) { if ( boost::filesystem::is_regular_file ( lPath ) ) { aFiles.push_back ( lPath ); } } } wordfree ( &lShellExpansion ); } catch ( const std::exception& aExc ) { uhal::exception::ExpandingShellExpressionFailed lExc; log ( lExc , "Caught exception: " , Quote ( aExc.what() ) ); throw lExc; } if ( ! aFiles.size() ) { uhal::exception::FileNotFound lExc; log ( lExc , "No matching files for expression " , Quote ( aFilenameExpr ) , " with parent path " , Quote ( aParentPath.c_str() ) ); throw lExc; } else { log ( Debug() , "Shell expansion of " , Quote ( aFilenameExpr.c_str() ) , " returned:" ); for ( std::vector< boost::filesystem::path >::iterator lIt = aFiles.begin() ; lIt != aFiles.end() ; ++lIt ) { log ( Debug() , " > [file] " , lIt->c_str() ); } } }
开发者ID:EUDAQforLC,项目名称:uhal_ubuntu,代码行数:51,
示例24: strdupstatic char *shell_expand(const char *in) { wordexp_t wexp; char *out = NULL; if (wordexp(in, &wexp, WRDE_NOCMD) < 0) return NULL; out = strdup(wexp.we_wordv[0]); wordfree(&wexp); if (out == NULL) return NULL; return out;}
开发者ID:sxdtxl,项目名称:burp,代码行数:14,
示例25: setVersionScopeDome::ScopeDome(){ setVersion(1, 0); targetAz = 0; shutterState = SHUTTER_UNKNOWN; simShutterStatus = SHUTTER_CLOSED; status = DOME_UNKNOWN; targetShutter = SHUTTER_CLOSE; SetDomeCapability(DOME_CAN_ABORT | DOME_CAN_ABS_MOVE | DOME_CAN_REL_MOVE | DOME_CAN_PARK | DOME_HAS_SHUTTER); stepsPerTurn = -1; // Load dome inertia table if present wordexp_t wexp; if (wordexp("~/.indi/ScopeDome_DomeInertia_Table.txt", &wexp, 0) == 0) { FILE *inertia = fopen(wexp.we_wordv[0], "r"); if (inertia) { // skip UTF-8 marker bytes fseek(inertia, 3, SEEK_SET); char line[100]; int lineNum = 0; while (fgets(line, sizeof(line), inertia)) { int step, result; if (sscanf(line, "%d ;%d", &step, &result) != 2) { sscanf(line, "%d;%d", &step, &result); } if (step == lineNum) { inertiaTable.push_back(result); } lineNum++; } fclose(inertia); LOGF_INFO("Read inertia file %s", wexp.we_wordv[0]); } else { LOG_INFO("Could not read inertia file, please generate one with Windows driver setup and copy to " "~/.indi/ScopeDome_DomeInertia_Table.txt"); } } wordfree(&wexp);}
开发者ID:azwing,项目名称:indi,代码行数:50,
示例26: wordexpFILE *file_open(const char *fname, const char *mode){ FILE *fd; wordexp_t p; fd = NULL; wordexp(fname, &p, 0); if(p.we_wordc < 1) goto error; fd = fopen(p.we_wordv[0], mode);error: wordfree(&p); return fd;}
开发者ID:pstach,项目名称:gls,代码行数:14,
示例27: commentDISABLE_COMPILER_WARNINGS#include <QDateTime>#include <QDebug>RESTORE_COMPILER_WARNINGS#include <assert.h>#include <errno.h>#if defined __linux__ || defined __APPLE__#include <unistd.h>#include <sys/stat.h>#include <wordexp.h>#elif defined _WIN32#include "windows/windowsutils.h"#include <Windows.h>#include <Shlwapi.h>#pragma comment(lib, "Shlwapi.lib") // This lib would have to be added not just to the top level application, but every plugin as well, so using #pragma instead#endifstatic inline QString expandEnvironmentVariables(const QString& string){#ifdef _WIN32 if (!string.contains('%')) return string; static WCHAR result[16384 + 1]; if (ExpandEnvironmentStringsW((WCHAR*)string.utf16(), result, sizeof(result) / sizeof(result[0])) != 0) return toPosixSeparators(QString::fromUtf16((char16_t*)result)); else return string;#else QString result = string; if (result.startsWith('~')) result.replace(0, 1, getenv("HOME")); if (result.contains('$')) { wordexp_t p; wordexp("$HOME/bin", &p, 0); const auto w = p.we_wordv; if (p.we_wordc > 0) result = w[0]; wordfree(&p); } return result;#endif}
开发者ID:VioletGiraffe,项目名称:file-commander,代码行数:50,
示例28: path_attributechar * path_attribute( char * line, unsigned int length ){ (void) length; wordexp_t wordexp_buffer; wordexp( line, &wordexp_buffer, 0 ); char * expanded = NULL; if ( strcmp( wordexp_buffer.we_wordv[0], "-" ) ) { expanded = strdup( wordexp_buffer.we_wordv[0] ); } wordfree( &wordexp_buffer ); return expanded;}
开发者ID:supki,项目名称:procfiled,代码行数:14,
注:本文中的wordfree函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ words函数代码示例 C++ wordexp函数代码示例 |