static char* gtk_mate_exporter_colour (GtkMateExporter* self, const char* colour) { GString* _result_; const char* _tmp9_; char* _tmp10_; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (colour != NULL, NULL); _result_ = g_string_new (""); if (string_get_length (colour) == 9) { char* _tmp1_; char* _tmp0_; char* _tmp3_; char* _tmp2_; char* _tmp5_; char* _tmp4_; char* _tmp6_; g_string_append (_result_, "\tbackground-color: rgba("); _tmp1_ = NULL; _tmp0_ = NULL; g_string_append (_result_, _tmp1_ = g_strconcat (_tmp0_ = g_strdup_printf ("%d", gtk_mate_colourer_hex_to_int (g_utf8_get_char (g_utf8_offset_to_pointer (colour, 1)), g_utf8_get_char (g_utf8_offset_to_pointer (colour, 2)))), ", ", NULL)); _tmp1_ = (g_free (_tmp1_), NULL); _tmp0_ = (g_free (_tmp0_), NULL); _tmp3_ = NULL; _tmp2_ = NULL; g_string_append (_result_, _tmp3_ = g_strconcat (_tmp2_ = g_strdup_printf ("%d", gtk_mate_colourer_hex_to_int (g_utf8_get_char (g_utf8_offset_to_pointer (colour, 3)), g_utf8_get_char (g_utf8_offset_to_pointer (colour, 4)))), ", ", NULL)); _tmp3_ = (g_free (_tmp3_), NULL); _tmp2_ = (g_free (_tmp2_), NULL); _tmp5_ = NULL; _tmp4_ = NULL; g_string_append (_result_, _tmp5_ = g_strconcat (_tmp4_ = g_strdup_printf ("%d", gtk_mate_colourer_hex_to_int (g_utf8_get_char (g_utf8_offset_to_pointer (colour, 5)), g_utf8_get_char (g_utf8_offset_to_pointer (colour, 6)))), ", ", NULL)); _tmp5_ = (g_free (_tmp5_), NULL); _tmp4_ = (g_free (_tmp4_), NULL); _tmp6_ = NULL; g_string_append (_result_, _tmp6_ = g_strdup_printf ("%0.2f", ((double) gtk_mate_colourer_hex_to_int (g_utf8_get_char (g_utf8_offset_to_pointer (colour, 7)), g_utf8_get_char (g_utf8_offset_to_pointer (colour, 8)))) / 256.0)); _tmp6_ = (g_free (_tmp6_), NULL); g_string_append (_result_, ");\n"); } else { if (string_get_length (colour) == 7) { char* _tmp8_; char* _tmp7_; _tmp8_ = NULL; _tmp7_ = NULL; g_string_append (_result_, _tmp8_ = g_strconcat (_tmp7_ = g_strconcat ("\tbackground-color: ", colour, NULL), ";\n", NULL)); _tmp8_ = (g_free (_tmp8_), NULL); _tmp7_ = (g_free (_tmp7_), NULL); } } _tmp9_ = NULL; _tmp10_ = NULL; return (_tmp10_ = (_tmp9_ = _result_->str, (_tmp9_ == NULL) ? NULL : g_strdup (_tmp9_)), (_result_ == NULL) ? NULL : (_result_ = (g_string_free (_result_, TRUE), NULL)), _tmp10_); }
int string_reader_has_more(const t_string_reader *reader) { const char *s; s = reader->file->content; return (reader->position.index < string_get_length(s)); }
static void serializer_visit_label (Serializer* self, GtkLabel* label) { char* label_text; g_return_if_fail (self != NULL); g_return_if_fail (label != NULL); label_text = g_strdup (gtk_label_get_label (label)); g_string_append (self->priv->label_sb, label_text); g_debug ("serializer.vala:143: append text = %s", label_text); if (GTK_IS_ACCEL_LABEL (label)) { GtkLabel* _tmp0_; GtkLabel* _tmp1_; char* accel_string; gboolean _tmp2_ = FALSE; gtk_accel_label_refetch ((_tmp0_ = label, GTK_IS_ACCEL_LABEL (_tmp0_) ? ((GtkAccelLabel*) _tmp0_) : NULL)); accel_string = string_strip ((_tmp1_ = label, GTK_IS_ACCEL_LABEL (_tmp1_) ? ((GtkAccelLabel*) _tmp1_) : NULL)->accel_string); if (string_get_length (accel_string) > 0) { _tmp2_ = _vala_strcmp0 (accel_string, "-/-") != 0; } else { _tmp2_ = FALSE; } if (_tmp2_) { char* _tmp3_; g_string_append (self->priv->sb, _tmp3_ = g_markup_printf_escaped (" accel=\"%s\"", accel_string)); _g_free0 (_tmp3_); } _g_free0 (accel_string); } _g_free0 (label_text); }
void matenu_settings_pull (MatenuSettings* self) { GError * _inner_error_; char* data; g_return_if_fail (self != NULL); _inner_error_ = NULL; data = matenu_settings_get_by_atom (self, self->priv->atom); if (data == NULL) { _g_free0 (data); return; } g_key_file_load_from_data (self->keyfile, data, (gsize) string_get_length (data), G_KEY_FILE_NONE, &_inner_error_); if (_inner_error_ != NULL) { _g_free0 (data); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } { const char** key_collection; int key_collection_length1; int key_it; key_collection = MATENU_SETTINGS_KEYS; key_collection_length1 = G_N_ELEMENTS (MATENU_SETTINGS_KEYS); for (key_it = 0; key_it < G_N_ELEMENTS (MATENU_SETTINGS_KEYS); key_it = key_it + 1) { const char* key; key = key_collection[key_it]; { matenu_settings_load_property (self, key); } } } _g_free0 (data); }
/* ** From Whiskey :-) */ char *read_whole_file(int file_descriptor) { size_t block_size; char *string; size_t length; ssize_t read_char_count; string = NULL; length = 0; block_size = 1024 * 1024; while ((string = realloc(string, length + block_size + 1)) != NULL) { read_char_count = read(file_descriptor, string + length, block_size); if (read_char_count > -1) string[read_char_count] = '\0'; length += read_char_count; if (read_char_count == -1 || string_get_length(string) != (int)length) { free(string); return (NULL); } if (read_char_count != (ssize_t)block_size) break; } return (string); }
gchar command_get_arg_desc (Command *self, guint arg_i) { gchar result = '\0'; if (arg_i >= string_get_length ((*self).args_desc)) { result = (gchar) 0; return result; } result = (gchar) g_utf8_get_char (g_utf8_offset_to_pointer ((*self).args_desc, arg_i)); return result; }
int string_is_alphanumeric(const char *str) { if (string_get_length(str) == 0) return (0); while (*str) { if (!char_is_alpha_numeric(*str++)) return (0); } return (1); }
int string_is_letter(const char *str) { if (string_get_length(str) == 0) return (0); while (*str) { if (!char_is_alpha(*str++)) return (0); } return (1); }
int string_is_lowercase(const char *str) { if (string_get_length(str) == 0) return (0); while (*str) { if (!char_is_lower(*str++)) return (0); } return (1); }
int string_is_digit(const char *str) { if (string_get_length(str) == 0) return (0); while (*str) { if (!char_is_digit(*str++)) return (0); } return (1); }
static char* matenu_menu_bar_overflown_path_to_path (MatenuMenuBar* self, const char* path) { char* result = NULL; gint slashes; GString* sb; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); slashes = 0; sb = g_string_new (""); { gint i; i = 0; { gboolean _tmp0_; _tmp0_ = TRUE; while (TRUE) { if (!_tmp0_) { i++; } _tmp0_ = FALSE; if (!(i < string_get_length (path))) { break; } if (g_utf8_get_char (g_utf8_offset_to_pointer (path, i)) == '/') { slashes++; } if (slashes != 1) { g_string_append_unichar (sb, g_utf8_get_char (g_utf8_offset_to_pointer (path, i))); } } } } if (slashes > 1) { result = g_strdup (sb->str); _g_string_free0 (sb); return result; } result = NULL; _g_string_free0 (sb); return result; }
static char* string_substring (const char* self, glong offset, glong len) { #line 144 "ease-import-flickr-service.c" char* result = NULL; glong string_length; const char* start; #line 1086 "glib-2.0.vapi" g_return_val_if_fail (self != NULL, NULL); #line 1087 "glib-2.0.vapi" string_length = string_get_length (self); #line 1088 "glib-2.0.vapi" if (offset < 0) { #line 1089 "glib-2.0.vapi" offset = string_length + offset; #line 1090 "glib-2.0.vapi" g_return_val_if_fail (offset >= 0, NULL); #line 158 "ease-import-flickr-service.c" } else { #line 1092 "glib-2.0.vapi" g_return_val_if_fail (offset <= string_length, NULL); #line 162 "ease-import-flickr-service.c" } #line 1094 "glib-2.0.vapi" if (len < 0) { #line 1095 "glib-2.0.vapi" len = string_length - offset; #line 168 "ease-import-flickr-service.c" } #line 1097 "glib-2.0.vapi" g_return_val_if_fail ((offset + len) <= string_length, NULL); #line 1098 "glib-2.0.vapi" start = g_utf8_offset_to_pointer (self, offset); #line 174 "ease-import-flickr-service.c" result = g_strndup (start, ((gchar*) g_utf8_offset_to_pointer (start, len)) - ((gchar*) start)); #line 1099 "glib-2.0.vapi" return result; #line 178 "ease-import-flickr-service.c" }
guint command_get_n_args (Command *self) { guint result = 0U; result = (guint) string_get_length ((*self).args_desc); return result; }
/* variable_serialize */ int variable_serialize(Variable * variable, Buffer * buffer, int type) { size_t size = 0; size_t offset; void * p; uint8_t u8; int16_t i16; uint16_t u16; int32_t i32; uint32_t u32; char buf[16]; #ifdef DEBUG fprintf(stderr, "DEBUG: %s(%u)\n", __func__, variable->type); #endif switch(variable->type) { case VT_NULL: p = NULL; break; case VT_BOOL: case VT_INT8: case VT_UINT8: size = sizeof(variable->u.int8); p = &variable->u.int8; break; case VT_INT16: size = sizeof(i16); i16 = htons(variable->u.int16); p = &i16; break; case VT_UINT16: size = sizeof(u16); u16 = htons(variable->u.uint16); p = &u16; break; case VT_INT32: size = sizeof(i32); i32 = htonl(variable->u.int32); p = &i32; break; case VT_UINT32: size = sizeof(u32); u32 = htonl(variable->u.uint32); p = &u32; break; case VT_INT64: case VT_UINT64: /* FIXME convert to network endian */ size = sizeof(variable->u.int64); p = &variable->u.int64; break; case VT_FLOAT: size = snprintf(buf, sizeof(buf), "%.e", variable->u.f); p = buf; break; case VT_DOUBLE: size = snprintf(buf, sizeof(buf), "%.e", variable->u.d); p = buf; break; case VT_BUFFER: size = buffer_get_size(variable->u.buffer); u32 = buffer_get_size(variable->u.buffer); u32 = htonl(u32); p = buffer_get_data(variable->u.buffer); break; case VT_STRING: size = string_get_length(variable->u.string) + 1; p = variable->u.string; break; } #ifdef DEBUG fprintf(stderr, "DEBUG: %s() %lu\n", __func__, size); #endif if(size == 0 && variable->type != VT_NULL) return -error_set_code(1, "Unable to serialize type %u", type); if(type) { /* prefix with the type */ u8 = variable->type; if(buffer_set(buffer, sizeof(u8), (char *)&u8) != 0) return -1; offset = sizeof(u8); if(variable->type == VT_BUFFER) { if(buffer_set_data(buffer, offset, (char *)&u32, sizeof(u32)) != 0) return -1; offset += sizeof(u32); } return buffer_set_data(buffer, offset, p, size); } if(variable->type == VT_BUFFER) { if(buffer_set(buffer, sizeof(u32), (char *)&u32) != 0) return -1; return buffer_set_data(buffer, sizeof(u32), p, size); } return buffer_set(buffer, size, p); }
static RestProxyCall* ease_flickr_service_real_create_call (EasePluginImportService* base, RestProxy* proxy, const char* search) { #line 184 "ease-import-flickr-service.c" EaseFlickrService * self; RestProxyCall* result = NULL; char* licenses; RestProxyCall* call; char* _tmp4_; self = (EaseFlickrService*) base; #line 40 "ease-import-flickr-service.vala" g_return_val_if_fail (proxy != NULL, NULL); #line 40 "ease-import-flickr-service.vala" g_return_val_if_fail (search != NULL, NULL); #line 195 "ease-import-flickr-service.c" licenses = NULL; #line 44 "ease-import-flickr-service.vala" if (gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->share_alike)) { #line 199 "ease-import-flickr-service.c" char* _tmp0_; #line 46 "ease-import-flickr-service.vala" licenses = (_tmp0_ = g_strdup (EASE_FLICKR_SERVICE_CC_BY_SA), _g_free0 (licenses), _tmp0_); #line 47 "ease-import-flickr-service.vala" if (!gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->for_commercial)) { #line 205 "ease-import-flickr-service.c" char* _tmp1_; #line 47 "ease-import-flickr-service.vala" licenses = (_tmp1_ = g_strconcat (licenses, EASE_FLICKR_SERVICE_CC_BY_NC_SA, NULL), _g_free0 (licenses), _tmp1_); #line 209 "ease-import-flickr-service.c" } } else { char* _tmp2_; #line 51 "ease-import-flickr-service.vala" licenses = (_tmp2_ = g_strdup (EASE_FLICKR_SERVICE_CC_BY), _g_free0 (licenses), _tmp2_); #line 52 "ease-import-flickr-service.vala" if (!gtk_toggle_button_get_active ((GtkToggleButton*) self->priv->for_commercial)) { #line 217 "ease-import-flickr-service.c" char* _tmp3_; #line 52 "ease-import-flickr-service.vala" licenses = (_tmp3_ = g_strconcat (licenses, EASE_FLICKR_SERVICE_CC_BY_NC, NULL), _g_free0 (licenses), _tmp3_); #line 221 "ease-import-flickr-service.c" } } #line 55 "ease-import-flickr-service.vala" call = rest_proxy_new_call (proxy); #line 56 "ease-import-flickr-service.vala" rest_proxy_call_set_function (call, "flickr.photos.search"); #line 57 "ease-import-flickr-service.vala" rest_proxy_call_add_params (call, "tags", search, "tag_mode", "all", "per_page", "10", "format", "json", "sort", "relevance", "nojsoncallback", "1", "license", _tmp4_ = string_substring (licenses, (glong) 0, string_get_length (licenses) - 1), "extras", "description,license", NULL, NULL); #line 230 "ease-import-flickr-service.c" _g_free0 (_tmp4_); result = call; _g_free0 (licenses); #line 71 "ease-import-flickr-service.vala" return result; #line 236 "ease-import-flickr-service.c" }