bool EASPolicyManager::importOldPolicySettings() { json_object *root = 0, *prop = 0, *key = 0; root = json_object_from_file((char*)s_policyFile); if (!root || is_error(root)) return false; prop = json_object_object_get(root, "version"); if (!prop) { g_message("converting version 1 schema to version %d", s_version); // migrate version 1 schema EASPolicy* p = new EASPolicy; if(p->fromJSON(root)) m_aggregate->merge (p); } else if (json_object_get_int(prop) == 2) { // parse version 2 schema g_message("parsing version 2 schema"); // parse all policies and create aggregate prop = json_object_object_get(root, "policies"); if (prop && !is_error(prop) && json_object_is_type(prop, json_type_array)) { for (int i = 0; i < json_object_array_length(prop); i++) { EASPolicy* p = new EASPolicy; key = json_object_array_get_idx(prop, i); if (p->fromJSON(key)) m_aggregate->merge(p); delete p; } } } else { g_critical("unrecognized EAS policy schema version %d", json_object_get_int(prop)); return false; } // status prop = json_object_object_get(root, "status"); if (prop && !is_error(prop)) { key = json_object_object_get(prop, "enforced"); m_isEnforced = (key == 0 ? false : json_object_get_boolean(key)); key = json_object_object_get(prop, "retriesLeft"); if (key) m_retriesLeft = json_object_get_int(key); else if (m_aggregate) m_retriesLeft = m_aggregate->maxRetries(); } else { m_isEnforced = false; if (m_aggregate) m_retriesLeft = m_aggregate->maxRetries(); } // check the installed policies against the set of email accounts json_object_put(root); return true; }
/** * Update any changes to the server. * * \param server AddressBook resource. * \param person ItemPerson holding user input. */ void ldapsvr_update_book(LdapServer *server, ItemPerson *item) { GList *node = NULL; GHashTable *contact = NULL; GList *contacts = NULL, *head = NULL; cm_return_if_fail(server != NULL); debug_print("updating ldap addressbook\n"); contact = g_hash_table_new(g_str_hash, g_str_equal); if (item) { gboolean result = ldapsvr_retrieve_item_person(item, contact); debug_print("Found contact to update: %s\n", result? "Yes" : "No"); if (result) { if (debug_get_mode()) { addritem_print_item_person(item, stdout); } contacts = g_list_append(contacts, contact); } } else { ItemFolder *folder = server->addressCache->rootFolder; node = folder->listFolder; if (node) { while (node) { AddrItemObject *aio = node->data; if (aio) { if (aio->type == ITEMTYPE_FOLDER) { ItemFolder *folder = (ItemFolder *) aio; GList *persons = folder->listPerson; while (persons) { AddrItemObject *aio = persons->data; if (aio) { if (aio->type == ITEMTYPE_PERSON) { ItemPerson *item = (ItemPerson *) aio; gboolean result = ldapsvr_retrieve_item_person(item, contact); debug_print("Found contact to update: %s\n", result? "Yes" : "No"); if (result) { if (debug_get_mode()) { gchar *uid = g_hash_table_lookup(contact, "uid"); item = ldapsvr_get_contact(server, uid); addritem_print_item_person(item, stdout); } contacts = g_list_append(contacts, contact); } } } persons = g_list_next(persons); } } } else { g_printerr("\t\tpid : ???\n"); } node = g_list_next(node); } } } head = contacts; if (debug_get_mode()) { if (contacts) debug_print("Contacts which must be updated in LDAP:\n"); while (contacts) { debug_print("\tContact:\n"); g_hash_table_foreach(contacts->data, ldapsvr_print_contacts_hashtable, stderr); contacts = g_list_next(contacts); } } if (contacts == NULL) contacts = head; while (contacts) { gchar *status; contact = (GHashTable *) contacts->data; status = (gchar *) g_hash_table_lookup(contact, "status"); if (status == NULL) status = g_strdup("NULL"); if (g_ascii_strcasecmp(status, "new") == 0) { ldapsvr_add_contact(server, contact); } else if (g_ascii_strcasecmp(status, "update") == 0) { ldapsvr_update_contact(server, contact); } else if (g_ascii_strcasecmp(status, "delete") == 0) { ldapsvr_delete_contact(server, contact); } else g_critical("ldapsvr_update_book->Unknown status: %s\n", status); contacts = g_list_next(contacts); } ldapsvr_free_hashtable(head); }
static int export_tiff (GeglOperation *operation, GeglBuffer *input, const GeglRectangle *result) { GeglProperties *o = GEGL_PROPERTIES(operation); Priv *p = (Priv*) o->user_data; gshort color_space, compression = COMPRESSION_NONE; gushort bits_per_sample, samples_per_pixel; gboolean has_alpha, alpha_is_premultiplied = FALSE; gushort sample_format, predictor = 0; gushort extra_types[1]; glong rows_per_stripe = 1; gint bytes_per_row; const Babl *type, *model; gchar format_string[32]; const Babl *format; g_return_val_if_fail(p->tiff != NULL, -1); TIFFSetField(p->tiff, TIFFTAG_SUBFILETYPE, 0); TIFFSetField(p->tiff, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(p->tiff, TIFFTAG_IMAGEWIDTH, result->width); TIFFSetField(p->tiff, TIFFTAG_IMAGELENGTH, result->height); format = gegl_buffer_get_format(input); model = babl_format_get_model(format); type = babl_format_get_type(format, 0); if (model == babl_model("Y") || model == babl_model("Y'")) { has_alpha = FALSE; color_space = PHOTOMETRIC_MINISBLACK; model = babl_model("Y'"); samples_per_pixel = 1; } else if (model == babl_model("YA") || model == babl_model("Y'A")) { has_alpha = TRUE; alpha_is_premultiplied = FALSE; color_space = PHOTOMETRIC_MINISBLACK; model = babl_model("Y'A"); samples_per_pixel = 2; } else if (model == babl_model("YaA") || model == babl_model("Y'aA")) { has_alpha = TRUE; alpha_is_premultiplied = TRUE; color_space = PHOTOMETRIC_MINISBLACK; model = babl_model("Y'aA"); samples_per_pixel = 2; } else if (model == babl_model("RGB") || model == babl_model("R'G'B'")) { has_alpha = FALSE; color_space = PHOTOMETRIC_RGB; model = babl_model("R'G'B'"); samples_per_pixel = 3; predictor = 2; } else if (model == babl_model("RGBA") || model == babl_model("R'G'B'A")) { has_alpha = TRUE; alpha_is_premultiplied = FALSE; color_space = PHOTOMETRIC_RGB; model = babl_model("R'G'B'A"); samples_per_pixel = 4; predictor = 2; } else if (model == babl_model("RaGaBaA") || model == babl_model("R'aG'aB'aA")) { has_alpha = TRUE; alpha_is_premultiplied = TRUE; color_space = PHOTOMETRIC_RGB; model = babl_model("R'aG'aB'aA"); samples_per_pixel = 4; predictor = 2; } else { g_warning("color space not supported: %s", babl_get_name(model)); has_alpha = TRUE; alpha_is_premultiplied = TRUE; color_space = PHOTOMETRIC_RGB; model = babl_model("R'aG'aB'aA"); samples_per_pixel = 4; predictor = 2; } TIFFSetField(p->tiff, TIFFTAG_PHOTOMETRIC, color_space); TIFFSetField(p->tiff, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel); TIFFSetField(p->tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); if (has_alpha) { if (alpha_is_premultiplied) extra_types[0] = EXTRASAMPLE_ASSOCALPHA; else extra_types[0] = EXTRASAMPLE_UNASSALPHA; TIFFSetField(p->tiff, TIFFTAG_EXTRASAMPLES, 1, extra_types); } if (predictor != 0) { if (compression == COMPRESSION_LZW) TIFFSetField(p->tiff, TIFFTAG_PREDICTOR, predictor); else if (compression == COMPRESSION_ADOBE_DEFLATE) TIFFSetField(p->tiff, TIFFTAG_PREDICTOR, predictor); } if (type == babl_type("u8")) { sample_format = SAMPLEFORMAT_UINT; bits_per_sample = 8; } else if (type == babl_type("half")) { sample_format = SAMPLEFORMAT_IEEEFP; bits_per_sample = 16; } else if (type == babl_type("u16")) { sample_format = SAMPLEFORMAT_UINT; bits_per_sample = 16; } else if (type == babl_type("float")) { sample_format = SAMPLEFORMAT_IEEEFP; bits_per_sample = 32; } else if (type == babl_type("u32")) { sample_format = SAMPLEFORMAT_UINT; bits_per_sample = 32; } else if (type == babl_type("double")) { sample_format = SAMPLEFORMAT_IEEEFP; bits_per_sample = 64; } else { g_warning("sample format not supported: %s", babl_get_name(type)); sample_format = SAMPLEFORMAT_UINT; type = babl_type("u8"); bits_per_sample = 8; } TIFFSetField(p->tiff, TIFFTAG_BITSPERSAMPLE, bits_per_sample); TIFFSetField(p->tiff, TIFFTAG_SAMPLEFORMAT, sample_format); TIFFSetField(p->tiff, TIFFTAG_COMPRESSION, compression); if ((compression == COMPRESSION_CCITTFAX3 || compression == COMPRESSION_CCITTFAX4) && (bits_per_sample != 1 || samples_per_pixel != 1)) { g_critical("only monochrome pictures can be compressed " "with \"CCITT Group 4\" or \"CCITT Group 3\""); return -1; } g_snprintf(format_string, 32, "%s %s", babl_get_name(model), babl_get_name(type)); format = babl_format(format_string); /* "Choose RowsPerStrip such that each strip is about 8K bytes." */ bytes_per_row = babl_format_get_bytes_per_pixel(format) * result->width; while (bytes_per_row * rows_per_stripe <= 8192) rows_per_stripe++; rows_per_stripe = MIN(rows_per_stripe, result->height); TIFFSetField(p->tiff, TIFFTAG_ROWSPERSTRIP, rows_per_stripe); return save_contiguous(operation, input, result, format); }
bool PrefsDb::checkTableConsistency() { if (!m_prefsDb) return false; int ret; std::string query; sqlite3_stmt* statement = 0; const char* tail = 0; if (!integrityCheckDb()) { g_critical("integrity check failed on prefs db and it cannot be recreated"); return false; } query = "SELECT value FROM Preferences WHERE key='databaseVersion'"; ret = sqlite3_prepare(m_prefsDb, query.c_str(), -1, &statement, &tail); if (ret) { g_warning("PrefsDb::checkTableConsistency(): Failed to prepare sql statement: %s (%s)", query.c_str(), sqlite3_errmsg(m_prefsDb)); sqlite3_finalize(statement); goto Recreate; } ret = sqlite3_step(statement); sqlite3_finalize(statement); if (ret != SQLITE_ROW) { // Database not consistent. recreate goto Recreate; } if (!m_standalone) { // check to see if all the defaults from the s_defaultPrefsFile at least exist and if not, add them synchronizeDefaults(); synchronizePlatformDefaults(); //check the same with the "customer care" file synchronizeCustomerCareInfo(); updateWithCustomizationPrefOverrides(); } //Everything is now ok. return true; Recreate: (void) sqlite3_exec(m_prefsDb, "DROP TABLE Preferences", NULL, NULL, NULL); ret = sqlite3_exec(m_prefsDb, "CREATE TABLE Preferences " "(key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE, " " value TEXT);", NULL, NULL, NULL); if (ret) { g_warning("PrefsDb::checkTableConsistency(): Failed to create Preferences table"); return false; } ret = sqlite3_exec(m_prefsDb, "INSERT INTO Preferences VALUES ('databaseVersion', '1.0')", NULL, NULL, NULL); if (ret) { g_warning("PrefsDb::checkTableConsistency(): Failed to create Preferences table"); return false; } if (!m_standalone) { loadDefaultPrefs(); loadDefaultPlatformPrefs(); updateWithCustomizationPrefOverrides(); } return true; }
static gboolean process_cm_event (GIOChannel *source, GIOCondition condition, gpointer data) { // Right now, we don't need 'source' and 'condition' // Tell the compiler to ignore them by (void)-ing them (void) source; (void) condition; g_debug ("CM event handler triggered"); if (!G_TRYLOCK (connection_handling)) { // Unsafe to handle connection management right now. // Wait for next dispatch. g_debug ("Connection handling is busy. Waiting for next dispatch"); return TRUE; } KiroServerPrivate *priv = (KiroServerPrivate *)data; struct rdma_cm_event *active_event; if (0 <= rdma_get_cm_event (priv->ec, &active_event)) { struct rdma_cm_event *ev = g_try_malloc (sizeof (*active_event)); if (!ev) { g_critical ("Unable to allocate memory for Event handling!"); rdma_ack_cm_event (active_event); goto exit; } memcpy (ev, active_event, sizeof (*active_event)); rdma_ack_cm_event (active_event); if (ev->event == RDMA_CM_EVENT_CONNECT_REQUEST) { if (TRUE == priv->close_signal) { //Main thread has signalled shutdown! //Don't connect this client any more. //Sorry mate! rdma_reject (ev->id, NULL, 0); goto exit; } do { g_debug ("Got connection request from client"); struct kiro_client_connection *cc = (struct kiro_client_connection *)g_try_malloc (sizeof (struct kiro_client_connection)); if (!cc) { errno = ENOMEM; rdma_reject (ev->id, NULL, 0); goto fail; } if (connect_client (ev->id)) goto fail; // Post a welcoming "Receive" for handshaking if (grant_client_access (ev->id, priv->mem, priv->mem_size, KIRO_ACK_RDMA)) goto fail; ibv_req_notify_cq (ev->id->recv_cq, 0); // Make the respective Queue push events onto the channel // Connection set-up successfully! (Server) // ctx was created by 'welcome_client' struct kiro_connection_context *ctx = (struct kiro_connection_context *) (ev->id->context); ctx->identifier = priv->next_client_id++; ctx->container = cc; // Make the connection aware of its container // Fill the client connection container. Also create a // g_io_channel wrapper for the new clients receive queue event // channel and add a main_loop watch to it. cc->id = ctx->identifier; cc->conn = ev->id; cc->rcv_ec = g_io_channel_unix_new (ev->id->recv_cq_channel->fd); priv->clients = g_list_append (priv->clients, (gpointer)cc); GList *client = g_list_find (priv->clients, (gpointer)cc); if (!client->data || client->data != cc) { g_critical ("Could not add client to list"); goto fail; } cc->source_id = g_io_add_watch (cc->rcv_ec, G_IO_IN | G_IO_PRI, process_rdma_event, (gpointer)client); g_io_channel_unref (cc->rcv_ec); // main_loop now holds a reference. We don't need ours any more g_debug ("Client connection assigned with ID %u", ctx->identifier); g_debug ("Currently %u clients in total are connected", g_list_length (priv->clients)); break; fail: g_warning ("Failed to accept client connection: %s", strerror (errno)); if (errno == EINVAL) g_message ("This might happen if the client pulls back the connection request before the server can handle it."); } while(0); } else if (ev->event == RDMA_CM_EVENT_DISCONNECTED) { struct kiro_connection_context *ctx = (struct kiro_connection_context *) (ev->id->context); if (!ctx->container) { g_debug ("Got disconnect request from unknown client"); goto exit; } GList *client = g_list_find (priv->clients, (gconstpointer) ctx->container); if (client) { g_debug ("Got disconnect request from client ID %u", ctx->identifier); struct kiro_client_connection *cc = (struct kiro_client_connection *)ctx->container; g_source_remove (cc->source_id); // this also unrefs the GIOChannel of the source. Nice. priv->clients = g_list_delete_link (priv->clients, client); g_free (cc); ctx->container = NULL; } else g_debug ("Got disconnect request from unknown client"); // Note: // The ProtectionDomain needs to be buffered and freed manually. // Each connecting client is attached with its own pd, which we // create manually. So we also need to clean it up manually. // This needs to be done AFTER the connection is brought down, so we // buffer the pointer to the pd and clean it up afterwards. struct ibv_pd *pd = ev->id->pd; kiro_destroy_connection (& (ev->id)); g_free (pd); g_debug ("Connection closed successfully. %u connected clients remaining", g_list_length (priv->clients)); } exit: g_free (ev); } G_UNLOCK (connection_handling); g_debug ("CM event handling done"); return TRUE; }
int main( int argc, char ** argv) { int c; char *command; application_argument_t argument; #ifdef STAR star_path = STAR; #else star_path = NULL; #endif star_tardumps = "/etc/tardumps"; star_dle_tardumps = 0; star_onefilesystem = 1; star_sparse = 1; star_directory = NULL; /* initialize */ /* * Configure program for internationalization: * 1) Only set the message locale for now. * 2) Set textdomain for all amanda related programs to "amanda" * We don't want to be forced to support dozens of message catalogs. */ setlocale(LC_MESSAGES, "C"); textdomain("amanda"); if (argc < 2) { printf("ERROR no command given to amstar\n"); error(_("No command given to amstar")); } /* drop root privileges */ if (!set_root_privs(0)) { if (strcmp(argv[1], "selfcheck") == 0) { printf("ERROR amstar must be run setuid root\n"); } error(_("amstar must be run setuid root")); } safe_fd(3, 2); set_pname("amstar"); /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); #if defined(USE_DBMALLOC) malloc_size_1 = malloc_inuse(&malloc_hist_1); #endif add_amanda_log_handler(amanda_log_stderr); add_amanda_log_handler(amanda_log_syslog); dbopen(DBG_SUBDIR_CLIENT); startclock(); dbprintf(_("version %s\n"), VERSION); config_init(CONFIG_INIT_CLIENT, NULL); //check_running_as(RUNNING_AS_DUMPUSER_PREFERRED); //root for amrecover //RUNNING_AS_CLIENT_LOGIN from selfcheck, sendsize, sendbackup /* parse argument */ command = argv[1]; argument.config = NULL; argument.host = NULL; argument.message = 0; argument.collection = 0; argument.calcsize = 0; argument.level = NULL; argument.command_options = NULL; init_dle(&argument.dle); opterr = 0; while (1) { int option_index = 0; c = getopt_long (argc, argv, "", long_options, &option_index); if (c == -1) break; switch (c) { case 1: argument.config = stralloc(optarg); break; case 2: argument.host = stralloc(optarg); break; case 3: argument.dle.disk = stralloc(optarg); break; case 4: argument.dle.device = stralloc(optarg); break; case 5: argument.level = g_slist_append(argument.level, GINT_TO_POINTER(atoi(optarg))); break; case 6: argument.dle.create_index = 1; break; case 7: argument.message = 1; break; case 8: argument.collection = 1; break; case 9: argument.dle.record = 1; break; case 10: star_path = stralloc(optarg); break; case 11: star_tardumps = stralloc(optarg); break; case 12: if (optarg && strcasecmp(optarg, "NO") == 0) star_dle_tardumps = 0; else if (optarg && strcasecmp(optarg, "YES") == 0) star_dle_tardumps = 1; else if (strcasecmp(command, "selfcheck") == 0) printf(_("ERROR [%s: bad STAR-DLE-TARDUMP property value (%s)]\n"), get_pname(), optarg); break; case 13: if (optarg && strcasecmp(optarg, "YES") != 0) { /* This option is required to be YES */ /* star_onefilesystem = 0; */ } break; case 14: if (optarg && strcasecmp(optarg, "NO") == 0) star_sparse = 0; else if (optarg && strcasecmp(optarg, "YES") == 0) star_sparse = 1; else if (strcasecmp(command, "selfcheck") == 0) printf(_("ERROR [%s: bad SPARSE property value (%s)]\n"), get_pname(), optarg); break; case 15: argument.calcsize = 1; break; case 16: if (optarg) normal_message = g_slist_append(normal_message, optarg); break; case 17: if (optarg) ignore_message = g_slist_append(ignore_message, optarg); break; case 18: if (optarg) strange_message = g_slist_append(strange_message, optarg); break; case 19: if (optarg) argument.dle.include_list = append_sl(argument.dle.include_list, optarg); break; case 20: if (optarg) argument.dle.exclude_list = append_sl(argument.dle.exclude_list, optarg); break; case 21: if (optarg) star_directory = stralloc(optarg); break; case 22: argument.command_options = g_slist_append(argument.command_options, stralloc(optarg)); case 23: if (optarg) argument.dle.exclude_file = append_sl(argument.dle.exclude_file, optarg); break; case ':': case '?': break; } } if (!argument.dle.disk && argument.dle.device) argument.dle.disk = stralloc(argument.dle.device); if (!argument.dle.device && argument.dle.disk) argument.dle.device = stralloc(argument.dle.disk); argument.argc = argc - optind; argument.argv = argv + optind; if (argument.config) { /* overlay this configuration on the existing (nameless) configuration */ config_init(CONFIG_INIT_CLIENT | CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_OVERLAY, argument.config); dbrename(get_config_name(), DBG_SUBDIR_CLIENT); } if (config_errors(NULL) >= CFGERR_ERRORS) { g_critical(_("errors processing config file")); } re_table = build_re_table(init_re_table, normal_message, ignore_message, strange_message); if (strcmp(command, "support") == 0) { amstar_support(&argument); } else if (strcmp(command, "selfcheck") == 0) { amstar_selfcheck(&argument); } else if (strcmp(command, "estimate") == 0) { amstar_estimate(&argument); } else if (strcmp(command, "backup") == 0) { amstar_backup(&argument); } else if (strcmp(command, "restore") == 0) { amstar_restore(&argument); } else if (strcmp(command, "validate") == 0) { amstar_validate(&argument); } else { fprintf(stderr, "Unknown command `%s'.\n", command); exit (1); } return 0; }
GncABTransDialog * gnc_ab_trans_dialog_new(GtkWidget *parent, AB_ACCOUNT *ab_acc, gint commodity_scu, GncABTransType trans_type, GList *templates) { GncABTransDialog *td; GtkBuilder *builder; const gchar *ab_ownername; const gchar *ab_accountnumber; const gchar *ab_bankname; const gchar *ab_bankcode; GtkWidget *heading_label; GtkWidget *recp_name_heading; GtkWidget *recp_account_heading; GtkWidget *recp_bankcode_heading; GtkWidget *amount_hbox; GtkWidget *orig_name_heading; GtkWidget *orig_name_label; GtkWidget *orig_account_heading; GtkWidget *orig_account_label; GtkWidget *orig_bankname_heading; GtkWidget *orig_bankname_label; GtkWidget *orig_bankcode_heading; GtkWidget *orig_bankcode_label; GtkCellRenderer *renderer; GtkTreeViewColumn *column; g_return_val_if_fail(ab_acc, NULL); ab_ownername = AB_Account_GetOwnerName(ab_acc); if (!ab_ownername) ab_ownername = ""; ab_accountnumber = AB_Account_GetAccountNumber(ab_acc); ab_bankcode = AB_Account_GetBankCode(ab_acc); ab_bankname = AB_Account_GetBankName(ab_acc); if (!ab_bankname || !*ab_bankname) ab_bankname = _("(unknown)"); td = g_new0(GncABTransDialog, 1); td->parent = parent; td->ab_acc = ab_acc; td->trans_type = trans_type; #if HAVE_KTOBLZCHECK_H td->blzcheck = AccountNumberCheck_new(); #endif builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-ab.glade", "Transaction Dialog"); td->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Transaction Dialog")); if (parent) gtk_window_set_transient_for(GTK_WINDOW(td->dialog), GTK_WINDOW(parent)); /* Extract widgets */ heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label")); recp_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_heading")); td->recp_name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_name_entry")); recp_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_heading")); td->recp_account_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_account_entry")); recp_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_heading")); td->recp_bankcode_entry = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankcode_entry")); td->recp_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "recp_bankname_label")); amount_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "amount_hbox")); td->purpose_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_entry")); td->purpose_cont_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont_entry")); td->purpose_cont2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont2_entry")); td->purpose_cont3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "purpose_cont3_entry")); orig_name_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_heading")); orig_name_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_name_label")); orig_account_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_heading")); orig_account_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_account_label")); orig_bankname_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_heading")); orig_bankname_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankname_label")); orig_bankcode_heading = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_heading")); orig_bankcode_label = GTK_WIDGET(gtk_builder_get_object (builder, "orig_bankcode_label")); td->template_gtktreeview = GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list")); /* Amount edit */ td->amount_edit = gnc_amount_edit_new(); gtk_box_pack_start_defaults(GTK_BOX(amount_hbox), td->amount_edit); gnc_amount_edit_set_evaluate_on_enter(GNC_AMOUNT_EDIT(td->amount_edit), TRUE); gnc_amount_edit_set_fraction(GNC_AMOUNT_EDIT(td->amount_edit), commodity_scu); /* Check for what kind of transaction this should be, and change the * labels accordingly */ switch (trans_type) { case SINGLE_TRANSFER: case SINGLE_INTERNAL_TRANSFER: /* all labels are already set */ break; case SINGLE_DEBITNOTE: gtk_label_set_text(GTK_LABEL (heading_label), /* Translators: Strings from this file are * needed only in countries that have one of * aqbanking's Online Banking techniques * available. This is 'OFX DirectConnect' * (U.S. and others), 'HBCI' (in Germany), * or 'YellowNet' (Switzerland). If none of * these techniques are available in your * country, you may safely ignore strings * from the import-export/hbci * subdirectory. */ _("Enter an Online Direct Debit Note")); gtk_label_set_text(GTK_LABEL(recp_name_heading), _("Debited Account Owner")); gtk_label_set_text(GTK_LABEL(recp_account_heading), _("Debited Account Number")); gtk_label_set_text(GTK_LABEL(recp_bankcode_heading), _("Debited Account Bank Code")); gtk_label_set_text(GTK_LABEL(orig_name_heading), _("Credited Account Owner")); gtk_label_set_text(GTK_LABEL(orig_account_heading), _("Credited Account Number")); gtk_label_set_text(GTK_LABEL(orig_bankcode_heading), _("Credited Account Bank Code")); break; default: g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d", trans_type); break; } gtk_label_set_text(GTK_LABEL(orig_name_label), ab_ownername); gtk_label_set_text(GTK_LABEL(orig_account_label), ab_accountnumber); gtk_label_set_text(GTK_LABEL(orig_bankname_label), ab_bankname); gtk_label_set_text (GTK_LABEL (orig_bankcode_label), ab_bankcode); /* Fill list for choosing a transaction template */ td->template_list_store = gtk_list_store_new(TEMPLATE_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER); g_list_foreach(templates, fill_templ_helper, td->template_list_store); gtk_tree_view_set_model(td->template_gtktreeview, GTK_TREE_MODEL(td->template_list_store)); td->templ_changed = FALSE; /* Keep a reference to the store */ /* Show this list */ renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes( "Template Name", renderer, "text", TEMPLATE_NAME, NULL); gtk_tree_view_append_column(td->template_gtktreeview, column); /* Connect the Signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, td); g_object_unref(G_OBJECT(builder)); return td; }
static void metadata_file_tests_test_properties (MetadataFileTests* self) { gchar* srcdir = NULL; const gchar* _tmp0_ = NULL; gchar* _tmp1_ = NULL; KkcMetadataFile* metadata = NULL; gchar* name = NULL; gchar* label = NULL; gchar* description = NULL; gchar* filename = NULL; GError * _inner_error_ = NULL; #line 57 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_return_if_fail (self != NULL); #line 58 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp0_ = g_getenv ("srcdir"); #line 58 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp1_ = g_strdup (_tmp0_); #line 58 "/home/ueno/devel/libkkc/tests/metadata-file.vala" srcdir = _tmp1_; #line 59 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _vala_assert (srcdir != NULL, "srcdir != null"); #line 421 "metadata-file.c" { EmptyMetadata* _tmp2_ = NULL; gchar* _tmp3_ = NULL; gchar* _tmp4_ = NULL; EmptyMetadata* _tmp5_ = NULL; EmptyMetadata* _tmp6_ = NULL; EmptyMetadata* _tmp7_ = NULL; #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp3_ = g_build_filename (srcdir, "metadata.json", NULL); #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp4_ = _tmp3_; #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp5_ = empty_metadata_new ("metadata", _tmp4_, &_inner_error_); #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp6_ = _tmp5_; #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (_tmp4_); #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp2_ = _tmp6_; #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" if (G_UNLIKELY (_inner_error_ != NULL)) { #line 443 "metadata-file.c" goto __catch2_g_error; } #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp7_ = _tmp2_; #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp2_ = NULL; #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_object_unref0 (metadata); #line 63 "/home/ueno/devel/libkkc/tests/metadata-file.vala" metadata = (KkcMetadataFile*) _tmp7_; #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_object_unref0 (_tmp2_); #line 456 "metadata-file.c" } goto __finally2; __catch2_g_error: { GError* e = NULL; #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" e = _inner_error_; #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _inner_error_ = NULL; #line 67 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_assert_not_reached (); #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_error_free0 (e); #line 470 "metadata-file.c" } __finally2: #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" if (G_UNLIKELY (_inner_error_ != NULL)) { #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_object_unref0 (metadata); #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (srcdir); #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" 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); #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_clear_error (&_inner_error_); #line 62 "/home/ueno/devel/libkkc/tests/metadata-file.vala" return; #line 485 "metadata-file.c" } #line 75 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_object_get ((GObject*) metadata, "name", &name, "label", &label, "description", &description, "filename", &filename, NULL); #line 57 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (filename); #line 57 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (description); #line 57 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (label); #line 57 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (name); #line 57 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_object_unref0 (metadata); #line 57 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (srcdir); #line 501 "metadata-file.c" }
bool run_test (void) { int result = 13; // pre handler add void *id = con_handler_add(CON_HANDLER_PRE, pre_handler, &result); con_buffer_add_string("test_pre_handler\n", true); if (result != 666) { g_critical("pre handler wasn't added"); return false; } // pre handler remove result = 13; con_handler_remove(id); con_buffer_add_string("test_pre_handler\n", true); if (result != 13) { g_critical("pre handler wasn't removed"); return false; } // post handler add id = con_handler_add(CON_HANDLER_POST, post_handler, &result); con_buffer_add_string("test_post_handler\n", true); if (result != 666) { g_critical("post handler wasn't added"); return false; } // post handler existing command result = 13; con_buffer_add_string("echo post handler should not run here\n", true); if (result != 13) { g_critical("post handler shouldn't be executed"); return false; } // post handler remove con_handler_remove(id); con_buffer_add_string("test_post_handler\n", true); if (result != 13) { g_critical("post handler wasn't removed"); return false; } // test value range con_var_t *c = con_var_get("test_cvar_range", "0", NULL, 0); con_var_set_clamp(c, -0.5, 1.5); con_var_set(c, "-1"); if (-0.5f != c->f || 0 != c->i || strcmp("-0.5", c->s)) { g_critical("got %.10g = %i = %s instead of -0.5 = 0 = -0.5", c->f, c->i, c->s); return false; } con_var_set(c, "2"); if (1.5f != c->f || 1 != c->i || strcmp("1.5", c->s)) { g_critical("got %.10g = %i = %s instead of 1.5 = 1 = 1.5", c->f, c->i, c->s); return false; } return true; }
static gint admin_reload_backends_if_necessary( network_mysqld_con* con ) { char command = -1; network_socket *recv_sock = con->client; GList *chunk = recv_sock->recv_queue->chunks->head; GString *packet = chunk->data; if (packet->len < NET_HEADER_SIZE) return EC_ADMIN_RELOAD_UNKNOWN; /* packet too short */ command = packet->str[NET_HEADER_SIZE + 0]; #ifdef _VINCHEN_TEST if (COM_QUERY == command) { gchar* cmd_str = NULL; cmd_str = g_strndup(&packet->str[NET_HEADER_SIZE + 1], packet->len - NET_HEADER_SIZE - 1); printf("query : %s\n", cmd_str); g_free(cmd_str); } else { printf("not a query : %d\n", command); } #endif // _VINCHEN_TEST /* not a query */ if (COM_QUERY != command) return EC_ADMIN_RELOAD_UNKNOWN; //刷新配置 if (packet->len - NET_HEADER_SIZE - 1 >= sizeof("refresh_backends('1.1.1.1:1')") - 1 && 0 == g_ascii_strncasecmp(packet->str + NET_HEADER_SIZE + 1, C("refresh_backends('"))) { gchar* back_str; gchar* p; gchar* s; gchar* p_end; gchar* cmd_str = NULL; gchar backend_buf[MAX_IP_PORT_STRING_LEN + 1]; int index = 0; GPtrArray* backend_array; gint ret; gint fail_flag; gchar fail_flag_buf[10]; gint fail_flag_ind = 0; gchar* fail_flag_err = NULL; cmd_str = g_strndup(&packet->str[NET_HEADER_SIZE + 1], packet->len - NET_HEADER_SIZE - 1); back_str = &packet->str[NET_HEADER_SIZE + 1 + sizeof("refrush_backends('") - 1]; p = back_str; backend_array = g_ptr_array_new(); p_end = packet->str + packet->len; while(p && *p != '\'' && p != p_end) { if (MAX_IP_PORT_STRING_LEN == index) { g_critical("%s: Refrush_backends error input %s", G_STRLOC, cmd_str); g_free(cmd_str); g_ptr_array_free_all(backend_array, g_free); return EC_ADMIN_RELOAD_FAIL; } else if (*p == ',') { if (index > 0) { backend_buf[index] = '\0'; g_ptr_array_add(backend_array, g_strdup(g_strstrip(backend_buf))); } index = 0; p++; continue; } backend_buf[index++] = *(p++); } if (index > 0) { backend_buf[index] = '\0'; g_ptr_array_add(backend_array, g_strdup(g_strstrip(backend_buf))); } if (p == p_end || *p != '\'') { g_ptr_array_free_all(backend_array, g_free); g_critical("%s: Refrush_backends error input %s", G_STRLOC, cmd_str); g_free(cmd_str); return EC_ADMIN_RELOAD_FAIL; } p++; //skip the space, \t while (p != p_end && g_ascii_isspace(*p)) p++; if (*p != ',') { g_ptr_array_free_all(backend_array, g_free); g_critical("%s: Refrush_backends error input %s", G_STRLOC, cmd_str); g_free(cmd_str); return EC_ADMIN_RELOAD_FAIL; } p++; if (NULL == (s = strchr(p, ')')) || s - p == 0) { g_ptr_array_free_all(backend_array, g_free); g_critical("%s: Refrush_backends error input %s", G_STRLOC, cmd_str); g_free(cmd_str); return EC_ADMIN_RELOAD_FAIL; } memcpy(fail_flag_buf, p, s-p); fail_flag_buf[s-p] = '\0'; g_strstrip(fail_flag_buf); fail_flag = strtoul(fail_flag_buf, &fail_flag_err, 10); if (fail_flag_err[0] != '\0') { g_critical("%s: IP-address and fail flag has to be in the form Refrush_backends('ip:port[;ip:port..]', fail_flag) %s. Failed to parse the fail_flag at '%s'", G_STRLOC, cmd_str, fail_flag_err); g_free(cmd_str); ret = EC_ADMIN_RELOAD_FAIL; return ret; } g_critical("%s: Executing %s", G_STRLOC, cmd_str); //backend_buf should by ip:port, to be new backend; ret = admin_reload_backends(con, backend_array, fail_flag); g_ptr_array_free_all(backend_array, g_free); return ret; } return EC_ADMIN_RELOAD_UNKNOWN; }
static void metadata_file_tests_test_load (MetadataFileTests* self) { #line 20 "/home/ueno/devel/libkkc/tests/metadata-file.vala" static const gchar* good[] = {"metadata"}; #line 24 "/home/ueno/devel/libkkc/tests/metadata-file.vala" static const gchar* bad[] = {"metadata-bad1", "metadata-bad2", "metadata-bad3", "metadata-bad4"}; #line 201 "metadata-file.c" gchar* srcdir = NULL; const gchar* _tmp0_ = NULL; gchar* _tmp1_ = NULL; const gchar* _tmp2_ = NULL; GError * _inner_error_ = NULL; #line 19 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_return_if_fail (self != NULL); #line 31 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp0_ = g_getenv ("srcdir"); #line 31 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp1_ = g_strdup (_tmp0_); #line 31 "/home/ueno/devel/libkkc/tests/metadata-file.vala" srcdir = _tmp1_; #line 32 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp2_ = srcdir; #line 32 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _vala_assert (_tmp2_ != NULL, "srcdir != null"); #line 219 "metadata-file.c" { const gchar** name_collection = NULL; gint name_collection_length1 = 0; gint _name_collection_size_ = 0; gint name_it = 0; #line 34 "/home/ueno/devel/libkkc/tests/metadata-file.vala" name_collection = good; #line 34 "/home/ueno/devel/libkkc/tests/metadata-file.vala" name_collection_length1 = G_N_ELEMENTS (good); #line 34 "/home/ueno/devel/libkkc/tests/metadata-file.vala" for (name_it = 0; name_it < G_N_ELEMENTS (good); name_it = name_it + 1) { #line 231 "metadata-file.c" const gchar* name = NULL; #line 34 "/home/ueno/devel/libkkc/tests/metadata-file.vala" name = name_collection[name_it]; #line 235 "metadata-file.c" { { const gchar* _tmp3_ = NULL; const gchar* _tmp4_ = NULL; const gchar* _tmp5_ = NULL; gchar* _tmp6_ = NULL; gchar* _tmp7_ = NULL; gchar* _tmp8_ = NULL; gchar* _tmp9_ = NULL; EmptyMetadata* _tmp10_ = NULL; EmptyMetadata* _tmp11_ = NULL; #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp3_ = name; #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp4_ = srcdir; #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp5_ = name; #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp6_ = g_strconcat (_tmp5_, ".json", NULL); #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp7_ = _tmp6_; #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp8_ = g_build_filename (_tmp4_, _tmp7_, NULL); #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp9_ = _tmp8_; #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp10_ = empty_metadata_new (_tmp3_, _tmp9_, &_inner_error_); #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp11_ = _tmp10_; #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_object_unref0 (_tmp11_); #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (_tmp9_); #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (_tmp7_); #line 36 "/home/ueno/devel/libkkc/tests/metadata-file.vala" if (G_UNLIKELY (_inner_error_ != NULL)) { #line 273 "metadata-file.c" goto __catch0_g_error; } } goto __finally0; __catch0_g_error: { GError* e = NULL; #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" e = _inner_error_; #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _inner_error_ = NULL; #line 41 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_assert_not_reached (); #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_error_free0 (e); #line 289 "metadata-file.c" } __finally0: #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" if (G_UNLIKELY (_inner_error_ != NULL)) { #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (srcdir); #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" 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); #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_clear_error (&_inner_error_); #line 35 "/home/ueno/devel/libkkc/tests/metadata-file.vala" return; #line 302 "metadata-file.c" } } } } { const gchar** name_collection = NULL; gint name_collection_length1 = 0; gint _name_collection_size_ = 0; gint name_it = 0; #line 45 "/home/ueno/devel/libkkc/tests/metadata-file.vala" name_collection = bad; #line 45 "/home/ueno/devel/libkkc/tests/metadata-file.vala" name_collection_length1 = G_N_ELEMENTS (bad); #line 45 "/home/ueno/devel/libkkc/tests/metadata-file.vala" for (name_it = 0; name_it < G_N_ELEMENTS (bad); name_it = name_it + 1) { #line 318 "metadata-file.c" const gchar* name = NULL; #line 45 "/home/ueno/devel/libkkc/tests/metadata-file.vala" name = name_collection[name_it]; #line 322 "metadata-file.c" { { const gchar* _tmp12_ = NULL; const gchar* _tmp13_ = NULL; const gchar* _tmp14_ = NULL; gchar* _tmp15_ = NULL; gchar* _tmp16_ = NULL; gchar* _tmp17_ = NULL; gchar* _tmp18_ = NULL; EmptyMetadata* _tmp19_ = NULL; EmptyMetadata* _tmp20_ = NULL; #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp12_ = name; #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp13_ = srcdir; #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp14_ = name; #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp15_ = g_strconcat (_tmp14_, ".json", NULL); #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp16_ = _tmp15_; #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp17_ = g_build_filename (_tmp13_, _tmp16_, NULL); #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp18_ = _tmp17_; #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp19_ = empty_metadata_new (_tmp12_, _tmp18_, &_inner_error_); #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _tmp20_ = _tmp19_; #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_object_unref0 (_tmp20_); #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (_tmp18_); #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (_tmp16_); #line 47 "/home/ueno/devel/libkkc/tests/metadata-file.vala" if (G_UNLIKELY (_inner_error_ != NULL)) { #line 360 "metadata-file.c" goto __catch1_g_error; } #line 51 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_assert_not_reached (); #line 365 "metadata-file.c" } goto __finally1; __catch1_g_error: { GError* e = NULL; #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" e = _inner_error_; #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _inner_error_ = NULL; #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_error_free0 (e); #line 377 "metadata-file.c" } __finally1: #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" if (G_UNLIKELY (_inner_error_ != NULL)) { #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (srcdir); #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" 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); #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" g_clear_error (&_inner_error_); #line 46 "/home/ueno/devel/libkkc/tests/metadata-file.vala" return; #line 390 "metadata-file.c" } } } } #line 19 "/home/ueno/devel/libkkc/tests/metadata-file.vala" _g_free0 (srcdir); #line 397 "metadata-file.c" }
static gint admin_reload_backends( network_mysqld_con* con, GPtrArray* backend_addr_str_array, gint fail_flag ) { chassis* srv; network_backends_t* backends; GPtrArray* cons; gchar* s; gchar* new_backend_addr; guint i; //gchar ip_address[MAX_IP_PORT_STRING_LEN + 1]; admin_network_addr_t* addr; GPtrArray* addr_array; gint ret = EC_ADMIN_RELOAD_SUCCESS; gboolean all_same_flag = 1; guint server_cnt = 0; guint client_cnt = 0; srv = con->srv; backends = srv->priv->backends; cons = srv->priv->cons; //for test if (fail_flag == 1000) { admin_print_all_backend_cons(con->srv); return EC_ADMIN_RELOAD_SUCCESS; } if (backend_addr_str_array->len != backends->backends->len) { g_critical("%s: Number of refresh backends num is not matched, new backends :%d, orignal backends : %d", G_STRLOC, backend_addr_str_array->len , backends->backends->len); return EC_ADMIN_RELOAD_FAIL; } if (fail_flag != 0 && fail_flag != 1) { g_critical("%s: Fail flag of refresh backends must be 0 or 1, but the flag is %d", G_STRLOC, fail_flag); return EC_ADMIN_RELOAD_FAIL; } addr_array = g_ptr_array_new(); /* 1. 测试DR连通性 */ for (i = 0; i < backend_addr_str_array->len; ++i) { new_backend_addr = g_ptr_array_index(backend_addr_str_array, i); addr = g_new0(admin_network_addr_t, 1); g_ptr_array_add(addr_array, addr); s = strchr(new_backend_addr, ':'); if (NULL != s) { gint len; char * port_err = NULL; network_backend_t* backend; backend = g_ptr_array_index(backends->backends, i); //check whether all backends are same //to do check backend:127.0.0.1:3306, addr:ip:3306? if (all_same_flag && g_strcasecmp(new_backend_addr, backend->addr->name->str) != 0 || backend->state == BACKEND_STATE_DOWN) { all_same_flag = 0; } len = s - new_backend_addr; if (len <= MAX_IP_PORT_STRING_LEN) { memcpy(addr->ip_address, new_backend_addr, len); addr->ip_address[len] = '\0'; addr->port = strtoul(s + 1, &port_err, 10); } if (len > MAX_IP_PORT_STRING_LEN || *(s + 1) == '\0') { g_critical("%s: Reload IP-address has to be in the form [<ip>][:<port>], is '%s'. No port number", G_STRLOC, new_backend_addr); ret = EC_ADMIN_RELOAD_FAIL; } else if (*port_err != '\0') { g_critical("%s: Reload IP-address has to be in the form [<ip>][:<port>], is '%s'. Failed to parse the port at '%s'", G_STRLOC, new_backend_addr, port_err); ret = EC_ADMIN_RELOAD_FAIL; } else { addr->addr = network_address_new(); if (network_address_set_address_ip(addr->addr, addr->ip_address, addr->port)) { g_critical("%s: Reload IP-address %s : %d error", G_STRLOC, addr->ip_address, addr->port); ret = EC_ADMIN_RELOAD_FAIL; } //ping the ip address and port; //ret = network_address_set_address_ip(addr, ip_address, port); //to do } } else ret = EC_ADMIN_RELOAD_FAIL; if (EC_ADMIN_RELOAD_FAIL == ret) { g_ptr_array_free_all(addr_array, admin_network_addr_free); return ret; } } //backends are same if (all_same_flag) { g_ptr_array_free_all(addr_array, admin_network_addr_free); return EC_ADMIN_RELOAD_SUCCESS; } /* 2. 置当前所有backends为down */ g_mutex_lock(backends->backends_mutex); for (i = 0; i < backends->backends->len; ++i) { network_backend_t* backend; backend = g_ptr_array_index(backends->backends, i); backend->state = BACKEND_STATE_DOWN; } g_mutex_unlock(backends->backends_mutex); /* 3. 当前backend为新地址 */ g_mutex_lock(backends->backends_mutex); for (i = 0; i < backends->backends->len; ++i) { network_backend_t* backend; backend = g_ptr_array_index(backends->backends, i); addr = g_ptr_array_index(addr_array, i); network_address_copy(backend->addr, addr->addr); // backend->addr->name->len = 0; /* network refresh name */ // // if (network_address_set_address_ip(backend->addr, addr->ip_address, addr->port)) // { // g_critical("%s: Reload IP-address %s : %d error" // G_STRLOC, addr->ip_address, addr->port); // ret = EC_ADMIN_RELOAD_FAIL; // // break; // } } g_mutex_unlock(backends->backends_mutex); /* 4. 关闭proxy当前所有连接 */ g_mutex_lock(srv->priv->cons_mutex); for (i = 0; i < cons->len; ++i) { con = g_ptr_array_index(cons, i); //区分了是否为backends的连接 if (con->server && con->server->backend_idx != -1) { //g_assert(con->server->fd != -1); if (con->server->fd != -1) { //closesocket(con->server->fd); con->server->fd_bak = con->server->fd; /* 后端连接暂不关闭,让其正常处理正在进行的事件 */ con->server->fd = -1; con->server->disconnect_flag = 1; server_cnt++; } //g_assert(con->client && con->client->fd != -1); if (con->client && con->client->fd != -1) { // int c_fd = con->client->fd; // con->client->fd = -1; // closesocket(c_fd); /* 需主动关闭前端fd,防止前端一直等待,但会导致con资源没有释放 */ client_cnt++; } /* 以上操作可能产生一种情况:客户端请求已在DB执行成功,但前端认为连接已断开 */ switch(con->state) { case CON_STATE_CLOSE_CLIENT: case CON_STATE_CLOSE_SERVER: case CON_STATE_SEND_ERROR: case CON_STATE_ERROR: break; case CON_STATE_INIT: case CON_STATE_CONNECT_SERVER: case CON_STATE_READ_HANDSHAKE: case CON_STATE_SEND_HANDSHAKE: case CON_STATE_READ_AUTH: case CON_STATE_SEND_AUTH: case CON_STATE_READ_AUTH_RESULT: case CON_STATE_SEND_AUTH_RESULT: case CON_STATE_READ_AUTH_OLD_PASSWORD: case CON_STATE_SEND_AUTH_OLD_PASSWORD: break; case CON_STATE_READ_QUERY: case CON_STATE_SEND_QUERY: break; case CON_STATE_READ_QUERY_RESULT: case CON_STATE_SEND_QUERY_RESULT: // //需要主动关闭连接 // if (fail_flag == 1) // { // if (con->client->fd != -1) // { // closesocket(con->client->fd); // con->client->fd = -1; // } // } break; case CON_STATE_READ_LOCAL_INFILE_DATA: case CON_STATE_SEND_LOCAL_INFILE_DATA: case CON_STATE_READ_LOCAL_INFILE_RESULT: case CON_STATE_SEND_LOCAL_INFILE_RESULT: break; } } } g_message("%s reload backends: connection count %d, close server count %d, close client count %d", G_STRLOC, srv->priv->cons->len, server_cnt, client_cnt); g_mutex_unlock(srv->priv->cons_mutex); if (ret != EC_ADMIN_RELOAD_SUCCESS) goto destroy_end; /* 5. 再把后端状态置为unknown,接收新连接 */ g_mutex_lock(backends->backends_mutex); for (i = 0; i < backends->backends->len; ++i) { network_backend_t* backend; backend = g_ptr_array_index(backends->backends, i); backend->state = BACKEND_STATE_UNKNOWN; } g_mutex_unlock(backends->backends_mutex); /* 6. 刷新配置 */ ret = admin_configure_flush_to_file(srv); destroy_end: g_ptr_array_free_all(addr_array, admin_network_addr_free); return ret; }
int admin_configure_flush_to_file( chassis* srv ) { GString* new_str = NULL; GString* backends_str = NULL; GString* r_backends_str = NULL; // gint backends_cnt = 0; // gint r_backends_cnt = 0; gchar buf[65535]; gchar plugins_buf[1000]; guint i; chassis_plugin* plugin; chassis_plugin* admin_plugin = NULL; chassis_plugin* proxy_plugin = NULL; // network_backend_t* backend = NULL; // struct chassis_proxy_plugin_config* proxy_config; FILE* ini_file = NULL; int ret; if (!srv->default_file) return EC_ADMIN_RELOAD_NO_CONS_FILE; new_str = g_string_new_len(NULL, 100000); g_string_append(new_str, ini_str_header); g_assert(srv->modules->len <= 2); //find plugins for (i = 0; i < srv->modules->len; ++i) { plugin = g_ptr_array_index(srv->modules, i); if (strcmp(plugin->name, "admin") == 0) admin_plugin = plugin; else if (strcmp(plugin->name, "proxy") == 0) proxy_plugin = plugin; else g_assert(0); if (i == 0) strcpy(plugins_buf, plugin->name); else { strcat(plugins_buf, ", "); strcat(plugins_buf, plugin->name); } } //find_backends // for (i = 0; i < srv->priv->backends->backends->len; ++i) // { // backend = g_ptr_array_index(srv->priv->backends->backends, i); // if (backend->type == BACKEND_TYPE_RW) // { // if (backends_cnt++ == 0) // { // backends_str = g_string_new_len(NULL, 100); // g_string_append(backends_str, backend->addr->name->str); // } // else // { // g_assert(backends_str); // g_string_append(backends_str, ","); // g_string_append(backends_str, backend->addr->name->str); // } // } // else if (backend->type == BACKEND_TYPE_RO) // { // if (r_backends_cnt++ == 0) // { // r_backends_str = g_string_new_len(NULL, 100); // g_string_append(r_backends_str, backend->addr->name->str); // } // else // { // g_assert(r_backends_str); // g_string_append(r_backends_str, ","); // g_string_append(r_backends_str, backend->addr->name->str); // } // } // else // g_assert(0); // } g_assert(proxy_plugin != NULL); ///////////////////admin if (admin_plugin != NULL) { admin_plugin->get_ini_str(buf, 65535, admin_plugin->config, srv); g_string_append(new_str, buf); } ///////////////////proxy if (proxy_plugin != NULL) { proxy_plugin->get_ini_str(buf, 65535, proxy_plugin->config, srv); g_string_append(new_str, buf); } // proxy_config = (struct chassis_proxy_plugin_config*)proxy_plugin->config; // // sprintf(buf, ini_str_proxy1, // proxy_plugin ? "" : "#", proxy_plugin ? proxy_config->address : "0.0.0.0:4040", // proxy_plugin && backends_str ? "" : "#", proxy_plugin && backends_str ? backends_str->str : "ip:port", // proxy_plugin && r_backends_str ? "" : "#", proxy_plugin && r_backends_str ? r_backends_str->str : "ip:port", // proxy_plugin && proxy_config->lua_script ? "" : "#", proxy_plugin && proxy_config->lua_script ? proxy_config->lua_script : "file_name"); // // g_string_append(new_str, buf); // // sprintf(buf, ini_str_proxy2, // proxy_plugin && proxy_config->fix_bug_25371 ? "" : "#", // proxy_plugin && proxy_config->pool_change_user == 0 ? "" : "#", // proxy_plugin && proxy_config->profiling == 0 ? "" : "#", // proxy_plugin && proxy_config->start_proxy == 0 ? "" : "#"); // g_string_append(new_str, buf); ///////////////////app g_assert(srv->event_thread_count > 0); sprintf(buf, ini_str_app1, srv->base_dir_org ? "" : "#", srv->base_dir_org ? srv->base_dir_org : "base_dir_path", "", srv->event_thread_count, srv->log_file_name_org ? "" : "#", srv->log_file_name_org ? srv->log_file_name_org : "log_file_name", "", chassis_log_get_level_name(srv->log->min_lvl), "", plugins_buf, #ifndef _WIN32 srv->auto_restart ? "" : "#", srv->daemon_mode ? "" : "#"); #else "#", "#"); #endif g_string_append(new_str, buf); sprintf(buf, ini_str_app2, srv->max_files_number ? "" : "#", srv->max_files_number ? srv->max_files_number : 0, srv->lua_cpath_org ? "" : "#", srv->lua_cpath_org ? srv->lua_cpath_org : "dir_name", srv->lua_path_org ? "" : "#", srv->lua_path_org ? srv->lua_path_org : "dir_name", srv->invoke_dbg_on_crash ? "" : "#", srv->log->use_syslog ? "" : "#", srv->pid_file_org ? "" : "#", srv->pid_file_org ? srv->pid_file_org : "file_name", srv->plugin_dir_org ? "" : "#", srv->plugin_dir_org ? srv->plugin_dir_org : "dir_name", srv->user ? "" : "#", srv->user ? srv->user : "******"); g_string_append(new_str, buf); // if (backends_str) // g_string_free(backends_str, TRUE); // // if (r_backends_str) // g_string_free(r_backends_str, TRUE); g_assert (srv->default_file); ini_file = fopen(srv->default_file, "w+"); if (NULL == ini_file) { g_string_free(new_str, TRUE); g_critical("%s: Can't open ini file %s", G_STRLOC, srv->default_file); return EC_ADMIN_RELOAD_WIRTE_FILE_FAIL; } if (fprintf(ini_file, new_str->str) < 0) ret = EC_ADMIN_RELOAD_WIRTE_FILE_FAIL; else ret = EC_ADMIN_RELOAD_SUCCESS; fclose(ini_file); g_string_free(new_str, TRUE); return ret; }
static network_mysqld_lua_stmt_ret admin_lua_read_query(network_mysqld_con *con) { network_mysqld_con_lua_t *st = con->plugin_con_state; char command = -1; network_socket *recv_sock = con->client; GList *chunk = recv_sock->recv_queue->chunks->head; GString *packet = chunk->data; if (packet->len < NET_HEADER_SIZE) return PROXY_SEND_QUERY; /* packet too short */ command = packet->str[NET_HEADER_SIZE + 0]; if (COM_QUERY == command) { /* we need some more data after the COM_QUERY */ if (packet->len < NET_HEADER_SIZE + 2) return PROXY_SEND_QUERY; /* LOAD DATA INFILE is nasty */ if (packet->len - NET_HEADER_SIZE - 1 >= sizeof("LOAD ") - 1 && 0 == g_ascii_strncasecmp(packet->str + NET_HEADER_SIZE + 1, C("LOAD "))) return PROXY_SEND_QUERY; } network_injection_queue_reset(st->injected.queries); /* ok, here we go */ #ifdef HAVE_LUA_H switch(network_mysqld_con_lua_register_callback(con, con->config->lua_script)) { case REGISTER_CALLBACK_SUCCESS: break; case REGISTER_CALLBACK_LOAD_FAILED: network_mysqld_con_send_error(con->client, C("MySQL Proxy Lua script failed to load. Check the error log.")); con->state = CON_STATE_SEND_ERROR; return PROXY_SEND_RESULT; case REGISTER_CALLBACK_EXECUTE_FAILED: network_mysqld_con_send_error(con->client, C("MySQL Proxy Lua script failed to execute. Check the error log.")); con->state = CON_STATE_SEND_ERROR; return PROXY_SEND_RESULT; } if (st->L) { lua_State *L = st->L; network_mysqld_lua_stmt_ret ret = PROXY_NO_DECISION; g_assert(lua_isfunction(L, -1)); lua_getfenv(L, -1); g_assert(lua_istable(L, -1)); /** * reset proxy.response to a empty table */ lua_getfield(L, -1, "proxy"); g_assert(lua_istable(L, -1)); lua_newtable(L); lua_setfield(L, -2, "response"); lua_pop(L, 1); /** * get the call back */ lua_getfield_literal(L, -1, C("read_query")); if (lua_isfunction(L, -1)) { /* pass the packet as parameter */ lua_pushlstring(L, packet->str + NET_HEADER_SIZE, packet->len - NET_HEADER_SIZE); if (lua_pcall(L, 1, 1, 0) != 0) { /* hmm, the query failed */ g_critical("(read_query) %s", lua_tostring(L, -1)); lua_pop(L, 2); /* fenv + errmsg */ /* perhaps we should clean up ?*/ return PROXY_SEND_QUERY; } else { if (lua_isnumber(L, -1)) { ret = lua_tonumber(L, -1); } lua_pop(L, 1); } switch (ret) { case PROXY_SEND_RESULT: /* check the proxy.response table for content, * */ if (network_mysqld_con_lua_handle_proxy_response(con, con->config->lua_script)) { /** * handling proxy.response failed * * send a ERR packet */ network_mysqld_con_send_error(con->client, C("(lua) handling proxy.response failed, check error-log")); } break; case PROXY_NO_DECISION: /** * PROXY_NO_DECISION and PROXY_SEND_QUERY may pick another backend */ break; case PROXY_SEND_QUERY: /* send the injected queries * * injection_new(..., query); * * */ if (st->injected.queries->length) { ret = PROXY_SEND_INJECTION; } break; default: break; } lua_pop(L, 1); /* fenv */ } else { lua_pop(L, 2); /* fenv + nil */ } g_assert(lua_isfunction(L, -1)); if (ret != PROXY_NO_DECISION) { return ret; } } #endif return PROXY_NO_DECISION; }
gint ease_main_main (char** args, int args_length1) { #line 383 "ease-main.c" gint result = 0; GOptionContext* context; UniqueApp* _tmp1_; gboolean _tmp2_; gboolean running; gboolean _tmp7_ = FALSE; GError * _inner_error_ = NULL; #line 61 "ease-main.vala" g_set_application_name ("Ease"); #line 62 "ease-main.vala" gtk_window_set_default_icon_name ("ease"); #line 65 "ease-main.vala" context = g_option_context_new (_ (" - a presentation editor")); #line 68 "ease-main.vala" g_option_context_add_main_entries (context, EASE_MAIN_options, NULL); #line 71 "ease-main.vala" g_option_context_add_group (context, gtk_get_option_group (TRUE)); #line 72 "ease-main.vala" g_option_context_add_group (context, clutter_get_option_group ()); #line 403 "ease-main.c" { gboolean _tmp0_; #line 76 "ease-main.vala" _tmp0_ = g_option_context_parse (context, &args_length1, &args, &_inner_error_); #line 408 "ease-main.c" if (_inner_error_ != NULL) { if (_inner_error_->domain == G_OPTION_ERROR) { goto __catch12_g_option_error; } _g_option_context_free0 (context); g_critical ("file %s: line %d: unexpected 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 0; } #line 76 "ease-main.vala" if (!_tmp0_) { #line 420 "ease-main.c" result = 1; _g_option_context_free0 (context); #line 76 "ease-main.vala" return result; #line 425 "ease-main.c" } } goto __finally12; __catch12_g_option_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { #line 80 "ease-main.vala" fprintf (stdout, _ ("error parsing options: %s\n"), e->message); #line 437 "ease-main.c" result = 1; _g_error_free0 (e); _g_option_context_free0 (context); #line 81 "ease-main.vala" return result; #line 443 "ease-main.c" } } __finally12: if (_inner_error_ != NULL) { _g_option_context_free0 (context); 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 0; } #line 85 "ease-main.vala" ease_main_app = (_tmp1_ = unique_app_new ("org.ease-project.ease", NULL), _g_object_unref0 (ease_main_app), _tmp1_); #line 86 "ease-main.vala" unique_app_add_command (ease_main_app, "Open document", (gint) EASE_MAIN_UNIQUE_COMMAND_OPEN_FILE); #line 87 "ease-main.vala" unique_app_add_command (ease_main_app, "Play document", (gint) EASE_MAIN_UNIQUE_COMMAND_PLAY_FILE); #line 88 "ease-main.vala" unique_app_add_command (ease_main_app, "Create new document", (gint) EASE_MAIN_UNIQUE_COMMAND_SHOW_WELCOME); #line 91 "ease-main.vala" running = (g_object_get (ease_main_app, "is-running", &_tmp2_, NULL), _tmp2_); #line 93 "ease-main.vala" if (!running) { #line 465 "ease-main.c" GeeArrayList* _tmp3_; ClutterBackend* backend; GtkSettings* settings; gint _tmp4_; gint _tmp5_; #line 96 "ease-main.vala" g_signal_connect (ease_main_app, "message-received", (GCallback) __lambda65__unique_app_message_received, NULL); #line 120 "ease-main.vala" gst_init (&args_length1, &args); #line 123 "ease-main.vala" ease_undo_controller_set_enable_debug (ease_main_debug_undo); #line 126 "ease-main.vala" ease_main_windows = (_tmp3_ = gee_array_list_new (EASE_MAIN_TYPE_EDITOR_WINDOW_INFO, (GBoxedCopyFunc) ease_main_editor_window_info_ref, ease_main_editor_window_info_unref, NULL), _g_object_unref0 (ease_main_windows), _tmp3_); #line 129 "ease-main.vala" backend = _g_object_ref0 (clutter_get_default_backend ()); #line 130 "ease-main.vala" settings = _g_object_ref0 (gtk_settings_get_default ()); #line 131 "ease-main.vala" clutter_backend_set_double_click_time (backend, (guint) (g_object_get (settings, "gtk-double-click-time", &_tmp4_, NULL), _tmp4_)); #line 132 "ease-main.vala" clutter_backend_set_double_click_distance (backend, (guint) (g_object_get (settings, "gtk-double-click-distance", &_tmp5_, NULL), _tmp5_)); #line 487 "ease-main.c" _g_object_unref0 (settings); _g_object_unref0 (backend); } #line 137 "ease-main.vala" if (ease_main_filenames != NULL) { #line 139 "ease-main.vala" if (!running) { #line 495 "ease-main.c" { gint i; #line 141 "ease-main.vala" i = 0; #line 500 "ease-main.c" { gboolean _tmp6_; #line 141 "ease-main.vala" _tmp6_ = TRUE; #line 141 "ease-main.vala" while (TRUE) { #line 141 "ease-main.vala" if (!_tmp6_) { #line 141 "ease-main.vala" i++; #line 511 "ease-main.c" } #line 141 "ease-main.vala" _tmp6_ = FALSE; #line 141 "ease-main.vala" if (!(ease_main_filenames[i] != NULL)) { #line 141 "ease-main.vala" break; #line 519 "ease-main.c" } #line 143 "ease-main.vala" ease_main_open_file (ease_main_filenames[i]); #line 523 "ease-main.c" } } } } else { UniqueMessageData* data; #line 148 "ease-main.vala" data = unique_message_data_new (); #line 149 "ease-main.vala" unique_message_data_set_uris (data, ease_main_filenames); #line 150 "ease-main.vala" unique_app_send_message (ease_main_app, (gint) EASE_MAIN_UNIQUE_COMMAND_OPEN_FILE, data); #line 535 "ease-main.c" _unique_message_data_free0 (data); } } #line 155 "ease-main.vala" if (ease_main_play_filename != NULL) { #line 157 "ease-main.vala" if (!running) { #line 159 "ease-main.vala" ease_main_play_file (ease_main_play_filename, ease_main_filenames == NULL); #line 545 "ease-main.c" } else { UniqueMessageData* data; #line 163 "ease-main.vala" data = unique_message_data_new (); #line 164 "ease-main.vala" unique_message_data_set_filename (data, ease_main_play_filename); #line 165 "ease-main.vala" unique_app_send_message (ease_main_app, (gint) EASE_MAIN_UNIQUE_COMMAND_PLAY_FILE, data); #line 554 "ease-main.c" _unique_message_data_free0 (data); } } #line 170 "ease-main.vala" if (ease_main_filenames == NULL) { #line 170 "ease-main.vala" _tmp7_ = ease_main_play_filename == NULL; #line 562 "ease-main.c" } else { #line 170 "ease-main.vala" _tmp7_ = FALSE; #line 566 "ease-main.c" } #line 170 "ease-main.vala" if (_tmp7_) { #line 172 "ease-main.vala" if (!running) { #line 172 "ease-main.vala" ease_main_show_welcome (); #line 574 "ease-main.c" } else { #line 173 "ease-main.vala" unique_app_send_message (ease_main_app, (gint) EASE_MAIN_UNIQUE_COMMAND_SHOW_WELCOME, NULL); #line 578 "ease-main.c" } } #line 177 "ease-main.vala" if (running) { #line 583 "ease-main.c" result = 0; _g_option_context_free0 (context); #line 177 "ease-main.vala" return result; #line 588 "ease-main.c" } #line 179 "ease-main.vala" gtk_main (); #line 181 "ease-main.vala" ease_temp_clean (); #line 594 "ease-main.c" result = 0; _g_option_context_free0 (context); #line 183 "ease-main.vala" return result; #line 599 "ease-main.c" }
/** * Automatic attempt to find out where you are using: * 1. http://www.hostip.info ++ * 2. if not specific enough fallback to using the default goto tool with a country name * ++ Using returned JSON information * c.f. with googlesearch.c - similar implementation is used here * * returns: * 0 if failed to locate anything * 1 if exact latitude/longitude found * 2 if position only as precise as a city * 3 if position only as precise as a country * @name: Contains the name of place found. Free this string after use. */ gint a_vik_goto_where_am_i ( VikViewport *vvp, struct LatLon *ll, gchar **name ) { gint result = 0; *name = NULL; gchar *tmpname = a_download_uri_to_tmp_file ( "http://api.hostip.info/get_json.php?position=true", NULL ); //gchar *tmpname = g_strdup ("../test/hostip2.json"); if (!tmpname) { return result; } ll->lat = 0.0; ll->lon = 0.0; gchar *pat; GMappedFile *mf; gchar *ss; gint fragment_len; gchar lat_buf[32], lon_buf[32]; lat_buf[0] = lon_buf[0] = '\0'; gchar *country = NULL; gchar *city = NULL; if ((mf = g_mapped_file_new(tmpname, FALSE, NULL)) == NULL) { g_critical(_("couldn't map temp file")); goto tidy; } gsize len = g_mapped_file_get_length(mf); gchar *text = g_mapped_file_get_contents(mf); if ((pat = g_strstr_len(text, len, HOSTIP_COUNTRY_PATTERN))) { pat += strlen(HOSTIP_COUNTRY_PATTERN); fragment_len = 0; ss = pat; while (*pat != '"') { fragment_len++; pat++; } country = g_strndup(ss, fragment_len); } if ((pat = g_strstr_len(text, len, HOSTIP_CITY_PATTERN))) { pat += strlen(HOSTIP_CITY_PATTERN); fragment_len = 0; ss = pat; while (*pat != '"') { fragment_len++; pat++; } city = g_strndup(ss, fragment_len); } if ((pat = g_strstr_len(text, len, HOSTIP_LATITUDE_PATTERN))) { pat += strlen(HOSTIP_LATITUDE_PATTERN); ss = lat_buf; if (*pat == '-') *ss++ = *pat++; while ((ss < (lat_buf + sizeof(lat_buf))) && (pat < (text + len)) && (g_ascii_isdigit(*pat) || (*pat == '.'))) *ss++ = *pat++; *ss = '\0'; ll->lat = g_ascii_strtod(lat_buf, NULL); } if ((pat = g_strstr_len(text, len, HOSTIP_LONGITUDE_PATTERN))) { pat += strlen(HOSTIP_LONGITUDE_PATTERN); ss = lon_buf; if (*pat == '-') *ss++ = *pat++; while ((ss < (lon_buf + sizeof(lon_buf))) && (pat < (text + len)) && (g_ascii_isdigit(*pat) || (*pat == '.'))) *ss++ = *pat++; *ss = '\0'; ll->lon = g_ascii_strtod(lon_buf, NULL); } if ( ll->lat != 0.0 && ll->lon != 0.0 ) { if ( ll->lat > -90.0 && ll->lat < 90.0 && ll->lon > -180.0 && ll->lon < 180.0 ) { // Found a 'sensible' & 'precise' location result = 1; *name = g_strdup ( _("Locality") ); //Albeit maybe not known by an actual name! } } else { // Hopefully city name is unique enough to lookup position on // Maybe for American places where hostip appends the State code on the end // But if the country code is not appended if could easily get confused // e.g. 'Portsmouth' could be at least // Portsmouth, Hampshire, UK or // Portsmouth, Viginia, USA. // Try city name lookup if ( city ) { g_debug ( "%s: found city %s", __FUNCTION__, city ); if ( strcmp ( city, "(Unknown city)" ) != 0 ) { VikCoord new_center; if ( vik_goto_place ( NULL, vvp, city, &new_center ) ) { // Got something vik_coord_to_latlon ( &new_center, ll ); result = 2; *name = city; goto tidy; } } } // Try country name lookup if ( country ) { g_debug ( "%s: found country %s", __FUNCTION__, country ); if ( strcmp ( country, "(Unknown Country)" ) != 0 ) { VikCoord new_center; if ( vik_goto_place ( NULL, vvp, country, &new_center ) ) { // Finally got something vik_coord_to_latlon ( &new_center, ll ); result = 3; *name = country; goto tidy; } } } } tidy: g_mapped_file_unref ( mf ); g_remove ( tmpname ); g_free ( tmpname ); return result; }
void ease_main_open_file (const char* path) { #line 626 "ease-main.c" GError * _inner_error_ = NULL; #line 195 "ease-main.vala" g_return_if_fail (path != NULL); #line 630 "ease-main.c" { GeeIterator* _info_it; #line 197 "ease-main.vala" _info_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) ease_main_windows); #line 197 "ease-main.vala" while (TRUE) { #line 637 "ease-main.c" EaseMainEditorWindowInfo* info; char* _tmp0_; char* _tmp1_; gboolean _tmp2_; #line 197 "ease-main.vala" if (!gee_iterator_next (_info_it)) { #line 197 "ease-main.vala" break; #line 646 "ease-main.c" } #line 197 "ease-main.vala" info = (EaseMainEditorWindowInfo*) gee_iterator_get (_info_it); #line 199 "ease-main.vala" if ((_tmp2_ = _vala_strcmp0 (_tmp0_ = ease_absolute_path (ease_document_get_filename (info->window->document)), _tmp1_ = ease_absolute_path (path)) == 0, _g_free0 (_tmp1_), _g_free0 (_tmp0_), _tmp2_)) { #line 202 "ease-main.vala" gtk_window_present ((GtkWindow*) info->window); #line 654 "ease-main.c" _ease_main_editor_window_info_unref0 (info); _g_object_unref0 (_info_it); #line 203 "ease-main.vala" return; #line 659 "ease-main.c" } _ease_main_editor_window_info_unref0 (info); } _g_object_unref0 (_info_it); } { EaseDocument* doc; EaseEditorWindow* win; #line 209 "ease-main.vala" doc = ease_document_new_from_saved (path, &_inner_error_); #line 670 "ease-main.c" if (_inner_error_ != NULL) { goto __catch13_g_error; } #line 210 "ease-main.vala" win = g_object_ref_sink (ease_editor_window_new (doc)); #line 211 "ease-main.vala" ease_main_add_window (win); #line 212 "ease-main.vala" gtk_widget_show_now ((GtkWidget*) win); #line 213 "ease-main.vala" gtk_window_present ((GtkWindow*) win); #line 682 "ease-main.c" _g_object_unref0 (win); _g_object_unref0 (doc); } goto __finally13; __catch13_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { #line 217 "ease-main.vala" ease_error_dialog (_ ("Error Opening Document"), e->message); #line 695 "ease-main.c" _g_error_free0 (e); #line 218 "ease-main.vala" return; #line 699 "ease-main.c" } } __finally13: if (_inner_error_ != NULL) { 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; } }
static GSList * parole_pl_parser_parse_xspf (const gchar *filename) { ParoleParserData data; GFile *file; gchar *contents; GError *error = NULL; gsize size; GMarkupParseContext *pctx; GMarkupParser parser = { parole_xspf_xml_start, parole_xspf_xml_end, parole_xspf_xml_text, NULL, NULL }; data.list = NULL; data.title = data.uri = NULL; file = g_file_new_for_path (filename); if ( !g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) ) goto out; if ( g_utf8_validate (contents, -1, NULL) == FALSE) { gchar *fixed; fixed = g_convert (contents, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL); if (fixed != NULL) { g_free (contents); contents = fixed; } } pctx = g_markup_parse_context_new (&parser, 0, &data, NULL); if ( !g_markup_parse_context_parse (pctx, contents, size, &error) ) { if ( error ) { g_critical ("Unable to parse xspf file : %s : %s\n", filename, error->message); g_error_free (error); } } else { if ( !g_markup_parse_context_end_parse (pctx, &error) ) { g_critical ("Unable to finish parsing xspf playlist file %s", error->message); g_error_free (error); } } g_markup_parse_context_free (pctx); out: g_object_unref (file); return data.list; }
static void display_ok_clicked (Display* self) { GError * _inner_error_; char* tmpname; char* bytes; char* cmd; char* _tmp15_; char* _tmp14_; char* _tmp13_; char* _tmp12_; char* _tmp11_; char* _tmp10_; char* _tmp9_; char* _tmp8_; g_return_if_fail (self != NULL); _inner_error_ = NULL; tmpname = g_strdup ("radare_XXXXXX."); bytes = NULL; cmd = NULL; if (_vala_strcmp0 (self->priv->selected, "raw") == 0) { char* _tmp0_; tmpname = (_tmp0_ = g_strconcat (tmpname, "gray", NULL), _g_free0 (tmpname), _tmp0_); } else { char* _tmp1_; tmpname = (_tmp1_ = g_strconcat (tmpname, self->priv->selected, NULL), _g_free0 (tmpname), _tmp1_); } { char* _tmp4_; gint _tmp3_; char* _tmp2_ = NULL; gint _tmp5_; _tmp5_ = (_tmp3_ = g_file_open_tmp (tmpname, &_tmp2_, &_inner_error_), self->priv->filename = (_tmp4_ = _tmp2_, _g_free0 (self->priv->filename), _tmp4_), _tmp3_); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_FILE_ERROR) { goto __catch0_g_file_error; } goto __finally0; } self->priv->tmp_file = _tmp5_; } goto __finally0; __catch0_g_file_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { g_error ("Display.vala:88: %s\n", e->message); _g_error_free0 (e); } } __finally0: if (_inner_error_ != NULL) { _g_free0 (tmpname); _g_free0 (bytes); _g_free0 (cmd); g_critical ("file %s: line %d: uncaught error: %s", __FILE__, __LINE__, _inner_error_->message); g_clear_error (&_inner_error_); return; } if (_vala_strcmp0 (self->priv->selected, "raw") == 0) { char* _tmp6_; bytes = (_tmp6_ = g_strdup_printf ("%d", ((gint) gtk_spin_button_get_value (self->priv->width)) * ((gint) gtk_spin_button_get_value (self->priv->height))), _g_free0 (bytes), _tmp6_); } else { char* _tmp7_; bytes = (_tmp7_ = g_strdup (g_getenv ("BSIZE")), _g_free0 (bytes), _tmp7_); } if (bytes == NULL) { g_error ("Display.vala:97: bytes is null, if you did not select raw, BSIZE needs to be exported!\n"); } cmd = (_tmp15_ = g_strconcat (_tmp14_ = g_strconcat (_tmp13_ = g_strconcat (_tmp12_ = g_strconcat (_tmp11_ = g_strconcat (_tmp10_ = g_strconcat (_tmp9_ = g_strconcat (_tmp8_ = g_strconcat ("dd if=\"", g_getenv ("FILE"), NULL), "\" of=\"", NULL), self->priv->filename, NULL), "\" count=", NULL), bytes, NULL), " bs=1 skip=", NULL), g_getenv ("OFFSET"), NULL), " & ", NULL), _g_free0 (cmd), _tmp15_); _g_free0 (_tmp14_); _g_free0 (_tmp13_); _g_free0 (_tmp12_); _g_free0 (_tmp11_); _g_free0 (_tmp10_); _g_free0 (_tmp9_); _g_free0 (_tmp8_); system (cmd); if (_vala_strcmp0 (self->priv->selected, "raw") == 0) { char* _tmp25_; char* _tmp24_; char* _tmp23_; char* _tmp22_; char* _tmp21_; char* _tmp20_; char* _tmp19_; char* _tmp18_; char* _tmp17_; char* _tmp16_; system (_tmp25_ = g_strconcat (_tmp24_ = g_strconcat (_tmp23_ = g_strconcat (_tmp21_ = g_strconcat (_tmp20_ = g_strconcat (_tmp18_ = g_strconcat (_tmp17_ = g_strconcat ("display -size ", _tmp16_ = g_strdup_printf ("%d", (gint) gtk_spin_button_get_value (self->priv->width)), NULL), "x", NULL), _tmp19_ = g_strdup_printf ("%d", (gint) gtk_spin_button_get_value (self->priv->height)), NULL), " -depth ", NULL), _tmp22_ = g_strdup_printf ("%d", (gint) gtk_spin_button_get_value (self->priv->depth)), NULL), " ", NULL), self->priv->filename, NULL)); _g_free0 (_tmp25_); _g_free0 (_tmp24_); _g_free0 (_tmp23_); _g_free0 (_tmp22_); _g_free0 (_tmp21_); _g_free0 (_tmp20_); _g_free0 (_tmp19_); _g_free0 (_tmp18_); _g_free0 (_tmp17_); _g_free0 (_tmp16_); } else { char* _tmp26_; system (_tmp26_ = g_strconcat ("display ", self->priv->filename, NULL)); _g_free0 (_tmp26_); } unlink (self->priv->filename); _g_free0 (tmpname); _g_free0 (bytes); _g_free0 (cmd); }
static void sync_pages (MooPrefsDialog *dialog) { GSList *old_plugin_pages, *plugin_pages, *plugin_ids, *l, *plugins; plugins = moo_list_plugins (); plugin_ids = NULL; for (l = plugins; l != NULL; l = l->next) { MooPlugin *plugin = l->data; plugin_ids = g_slist_append (plugin_ids, g_strdup (moo_plugin_id (plugin))); } old_plugin_pages = g_object_get_data (G_OBJECT (dialog), "moo-plugin-prefs-pages"); plugin_pages = NULL; for (l = plugins; l != NULL; l = l->next) { MooPlugin *plugin = l->data; if (moo_plugin_enabled (plugin) && MOO_PLUGIN_GET_CLASS(plugin)->create_prefs_page) { GSList *link = g_slist_find_custom (old_plugin_pages, moo_plugin_id (l->data), (GCompareFunc) cmp_page_and_id); if (link) { plugin_pages = g_slist_append (plugin_pages, link->data); } else { GtkWidget *plugin_page = MOO_PLUGIN_GET_CLASS(plugin)->create_prefs_page (plugin); if (plugin_page) { if (!MOO_IS_PREFS_PAGE (plugin_page)) { g_critical ("oops"); } else { g_object_set_data_full (G_OBJECT (plugin_page), "moo-plugin-id", g_strdup (moo_plugin_id (plugin)), g_free); plugin_pages = g_slist_append (plugin_pages, plugin_page); moo_prefs_dialog_insert_page (dialog, plugin_page, -1); } } } } } for (l = old_plugin_pages; l != NULL; l = l->next) if (!g_slist_find (plugin_pages, l->data)) moo_prefs_dialog_remove_page (dialog, l->data); g_object_set_data_full (G_OBJECT (dialog), "moo-plugin-prefs-pages", plugin_pages, (GDestroyNotify) g_slist_free); g_slist_foreach (plugin_ids, (GFunc) g_free, NULL); g_slist_free (plugin_ids); g_slist_free (plugins); }
int main( int argc, char ** argv) { int c; char *command; application_argument_t argument; int i; #ifdef GNUTAR gnutar_path = GNUTAR; #else gnutar_path = NULL; #endif gnutar_directory = NULL; gnutar_onefilesystem = 1; gnutar_atimepreserve = 1; gnutar_checkdevice = 1; gnutar_sparse = 1; gnutar_no_unquote = 0; exit_handling = NULL; /* initialize */ /* * Configure program for internationalization: * 1) Only set the message locale for now. * 2) Set textdomain for all amanda related programs to "amanda" * We don't want to be forced to support dozens of message catalogs. */ setlocale(LC_MESSAGES, "C"); textdomain("amanda"); if (argc < 2) { printf("ERROR no command given to amgtar\n"); error(_("No command given to amgtar")); } /* drop root privileges */ if (!set_root_privs(0)) { if (strcmp(argv[1], "selfcheck") == 0) { printf("ERROR amgtar must be run setuid root\n"); } error(_("amgtar must be run setuid root")); } safe_fd(3, 2); set_pname("amgtar"); /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); #if defined(USE_DBMALLOC) malloc_size_1 = malloc_inuse(&malloc_hist_1); #endif erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG); dbopen(DBG_SUBDIR_CLIENT); startclock(); dbprintf(_("version %s\n"), version()); config_init(CONFIG_INIT_CLIENT, NULL); //check_running_as(RUNNING_AS_DUMPUSER_PREFERRED); //root for amrecover //RUNNING_AS_CLIENT_LOGIN from selfcheck, sendsize, sendbackup /* parse argument */ command = argv[1]; argument.config = NULL; argument.host = NULL; argument.message = 0; argument.collection = 0; argument.calcsize = 0; argument.tar_blocksize = NULL; argument.level = NULL; init_dle(&argument.dle); while (1) { int option_index = 0; c = getopt_long (argc, argv, "", long_options, &option_index); if (c == -1) { break; } switch (c) { case 1: argument.config = stralloc(optarg); break; case 2: argument.host = stralloc(optarg); break; case 3: argument.dle.disk = stralloc(optarg); break; case 4: argument.dle.device = stralloc(optarg); break; case 5: argument.level = g_slist_append(argument.level, GINT_TO_POINTER(atoi(optarg))); break; case 6: argument.dle.create_index = 1; break; case 7: argument.message = 1; break; case 8: argument.collection = 1; break; case 9: argument.dle.record = 1; break; case 10: gnutar_path = stralloc(optarg); break; case 11: gnutar_listdir = stralloc(optarg); break; case 12: if (optarg && strcasecmp(optarg, "NO") == 0) gnutar_onefilesystem = 0; else if (optarg && strcasecmp(optarg, "YES") == 0) gnutar_onefilesystem = 1; else if (strcasecmp(command, "selfcheck") == 0) printf(_("ERROR [%s: bad ONE-FILE-SYSTEM property value (%s)]\n"), get_pname(), optarg); break; case 13: if (optarg && strcasecmp(optarg, "NO") == 0) gnutar_sparse = 0; else if (optarg && strcasecmp(optarg, "YES") == 0) gnutar_sparse = 1; else if (strcasecmp(command, "selfcheck") == 0) printf(_("ERROR [%s: bad SPARSE property value (%s)]\n"), get_pname(), optarg); break; case 14: if (optarg && strcasecmp(optarg, "NO") == 0) gnutar_atimepreserve = 0; else if (optarg && strcasecmp(optarg, "YES") == 0) gnutar_atimepreserve = 1; else if (strcasecmp(command, "selfcheck") == 0) printf(_("ERROR [%s: bad ATIME-PRESERVE property value (%s)]\n"), get_pname(), optarg); break; case 15: if (optarg && strcasecmp(optarg, "NO") == 0) gnutar_checkdevice = 0; else if (optarg && strcasecmp(optarg, "YES") == 0) gnutar_checkdevice = 1; else if (strcasecmp(command, "selfcheck") == 0) printf(_("ERROR [%s: bad CHECK-DEVICE property value (%s)]\n"), get_pname(), optarg); break; case 16: if (optarg) argument.dle.include_file = append_sl(argument.dle.include_file, optarg); break; case 17: if (optarg) argument.dle.include_list = append_sl(argument.dle.include_list, optarg); break; case 18: argument.dle.include_optional = 1; break; case 19: if (optarg) argument.dle.exclude_file = append_sl(argument.dle.exclude_file, optarg); break; case 20: if (optarg) argument.dle.exclude_list = append_sl(argument.dle.exclude_list, optarg); break; case 21: argument.dle.exclude_optional = 1; break; case 22: gnutar_directory = stralloc(optarg); break; case 23: if (optarg) normal_message = g_slist_append(normal_message, optarg); break; case 24: if (optarg) ignore_message = g_slist_append(ignore_message, optarg); break; case 25: if (optarg) strange_message = g_slist_append(strange_message, optarg); break; case 26: if (optarg) exit_handling = stralloc(optarg); break; case 27: argument.calcsize = 1; break; case 28: argument.tar_blocksize = stralloc(optarg); break; case 29: if (optarg && strcasecmp(optarg, "NO") == 0) gnutar_no_unquote = 0; else if (optarg && strcasecmp(optarg, "YES") == 0) gnutar_no_unquote = 1; else if (strcasecmp(command, "selfcheck") == 0) printf(_("ERROR [%s: bad No_UNQUOTE property value (%s)]\n"), get_pname(), optarg); break; case ':': case '?': break; } } argument.argc = argc - optind; argument.argv = argv + optind; if (argument.config) { config_init(CONFIG_INIT_CLIENT | CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_OVERLAY, argument.config); dbrename(get_config_name(), DBG_SUBDIR_CLIENT); } if (config_errors(NULL) >= CFGERR_ERRORS) { g_critical(_("errors processing config file")); } re_table = build_re_table(init_re_table, normal_message, ignore_message, strange_message); for(i=0;i<256;i++) exit_value[i] = 1; /* BAD */ exit_value[0] = 0; /* GOOD */ exit_value[1] = 0; /* GOOD */ if (exit_handling) { char *s = exit_handling; while (s) { char *r = strchr(s, '='); if (r) { int j = atoi(s); if (j >= 0 && j < 256) { r++; if (strncasecmp(r, "GOOD", 4) == 0) { exit_value[j] = 0; } } } s = strchr(s+1, ' '); } } gnutar_listdir = getconf_str(CNF_GNUTAR_LIST_DIR); if (strlen(gnutar_listdir) == 0) gnutar_listdir = NULL; if (gnutar_path) { dbprintf("GNUTAR-PATH %s\n", gnutar_path); } else { dbprintf("GNUTAR-PATH is not set\n"); } if (gnutar_listdir) { dbprintf("GNUTAR-LISTDIR %s\n", gnutar_listdir); } else { dbprintf("GNUTAR-LISTDIR is not set\n"); } if (gnutar_directory) { dbprintf("DIRECTORY %s\n", gnutar_directory); } dbprintf("ONE-FILE-SYSTEM %s\n", gnutar_onefilesystem? "yes":"no"); dbprintf("SPARSE %s\n", gnutar_sparse? "yes":"no"); dbprintf("NO-UNQUOTE %s\n", gnutar_no_unquote? "yes":"no"); dbprintf("ATIME-PRESERVE %s\n", gnutar_atimepreserve? "yes":"no"); dbprintf("CHECK-DEVICE %s\n", gnutar_checkdevice? "yes":"no"); { amregex_t *rp; for (rp = re_table; rp->regex != NULL; rp++) { switch (rp->typ) { case DMP_NORMAL : dbprintf("NORMAL %s\n", rp->regex); break; case DMP_IGNORE : dbprintf("IGNORE %s\n", rp->regex); break; case DMP_STRANGE: dbprintf("STRANGE %s\n", rp->regex); break; case DMP_SIZE : dbprintf("SIZE %s\n", rp->regex); break; case DMP_ERROR : dbprintf("ERROR %s\n", rp->regex); break; } } } if (strcmp(command, "support") == 0) { amgtar_support(&argument); } else if (strcmp(command, "selfcheck") == 0) { amgtar_selfcheck(&argument); } else if (strcmp(command, "estimate") == 0) { amgtar_estimate(&argument); } else if (strcmp(command, "backup") == 0) { amgtar_backup(&argument); } else if (strcmp(command, "restore") == 0) { amgtar_restore(&argument); } else if (strcmp(command, "validate") == 0) { amgtar_validate(&argument); } else { dbprintf("Unknown command `%s'.\n", command); fprintf(stderr, "Unknown command `%s'.\n", command); exit (1); } return 0; }
int main(int argc, char** argv) { g_critical("You will need at least GTK+ 2.14.0 to run the unit tests."); return 0; }
static gboolean process_rdma_event (GIOChannel *source, GIOCondition condition, gpointer data) { // Right now, we don't need 'source' // Tell the compiler to ignore it by (void)-ing it (void) source; if (!G_TRYLOCK (rdma_handling)) { g_debug ("RDMA handling will wait for the next dispatch."); return TRUE; } g_debug ("Got message on condition: %i", condition); void *payload = ((GList *)data)->data; struct kiro_client_connection *cc = (struct kiro_client_connection *)payload; struct ibv_wc wc; gint num_comp = ibv_poll_cq (cc->conn->recv_cq, 1, &wc); if (!num_comp) { g_critical ("RDMA event handling was triggered, but there is no completion on the queue"); goto end_rmda_eh; } if (num_comp < 0) { g_critical ("Failure getting receive completion event from the queue: %s", strerror (errno)); goto end_rmda_eh; } g_debug ("Got %i receive events from the queue", num_comp); void *cq_ctx; struct ibv_cq *cq; int err = ibv_get_cq_event (cc->conn->recv_cq_channel, &cq, &cq_ctx); if (!err) ibv_ack_cq_events (cq, 1); struct kiro_connection_context *ctx = (struct kiro_connection_context *)cc->conn->context; guint type = ((struct kiro_ctrl_msg *)ctx->cf_mr_recv->mem)->msg_type; g_debug ("Received a message from Client %u of type %u", cc->id, type); switch (type) { case KIRO_PING: { struct kiro_ctrl_msg *msg = (struct kiro_ctrl_msg *) (ctx->cf_mr_send->mem); msg->msg_type = KIRO_PONG; if (!send_msg (cc->conn, ctx->cf_mr_send)) { g_warning ("Failure while trying to post PONG send: %s", strerror (errno)); goto done; } break; } case KIRO_ACK_RDMA: { g_debug ("ACK received"); if (G_TRYLOCK (realloc_timeout)) { g_debug ("Client %i has ACKed the reallocation request", cc->id); GList *client = g_list_find (realloc_list, (gpointer)cc); if (client) { realloc_list = g_list_remove_link (realloc_list, client); if (cc->backup_mri->mr) ibv_dereg_mr (cc->backup_mri->mr); g_free (cc->backup_mri); cc->backup_mri = NULL; g_debug ("Client %i removed from realloc_list", cc->id); } G_UNLOCK (realloc_timeout); } break; } default: g_debug ("Message Type is unknow. Ignoring..."); } done: //Post a generic receive in order to stay responsive to any messages from //the client if (rdma_post_recv (cc->conn, cc->conn, ctx->cf_mr_recv->mem, ctx->cf_mr_recv->size, ctx->cf_mr_recv->mr)) { //TODO: Connection teardown in an event handler routine? Not a good //idea... g_critical ("Posting generic receive for event handling failed: %s", strerror (errno)); kiro_destroy_connection_context (&ctx); rdma_destroy_ep (cc->conn); goto end_rmda_eh; } ibv_req_notify_cq (cc->conn->recv_cq, 0); // Make the respective Queue push events onto the channel g_debug ("Finished RDMA event handling"); end_rmda_eh: G_UNLOCK (rdma_handling); return TRUE; }
static void clutter_stage_win32_realize (ClutterActor *actor) { ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor); ClutterBackendWin32 *backend_win32; PIXELFORMATDESCRIPTOR pfd; int pf; CLUTTER_NOTE (MISC, "Realizing main stage"); backend_win32 = CLUTTER_BACKEND_WIN32 (clutter_get_default_backend ()); if (stage_win32->hwnd == NULL) { ATOM window_class = clutter_stage_win32_get_window_class (); int win_xpos, win_ypos, win_width, win_height; if (window_class == 0) { g_critical ("Unable to register window class"); goto fail; } /* If we're in fullscreen mode then use the fullscreen rect instead */ if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN)) { get_fullscreen_rect (stage_win32); win_xpos = stage_win32->fullscreen_rect.left; win_ypos = stage_win32->fullscreen_rect.top; win_width = stage_win32->fullscreen_rect.right - win_xpos; win_height = stage_win32->fullscreen_rect.left - win_ypos; } else { win_xpos = win_ypos = CW_USEDEFAULT; get_full_window_size (stage_win32, stage_win32->win_width, stage_win32->win_height, &win_width, &win_height); } stage_win32->hwnd = CreateWindowW ((LPWSTR) MAKEINTATOM (window_class), L".", get_window_style (stage_win32), win_xpos, win_ypos, win_width, win_height, NULL, NULL, GetModuleHandle (NULL), NULL); if (stage_win32->hwnd == NULL) { g_critical ("Unable to create stage window"); goto fail; } /* Store a pointer to the actor in the extra bytes of the window so we can quickly access it in the window procedure */ SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) stage_win32); } if (stage_win32->client_dc) ReleaseDC (stage_win32->hwnd, stage_win32->client_dc); stage_win32->client_dc = GetDC (stage_win32->hwnd); pf = clutter_stage_win32_choose_pixel_format (stage_win32->client_dc, &pfd); if (pf == 0 || !SetPixelFormat (stage_win32->client_dc, pf, &pfd)) { g_critical ("Unable to find suitable GL pixel format"); goto fail; } if (backend_win32->gl_context == NULL) { backend_win32->gl_context = wglCreateContext (stage_win32->client_dc); if (backend_win32->gl_context == NULL) { g_critical ("Unable to create suitable GL context"); goto fail; } /* Make the context current so we can check the GL version */ wglMakeCurrent (stage_win32->client_dc, backend_win32->gl_context); if (!clutter_stage_win32_check_gl_version ()) { g_critical ("OpenGL version number is too low"); goto fail; } } CLUTTER_NOTE (BACKEND, "Successfully realized stage"); return; fail: CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); }
int kiro_server_start (KiroServer *self, const char *address, const char *port, void *mem, size_t mem_size) { g_return_val_if_fail (self != NULL, -1); KiroServerPrivate *priv = KIRO_SERVER_GET_PRIVATE (self); if (priv->base) { g_debug ("Server already started."); return -1; } if (!mem || mem_size == 0) { g_warning ("Invalid memory given to provide."); return -1; } struct rdma_addrinfo hints, *res_addrinfo; memset (&hints, 0, sizeof (hints)); hints.ai_port_space = RDMA_PS_IB; hints.ai_flags = RAI_PASSIVE; char *addr_c = g_strdup (address); char *port_c = g_strdup (port); int rtn = rdma_getaddrinfo (addr_c, port_c, &hints, &res_addrinfo); g_free (addr_c); g_free (port_c); if (rtn) { g_critical ("Failed to create address information: %s", strerror (errno)); return -1; } struct ibv_qp_init_attr qp_attr; memset (&qp_attr, 0, sizeof (qp_attr)); qp_attr.cap.max_send_wr = 10; qp_attr.cap.max_recv_wr = 10; qp_attr.cap.max_send_sge = 1; qp_attr.cap.max_recv_sge = 1; qp_attr.qp_context = priv->base; qp_attr.sq_sig_all = 1; if (rdma_create_ep (& (priv->base), res_addrinfo, NULL, &qp_attr)) { g_critical ("Endpoint creation failed: %s", strerror (errno)); g_free (res_addrinfo); return -1; } g_free (res_addrinfo); // No longer needed g_debug ("Endpoint created"); char *addr_local = NULL; struct sockaddr *src_addr = rdma_get_local_addr (priv->base); if (!src_addr) { addr_local = "NONE"; } else { addr_local = inet_ntoa (((struct sockaddr_in *)src_addr)->sin_addr); /* if(src_addr->sa_family == AF_INET) addr_local = &(((struct sockaddr_in*)src_addr)->sin_addr); else addr_local = &(((struct sockaddr_in6*)src_addr)->sin6_addr); */ } g_message ("Server bound to address %s:%s", addr_local, port); if (rdma_listen (priv->base, 0)) { g_critical ("Failed to put server into listening state: %s", strerror (errno)); rdma_destroy_ep (priv->base); return -1; } priv->mem = mem; priv->mem_size = mem_size; priv->ec = rdma_create_event_channel(); if (rdma_migrate_id (priv->base, priv->ec)) { g_critical ("Was unable to migrate connection to new Event Channel: %s", strerror (errno)); rdma_destroy_ep (priv->base); return -1; } priv->main_loop = g_main_loop_new (NULL, FALSE); priv->conn_ec = g_io_channel_unix_new (priv->ec->fd); g_io_add_watch (priv->conn_ec, G_IO_IN | G_IO_PRI, process_cm_event, (gpointer)priv); priv->main_thread = g_thread_new ("KIRO Server main loop", start_server_main_loop, priv->main_loop); // We gave control to the main_loop (with add_watch) and don't need our ref // any longer g_io_channel_unref (priv->conn_ec); g_message ("Enpoint listening"); return 0; }
/** * Writes this code node and all children with the specified C code * writer. * * @param writer a C code writer */ static void vala_ccode_node_real_write (ValaCCodeNode* self, ValaCCodeWriter* writer) { g_critical ("Type `%s' does not implement abstract method `vala_ccode_node_write'", g_type_name (G_TYPE_FROM_INSTANCE (self))); return; }
void ags_menu_action_about_callback(GtkWidget *menu_item, gpointer data) { AgsApplicationContext *application_context; AgsWindow *window; static FILE *file = NULL; struct stat sb; static gchar *license; static GdkPixbuf *logo = NULL; gchar *license_filename; gchar *logo_filename; gchar *str; int n_read; GError *error; gchar *authors[] = { "Joël Krähemann", NULL }; #ifdef AGS_LICENSE_FILENAME license_filename = AGS_LICENSE_FILENAME; #else if((license_filename = getenv("AGS_LICENSE_FILENAME")) == NULL){ license_filename = "/usr/share/common-licenses/GPL-3"; } #endif if(g_file_test(license_filename, G_FILE_TEST_EXISTS)){ if(file == NULL){ file = fopen(license_filename, "r"); stat(license_filename, &sb); license = (gchar *) malloc((sb.st_size + 1) * sizeof(gchar)); n_read = fread(license, sizeof(char), sb.st_size, file); if(n_read != sb.st_size){ g_critical("fread() number of bytes returned doesn't match buffer size"); } license[sb.st_size] = '\0'; fclose(file); #ifdef AGS_LOGO_FILENAME logo_filename = g_strdup(AGS_LOGO_FILENAME); #else if((logo_filename = getenv("AGS_LOGO_FILENAME")) == NULL){ logo_filename = g_strdup_printf("%s%s", DESTDIR, "/gsequencer/images/ags.png"); }else{ logo_filename = g_strdup(logo_filename); } #endif error = NULL; logo = gdk_pixbuf_new_from_file(logo_filename, &error); //g_free(logo_filename); } } application_context = ags_application_context_get_instance(); window = (AgsWindow *) ags_ui_provider_get_window(AGS_UI_PROVIDER(application_context)); gtk_show_about_dialog((GtkWindow *) window, "program-name", "gsequencer", "authors", authors, "license", license, "version", AGS_VERSION, "website", "http://nongnu.org/gsequencer", "title", "Advanced Gtk+ Sequencer", "logo", logo, NULL); }
static UniqueResponse _lambda65_ (UniqueApp* _self_, gint cmd, UniqueMessageData* data, guint time_) { #line 283 "ease-main.c" UniqueResponse result = 0; #line 96 "ease-main.vala" g_return_val_if_fail (_self_ != NULL, 0); #line 96 "ease-main.vala" g_return_val_if_fail (data != NULL, 0); #line 97 "ease-main.vala" switch (cmd) { #line 291 "ease-main.c" case EASE_MAIN_UNIQUE_COMMAND_OPEN_FILE: { gint filenames_length1; gint _filenames_size_; char** _tmp0_; char** filenames; filenames = (_tmp0_ = unique_message_data_get_uris (data), filenames_length1 = -1, _filenames_size_ = filenames_length1, _tmp0_); { gint i; #line 101 "ease-main.vala" i = 0; #line 303 "ease-main.c" { gboolean _tmp1_; #line 101 "ease-main.vala" _tmp1_ = TRUE; #line 101 "ease-main.vala" while (TRUE) { #line 101 "ease-main.vala" if (!_tmp1_) { #line 101 "ease-main.vala" i++; #line 314 "ease-main.c" } #line 101 "ease-main.vala" _tmp1_ = FALSE; #line 101 "ease-main.vala" if (!(filenames[i] != NULL)) { #line 101 "ease-main.vala" break; #line 322 "ease-main.c" } #line 103 "ease-main.vala" ease_main_open_file (filenames[i]); #line 326 "ease-main.c" } } } result = UNIQUE_RESPONSE_OK; filenames = (_vala_array_free (filenames, filenames_length1, (GDestroyNotify) g_free), NULL); #line 105 "ease-main.vala" return result; #line 334 "ease-main.c" } case EASE_MAIN_UNIQUE_COMMAND_PLAY_FILE: { #line 107 "ease-main.vala" ease_main_play_file (unique_message_data_get_filename (data), FALSE); #line 340 "ease-main.c" result = UNIQUE_RESPONSE_OK; #line 108 "ease-main.vala" return result; #line 344 "ease-main.c" } case EASE_MAIN_UNIQUE_COMMAND_SHOW_WELCOME: { #line 110 "ease-main.vala" ease_main_show_welcome (); #line 350 "ease-main.c" result = UNIQUE_RESPONSE_OK; #line 111 "ease-main.vala" return result; #line 354 "ease-main.c" } } #line 115 "ease-main.vala" g_critical ("ease-main.vala:115: Invalid UniqueCommand"); #line 359 "ease-main.c" result = UNIQUE_RESPONSE_PASSTHROUGH; #line 116 "ease-main.vala" return result; #line 363 "ease-main.c" }
EaseDialogProgress* ease_dialog_progress_construct (GType object_type, const char* title, gboolean cancellable, double max, GtkWindow* modal) { #line 104 "ease-dialog-progress.c" EaseDialogProgress * self; GtkBuilder* _tmp0_; GObject* _tmp3_; GtkDialog* _tmp4_; GObject* _tmp5_; GtkButton* _tmp6_; GObject* _tmp7_; GtkProgressBar* _tmp8_; GError * _inner_error_ = NULL; #line 43 "ease-dialog-progress.vala" g_return_val_if_fail (title != NULL, NULL); #line 43 "ease-dialog-progress.vala" self = (EaseDialogProgress*) g_object_new (object_type, NULL); #line 46 "ease-dialog-progress.vala" self->priv->max_val = max; #line 48 "ease-dialog-progress.vala" self->priv->builder = (_tmp0_ = gtk_builder_new (), _g_object_unref0 (self->priv->builder), _tmp0_); #line 122 "ease-dialog-progress.c" { char* _tmp1_; char* _tmp2_; #line 51 "ease-dialog-progress.vala" gtk_builder_add_from_file (self->priv->builder, _tmp2_ = ease_data_path (_tmp1_ = g_build_filename (EASE_TEMP_UI_DIR, EASE_DIALOG_PROGRESS_UI_FILE, NULL)), &_inner_error_); #line 128 "ease-dialog-progress.c" _g_free0 (_tmp2_); _g_free0 (_tmp1_); if (_inner_error_ != NULL) { goto __catch8_g_error; } } goto __finally8; __catch8_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { #line 54 "ease-dialog-progress.vala" g_error ("ease-dialog-progress.vala:54: Error loading UI: %s", e->message); #line 144 "ease-dialog-progress.c" _g_error_free0 (e); } } __finally8: if (_inner_error_ != NULL) { 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 NULL; } #line 57 "ease-dialog-progress.vala" self->priv->dialog = (_tmp4_ = _g_object_ref0 ((_tmp3_ = gtk_builder_get_object (self->priv->builder, "dialog"), GTK_IS_DIALOG (_tmp3_) ? ((GtkDialog*) _tmp3_) : NULL)), _g_object_unref0 (self->priv->dialog), _tmp4_); #line 58 "ease-dialog-progress.vala" self->priv->cancel = (_tmp6_ = _g_object_ref0 ((_tmp5_ = gtk_builder_get_object (self->priv->builder, "cancel"), GTK_IS_BUTTON (_tmp5_) ? ((GtkButton*) _tmp5_) : NULL)), _g_object_unref0 (self->priv->cancel), _tmp6_); #line 59 "ease-dialog-progress.vala" self->priv->progress = (_tmp8_ = _g_object_ref0 ((_tmp7_ = gtk_builder_get_object (self->priv->builder, "progress"), GTK_IS_PROGRESS_BAR (_tmp7_) ? ((GtkProgressBar*) _tmp7_) : NULL)), _g_object_unref0 (self->priv->progress), _tmp8_); #line 62 "ease-dialog-progress.vala" gtk_window_set_title ((GtkWindow*) self->priv->dialog, title); #line 63 "ease-dialog-progress.vala" gtk_widget_set_visible ((GtkWidget*) self->priv->cancel, cancellable); #line 164 "ease-dialog-progress.c" return self; }
static gboolean clutter_stage_win32_realize (ClutterStageWindow *stage_window) { ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window); ClutterBackend *backend; ClutterBackendWin32 *backend_win32; CoglFramebuffer *framebuffer; gfloat width; gfloat height; GError *error = NULL; const char *clutter_vblank; CLUTTER_NOTE (MISC, "Realizing main stage"); backend = CLUTTER_BACKEND (stage_win32->backend); backend_win32 = CLUTTER_BACKEND_WIN32 (backend); clutter_actor_get_size (CLUTTER_ACTOR (stage_win32->wrapper), &width, &height); stage_win32->onscreen = cogl_onscreen_new (backend->cogl_context, width, height); if (stage_win32->hwnd == NULL) { ATOM window_class = clutter_stage_win32_get_window_class (); int win_xpos, win_ypos, win_width, win_height; if (window_class == 0) { g_critical ("Unable to register window class"); goto fail; } /* If we're in fullscreen mode then use the fullscreen rect instead */ if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN)) { get_fullscreen_rect (stage_win32); win_xpos = stage_win32->fullscreen_rect.left; win_ypos = stage_win32->fullscreen_rect.top; win_width = stage_win32->fullscreen_rect.right - win_xpos; win_height = stage_win32->fullscreen_rect.bottom - win_ypos; } else { win_xpos = win_ypos = CW_USEDEFAULT; get_full_window_size (stage_win32, stage_win32->win_width, stage_win32->win_height, &win_width, &win_height); } if (stage_win32->wtitle == NULL) stage_win32->wtitle = g_utf8_to_utf16 (".", -1, NULL, NULL, NULL); stage_win32->hwnd = CreateWindowW ((LPWSTR) MAKEINTATOM (window_class), stage_win32->wtitle, get_window_style (stage_win32), win_xpos, win_ypos, win_width, win_height, NULL, NULL, GetModuleHandle (NULL), NULL); if (stage_win32->hwnd == NULL) { g_critical ("Unable to create stage window"); goto fail; } /* Store a pointer to the actor in the extra bytes of the window so we can quickly access it in the window procedure */ SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) stage_win32); } cogl_onscreen_win32_set_foreign_window (stage_win32->onscreen, stage_win32->hwnd); clutter_vblank = _clutter_backend_win32_get_vblank (); if (clutter_vblank && strcmp (clutter_vblank, "none") == 0) cogl_onscreen_set_swap_throttled (stage_win32->onscreen, FALSE); framebuffer = COGL_FRAMEBUFFER (stage_win32->onscreen); if (!cogl_framebuffer_allocate (framebuffer, &error)) { g_warning ("Failed to allocate stage: %s", error->message); g_error_free (error); cogl_object_unref (stage_win32->onscreen); stage_win32->onscreen = NULL; goto fail; } /* Create a context. This will be a no-op if we already have one */ if (!_clutter_backend_create_context (CLUTTER_BACKEND (backend_win32), &error)) { g_critical ("Unable to realize stage: %s", error->message); g_error_free (error); goto fail; } CLUTTER_NOTE (BACKEND, "Successfully realized stage"); return TRUE; fail: return FALSE; }