static void set_message_area_text_and_icon (GtkWidget *message_area, const gchar *icon_stock_id, const gchar *primary_text, const gchar *secondary_text) { GtkWidget *hbox_content; GtkWidget *image; GtkWidget *vbox; gchar *primary_markup; gchar *secondary_markup; GtkWidget *primary_label; GtkWidget *secondary_label; hbox_content = gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox_content); image = gtk_image_new_from_stock (icon_stock_id, GTK_ICON_SIZE_DIALOG); gtk_widget_show (image); gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox); gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0); primary_markup = g_strdup_printf ("<b>%s</b>", primary_text); primary_label = gtk_label_new (primary_markup); g_free (primary_markup); gtk_widget_show (primary_label); gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5); GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS); gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); if (secondary_text != NULL) { secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text); secondary_label = gtk_label_new (secondary_markup); g_free (secondary_markup); gtk_widget_show (secondary_label); gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS); gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5); } set_contents (message_area, hbox_content); }
static value_t set_heap_object_contents_with_utf8_type(runtime_t *runtime, value_t object, value_t header, value_t payload) { value_t factories = ROOT(runtime, plankton_factories); value_t factory = get_id_hash_map_at(factories, header); if (in_family(ofFactory, factory)) { value_t set_contents_wrapper = get_factory_set_contents(factory); void *set_contents_ptr = get_void_p_value(set_contents_wrapper); factory_set_contents_t *set_contents = (factory_set_contents_t*) (intptr_t) set_contents_ptr; return set_contents(object, runtime, payload); } else { set_seed_payload(object, payload); return success(); } }
bool notepad::load() { db_cnx db; try { sql_stream s ("SELECT contents FROM global_notepad", db); if (!s.eof()) { QString contents; s >> contents; set_contents(contents); } } catch (db_excpt& p) { DBEXCPT(p); return false; } return true; }
oop abstractSlotRef::interpretData(oop receiver, oop sel, oop arg1) { switch (resultType(sel)) { case constantResult: case dataResult: return contents(); case assignmentResult: set_contents(arg1); return receiver; case methodResult: return badOop; default: fatal("should never happen"); return NULL; } }
GtkWidget * gedit_no_backup_saving_error_message_area_new (const gchar *uri, const GError *error) { GtkWidget *message_area; GtkWidget *hbox_content; GtkWidget *image; GtkWidget *vbox; gchar *primary_markup; gchar *secondary_markup; GtkWidget *primary_label; GtkWidget *secondary_label; gchar *primary_text; const gchar *secondary_text; gchar *full_formatted_uri; gchar *uri_for_display; gchar *temp_uri_for_display; g_return_val_if_fail (uri != NULL, NULL); g_return_val_if_fail (error != NULL, NULL); g_return_val_if_fail (((error->domain == GEDIT_DOCUMENT_ERROR && error->code == GEDIT_DOCUMENT_ERROR_CANT_CREATE_BACKUP) || (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANT_CREATE_BACKUP)), NULL); full_formatted_uri = gedit_utils_uri_for_display (uri); /* Truncate the URI so it doesn't get insanely wide. Note that even * though the dialog uses wrapped text, if the URI doesn't contain * white space then the text-wrapping code is too stupid to wrap it. */ temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH); g_free (full_formatted_uri); uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display); g_free (temp_uri_for_display); #if !GTK_CHECK_VERSION (2, 17, 1) message_area = gedit_message_area_new (); gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area), _("S_ave Anyway"), GTK_STOCK_SAVE, GTK_RESPONSE_YES); gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area), _("D_on't Save"), GTK_RESPONSE_CANCEL); #else message_area = gtk_info_bar_new (); info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("S_ave Anyway"), GTK_STOCK_SAVE, GTK_RESPONSE_YES); gtk_info_bar_add_button (GTK_INFO_BAR (message_area), _("D_on't Save"), GTK_RESPONSE_CANCEL); gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING); #endif hbox_content = gtk_hbox_new (FALSE, 8); image = gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0); // FIXME: review this messages if (gedit_prefs_manager_get_create_backup_copy ()) primary_text = g_strdup_printf (_("Could not create a backup file while saving %s"), uri_for_display); else primary_text = g_strdup_printf (_("Could not create a temporary backup file while saving %s"), uri_for_display); g_free (uri_for_display); primary_markup = g_strdup_printf ("<b>%s</b>", primary_text); g_free (primary_text); primary_label = gtk_label_new (primary_markup); g_free (primary_markup); gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5); GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS); gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); secondary_text = _("gedit could not back up the old copy of the file before saving the new one. " "You can ignore this warning and save the file anyway, but if an error " "occurs while saving, you could lose the old copy of the file. Save anyway?"); secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text); secondary_label = gtk_label_new (secondary_markup); g_free (secondary_markup); gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS); gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5); gtk_widget_show_all (hbox_content); set_contents (message_area, hbox_content); return message_area; }
GtkWidget * gedit_externally_modified_saving_error_message_area_new ( const gchar *uri, const GError *error) { GtkWidget *message_area; GtkWidget *hbox_content; GtkWidget *image; GtkWidget *vbox; gchar *primary_markup; gchar *secondary_markup; GtkWidget *primary_label; GtkWidget *secondary_label; gchar *primary_text; const gchar *secondary_text; gchar *full_formatted_uri; gchar *uri_for_display; gchar *temp_uri_for_display; g_return_val_if_fail (uri != NULL, NULL); g_return_val_if_fail (error != NULL, NULL); g_return_val_if_fail (error->domain == GEDIT_DOCUMENT_ERROR, NULL); g_return_val_if_fail (error->code == GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED, NULL); full_formatted_uri = gedit_utils_uri_for_display (uri); /* Truncate the URI so it doesn't get insanely wide. Note that even * though the dialog uses wrapped text, if the URI doesn't contain * white space then the text-wrapping code is too stupid to wrap it. */ temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH); g_free (full_formatted_uri); uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display); g_free (temp_uri_for_display); #if !GTK_CHECK_VERSION (2, 17, 1) message_area = gedit_message_area_new (); gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area), _("S_ave Anyway"), GTK_STOCK_SAVE, GTK_RESPONSE_YES); gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area), _("D_on't Save"), GTK_RESPONSE_CANCEL); #else message_area = gtk_info_bar_new (); info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("S_ave Anyway"), GTK_STOCK_SAVE, GTK_RESPONSE_YES); gtk_info_bar_add_button (GTK_INFO_BAR (message_area), _("D_on't Save"), GTK_RESPONSE_CANCEL); gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING); #endif hbox_content = gtk_hbox_new (FALSE, 8); image = gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0); // FIXME: review this message, it's not clear since for the user the "modification" // could be interpreted as the changes he made in the document. beside "reading" is // not accurate (since last load/save) primary_text = g_strdup_printf (_("The file %s has been modified since reading it."), uri_for_display); g_free (uri_for_display); primary_markup = g_strdup_printf ("<b>%s</b>", primary_text); g_free (primary_text); primary_label = gtk_label_new (primary_markup); g_free (primary_markup); gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5); GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS); gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); secondary_text = _("If you save it, all the external changes could be lost. Save it anyway?"); secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text); secondary_label = gtk_label_new (secondary_markup); g_free (secondary_markup); gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS); gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5); gtk_widget_show_all (hbox_content); set_contents (message_area, hbox_content); return message_area; }
GtkWidget * gedit_file_already_open_warning_message_area_new (const gchar *uri) { GtkWidget *message_area; GtkWidget *hbox_content; GtkWidget *image; GtkWidget *vbox; gchar *primary_markup; gchar *secondary_markup; GtkWidget *primary_label; GtkWidget *secondary_label; gchar *primary_text; const gchar *secondary_text; gchar *full_formatted_uri; gchar *uri_for_display; gchar *temp_uri_for_display; full_formatted_uri = gedit_utils_uri_for_display (uri); /* Truncate the URI so it doesn't get insanely wide. Note that even * though the dialog uses wrapped text, if the URI doesn't contain * white space then the text-wrapping code is too stupid to wrap it. */ temp_uri_for_display = gedit_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH); g_free (full_formatted_uri); uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display); g_free (temp_uri_for_display); #if !GTK_CHECK_VERSION (2, 17, 1) message_area = gedit_message_area_new (); gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area), _("Edit Any_way"), GTK_RESPONSE_YES); gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area), _("D_on't Edit"), GTK_RESPONSE_CANCEL); #else message_area = gtk_info_bar_new (); gtk_info_bar_add_button (GTK_INFO_BAR (message_area), /* Translators: the access key chosen for this string should be different from other main menu access keys (Open, Edit, View...) */ _("Edit Any_way"), GTK_RESPONSE_YES); gtk_info_bar_add_button (GTK_INFO_BAR (message_area), /* Translators: the access key chosen for this string should be different from other main menu access keys (Open, Edit, View...) */ _("D_on't Edit"), GTK_RESPONSE_CANCEL); gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING); #endif hbox_content = gtk_hbox_new (FALSE, 8); image = gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0); primary_text = g_strdup_printf (_("This file (%s) is already open in another gedit window."), uri_for_display); g_free (uri_for_display); primary_markup = g_strdup_printf ("<b>%s</b>", primary_text); g_free (primary_text); primary_label = gtk_label_new (primary_markup); g_free (primary_markup); gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5); GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS); gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); secondary_text = _("gedit opened this instance of the file in a non-editable way. " "Do you want to edit it anyway?"); secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text); secondary_label = gtk_label_new (secondary_markup); g_free (secondary_markup); gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS); gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5); gtk_widget_show_all (hbox_content); set_contents (message_area, hbox_content); return message_area; }
static GtkWidget * create_conversion_error_message_area (const gchar *primary_text, const gchar *secondary_text, gboolean edit_anyway) { GtkWidget *message_area; GtkWidget *hbox_content; GtkWidget *image; GtkWidget *vbox; gchar *primary_markup; gchar *secondary_markup; GtkWidget *primary_label; GtkWidget *secondary_label; #if !GTK_CHECK_VERSION (2, 17, 1) message_area = gedit_message_area_new (); gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area), _("_Retry"), GTK_STOCK_REDO, GTK_RESPONSE_OK); if (edit_anyway) { gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area), _("Edit Any_way"), GTK_RESPONSE_YES); gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area), _("D_on't Edit"), GTK_RESPONSE_NO); } else { gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); } #else message_area = gtk_info_bar_new (); info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("_Retry"), GTK_STOCK_REDO, GTK_RESPONSE_OK); if (edit_anyway) { gtk_info_bar_add_button (GTK_INFO_BAR (message_area), /* Translators: the access key chosen for this string should be different from other main menu access keys (Open, Edit, View...) */ _("Edit Any_way"), GTK_RESPONSE_YES); gtk_info_bar_add_button (GTK_INFO_BAR (message_area), /* Translators: the access key chosen for this string should be different from other main menu access keys (Open, Edit, View...) */ _("D_on't Edit"), GTK_RESPONSE_NO); gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING); } else { gtk_info_bar_add_button (GTK_INFO_BAR (message_area), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_ERROR); } #endif hbox_content = gtk_hbox_new (FALSE, 8); image = gtk_image_new_from_stock ("gtk-dialog-error", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0); primary_markup = g_strdup_printf ("<b>%s</b>", primary_text); primary_label = gtk_label_new (primary_markup); g_free (primary_markup); gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5); GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS); gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); if (secondary_text != NULL) { secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text); secondary_label = gtk_label_new (secondary_markup); g_free (secondary_markup); gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS); gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE); gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5); } create_combo_box (message_area, vbox); gtk_widget_show_all (hbox_content); set_contents (message_area, hbox_content); return message_area; }
static void handle_http_transaction_from_main( http_transaction *transaction ) { assert( transaction != NULL ); http_request *request = &transaction->request; uint32_t content_length = 0; if ( request->content.body != NULL && request->content.body->length > 0 ) { content_length = ( uint32_t ) --request->content.body->length; // We only accept null-terminated string. } debug( "Handling a transaction from main thread ( method = %#x, uri = %s, content_length = %u, content_type = %s, content_body = %p ).", request->method, request->uri, content_length, request->content.content_type, request->content.body ); transaction->slist = NULL; CURL *handle = curl_easy_init(); CURLcode retval = CURLE_OK; switch ( request->method ) { case HTTP_METHOD_GET: { retval = curl_easy_setopt( handle, CURLOPT_HTTPGET, 1 ); if ( retval != CURLE_OK ) { error( "Failed to set HTTP method to GET ( handle = %p, error = %s ).", handle, curl_easy_strerror( retval ) ); goto error; } } break; case HTTP_METHOD_PUT: { retval = curl_easy_setopt( handle, CURLOPT_UPLOAD, 1 ); if ( retval != CURLE_OK ) { error( "Failed to set HTTP method to PUT ( handle = %p, error = %s ).", handle, curl_easy_strerror( retval ) ); goto error; } retval = curl_easy_setopt( handle, CURLOPT_INFILESIZE, content_length ); if ( retval != CURLE_OK ) { error( "Failed to set content length value ( content_length = %u, handle = %p, error = %s ).", content_length, handle, curl_easy_strerror( retval ) ); goto error; } transaction->slist = curl_slist_append( transaction->slist, "Expect:" ); } break; case HTTP_METHOD_POST: { retval = curl_easy_setopt( handle, CURLOPT_POST, 1 ); if ( retval != CURLE_OK ) { error( "Failed to set HTTP method to POST ( handle = %p, error = %s ).", handle, curl_easy_strerror( retval ) ); goto error; } retval = curl_easy_setopt( handle, CURLOPT_POSTFIELDSIZE, content_length ); if ( retval != CURLE_OK ) { error( "Failed to set content length value ( content_length = %u, handle = %p, error = %s ).", content_length, handle, curl_easy_strerror( retval ) ); goto error; } } break; case HTTP_METHOD_DELETE: { retval = curl_easy_setopt( handle, CURLOPT_CUSTOMREQUEST, "DELETE" ); if ( retval != CURLE_OK ) { error( "Failed to set HTTP method to DELETE ( handle = %p, error = %s ).", handle, curl_easy_strerror( retval ) ); goto error; } } break; default: { error( "Undefined HTTP request method ( %u ).", request->method ); assert( 0 ); } break; } bool ret = set_contents( handle, transaction ); if ( !ret ) { goto error; } retval = curl_easy_setopt( handle, CURLOPT_USERAGENT, USER_AGENT ); if ( retval != CURLE_OK ) { error( "Failed to set User-Agent header field value ( handle = %p, transaction = %p, error = %s ).", handle, transaction, curl_easy_strerror( retval ) ); goto error; } retval = curl_easy_setopt( handle, CURLOPT_URL, request->uri ); if ( retval != CURLE_OK ) { error( "Failed to set URL value ( uri = %s, handle = %p, transaction = %p, error = %s ).", request->uri, handle, transaction, curl_easy_strerror( retval ) ); goto error; } retval = curl_easy_setopt( handle, CURLOPT_NOPROGRESS, 1 ); if ( retval != CURLE_OK ) { error( "Failed to enable NOPROGRESS option ( handle = %p, transaction = %p, error = %s ).", handle, transaction, curl_easy_strerror( retval ) ); goto error; } retval = curl_easy_setopt( handle, CURLOPT_WRITEFUNCTION, write_to_buffer ); if ( retval != CURLE_OK ) { error( "Failed to set a write function ( handle = %p, transaction = %p, error = %s ).", handle, transaction, curl_easy_strerror( retval ) ); goto error; } http_response *response = &transaction->response; response->content.body = alloc_buffer_with_length( 1024 ); retval = curl_easy_setopt( handle, CURLOPT_WRITEDATA, ( void * ) response->content.body ); if ( retval != CURLE_OK ) { error( "Failed to set a write data ( handle = %p, transaction = %p, error = %s ).", handle, transaction, curl_easy_strerror( retval ) ); goto error; } if ( transaction->slist != NULL ) { retval = curl_easy_setopt( handle, CURLOPT_HTTPHEADER, transaction->slist ); if ( retval != CURLE_OK ) { error( "Failed to set custom header field values ( handle = %p, transaction = %p, slist = %p, error = %s ).", handle, transaction, transaction->slist, curl_easy_strerror( retval ) ); goto error; } } add_http_transaction( transaction, handle ); return; error: if ( handle != NULL ) { curl_easy_cleanup( handle ); } if ( transaction->slist != NULL ) { curl_slist_free_all( transaction->slist ); transaction->slist = NULL; } response = &transaction->response; response->status = HTTP_TRANSACTION_FAILED; response->code = 0; enqueue( http_client_to_main_queue, transaction ); notify_main(); }