static int latch_overlay_get_account_id(latch_overlay_config_data *cfg, char *id, char **account_id) { int search_scope = LDAP_SCOPE_BASE; char *search_base_dn = NULL; char *search_filter = NULL; int rv = ERROR; Log1(LDAP_DEBUG_TRACE, LDAP_LEVEL_DEBUG, ">>> %s\n", __func__); search_base_dn = replace_str(cfg->ldap_search_base_dn, "@@@USER@@@", id); search_filter = replace_str(cfg->ldap_search_filter, "@@@USER@@@", id); if (cfg->ldap_search_scope != NULL) { if (strcmp("onelevel", cfg->ldap_search_scope) == 0) { search_scope = LDAP_SCOPE_ONELEVEL; } else if (strcmp("subtree", cfg->ldap_search_scope) == 0) { search_scope = LDAP_SCOPE_SUBTREE; } } rv = latch_overlay_get_entry_attribute(cfg->ldap_uri, cfg->ldap_bind_dn, cfg->ldap_bind_password, search_base_dn, search_filter, search_scope, cfg->ldap_attribute, cfg->ldap_tls_ca_file, account_id); free(search_base_dn); free(search_filter); Log1(LDAP_DEBUG_TRACE, LDAP_LEVEL_DEBUG, "<<< %s\n", __func__); return rv; }
static gchar * ensure_dest_path (GFile *file, gint icon_size) { gchar *str, *str2, *size_string, *dest_path; GFile *dest_file, *dest_dir, *tmp; str = g_file_get_relative_path (gnome_dir, file); tmp = g_file_resolve_relative_path (hc_dir, str); g_free (str); str = g_file_get_path (tmp); size_string = g_strdup_printf ("%dx%d", icon_size, icon_size); str2 = replace_str (str, "-symbolic.svg", ".png"); dest_path = replace_str (str2, "scalable", size_string); dest_file = g_file_new_for_path (dest_path); dest_dir = g_file_get_parent (dest_file); g_file_make_directory_with_parents (dest_dir, NULL, NULL); g_object_unref (dest_file); g_object_unref (dest_dir); g_object_unref (tmp); g_free (str); g_free (size_string); return dest_path; }
void AVReceiver::dataGet(std::string msg) { if (msg.find('\n') == std::string::npos && msg.find('\r') == std::string::npos) { //We have not a complete paquet yet, buffurize it. recv_buffer += msg; cDebugDom("output") << "Bufferize data."; return; } if (!recv_buffer.empty()) { //Put last data in buffer recv_buffer += msg; msg = recv_buffer; recv_buffer.clear(); } replace_str(msg, "\r\n", "\n"); replace_str(msg, "\r", "\n"); std::vector<std::string> tokens; Utils::split(msg, tokens, "\n"); cDebugDom("output") << "Got " << tokens.size() << " messages."; for(uint i = 0; i < tokens.size(); i++) processMessage(tokens[i]); }
/** * Performs replacement of all keys by their value based on the hotplug * event structure. Keys are identified as strings %KEY%. * * @1 Haystack * @2 Hotplug event structure * * Returns: Newly allocated haystack (old is freed) */ static char *replace_key_by_value(char *hay, struct hotplug2_event_t *event) { char *sptr = hay, *ptr = hay; char *buf, *replacement; while ((sptr = strchr(sptr, '%')) != NULL) { ptr = strchr(sptr+1, '%'); if (ptr != NULL) { buf = xmalloc(ptr - sptr + 2); buf[ptr - sptr + 1] = '\0'; memcpy(buf, sptr, ptr - sptr + 1); buf[ptr - sptr] = '\0'; replacement = get_hotplug2_value_by_key(event, &buf[1]); buf[ptr - sptr] = '%'; if (replacement != NULL) { hay = replace_str(hay, buf, replacement); sptr = hay; } else { sptr++; } free(buf); } else { sptr++; } } hay = replace_str(hay, "%\\", "%"); return hay; }
int main ( ) { char *command = malloc(1000*sizeof(char)); char *user = getenv("USER"); char hostname[1000]; gethostname(hostname,1000); while (1) { char *home = malloc(1000*sizeof(char)); strcpy(home,"/home/"); home = strcat(home,user); char cwd[1000]; char *curr_dir = getcwd(cwd, sizeof(cwd)); char *display = malloc(1000*sizeof(char)); strcpy(display,user); display = strcat(display,"@"); display = strcat(display,hostname); display = strcat(display,":"); display = strcat(display,curr_dir); display = strcat(display,"$ "); printf("%s",display); readLine(command); while (command[0] == '\0') { printf("%s",display); readLine(command); } command = replace_str(command,"~",home); if( check_semicolon ){ command = trimwhitespace(command); char *pch = strtok( command , ";" ); while( pch != NULL ){ ampercent = 0; ampercent = check_ampercent(pch); pch = replace_str(pch,"&"," "); pch = trimwhitespace(pch); if (strncmp (pch , "quit" , 4) == 0) return 0; if (strncmp (pch , "exit" , 4) == 0) return 0; parseCommandLine(pch); pch = strtok( NULL , ";" ); } continue; } if (strncmp (command , "quit" , 4) == 0) return 0; if (strncmp (command , "exit" , 4) == 0) return 0; parseCommandLine(command); } return 0; }
GenlistItemSimple::GenlistItemSimple(Evas *_evas, Evas_Object *_parent, string _label, bool can_select, bool _multiline, void *data, string style_addition): GenlistItemBase(_evas, _parent, string(can_select? "simple_select":"simple") + string(_multiline? "/multiline":"") + string((style_addition != "")? "/" + style_addition:""), ELM_GENLIST_ITEM_NONE, data), label(_label), multiline(_multiline) { if (multiline) { replace_str(label, "\n", "<br>"); replace_str(label, "&", "&"); } }
int main (int argc, char *argv[]) { int opt = 0; char* str = NULL; char* find = NULL; char* replace = NULL; char* new_str = NULL; while ((opt = getopt(argc, argv, "s:f:r:")) != -1) { switch(opt) { case 's': str = duplicate_string(optarg); break; case 'f': find = duplicate_string(optarg); break; case 'r': replace = duplicate_string(optarg); break; case '?': printf("invalid charachter\n"); break; } } new_str = replace_str(str, find, replace); printf("====== new_str=%s ======\n", new_str); // Free memory free(str); free(find); free(replace); }
int main() { int c, i, blank_count; char result[MAXLINE]; blank_count = 0; i = 0; while((c = getchar()) != EOF) { if(is_blank(c)) { blank_count++; // Start count } else { // check counter i = replace_str(i, blank_count ,result); blank_count = 0; result[i] = c; if(c == '\n') { /* Print final result, reset for the next line after line break */ printf("%s \n", result); i = 0; strcpy(result," "); } i++; } } return 0; }
int install_update_zip(char* filename) { char *path = NULL; puts(filename); path = replace_str(filename, "/sdcard/", "SDCARD:"); ui_print("\n-- Install update.zip from sdcard...\n"); set_sdcard_update_bootloader_message(); ui_print("Attempting update from...\n"); ui_print(filename); ui_print("\n"); int status = install_package(path); if (status != INSTALL_SUCCESS) { ui_set_background(BACKGROUND_ICON_ERROR); ui_print("Installation aborted.\n"); return 0; } else if (!ui_text_visible()) { return 0; // reboot if logs aren't visible } else { if (firmware_update_pending()) { ui_print("\nReboot via menu to complete\ninstallation.\n"); return 0; } else { ui_print("\nInstall from sdcard complete.\n"); ui_print("\nThanks for using RZrecovery.\n"); } } return 0; }
int main(int argc, char **argv) { sqlite3 *db; char *zErrMsg = 0; int rc; if( argc!=3 ) { fprintf(stderr, "Usar: %s BASE_DE_DATOS INSTRUCCION-SQL\n", argv[0]); return(1); } rc = sqlite3_open(argv[1], &db); if( rc ) { fprintf(stderr, "No puedo abrir la base de datos: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return(1); } rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg); if( rc!=SQLITE_OK ) { char* nvaSentencia = replace_str(argv[2], "votaciones", "fraudes"); rc = sqlite3_exec(db, nvaSentencia, callback, 0, &zErrMsg); printf("Buena sentencia : %s\n", nvaSentencia); fprintf(stderr, "Error en la consulta SQL: %s\n", zErrMsg); sqlite3_free(zErrMsg); } sqlite3_close(db); return 0; }
void eval_buffer_exec(lua_State *lua) { pthread_mutex_lock(&eval_buffer_mutex); if (eval_buffer) { /* returns > 0 if error */ if (luaL_dostring(lua, eval_buffer)) { replace_str(&err_str, lua_tostring(lua, -1)); } else { replace_str(&err_str, NULL); } replace_str(&eval_buffer, NULL); } pthread_mutex_unlock(&eval_buffer_mutex); pthread_cond_signal(&eval_buffer_cond); }
void IntegerItem::Measure(HDC hDC, SIZE *size) { if (Settings_menu.showBroams) { MenuItem::Measure(hDC, size); m_Justify = MENUITEM_STANDARD_JUSTIFY; } else { char buf[100]; char val[100]; const char *s; if (m_offvalue == m_value && m_offstring) s = NLS1(m_offstring); else s = val, sprintf(val, "%d", m_value); sprintf(buf, "%c %s %c", m_value == m_min ? ' ': '-', s, m_value == m_max ? ' ': '+' ); replace_str(&m_pszTitle, buf); MenuItem::Measure(hDC, size); if (size->cx > m_oldsize+5 || size->cx < m_oldsize-5) m_oldsize = size->cx; size->cx = m_oldsize + 5; m_Justify = DT_CENTER; } }
int exec_cd_change_path(t_struc *s, char *pwd, char *s1, char *s2) { int i; int j; int start; int replaced_something; i = -1; replaced_something = 0; while (pwd[++i]) { j = 0; while (pwd[i] && pwd[i] != s1[j]) i++; if (!pwd[i] && !replaced_something) return (print_string_is_not_in_pwd_error(s1)); else if (!pwd[i]) return (0); start = i; while (pwd[i] && s1[j] && pwd[i++] == s1[j++]) ; if (!s1[j]) s->argv[1] = replace_str(pwd, s2, start, i); if (!s1[j]) replaced_something = 1; } return (0); }
void TestCommunicationChannel::SplitHelpExamples(string& buffer, string& result, const string token) { ACE_TRACE(ACE_TEXT("[TestCommunicationChannel::SplitHelpExamples()]")); string::size_type pos = 0; string replace_str(""); char rm_buff[150]; pos = buffer.find(token, pos); if (pos == string::npos) { return; } ++pos; int length = buffer.copy(rm_buff, pos, 0); rm_buff[length] = '\0'; FindAndReplace(buffer, rm_buff, ""); result = rm_buff; FindAndReplace(result, token, ""); return; }
int main(int argc, char* argv[]) { int my_id, numprocs,length; int i; char *srcPath; char *dstPath; char command[1024]; memset(command, '\0', 1024); PRINTF(">>>> SYNcer I'm child process SYNcer MY Rank is %d \n", my_id ); PRINTF(">>>> remote job here is =%s\n", argv[0]); PRINTF(">>>> num argument argc=%d\n", argc); for(i=1; i< argc; i++) { PRINTF(">>>> SYNcer passed in argument i=%d, argv[%d]= %s\n", i, i, argv[i]); } srcPath = argv[1]; dstPath = replace_str(srcPath, argv[2]); PRINTF("Data file srcPath (%s)\n", srcPath); PRINTF("Data file dstPath (%s)\n", dstPath); if ( strcmp(srcPath, dstPath) ) { /* issue RPC request to SYNcer server */ syncer_copy(srcPath, dstPath, 0); /* call ALL_BACK */ /* // disable. Jon W will script alternative approach sprintf(command, "$s%s%s", CALL_BACK, srcPath, "&"); system(command); */ } return 0; }
// // list_inから str1 を str2 に置き換えてリストを返す // const std::list< std::string > MISC::replace_str_list( const std::list< std::string >& list_in, const std::string& str1, const std::string& str2 ) { std::list< std::string > list_out; std::list< std::string >::const_iterator it = list_in.begin(); for( ; it != list_in.end(); ++it ) list_out.push_back( replace_str( *it, str1, str2 ) ); return list_out; }
StringItem::StringItem(const char* pszCommand, const char *init_string) : CommandItem(pszCommand, NULL, false) { if (init_string) replace_str(&m_pszTitle, init_string); hText = NULL; m_ItemID = MENUITEM_ID_STR; }
void http_start(const char *web_root_, const char *doc_root_) { replace_str(&doc_root, doc_root_); replace_str(&web_root, web_root_); http_stop(); ctx = mg_start(); mg_set_option(ctx, "root", web_root); mg_set_option(ctx, "ports", http_port); mg_set_uri_callback(ctx, "/", &show_index, NULL); mg_set_uri_callback(ctx, "/eval", &eval_script, NULL); mg_set_uri_callback(ctx, "/get_files", &get_files, NULL); mg_set_uri_callback(ctx, "/open_file", &open_file, NULL); mg_set_uri_callback(ctx, "/upload_file", &upload_file, NULL); mg_set_uri_callback(ctx, "/upload_script", &upload_script, NULL); }
const char* config_cook_string(zone_options_t* zone, const char* input) { static char f[1024]; /* if not a template, return as-is */ if(!strchr(input, '%')) { return input; } strlcpy(f, input, sizeof(f)); if(strstr(f, "%1")) replace_str(f, sizeof(f), "%1", get_char(zone->name, 0)); if(strstr(f, "%2")) replace_str(f, sizeof(f), "%2", get_char(zone->name, 1)); if(strstr(f, "%3")) replace_str(f, sizeof(f), "%3", get_char(zone->name, 2)); if(strstr(f, "%z")) replace_str(f, sizeof(f), "%z", get_end_label(zone, 1)); if(strstr(f, "%y")) replace_str(f, sizeof(f), "%y", get_end_label(zone, 2)); if(strstr(f, "%x")) replace_str(f, sizeof(f), "%x", get_end_label(zone, 3)); if(strstr(f, "%s")) replace_str(f, sizeof(f), "%s", zone->name); return f; }
static int wenv_func(char *arg, int flags) { char *p = arg; char *p1; int ret = 0; int status = 0; int i; wenv_flags = 0; char *cmd_buff; if ((cmd_buff = malloc(0x800)) == NULL) return 0; while ( *p && (arg = p) != NULL) { if (*arg == '(') { p = check_Brackets(arg); if (p == NULL) { free(cmd_buff); return !(errnum = ERR_BAD_ARGUMENT); } *p++ = '\0'; p = skip_next_next_cmd(p,&status,STATUS_NONE); ret = wenv_func(++arg,flags); } else { #ifdef DEBUG printf("wenv_arg:%s\n",arg); #endif *cmd_buff = '\0'; p = skip_next_next_cmd(p,&status,STATUS_NONE); replace_str(arg,cmd_buff,REPLACE_TRIM | MAX_ENV_LEN); //替换变量 arg = cmd_buff; for (i=0;p_cmd_list[i].name != NULL ;i++) { if (strcmp_ex(arg, p_cmd_list[i].name) == 0) { arg = skip_next(0, arg); if((unsigned char)*arg < (unsigned char)p_cmd_list[i].flags) { free(cmd_buff); return wenv_help_ex(p_cmd_list[i].flags >> 8); } break; } } if (p_cmd_list[i].func == NULL) { if (debug == 2) printf("wenv_arg:%s\n",arg); free(cmd_buff); return !(errnum = ERR_BAD_ARGUMENT); } ret = p_cmd_list[i].func(arg,flags); }
void getFileName(char *prefix, char * wrkDir, char *fileName, char *result) { if (wrkDir != NULL) { // make sure we don't have wrkDir in both the prefix and the wrkDir char *wrkPrefix = replace_str(prefix, wrkDir, ""); sprintf(result, "%s%s_%s", wrkDir, wrkPrefix, fileName); } else { sprintf(result, "%s_%s", prefix, fileName); } }
int main(void) { char str[100],str1[50],str2[50]; printf("Enter a one line string..\n"); gets(str); printf("Enter the sub string to be replaced..\n"); gets(str1); printf("Enter the replacing string....\n"); gets(str2); puts(replace_str(str, str1, str2)); return 0; }
int smbc_wrapper_parse_path(connection* con, char *pWorkgroup, char *pServer, char *pShare, char *pPath){ if(con->mode== SMB_BASIC||con->mode== SMB_NTLM){ smbc_parse_path(con->physical.path->ptr, pWorkgroup, pServer, pShare, pPath); //- Jerry add: replace '\\' to '/' do{ char buff[4096]; strcpy( pPath, replace_str(&pPath[0],"\\","/", (char *)&buff[0]) ); }while(strstr(pPath,"\\")!=NULL); } return 1; }
gpointer* add_folder_to_playqueue(gpointer* data){ /* this sets threw each folder recursivly and adds all file to playqueue (although it's really a list)*/ DIR *dp; struct dirent *ep; char *newDirFile; char* dirFile = (char*) data; if ((dp=opendir(dirFile))==NULL) { dirFile = replace_str(dirFile,get_setting_str(VIDEO_ROOT),"/mnt/raid/"); add_file_to_playqueue((gpointer*)dirFile); } else { while((ep=readdir(dp))) { queue_function_data* func = g_malloc(sizeof(queue_function_data)); if (!strcmp(ep->d_name,".") || !strcmp(ep->d_name, "..")) { continue; } newDirFile = g_strdup_printf("%s/%s", dirFile, ep->d_name); printf("Directory: %s",newDirFile); switch(file_type(newDirFile)){ case FTDIR: func->func = *add_folder_to_playqueue; func->data = g_strdup(newDirFile); func->priority = TP_NORMAL; g_async_queue_push_sorted(file_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); break; case FTFILE: newDirFile = replace_str(newDirFile,get_setting_str(VIDEO_ROOT),"/mnt/raid/"); func->func = *add_file_to_playqueue; func->data = g_strdup(newDirFile); func->priority = TP_NORMAL; g_async_queue_push_sorted(file_async_queue,(gpointer)func,(GCompareDataFunc)sort_async_queue,NULL); break; case FTDONOTPROC: break; } g_free(newDirFile); } closedir(dp); } return NULL; }
void ActivityWebView::_webLoadFinished(Elm_Web_Frame_Load_Error *error) { EmitSignal("hide,keyboard", "calaos"); EmitSignal("stop,loading", "calaos"); if (error && !error->is_cancellation) { #ifdef HAVE_EWEBKIT string t = WEBKIT_ERROR_HTML; replace_str(t, "{FAILING_URL}", error->failing_url); replace_str(t, "{DESC}", error->description); Evas_Object *eview = elm_web_webkit_view_get(web); Evas_Object *frame = ewk_view_frame_main_get(eview); ewk_frame_contents_set(frame, t.c_str(), t.length(), "text/html", "UTF-8", error->failing_url); #endif } }
char *replaceIncorrectCharacters (char *name){ char * newName = replace_str(name, "\"", "'"); newName = replace_str(newName, "[", " "); newName = replace_str(newName, "]", " "); newName = replace_str(newName, "{", " "); newName = replace_str(newName, "}", " "); newName = replace_str(newName, ",", " "); return newName; }
int tellstdfunc::stdCHANGESTRING::execute() { std::string newstring = getStringValue(); laydata::tdtdesign* ATDB = DATC->lockDB(); // first save the list of all currently selected components ... laydata::selectList* savelist = ATDB->copy_selist(); // get a list of selected texts only laydata::selectList* texts4u = filter_selist(savelist, laydata::_lmtext); if (texts4u->empty()) { for (laydata::selectList::const_iterator CL = savelist->begin(); CL != savelist->end(); CL++) delete CL->second; delete savelist; for (laydata::selectList::const_iterator CL = texts4u->begin(); CL != texts4u->end(); CL++) delete CL->second; delete texts4u; tell_log(console::MT_ERROR,"No text objects selected"); } else {// just if we have selected texts UNDOcmdQ.push_front(this); // now unselect all ... ATDB->unselect_all(); // ... and select back only text shapes ATDB->select_fromList(texts4u); // delete them from the DB - get back the list of deleted shapes. laydata::atticList* fha = DEBUG_NEW laydata::atticList(); ATDB->delete_selected(fha, DATC->TEDLIB()); // save the deleted shapes in the UNDO data stack UNDOPstack.push_front(make_ttlaylist(fha)); // replace the strings laydata::atticList* fhba = replace_str(fha, newstring); telldata::ttlist* fhb = make_ttlaylist(fhba); // save the new texts in the UNDO data stack UNDOPstack.push_front(fhb); // add the new objects back to the DB ATDB->addlist(get_shlaylist(fhb)); // now restore selection ATDB->select_fromList(savelist); ATDB->select_fromList(get_ttlaylist(fhb)); // that's it! clean_atticlist(fha); delete fha; clean_atticlist(fhba);delete fhba; LogFile << LogFile.getFN() << "(\"" << newstring << "\");"; LogFile.flush(); RefreshGL(); } DATC->unlockDB(); return EXEC_NEXT; }
void parse_file(char *tpl_name, char* to_file,char** replace_argv,int replace_argc){ char buf[4096] = {0}; FILE *fp = NULL ; char new_file_name[128]; int i = 0; fp = fopen(tpl_name,"r"); fread(buf,4096,1,fp); fclose(fp); for(;i < (replace_argc - 1) ; i += 2){ replace_str(buf,replace_argv[i],replace_argv[i+1]); } fp = fopen(to_file,"w+"); fwrite(buf,strlen(buf),1,fp); fclose(fp); }
char *replace_str(char *str, char *orig, char *rep) { static char buffer[4096]; char *p; if(!(p = strstr(str, orig))) return str; strncpy(buffer, str, p-str); // Copy characters from 'str' start to 'orig' st$ buffer[p-str] = '\0'; sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig)); if(p = strstr(str, orig)) replace_str(buffer, orig, rep); return buffer; }
string CSnsSigCheck:: url_encode(const string& src) { char* p_dest = oauth_url_escape(src.c_str()); if (p_dest == NULL) { return ""; } string str_dest = p_dest; delete [] p_dest; p_dest = NULL; str_dest = replace_str(str_dest, "~", "%7E"); return str_dest; }