static void console_controller_reprint_suffix(ConsoleController *ctrl) { gchar *suffix, *suffix_cmd, *backspace; glong bksplen, avlen, suflen = 0; InputNode *cursor = ctrl->input_cursor->next; if (cursor) { avlen = ctrl->input_length + 1; suffix = (gchar*) g_slice_alloc(avlen * sizeof(gchar)); while(cursor) { suffix[suflen++] = cursor->charData; cursor = cursor->next; } suffix[suflen] = '\0'; bksplen = slice_sprintnum(&backspace, "\033[O\033[%dD\033[N", suflen); if (suflen + bksplen > avlen) { suffix_cmd = (gchar*) g_slice_alloc((suflen + bksplen) * sizeof(gchar)); g_stpcpy(suffix_cmd, suffix); } else { suffix_cmd = suffix; } g_stpcpy(suffix_cmd + suflen, backspace); } if (suflen) { vte_terminal_feed(ctrl->terminal, suffix_cmd, suflen + bksplen); if (suffix_cmd != suffix) g_slice_free1((suflen + bksplen) * sizeof(gchar), suffix_cmd); g_slice_free1(avlen * sizeof(gchar), suffix); g_slice_free1(bksplen * sizeof(gchar), backspace); } }
gchar * wmem_strconcat(wmem_allocator_t *allocator, const gchar *first, ...) { gsize len; va_list args; gchar *s; gchar *concat; gchar *ptr; if (!first) return NULL; len = 1 + strlen(first); va_start(args, first); while ((s = va_arg(args, gchar*))) { len += strlen(s); } va_end(args); ptr = concat = (gchar *)wmem_alloc(allocator, len); ptr = g_stpcpy(ptr, first); va_start(args, first); while ((s = va_arg(args, gchar*))) { ptr = g_stpcpy(ptr, s); } va_end(args); return concat; }
static void gwy_layer_basic_connect_fixed(GwyLayerBasic *basic_layer) { GwyDataViewLayer *layer; const gchar *prefix; gchar *detailed_signal; guint len; layer = GWY_DATA_VIEW_LAYER(basic_layer); if (!layer->data || !basic_layer->fixed_key) return; prefix = g_quark_to_string(basic_layer->fixed_key); len = strlen(prefix); detailed_signal = g_newa(gchar, len + sizeof("item-changed::") + sizeof("/min")); len += sizeof("item-changed::"); g_stpcpy(g_stpcpy(g_stpcpy(detailed_signal, "item-changed::"), prefix), "/min"); basic_layer->min_id = connect_swapped_after(layer->data, detailed_signal, gwy_layer_basic_min_max_changed, layer); strcpy(detailed_signal + len, "max"); basic_layer->max_id = connect_swapped_after(layer->data, detailed_signal, gwy_layer_basic_min_max_changed, layer); }
gchar * g_strjoinv (const gchar *separator, gchar **str_array) { char *res, *r; size_t slen, len, i; if (separator != NULL) slen = strlen (separator); else slen = 0; len = 0; for (i = 0; str_array [i] != NULL; i++){ len += strlen (str_array [i]); len += slen; } if (len == 0) return g_strdup (""); if (slen > 0 && len > 0) len -= slen; res = g_malloc (len + 1); r = g_stpcpy (res, str_array [0]); for (i = 1; str_array [i] != NULL; i++){ if (separator != NULL) r = g_stpcpy (r, separator); r = g_stpcpy (r, str_array [i]); } return res; }
static void fm_path_entry_completion_render_func(GtkCellLayout *cell_layout, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { gchar *model_file_name; int model_file_name_len; FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE( FM_PATH_ENTRY(data) ); gtk_tree_model_get(GTK_TREE_MODEL(model), iter, COL_BASENAME, &model_file_name, -1); model_file_name_len = strlen(model_file_name); if( priv->highlight_completion_match ) { int buf_len = model_file_name_len + 14 + 1; gchar* markup = g_malloc(buf_len); gchar *trail = g_stpcpy(markup, "<b><u>"); trail = strncpy(trail, model_file_name, priv->typed_basename_len) + priv->typed_basename_len; trail = g_stpcpy(trail, "</u></b>"); trail = g_stpcpy(trail, model_file_name + priv->typed_basename_len); g_object_set(cell, "markup", markup, NULL); g_free(markup); } /* FIXME: We don't need a custom render func if we don't hightlight */ else g_object_set(cell, "text", model_file_name, NULL); g_free(model_file_name); }
/** Store (key,value) pairs. */ gboolean dt_pwstorage_gconf_set(const gchar* slot, GHashTable* table) { GHashTableIter iter; g_hash_table_iter_init (&iter, table); gpointer key, value; while (g_hash_table_iter_next (&iter, &key, &value)) { dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_gconf_set] storing (%s, %s)\n",(gchar*)key, (gchar*)value); gsize size = strlen(gconf_path) + strlen(slot) + 1 + strlen(key); gchar* _path = g_malloc(size+1); gchar* _tmp = _path; if(_path == NULL) return FALSE; _tmp = g_stpcpy(_tmp, gconf_path); _tmp = g_stpcpy(_tmp, slot); _tmp[0] = '/'; _tmp++; g_stpcpy(_tmp, key); // This would be the place to do manual encryption of the data. // I know enough about cryptography to not implement this. // If you don't like plain text password just use one of the other backends. dt_conf_set_string( _path, value ); g_free(_path); } return TRUE; }
static void gwy_layer_basic_get_fixed_range(GwyLayerBasic *basic_layer, GwyContainer *container, GwyDataField *data_field, gdouble *rmin, gdouble *rmax) { const gchar *prefix; gchar *key; guint len; if (!basic_layer->fixed_key) { gwy_data_field_get_min_max(data_field, rmin, rmax); return; } prefix = g_quark_to_string(basic_layer->fixed_key); len = strlen(prefix); key = g_newa(gchar, len + sizeof("/min")); g_stpcpy(g_stpcpy(key, prefix), "/min"); if (!gwy_container_gis_double_by_name(container, key, rmin)) *rmin = gwy_data_field_get_min(data_field); strcpy(key + len + 1, "max"); if (!gwy_container_gis_double_by_name(container, key, rmax)) *rmax = gwy_data_field_get_max(data_field); }
/* append a script output into the tooltip buffer */ static void na_script_append_out(run_data_t* s, gchar* tooltip_buffer) { gchar* p = tooltip_buffer; guint rst; char name[32]; while(*p) p++; rst = tooltip_buffer + BUFSIZ - p; if (WIFSIGNALED(s->status)) snprintf(name, sizeof(name), "%s(sig%d)", s->name, WTERMSIG(s->status)); else if (WIFEXITED(s->status) && WEXITSTATUS(s->status) != 0) snprintf(name, sizeof(name), "%s(%d)", s->name, WEXITSTATUS(s->status)); else snprintf(name, sizeof(name), "%s", s->name); if (strlen(name) < rst) p = g_stpcpy(p, name); if (strlen(name) + strlen(": ") + strlen(s->buf) >= rst){ p = g_stpcpy(p, "too long!"); } else { p = g_stpcpy(p, ": "); p = g_stpcpy(p, s->buf); if(p[-1] == '\n') { p[-1] = '\0'; p--; } } p = g_stpcpy(p, "\n"); return; }
void mbm_set_supl_password (gchar * _supl_password) { if (_supl_password && strlen (_supl_password) < 500) g_stpcpy (supl_password, _supl_password); else g_stpcpy (supl_password, ""); mbm_set_supl_settings_changed (1); }
void mbm_set_supl_user (gchar * _supl_user) { if (_supl_user && strlen (_supl_user) < 500) g_stpcpy (supl_user, _supl_user); else g_stpcpy (supl_user, ""); mbm_set_supl_settings_changed (1); }
void mbm_set_supl_apn (gchar * _supl_apn) { if (_supl_apn && strlen (_supl_apn) < 500) g_stpcpy (supl_apn, _supl_apn); else g_stpcpy (supl_apn, ""); mbm_set_supl_settings_changed (1); }
void mbm_set_supl_address (gchar * _supl_address) { if (_supl_address && strlen (_supl_address) < 500) g_stpcpy (supl_address, _supl_address); else g_stpcpy (supl_address, ""); mbm_set_supl_settings_changed (1); }
const char * font_style_info_to_string (FontStretches stretch, FontWeights weight, FontStyles style) { static char namebuf[256]; guint i = 0; char *p; namebuf[0] = '\0'; p = namebuf; if (stretch != FontStretchesNormal) { while (style_hints[i].type == FontPropertyStretch) { if (style_hints[i].value == stretch) { p = g_stpcpy (p, style_hints[i].name); break; } i++; } } if (weight != FontWeightsNormal) { while (style_hints[i].type != FontPropertyWeight) i++; while (style_hints[i].type == FontPropertyWeight) { if (style_hints[i].value == weight) { if (p != namebuf) *p++ = ' '; p = g_stpcpy (p, style_hints[i].name); break; } i++; } } if (style != FontStylesNormal) { while (style_hints[i].type != FontPropertyStyle) i++; while (i < G_N_ELEMENTS (style_hints)) { if (style_hints[i].value == style) { if (p != namebuf) *p++ = ' '; p = g_stpcpy (p, style_hints[i].name); break; } i++; } } return namebuf; }
void login(GtkWidget *widget, gpointer data) { //login function const gchar *login, *l_pass; char buffer[20]; gchar full[64], temp[20]; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (status))) { //see if we're connected PS:Not the best way is used login = gtk_entry_get_text((GtkEntry *) logname); //get name from input l_pass = gtk_entry_get_text((GtkEntry *) pass); //get password from input send(sock, login, strlen(login) + 1, 0); //send name to the server send(sock, l_pass, strlen(l_pass) + 1, 0); //send password to the server rec = recv(sock, buffer, buffsize - 1, 0); //receive answer if (strcmp(buffer, "TRUE")) { //see if we were successful or not return; } else { recv(sock, (char *) &user, sizeof(caracter), 0); printf( "%s ;%c ;%d.%d.%d ;%d ;%d ;%s ;%d ;%d ;%d ;%d ;%d ;%d ;%d ;%d ;%d ;" " Talents: ; Abilities: ; Techniques: ; Personality Traits: ; Reputation: ; Known Locations: ;", user.name, user.Gender, user.born.year, user.born.month, user.born.day, user.height, user.weight, user.House, user.str, user.dex, user.inte, user.vit, user.wis, user.sta, user.spd, user.cha, user.hly); g_stpcpy(full, user.House); g_strlcat(full, " ", 32); g_strlcat(full, user.name, 63); gtk_label_set_text((GtkLabel *) name, full); gtk_label_set_text((GtkLabel *) name, full); itoa(user.born.year, temp, 10); g_stpcpy(full, temp); g_strlcat(full, ".", 5); itoa(user.born.month, temp, 10); g_strlcat(full, temp, 7); g_strlcat(full, ".", 8); itoa(user.born.day, temp, 10); g_strlcat(full, temp, 10); gtk_label_set_text((GtkLabel *) born, full); gtk_label_set_text((GtkLabel *) gender, (user.Gender == 'F') ? "Female" : "Male"); itoa(user.height, full, 10); gtk_label_set_text((GtkLabel *) height, full); itoa(user.weight, full, 10); gtk_label_set_text((GtkLabel *) weight, full); gtk_button_clicked((GtkButton *) cbutton); //get some text gtk_widget_hide_all(logbox); //exchange login fields with something else gtk_widget_show_all(gamebox); return; } } else { err("Please connect to the server"); //if we're not connected make an error message } }
static void test_streams (GDir *dir, const char *datadir, const char *filename) { char inpath[256], outpath[256], *p, *q, *o; const char *dent, *d; gint64 start, end; size_t n; guint i; p = g_stpcpy (inpath, datadir); *p++ = G_DIR_SEPARATOR; p = g_stpcpy (p, "input"); *p++ = G_DIR_SEPARATOR; strcpy (p, filename); q = g_stpcpy (outpath, datadir); *q++ = G_DIR_SEPARATOR; q = g_stpcpy (q, "output"); *q++ = G_DIR_SEPARATOR; *q = '\0'; n = strlen (filename); while ((dent = g_dir_read_name (dir))) { if (strncmp (dent, filename, n) != 0 || dent[n] != '_') continue; d = dent + n + 1; if ((start = strtol (d, &o, 10)) < 0 || *o != ',') continue; d = o + 1; if ((((end = strtol (d, &o, 10)) < start) && end != -1) || *o != '\0') continue; strcpy (q, dent); for (i = 0; i < G_N_ELEMENTS (checks); i++) { testsuite_check ("%s on `%s'", checks[i].what, dent); try { if (!checks[i].check (inpath, outpath, dent, start, end)) { testsuite_check_warn ("%s could not open `%s'", checks[i].what, dent); } else { testsuite_check_passed (); } } catch (ex) { testsuite_check_failed ("%s on `%s' failed: %s", checks[i].what, dent, ex->message); } finally; } } g_dir_rewind (dir); }
//todo: used only in ui_prefs.c gchar *hb_str_formatd(gchar *outstr, gint outlen, gchar *buf1, Currency *cur, gboolean showsymbol) { gint len, nbd, nbi; gchar *s, *d, *tmp; d = tmp = outstr; if(showsymbol && cur->sym_prefix) { d = g_stpcpy (d, cur->symbol); *d++ = ' '; tmp = d; } d = _strfnumcopycount(buf1, d, cur->decimal_char, &len, &nbi, &nbd); if( cur->grouping_char != NULL && strlen(cur->grouping_char) > 0 ) { gint i, grpcnt; s = buf1; d = tmp; if(*s == '-') *d++ = *s++; grpcnt = 4 - nbi; for(i=0;i<nbi;i++) { *d++ = *s++; if( !(grpcnt % 3) && i<(nbi-1)) { d = g_stpcpy(d, cur->grouping_char); } grpcnt++; } if(nbd > 0) { d = g_stpcpy(d, cur->decimal_char); d = g_stpcpy(d, s+1); } *d = 0; } if(showsymbol && !cur->sym_prefix) { *d++ = ' '; d = g_stpcpy (d, cur->symbol); } *d = 0; return d; }
/** Load (key,value) pairs. */ GHashTable* dt_pwstorage_gconf_get(const gchar* slot) { GHashTable* table = g_hash_table_new(g_str_hash, g_str_equal); gsize size = strlen(gconf_path) + strlen(slot); gchar* _path = g_malloc(size+1); gchar* _tmp = _path; if(_path == NULL) return table; _tmp = g_stpcpy(_tmp, gconf_path); g_stpcpy(_tmp, slot); GSList* list; list = dt_conf_all_string_entries(_path); g_free(_path); GSList* next = list; while(next) { gchar* key = ((dt_conf_string_entry_t*)next->data)->key; gsize size = strlen(gconf_path) + strlen(slot) + 1 + strlen(key); gchar* _path = g_malloc(size+1); gchar* _tmp = _path; if(_path == NULL) return table; _tmp = g_stpcpy(_tmp, gconf_path); _tmp = g_stpcpy(_tmp, slot); _tmp[0] = '/'; _tmp++; g_stpcpy(_tmp, key); gchar* value = ((dt_conf_string_entry_t*)next->data)->value; g_free(_path); dt_print(DT_DEBUG_PWSTORAGE,"[pwstorage_gconf_get] reading (%s, %s)\n",(gchar*)key, (gchar*)value); // This would be the place for manual decryption. // See above. g_hash_table_insert(table, g_strdup(key), g_strdup(value)); next = next->next; } g_slist_free(list); return table; }
void reg(int clntSocket) { //A registration function -> game mechanics FILE *p; gchar path[36], name[31], pass[31]; g_stpcpy(path, "user/"); //prepare the path recv(clntSocket, name, RCVBUFSIZE, 0); //receive name g_strlcat(path, name, 36); //make the path recv(clntSocket, pass, RCVBUFSIZE, 0); //receive password //g_printf("%s", path); if (!access(path, F_OK)) { //check if file is present -> as in already registered or not //file was present send(clntSocket, "FALSE", 6, 0); //send the failed signal return; //end function } //file was NOT present send(clntSocket, "TRUE", 5, 0); //send the OK signal p = fopen(path, "w"); //make the user's file fprintf( p, //if we made it we should write something to it "Name: ;Gender: ; Born: ;height;weight: ;House: ;STR ;DEX ;INT ;VIT ;WIS ;STA ;SPD ;CHA ;HLY ;" " Talents: ; Abilities: ; Techniques: ; Personality Traits: ; Reputation: ; Known Locations: ;"); fclose(p); //close the file return; //end function }
//Record client (if new) void add_client(char* ClientIpAd, gpointer connection_in) { /* Check if client exists. If exists return else record it */ int i; for (i = 0; i < MAXCLIENT; i++) { //Search thru the client list if ( (ConnectedClients[i].used > 0) ) { //Client list is being used if ( g_strcmp0(ClientIpAd , ConnectedClients[i].client_ip) == 0 ) { //Already in client list return return; } continue; } //no record found! //record new client ip g_stpcpy(ConnectedClients[i].client_ip,ClientIpAd); ConnectedClients[i].ClientTcpData = connection_in; // ConnectedClients[i].used = 1; if (verbose) { printf("App Server: New client added to client list %s\n", ConnectedClients[i].client_ip); fflush(stdout); } break; } }
static void ril_pin_send(struct ofono_sim *sim, const char *passwd, ofono_sim_lock_unlock_cb_t cb, void *data) { struct sim_data *sd = ofono_sim_get_data(sim); struct cb_data *cbd = cb_data_new(cb, data); struct parcel rilp; int request = RIL_REQUEST_ENTER_SIM_PIN; int ret; sd->passwd_type = OFONO_SIM_PASSWORD_SIM_PIN; cbd->user = sd; if (current_passwd) g_stpcpy(current_passwd, passwd); parcel_init(&rilp); parcel_w_int32(&rilp, ENTER_SIM_PIN_PARAMS); parcel_w_string(&rilp, (char *) passwd); parcel_w_string(&rilp, sd->aid_str); ret = g_ril_send(sd->ril, request, rilp.data, rilp.size, ril_pin_change_state_cb, cbd, g_free); g_ril_append_print_buf(sd->ril, "(%s,aid=%s)", passwd, sd->aid_str); g_ril_print_request(sd->ril, ret, request); parcel_free(&rilp); if (ret <= 0) { g_free(cbd); CALLBACK_WITH_FAILURE(cb, data); } }
int main(int argc, char const *argv[]) { char *filename = NULL; if (argc > 1) { size_t len = strlen(argv[1]); filename = malloc(len+1); g_stpcpy(filename, argv[1]); //g_printf("Parsing file %s...\n", argv[1]); } else { filename = (char*) "alice.txt"; //g_printf("Please provide a filename to parse.\n"); //return 0 } GHashTable* table = g_hash_table_new(g_str_hash,g_str_equal); if (!table) { g_printf("Failed to create table, allocation failure.\n"); exit(1); } parse_file(filename, table); GSList* sorted_results = NULL; //g_hash_table_foreach(table, (GHFunc) print_result, NULL); g_hash_table_foreach(table, (GHFunc) insert_result, &sorted_results); print_list(sorted_results); g_slist_free_full(sorted_results, (GDestroyNotify) free_word_count); g_hash_table_foreach(table, free_key_value, NULL); g_hash_table_destroy(table); return 0; }
/* Remove Duplicate Lines, sorted */ gint rmdupst(gchar **lines, gint num_lines, gchar *new_file) { gchar *nf_end = new_file; /* points to last char of new_file */ gchar *lineptr = (gchar *)" "; /* temporary line pointer */ gint i = 0; /* iterator */ gint changed = 0; /* number of lines removed */ /* sort **lines ascending */ qsort(lines, num_lines, sizeof(gchar *), compare_asc); /* loop through **lines, join first occurances into one str (new_file) */ for(i = 0; i < num_lines; i++) { if(strcmp(lines[i], lineptr) != 0) { changed++; /* number of lines kept */ lineptr = lines[i]; nf_end = g_stpcpy(nf_end, lines[i]); } } /* return the number of lines deleted */ return -(num_lines - changed); }
/** Converts unicode strings such as \003d into = * Code blatantly nicked from the Facebook plugin */ gchar * convert_unicode(const gchar *input) { gunichar unicode_char; gchar unicode_char_str[6]; gint unicode_char_len; gchar *next_pos; gchar *input_string; gchar *output_string; if (input == NULL) return NULL; next_pos = input_string = g_strdup(input); while ((next_pos = strstr(next_pos, "\\u"))) { /* grab the unicode */ sscanf(next_pos, "\\u%4x", &unicode_char); /* turn it to a char* */ unicode_char_len = g_unichar_to_utf8(unicode_char, unicode_char_str); /* shove it back into the string */ g_memmove(next_pos, unicode_char_str, unicode_char_len); /* move all the data after the \u0000 along */ g_stpcpy(next_pos + unicode_char_len, next_pos + 6); } output_string = g_strcompress(input_string); g_free(input_string); return output_string; }
static void ril_pin_change_state_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_lock_unlock_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct parcel rilp; int retry_count; int retries[OFONO_SIM_PASSWORD_INVALID]; int passwd_type; /* There is no reason to ask SIM status until * unsolicited sim status change indication * Looks like state does not change before that. */ passwd_type = sd->passwd_type; ril_util_init_parcel(message, &rilp); parcel_r_int32(&rilp); retry_count = parcel_r_int32(&rilp); retries[passwd_type] = retry_count; sd->retries[passwd_type] = retries[passwd_type]; DBG("result=%d passwd_type=%d retry_count=%d", message->error, passwd_type, retry_count); if (message->error == RIL_E_SUCCESS) { CALLBACK_WITH_SUCCESS(cb, cbd->data); g_ril_print_response_no_args(sd->ril, message); } else { if (current_passwd) g_stpcpy(current_passwd, defaultpasswd); CALLBACK_WITH_FAILURE(cb, cbd->data); } }
/* this function copy a number 99999.99 at s into d and count * number of digits for integer part and decimal part */ static gchar * _strfnumcopycount(gchar *s, gchar *d, gchar *decchar, gint *plen, gint *pnbint, gint *pnbdec) { gint len=0, nbint=0, nbdec=0; // sign part if(*s == '-') { *d++ = *s++; len++; } // integer part while(*s != 0 && *s != '.') { *d++ = *s++; nbint++; len++; } // decimal separator if(*s == '.') { d = g_stpcpy(d, decchar); len++; s++; } // decimal part while(*s != 0) { *d++ = *s++; nbdec++; len++; } // end string | fill external count *d = 0; *plen = len; *pnbint = nbint; *pnbdec = nbdec; return d; }
char *rm_trie_build_path_unlocked(RmNode *node, char *buf, size_t buf_len) { if(node == NULL) { return NULL; } size_t n_elements = 1; char *elements[PATH_MAX / 2 + 1] = {node->basename, NULL}; /* walk up the folder tree, collecting path elements into a list */ for(RmNode *folder = node->parent; folder && folder->parent; folder = folder->parent) { elements[n_elements++] = folder->basename; if(n_elements >= sizeof(elements)) { break; } } /* copy collected elements into *buf */ char *buf_ptr = buf; while(n_elements && (size_t)(buf_ptr - buf) < buf_len) { *buf_ptr = '/'; buf_ptr = g_stpcpy(buf_ptr + 1, (char *)elements[--n_elements]); } return buf; }
static Currency *hb_strfmon_check(gchar *outstr, guint32 kcur) { Currency *cur = da_cur_get(kcur); if(cur == NULL) g_stpcpy(outstr, "nan"); return cur; }
static gboolean gmod_find_sym (GMod* gmod, gpointer* init_func, gpointer* shutdown_func) { char sym[256]; g_stpcpy(sym, "init"); if ( !g_module_symbol (gmod->module, sym, init_func) ){ LOCATION_LOGW("symbol not found: %s", sym); return FALSE; } g_stpcpy(sym, "shutdown"); if ( !g_module_symbol (gmod->module, sym, shutdown_func) ){ LOCATION_LOGW("symbol not found: %s", sym); return FALSE; } return TRUE; }
EXPORT_C gint32 CPhoneContact::GetAddress(ECommType eAddrType, stAddress ** sAddress) { if (NULL == m_aAddressArray) { GetAllCommInfo(); } if (NULL == sAddress) return ERROR(ESide_Client, EModule_Db, ECode_Invalid_Param); *sAddress = NULL; for (guint32 j=0; j<m_aAddressArray->len; j++) { stAddress * srcAddr = (stAddress*)g_ptr_array_index(m_aAddressArray, j); if (eAddrType == srcAddr->atype) { *sAddress = (stAddress*)g_malloc0(sizeof(stAddress)); if (NULL == *sAddress) return ERROR(ESide_Client, EModule_Sys, ECode_No_Memory); (*sAddress)->aid = srcAddr->aid; (*sAddress)->atype = srcAddr->atype; g_stpcpy((*sAddress)->block, srcAddr->block); g_stpcpy((*sAddress)->street, srcAddr->street); g_stpcpy((*sAddress)->district, srcAddr->district); g_stpcpy((*sAddress)->city, srcAddr->district); g_stpcpy((*sAddress)->state, srcAddr->state); g_stpcpy((*sAddress)->country, srcAddr->country); g_stpcpy((*sAddress)->postcode, srcAddr->postcode); } } return 0; }
EXPORT_C gint32 CPhoneContact::SetAddress(ECommType eAddrType, stAddress * sAddress) { if (NULL == m_aAddressArray) m_aAddressArray = g_ptr_array_new(); if (NULL == sAddress) return ERROR(ESide_Client, EModule_Db, ECode_Invalid_Param); guint32 j = 0; for (j=0; j<m_aAddressArray->len; j++) if (eAddrType == ((stAddress*)g_ptr_array_index(m_aAddressArray, j))->atype) break; stAddress * addr; if (j < m_aAddressArray->len) addr = (stAddress*)g_ptr_array_index(m_aAddressArray, j); else addr = (stAddress*)g_malloc0(sizeof(stAddress)); addr->aid = sAddress->aid; addr->atype = sAddress->atype; g_stpcpy(addr->block, sAddress->block); g_stpcpy(addr->street, sAddress->street); g_stpcpy(addr->district, sAddress->district); g_stpcpy(addr->city, sAddress->city); g_stpcpy(addr->state, sAddress->state); g_stpcpy(addr->country, sAddress->country); g_stpcpy(addr->postcode, sAddress->postcode); if (j >= m_aAddressArray->len) g_ptr_array_add(m_aAddressArray, addr); return 0; }