static void pro_tuning_reset_indication (PROFILE_INSTANCE *pi) { if (pro_debug) { fprintf (stderr, "%s tuning_reset_indication\n", pro_name (pi -> channel -> profile_registration -> uri)); fflush (stderr); } }
void MainWindow::import_data2db() { int bRes; QString path_name = QFileDialog::getExistingDirectory(this); if (path_name.isNull()) return; QDirIterator dir_itr(path_name, QDir::Files, QDirIterator::Subdirectories); bdbXMLInterface db_interface; while (dir_itr.hasNext()) { QString cur_pathname = dir_itr.next(); QFileInfo cur_file(cur_pathname); if (!cur_file.isFile()) continue; QString cur_filename = cur_file.fileName(); //file name is ended with .xml? QString xml_ext(".xml"); if (!cur_filename.endsWith(xml_ext, Qt::CaseInsensitive)) { continue; } else { int str_len = cur_filename.size(); cur_filename.remove(str_len - 4, 4); } BdRetVal bsucc = db_interface.add_files(cur_pathname.toStdString(), cur_filename.toStdString()); //add to directory } Driver driver; try { bool errno = driver.beginSimulation (); if (errno == 0) { QStringList par_list; QString pro_name("../../../ExternalLib/linux/CopasiUI"); QString par_1("-i"); QString par_2("network.xml"); par_list << par_1 << par_2; QProcess::execute(pro_name, par_list); } } catch (CoreException &se) { cout << "exceptions" << endl; } }
static char * pro_connection_fin (PROFILE_REGISTRATION *pr, BP_CONNECTION *bp) { if (pro_debug) { fprintf (stderr, "%s connection_fin\n", pro_name (pr -> uri)); fflush (stderr); } return NULL; }
static char * pro_session_init (PROFILE_REGISTRATION *pr, BP_CONNECTION *bp) { if (pro_debug) { fprintf (stderr, "%s session_init: role='%c' mode=\"%s\"\n", pro_name (pr -> uri), bp -> role, bp -> mode); fflush (stderr); } return NULL; }
static void pro_window_full (PROFILE_INSTANCE *pi) { DIAGNOSTIC *d; if (pro_debug) { fprintf (stderr, "%s window_full\n", pro_name (pi -> channel -> profile_registration -> uri)); fflush (stderr); } bp_log (pi -> channel -> conn, LOG_PROF, 5, "%s channel window full!?!", pro_name (pi -> channel -> profile_registration -> uri)); if (!(d = bpc_close_request (pi -> channel, BLU_CHAN0_MSGNO_DEFAULT, 550, NULL, "stop misbehaving", NULL, NULL))) { bp_log (pi -> channel -> conn, LOG_PROF, 4, "unable to close SASL channel: [%d] %s", d -> code, d -> message); bp_diagnostic_destroy (pi -> channel -> conn, d); } }
static void pro_tuning_reset_confirmation (PROFILE_INSTANCE *pi, char status) { if (pro_debug) { fprintf (stderr, "%s tuning_reset_confirmation: status=%c\n", pro_name (pi -> channel -> profile_registration -> uri), status); fflush (stderr); } pro_close_confirmation (pi, status, NULL, PRO_ACTION_LOCAL, PRO_ACTION_SESSION); }
static void pro_close_confirmation (PROFILE_INSTANCE *pi, char status, DIAGNOSTIC *error, char origin, char scope) { PRO_LOCALDATA *il = (PRO_LOCALDATA *) pi -> user_ptr1; if (pro_debug) { if (error) fprintf (stderr, "%s close_confirmation: status=%c error=[%d] \"%s\" origin=%c scope=%c\n", pro_name (pi -> channel -> profile_registration -> uri), status, error -> code, error -> message ? error -> message : "<NULL>", origin, scope); else fprintf (stderr, "%s close_confirmation: status=%c no error origin=%c scope=%c\n", pro_name (pi -> channel -> profile_registration -> uri), status, origin, scope); fflush (stderr); } if (status != PRO_ACTION_SUCCESS) return; if (il) { if (il -> pl_flags & PRO_INITIATOR) { il -> pl_flags |= PRO_CLOSED; } else { pi -> user_ptr1 = NULL; lib_free (il); } } }
static void pro_close_indication (PROFILE_INSTANCE *pi, DIAGNOSTIC *request, char origin, char scope) { if (pro_debug) { fprintf (stderr, "%s close_indication: request=[%d] \"%s\" origin=%c scope=%c\n", pro_name (pi -> channel -> profile_registration -> uri), request -> code, request -> message ? request -> message : "<NULL>", origin, scope); fflush (stderr); } bpc_close_response (pi -> channel, NULL); }
static void pro_message_available (PROFILE_INSTANCE *pi) { int result, size; char *buffer, *payload, *response; FRAME *f; struct configobj *appconfig = bp_get_config (pi -> channel -> conn); PRO_LOCALDATA *il = (PRO_LOCALDATA *) pi -> user_ptr1; result = SASL_ALREADY_DONE; if (!(f = bpc_query_message (pi -> channel, BLU_QUERY_ANYTYPE, BLU_QUERY_ANYMSG, BLU_QUERY_ANYANS))) return; if (pro_debug) { fprintf (stderr, "%s message_available: type=%c number=%ld answer=%ld size=%ld\n", pro_name (pi -> channel -> profile_registration -> uri), f -> msg_type, f -> message_number, f -> answer_number, f -> size); fprintf (stderr, f -> size > 150 ? "%-150.150s...\n" : "%s\n", f -> payload); fflush (stderr); } size = bpc_frame_aggregate (pi -> channel, f, &buffer); if (buffer == NULL) { bp_log (pi -> channel -> conn, LOG_PROF, 5, "%s message_available: out of memory aggregating message", pro_name (pi -> channel -> profile_registration -> uri)); bpc_frame_destroy (pi -> channel, f); return; } switch (il -> pl_task) { case PRO_CLIENT_ANON: break; case PRO_CLIENT_OTP: if (il -> pl_sent != 2) break; if (strstr (buffer, "<error") != NULL) sasl_error (pi, buffer, size); else { parse_blob (buffer, &il -> pl_sdb); if (!strcmp (il -> pl_sdb.parse_blob_status, "complete")) sasl_set_local_success (pi); else sasl_set_local_failure (pi, NULL); } break; case PRO_SERVER_ANON: if (il -> pl_sent != 0) break; if ((result = sasl_anonymous_server_guts (buffer, &il -> pl_sdb)) == SASL_COMPLETE) config_set (appconfig, SASL_REMOTE_USERNAME, il -> pl_sdb.parse_blob_data); break; case PRO_SERVER_OTP: switch (il -> pl_sent) { case 0: result = sasl_otp_server_guts_1 (buffer, &il -> pl_sdb); break; case 1: if ((result = sasl_otp_server_guts_2 (buffer, &il -> pl_sdb)) == SASL_COMPLETE) { config_set (appconfig, SASL_REMOTE_USERNAME, il -> pl_sdb.authenID); config_set (appconfig, SASL_REMOTE_TARGET, (il -> pl_sdb.authorID[0] != '\0') ? il -> pl_sdb.authorID : il -> pl_sdb.authenID); } break; } break; } bpc_buffer_destroy (pi -> channel, buffer); switch (il -> pl_task) { case PRO_CLIENT_ANON: case PRO_CLIENT_OTP: response = NULL; break; case PRO_SERVER_ANON: case PRO_SERVER_OTP: response = sasl_response (pi, result); break; } if (f -> msg_type == BLU_FRAME_TYPE_MSG) { payload = response ? response : "<error code='521'>Client-side only</error>"; size = strlen (payload) + sizeof DEFAULT_CONTENT_TYPE - 1; if ((buffer = bpc_buffer_allocate(pi -> channel, size)) != NULL) { sprintf (buffer, "%s%s", DEFAULT_CONTENT_TYPE, payload); bpc_send (pi -> channel, (payload[1] == 'e') ? BLU_FRAME_TYPE_ERR : BLU_FRAME_TYPE_RPY, f -> message_number, f -> answer_number, BLU_FRAME_COMPLETE, buffer, size); il -> pl_sent++; } else bp_log (pi -> channel -> conn, LOG_PROF, 5, "%s message: out of memory sending response", pro_name (pi -> channel -> profile_registration -> uri)); } bpc_frame_destroy (pi -> channel, f); }
static void pro_start_confirmation (void *clientData, PROFILE_INSTANCE *pi, PROFILE *po) { int problem, size; char *buffer, *payload; PRO_LOCALDATA *il = clientData; struct configobj *appconfig = bp_get_config (pi -> channel -> conn); if (pro_debug) { fprintf (stderr, "%s start_confirmation: piggyback=\"%s\"\n", pro_name (po -> uri), po -> piggyback ? po -> piggyback : "<NULL>"); fflush (stderr); } pi -> user_ptr1 = il; il -> pl_flags &= ~(PRO_STARTING | PRO_CLOSED); il -> pl_channel = pi -> channel; if (po -> piggyback_length == 0) { il -> pl_status = bp_diagnostic_new (pi -> channel -> conn, 504, NULL, "expecting blob element"); return; } if (strstr (po -> piggyback, "<error")) { sasl_error (pi, po -> piggyback, po -> piggyback_length); return; } switch (il -> pl_task) { case PRO_CLIENT_ANON: parse_blob (po -> piggyback, &il -> pl_sdb); if (!strcmp (il -> pl_sdb.parse_blob_status, "complete")) sasl_set_local_success (pi); else sasl_set_local_failure (pi, NULL); break; case PRO_CLIENT_OTP: if (!(payload = sasl_otp_client_guts_2 (po -> piggyback, config_get (appconfig, SASL_LOCAL_PASSPHRASE), &problem, &il -> pl_sdb))) { if (problem == SASL_ERROR_ALGORITHM) { config_set (appconfig, SASL_LOCAL_CODE, "504"); config_set (appconfig, SASL_LOCAL_REASON, "unsupported algorithm"); } else { config_set (appconfig, SASL_LOCAL_CODE, "501"); config_set (appconfig, SASL_LOCAL_REASON, "unable to parse blob"); } payload = "<blob status='abort' />"; } size = strlen (payload) + sizeof DEFAULT_CONTENT_TYPE - 1; if ((buffer = bpc_buffer_allocate (pi -> channel, size)) != NULL) { sprintf (buffer, "%s%s", DEFAULT_CONTENT_TYPE, payload); bpc_send (pi -> channel, BLU_FRAME_TYPE_MSG, BLU_FRAME_MSGNO_UNUSED, BLU_FRAME_IGNORE_ANSNO, BLU_FRAME_COMPLETE, buffer, size); il -> pl_sent++; } else bp_log (pi -> channel -> conn, LOG_PROF, 5, "%s start_confirmation: out of memory", pro_name (po -> uri)); break; } }
static void pro_start_indication (PROFILE_INSTANCE *pi, PROFILE *po) { char *cp, *otp; DIAGNOSTIC ds, *d = &ds; PRO_LOCALDATA *il; PROFILE ps, *p = &ps; struct configobj *appconfig = bp_get_config (pi -> channel -> conn); struct cfgsearchobj *cs; if (pro_debug) { fprintf (stderr, "%s start_indication: piggyback=\"%s\"\n", pro_name (po -> uri), po -> piggyback ? po -> piggyback : "<NULL>"); fflush (stderr); } memset (p, 0, sizeof *p); p -> uri = po -> uri; memset (d, 0, sizeof *d); d -> code = 421; if (((cp = config_get (appconfig, SASL_LOCAL_CODE)) != NULL) && (*cp == '2')) { d -> code = 520; d -> message = "already tuned for authentication"; bpc_start_response (pi -> channel, p, d); return; } if (!(il = (PRO_LOCALDATA *) lib_malloc (sizeof *il))) { d -> message = "out of memory"; bpc_start_response (pi -> channel, p, d); return; } pi -> user_ptr1 = il; memset (il, 0, sizeof *il); if (!(otp = config_get (appconfig, SASL_OTP_URI))) otp = PRO_OTP_URI; il -> pl_task = strcmp (po -> uri, otp) ? PRO_SERVER_ANON : PRO_SERVER_OTP; if (!(il -> pl_sdb.path = config_get (appconfig, SASL_OTP_DIRECTORY))) il -> pl_sdb.path = "/tmp"; cs = config_search_init (appconfig, SASL_REMOTE_PREFIX, ""); for (cp = config_search_string_firstkey (cs); cp; cp = config_search_string_nextkey (cs)) config_delete (appconfig, cp); config_search_fin (&cs); switch (il -> pl_task) { case PRO_SERVER_ANON: config_set (appconfig, SASL_REMOTE_MECHANISM, "anonymous"); break; case PRO_SERVER_OTP: config_set (appconfig, SASL_REMOTE_MECHANISM, "otp"); break; } if (po -> piggyback_length > 0) { int result; switch (il -> pl_task) { case PRO_SERVER_ANON: if ((result = sasl_anonymous_server_guts (po -> piggyback, &il -> pl_sdb)) == SASL_COMPLETE) config_set (appconfig, SASL_REMOTE_USERNAME, il -> pl_sdb.parse_blob_data); break; case PRO_SERVER_OTP: result = sasl_otp_server_guts_1 (po -> piggyback, &il -> pl_sdb); break; } p -> piggyback_length = strlen (p -> piggyback = sasl_response (pi, result)); il -> pl_sent = 1; } bpc_start_response (pi -> channel, p, NULL); }