static int generate_response(void *user_data) { struct pbap_session *pbap = user_data; GSList *sorted; GSList *l; uint16_t max = pbap->params->maxlistcount; DBG(""); if (max == 0) { /* Ignore all other parameter and return PhoneBookSize */ uint16_t size = g_slist_length(pbap->cache.entries); pbap->obj->firstpacket = TRUE; pbap->obj->apparam = g_obex_apparam_set_uint16( pbap->obj->apparam, PHONEBOOKSIZE_TAG, size); return 0; } /* * Don't free the sorted list content: this list contains * only the reference for the "real" cache entry. */ sorted = sort_entries(pbap->cache.entries, pbap->params->order, pbap->params->searchattrib, (const char *) pbap->params->searchval); /* Computing offset considering first entry of the phonebook */ l = g_slist_nth(sorted, pbap->params->liststartoffset); pbap->obj->buffer = g_string_new(VCARD_LISTING_BEGIN); for (; l && max; l = l->next, max--) { const struct cache_entry *entry = l->data; char *escaped_name = g_markup_escape_text(entry->name, -1); g_string_append_printf(pbap->obj->buffer, VCARD_LISTING_ELEMENT, entry->handle, escaped_name); g_free(escaped_name); } pbap->obj->buffer = g_string_append(pbap->obj->buffer, VCARD_LISTING_END); g_slist_free(sorted); return 0; }
/** * nm_setting_ip4_config_remove_address: * @setting: the #NMSettingIP4Config * @i: index number of the address to remove * * Removes the address at index @i. **/ void nm_setting_ip4_config_remove_address (NMSettingIP4Config *setting, guint32 i) { NMSettingIP4ConfigPrivate *priv; GSList *elt; g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting)); priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting); elt = g_slist_nth (priv->addresses, i); g_return_if_fail (elt != NULL); nm_ip4_address_unref ((NMIP4Address *) elt->data); priv->addresses = g_slist_delete_link (priv->addresses, elt); }
static libspectrum_error jump_blocks( libspectrum_tape *tape, int offset ) { gint current_position; GSList *new_block; current_position = g_slist_position( tape->blocks, tape->current_block ); if( current_position == -1 ) return LIBSPECTRUM_ERROR_LOGIC; new_block = g_slist_nth( tape->blocks, current_position + offset ); if( new_block == NULL ) return LIBSPECTRUM_ERROR_CORRUPT; tape->current_block = new_block; return LIBSPECTRUM_ERROR_NONE; }
/** * nm_setting_wired_remove_mac_blacklist_item: * @setting: the #NMSettingWired * @idx: index number of the MAC address * * Removes the MAC address at index @idx from the blacklist. * * Since: 0.9.10 **/ void nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx) { NMSettingWiredPrivate *priv; GSList *elt; g_return_if_fail (NM_IS_SETTING_WIRED (setting)); priv = NM_SETTING_WIRED_GET_PRIVATE (setting); elt = g_slist_nth (priv->mac_address_blacklist, idx); g_return_if_fail (elt != NULL); g_free (elt->data); priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt); }
static void key_next_window_item(void) { SERVER_REC *server; int index; if (active_win->items != NULL) signal_emit("command window item next", 3, "", active_win->active_server, active_win->active); else if (active_win->active_server != NULL) { /* change server */ index = g_slist_index(servers, active_win->active_server); server = index > 0 ? g_slist_nth(servers, index-1)->data : g_slist_last(servers)->data; signal_emit("command window server", 3, server->tag, active_win->active_server, active_win->active); } }
/** * nm_setting_ip6_config_remove_dns_search: * @setting: the #NMSettingIP6Config * @i: index number of the DNS search domain * * Removes the DNS search domain at index @i. **/ void nm_setting_ip6_config_remove_dns_search (NMSettingIP6Config *setting, guint32 i) { NMSettingIP6ConfigPrivate *priv; GSList *elt; g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting)); priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting); elt = g_slist_nth (priv->dns_search, i); g_return_if_fail (elt != NULL); g_free (elt->data); priv->dns_search = g_slist_delete_link (priv->dns_search, elt); }
/** * nm_setting_ip6_config_remove_route: * @setting: the #NMSettingIP6Config * @i: index number of the route * * Removes the route at index @i. **/ void nm_setting_ip6_config_remove_route (NMSettingIP6Config *setting, guint32 i) { NMSettingIP6ConfigPrivate *priv; GSList *elt; g_return_if_fail (NM_IS_SETTING_IP6_CONFIG (setting)); priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting); elt = g_slist_nth (priv->routes, i); g_return_if_fail (elt != NULL); nm_ip6_route_unref ((NMIP6Route *) elt->data); priv->routes = g_slist_delete_link (priv->routes, elt); }
/** * nm_setting_connection_remove_secondary: * @setting: the #NMSettingConnection * @idx: index number of the secondary connection UUID * * Removes the secondary coonnection UUID at index @idx. **/ void nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 idx) { NMSettingConnectionPrivate *priv; GSList *elt; g_return_if_fail (NM_IS_SETTING_CONNECTION (setting)); priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting); elt = g_slist_nth (priv->secondaries, idx); g_return_if_fail (elt != NULL); g_free (elt->data); priv->secondaries = g_slist_delete_link (priv->secondaries, elt); }
void test_get_container_chunks() { GError *error = NULL; GSList *list_chunk = NULL; /* Add two chunks from the same content and container */ test_dept_assert_true(add_chunk_to_db(VOLUME_ROOT, CHUNK_PATH, CONTENT_NAME, CONTAINER_ID, &error)); test_dept_assert_true(add_chunk_to_db(VOLUME_ROOT, CHUNK_PATH2, CONTENT_NAME, CONTAINER_ID, &error)); /* Get chunks and check */ test_dept_assert_true(get_container_chunks(VOLUME_ROOT, CONTAINER_ID, &list_chunk, &error)); test_dept_assert_equals_int(2, g_slist_length(list_chunk)); test_dept_assert_not_equals_string(((char*)g_slist_nth(list_chunk, 0)->data), ((char*)g_slist_nth(list_chunk, 1)->data)); }
static void webx_dialog_format_changed (GtkToggleButton *togglebutton, WebxDialog *dlg) { g_return_if_fail (WEBX_IS_DIALOG (dlg)); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (togglebutton))) { GtkWidget *widget; gint position; position = g_slist_index (dlg->radio_list, togglebutton); widget = GTK_WIDGET (g_slist_nth (dlg->target_list, position)->data); webx_dialog_format_set (WEBX_DIALOG (dlg), WEBX_TARGET (widget)); } }
/** * nm_setting_wireless_remove_mac_blacklist_item: * @setting: the #NMSettingWireless * @idx: index number of the MAC address * * Removes the MAC address at index @idx from the blacklist. * * Since: 0.9.10 **/ void nm_setting_wireless_remove_mac_blacklist_item (NMSettingWireless *setting, guint32 idx) { NMSettingWirelessPrivate *priv; GSList *elt; g_return_if_fail (NM_IS_SETTING_WIRELESS (setting)); priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting); elt = g_slist_nth (priv->mac_address_blacklist, idx); g_return_if_fail (elt != NULL); g_free (elt->data); priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt); g_object_notify (G_OBJECT (setting), NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST); }
/** * nm_setting_connection_remove_permission: * @setting: the #NMSettingConnection * @idx: the zero-based index of the permission to remove * * Removes the permission at index @idx from the connection. */ void nm_setting_connection_remove_permission (NMSettingConnection *setting, guint32 idx) { NMSettingConnectionPrivate *priv; GSList *iter; g_return_if_fail (NM_IS_SETTING_CONNECTION (setting)); priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting); iter = g_slist_nth (priv->permissions, idx); g_return_if_fail (iter != NULL); permission_free ((Permission *) iter->data); priv->permissions = g_slist_delete_link (priv->permissions, iter); }
void nm_ip4_config_replace_route (NMIP4Config *config, guint i, NMIP4Route *new_route) { NMIP4ConfigPrivate *priv; GSList *old; g_return_if_fail (NM_IS_IP4_CONFIG (config)); priv = NM_IP4_CONFIG_GET_PRIVATE (config); old = g_slist_nth (priv->routes, i); g_return_if_fail (old != NULL); nm_ip4_route_unref ((NMIP4Route *) old->data); old->data = nm_ip4_route_dup (new_route); }
/** * nm_setting_vlan_remove_priority: * @setting: the #NMSettingVlan * @map: the type of priority map * @idx: the zero-based index of the priority map to remove * * Removes the priority map at index @idx from the * #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map * properties. */ void nm_setting_vlan_remove_priority (NMSettingVlan *setting, NMVlanPriorityMap map, guint32 idx) { GSList *list = NULL, *item = NULL; g_return_if_fail (NM_IS_SETTING_VLAN (setting)); g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP); list = get_map (setting, map); g_return_if_fail (idx < g_slist_length (list)); item = g_slist_nth (list, idx); priority_map_free ((PriorityMap *) (item->data)); set_map (setting, map, g_slist_delete_link (list, item)); }
void nm_ip4_config_replace_address (NMIP4Config *config, guint i, NMIP4Address *new_address) { NMIP4ConfigPrivate *priv; GSList *old; g_return_if_fail (NM_IS_IP4_CONFIG (config)); priv = NM_IP4_CONFIG_GET_PRIVATE (config); old = g_slist_nth (priv->addresses, i); g_return_if_fail (old != NULL); nm_ip4_address_unref ((NMIP4Address *) old->data); old->data = nm_ip4_address_dup (new_address); }
Php::Value GtkFileChooserDialog_::list_filters() { GSList *ret = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER(instance)); Php::Value ret_arr; for(int index=0; GSList *item=g_slist_nth(ret, index); index++) { GtkFileFilter_ *return_parsed = new GtkFileFilter_(); return_parsed->set_instance((gpointer *)GTK_FILE_CHOOSER(item->data)); ret_arr[index] = Php::Object("GtkFileFilter", return_parsed); } return ret_arr; }
/** * main: Starts with an RPTable of 10 resources, adds 5 rdr * to first resource. Fetches rdrs randomly by type and compares * with original. A failed comparison means the test failed, * otherwise the test passed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); GSList *records = NULL; guint i = 0; for (i = 0; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries + i, NULL, 0)) return 1; } for (i = 0; i < 5; i++) { if (oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, rdrs + i, NULL,0)) return 1; else records = g_slist_append(records, rdrs + i); } for (; records; i--) { SaHpiRdrT *tmprdr = NULL, *randrdr = NULL; GSList *tmpnode = NULL; guint k = (guint) (((gfloat)i)*rand()/(RAND_MAX+1.0)); tmpnode = g_slist_nth(records, k); randrdr = (SaHpiRdrT *)tmpnode->data; randrdr->RecordId = get_rdr_uid(randrdr->RdrType, randrdr->RdrTypeUnion.SensorRec.Num); tmprdr = oh_get_rdr_by_type(rptable, SAHPI_FIRST_ENTRY, randrdr->RdrType, randrdr->RdrTypeUnion.SensorRec.Num); if (!tmprdr || memcmp(randrdr, tmprdr, sizeof(SaHpiRdrT))) return 1; else { records = g_slist_remove_link(records, tmpnode); g_slist_free_1(tmpnode); } } return 0; }
/* SYNTAX: UNIGNORE <id>|<mask> */ static void cmd_unignore(const char *data) { IGNORE_REC *rec; GSList *tmp; char *mask, *mask_orig; void *free_arg; if (!cmd_get_params(data, &free_arg, 1, &mask)) return; if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); /* Save the mask string here since it might be modified in the code * below and we need it to print meaningful error messages. */ mask_orig = mask; if (is_numeric(mask, ' ')) { /* with index number */ tmp = g_slist_nth(ignores, atoi(mask)-1); rec = tmp == NULL ? NULL : tmp->data; } else { /* with mask */ const char *chans[2] = { "*", NULL }; if (active_win->active_server != NULL && server_ischannel(active_win->active_server, mask)) { chans[0] = mask; mask = NULL; } rec = ignore_find_full("*", mask, NULL, (char **) chans, 0); if (rec == NULL) { rec = ignore_find_full("*", mask, NULL, (char **) chans, IGNORE_FIND_NOACT); } } if (rec != NULL) { rec->level = 0; ignore_update_rec(rec); } else { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_IGNORE_NOT_FOUND, mask_orig); } cmd_params_free(free_arg); }
void gtk_clist_sort(GtkCList *clist) { HWND hWnd; gint rowind; GList *sel; GSList *rowpt; sorting_clist = clist; if (clist && clist->cmp_func && clist->rows) { /* Since the order of the list may change, we need to change the * selection as well. Do this by converting the row indices into * GSList pointers (which are invariant to the sort) and then convert * back afterwards */ for (sel = clist->selection; sel; sel = g_list_next(sel)) { rowind = GPOINTER_TO_INT(sel->data); sel->data = (gpointer)g_slist_nth(clist->rowdata, rowind); } clist->rowdata = g_slist_sort(clist->rowdata, gtk_clist_sort_func); for (sel = clist->selection; sel; sel = g_list_next(sel)) { rowpt = (GSList *)(sel->data); sel->data = GINT_TO_POINTER(g_slist_position(clist->rowdata, rowpt)); } if (GTK_WIDGET_REALIZED(GTK_WIDGET(clist))) { hWnd = GTK_WIDGET(clist)->hWnd; if (clist->mode == GTK_SELECTION_SINGLE) { sel = clist->selection; if (sel) rowind = GPOINTER_TO_INT(sel->data); else rowind = -1; SendMessage(hWnd, LB_SETCURSEL, (WPARAM)rowind, 0); } else { for (rowind = 0; rowind < clist->rows; rowind++) { SendMessage(hWnd, LB_SETSEL, (WPARAM)FALSE, (LPARAM)rowind); } for (sel = clist->selection; sel; sel = g_list_next(sel)) { rowind = GPOINTER_TO_INT(sel->data); SendMessage(hWnd, LB_SETSEL, (WPARAM)TRUE, (LPARAM)rowind); } } InvalidateRect(hWnd, NULL, FALSE); UpdateWindow(hWnd); } } }
static void xkb_layouts_dnd_data_received (GtkWidget * widget, GdkDragContext * dc, gint x, gint y, GtkSelectionData * selection_data, guint info, guint t, GtkBuilder * dialog) { gint sidx = find_selected_layout_idx (dialog); GtkWidget *tree_view = WID ("xkb_layouts_selected"); GtkTreePath *path = NULL; GtkTreeViewDropPosition pos; gint didx; gchar *id; GSList *layouts_list; GSList *node2Remove; if (sidx == -1) return; layouts_list = xkb_layouts_get_selected_list (); node2Remove = g_slist_nth (layouts_list, sidx); id = (gchar *) node2Remove->data; layouts_list = g_slist_delete_link (layouts_list, node2Remove); if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (tree_view), x, y, &path, &pos)) { /* Move to the very end */ layouts_list = g_slist_append (layouts_list, g_strdup (id)); xkb_layouts_set_selected_list (layouts_list); } else if (path != NULL) { gint *indices = gtk_tree_path_get_indices (path); didx = indices[0]; gtk_tree_path_free (path); /* Move to the new position */ if (sidx != didx) { layouts_list = g_slist_insert (layouts_list, g_strdup (id), didx); xkb_layouts_set_selected_list (layouts_list); } } g_free (id); clear_xkb_elements_list (layouts_list); }
void curlapi_http_cb(gchar *inputurl, gchar *inputparams, GSList *args, gboolean oauth) { gchar *url = g_strdup(inputurl); gchar *params = g_strdup(inputparams); struct curl_slist *oauthheader = NULL; CURL *curlapi = curl_easy_init(); GString *buffer = g_string_new(NULL); GSList *threadargs = g_slist_copy(args); CURLcode returncode; threadargs = g_slist_prepend(threadargs, buffer); curl_easy_setopt(curlapi, CURLOPT_WRITEFUNCTION, curlapi_http_write_cb); curl_easy_setopt(curlapi, CURLOPT_WRITEDATA, threadargs); oauthheader = curlapi_get_oauthheader(&url, ¶ms, oauth); curl_easy_setopt(curlapi, CURLOPT_URL, url); curl_easy_setopt(curlapi, CURLOPT_HTTPHEADER, oauthheader); if(params) curl_easy_setopt(curlapi, CURLOPT_POSTFIELDS, params); //curl_easy_setopt(curlapi, CURLOPT_VERBOSE, 1); curl_easy_setopt(curlapi, CURLOPT_FAILONERROR, 1); returncode = curl_easy_perform(curlapi); if(returncode != CURLE_OK && returncode != CURLE_WRITE_ERROR) { gchar *httperror = NULL; void (*write_cb)(GSList *args) = NULL; httperror = curlapi_http(url, params, oauth); threadargs = g_slist_remove(threadargs, buffer); write_cb = g_slist_nth_data(threadargs, 0); threadargs = g_slist_append(threadargs, g_strdup(httperror)); write_cb(g_slist_nth(threadargs, 1)); g_free(httperror); } g_free(url); g_free(params); g_string_free(buffer, TRUE); if(oauthheader) curl_slist_free_all(oauthheader); curl_easy_cleanup(curlapi); }
gboolean hal_property_strlist_remove_elem (HalProperty *prop, guint index) { GSList *elem; g_return_val_if_fail (prop != NULL, FALSE); g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE); if (prop->v.strlist_value == NULL) return FALSE; elem = g_slist_nth (prop->v.strlist_value, index); if (elem == NULL) return FALSE; g_free (elem->data); prop->v.strlist_value = g_slist_delete_link (prop->v.strlist_value, elem); return TRUE; }
/* copied from uim-cand-win-gtk.c and adjusted */ static void uim_cand_win_gtk_set_page_candidates(UIMCandidateWindow *cwin, guint page, GSList *candidates) { GtkListStore *store; GSList *node; gint j, len; g_return_if_fail(UIM_IS_CANDIDATE_WINDOW(cwin)); if (candidates == NULL) return; cwin->sub_window.active = FALSE; len = g_slist_length(candidates); /* create GtkListStores, and set candidates */ store = gtk_list_store_new(NR_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); cwin->stores->pdata[page] = store; /* set candidates */ for (j = 0, node = g_slist_nth(candidates, j); j < len; j++, node = g_slist_next(node)) { GtkTreeIter ti; if (node) { gchar *str = node->data; gchar **column = g_strsplit(str, "\a", 3); gtk_list_store_append(store, &ti); gtk_list_store_set(store, &ti, COLUMN_HEADING, column[0], COLUMN_CANDIDATE, column[1], COLUMN_ANNOTATION, column[2], TERMINATOR); g_strfreev(column); g_free(str); } } }
void uim_cand_win_gtk_set_page_candidates(UIMCandWinGtk *cwin, guint page, GSList *candidates) { GtkListStore *store; GSList *node; gint j, len; g_return_if_fail(UIM_IS_CAND_WIN_GTK(cwin)); if (candidates == NULL) return; cwin->sub_window.active = FALSE; len = g_slist_length(candidates); /* create GtkListStores, and set candidates */ store = gtk_list_store_new(NR_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); cwin->stores->pdata[page] = store; /* set candidates */ for (j = 0, node = g_slist_nth(candidates, j); j < len; j++, node = g_slist_next(node)) { GtkTreeIter ti; if (node) { uim_candidate cand = node->data; gtk_list_store_append(store, &ti); gtk_list_store_set(store, &ti, COLUMN_HEADING, uim_candidate_get_heading_label(cand), COLUMN_CANDIDATE, uim_candidate_get_cand_str(cand), COLUMN_ANNOTATION, uim_candidate_get_annotation_str(cand), TERMINATOR); } } }
/** * mx_combo_box_remove_text: * @box: A #MxComboBox * @position: position of the item to remove * * Remove the item at @position * */ void mx_combo_box_remove_text (MxComboBox *box, gint position) { GSList *item; g_return_if_fail (MX_IS_COMBO_BOX (box)); g_return_if_fail (position >= 0); /* find the item, free the string and remove it from the list */ item = g_slist_nth (box->priv->actions, position); if (!item) return; g_object_unref (G_OBJECT (item->data)); box->priv->actions = g_slist_delete_link (box->priv->actions, item); mx_combo_box_update_menu (box); }
int main(void) { GSList * slist = NULL; g_fprintf (stdout, "Jumlah node: %d\n", g_slist_length (slist)); g_fprintf (stdout, "Tambahkan 'node 1' dan 'node 2'\n"); slist = g_slist_append (slist, "node 1"); slist = g_slist_append (slist, "node 2"); g_fprintf (stdout, "Jumlah node: %d\n", g_slist_length (slist)); g_fprintf (stdout, "\tHead: %s\n", g_slist_nth (slist, 0)-> data ); g_slist_free (slist); return 0; };
static DBusMessage *remove_path(DBusConnection *conn, DBusMessage *msg, GSList **list, const char *sname) { const char *path; GSList *l; if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID) == FALSE) return NULL; l = g_slist_find_custom(*list, path, (GCompareFunc) strcmp); if (!l) return does_not_exist(msg); /* Remove references from the storage */ if (*list == connection_paths) { if (connection_has_pending(path)) return connection_is_busy(msg); connection_remove_stored(path); /* Reset default connection */ if (l == g_slist_nth(*list, default_index)) { const char *dpath; dpath = last_connection_used(conn); connection_store(dpath, TRUE); } } g_free(l->data); *list = g_slist_remove(*list, l->data); g_dbus_emit_signal(conn, NETWORK_PATH, NETWORK_MANAGER_INTERFACE, sname, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID); g_dbus_unregister_interface(conn, path, NETWORK_CONNECTION_INTERFACE); return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); }
static void pattern_clist_row_move_callback (GtkWidget *widget, int source, int dest, gpointer data) { GtkCList *clist = GTK_CLIST (widget); GSList *link; struct player_pattern *pp; debug(5,"pattern_clist_row_move_callback(widget=%d,source=%d,dest=%d)",widget,source,dest); if (source < 0 || dest < 0 || source == dest || source > clist->rows || dest > clist->rows) { return; } link = g_slist_nth (curplrs, source); pp = (struct player_pattern *) link->data; curplrs = g_slist_remove_link (curplrs, link); curplrs = g_slist_insert (curplrs, pp, dest); current_row = dest; }
/* Create the remaining hardlinks in the target directory */ gboolean mk_hlink(GSList * h) { struct rdup *e; GSList *p; struct stat *st; gchar *parent; if (opt_dry) return TRUE; for (p = g_slist_nth(h, 0); p; p = p->next) { e = (struct rdup *)p->data; if (link(e->f_target, e->f_name) == -1) { if (errno == EACCES) { parent = dir_parent(e->f_name); st = dir_write(parent); if (link(e->f_target, e->f_name) == -1) { msgd(__func__, __LINE__, _ ("Failed to create hardlink `%s -> %s\': %s"), e->f_name, e->f_target, strerror(errno)); dir_restore(parent, st); g_free(parent); return FALSE; } dir_restore(parent, st); g_free(parent); return TRUE; } else { msgd(__func__, __LINE__, _ ("Failed to create hardlink `%s -> %s\': %s"), e->f_name, e->f_target, strerror(errno)); return FALSE; } } entry_free(e); } return TRUE; }
static size_t curlapi_http_write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) { gsize length = 0; GString *buffer = NULL; GSList *args = NULL; GSList *threadargs = NULL; gboolean (*write_cb)(GSList *args) = NULL; gchar *string = NULL; gchar *fullstring = NULL; length = size * nmemb; args = (GSList *) userdata; buffer = g_slist_nth_data(args, 0); write_cb = g_slist_nth_data(args, 1); string = g_strndup(ptr, length); if(g_strcmp0("\r\n", &string[length - 2]) == 0) { string[length - 2] = '\0'; g_string_append(buffer, string); g_free(string); fullstring = g_strdup(buffer->str); g_string_set_size(buffer, 0); threadargs = g_slist_copy(g_slist_nth(args, 2)); threadargs = g_slist_append(threadargs, fullstring); //Make sure write_cb returns true, else die. if(write_cb(threadargs) == FALSE) length = 0; } else { g_string_append(buffer, string); g_free(string); } return(length); }