bool Packet::length_valid() const { const size_t extra_bits = data_and_fcs_length() & 7; if( extra_bits != 0 ) { return false; } const PacketLengthValidator packet_length_valid; if( !packet_length_valid(message_id(), data_length()) ) { return false; } return true; }
// --------------------------------------------------------- // CDpMif::RunL // This method handles received message from Isc Api and // renews read from Isc Api. // --------------------------------------------------------- // void CDpMif::RunL() { OstTrace0( TRACE_NORMAL, CDPMIF_RUNL, "CDpMif::RunL" ); LOGM1("CDpMif::RunL - Port %d", iDataPort.PortUnit() ); // we are always signaled from PhoNet ReceiveMessage if ( KErrNoMemory == iStatus.Int() ) { LOGM(" ==> KErrNoMemory"); OstTrace0( TRACE_NORMAL, DUP1_CDPMIF_RUNL, "CDpMif:: ==> KErrNoMemory" ); // deallocate current message if ( iMsgReceiveBuffer ) { delete iMsgReceiveBuffer; iMsgReceiveBuffer = NULL; iReceiveMessage.Set( NULL, 0, 0 ); } //no else // ISA Handle receive // Trying to allocate a new message iMsgReceiveBuffer = HBufC8::NewL( ISI_HEADER_SIZE + iLen ); _LIT( KPanicStr, "Dataport - CDpMif::RunL" ); __ASSERT_ALWAYS( iMsgReceiveBuffer, User::Panic( KPanicStr, KErrNoMemory ) ); iReceiveMessage.Set( iMsgReceiveBuffer->Des() ); iLen = 0; if ( !IsActive() ) { iDataPort.ISAHandle().Receive( iStatus, iReceiveMessage, iLen ); SetActive(); } //no else } else { OstTrace0( TRACE_NORMAL, DUP2_CDPMIF_RUNL, "CDpMif:: ==> ISI-message received" ); OstPrintIsiMessage( iReceiveMessage ); LOGM(" ==> ISI-message received"); LOGMESSAGE( iReceiveMessage ); TIsiReceiveC receivedMsg( iReceiveMessage ); TUint8 resource_id( receivedMsg.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) ); TUint8 message_id( receivedMsg.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) ); switch ( resource_id ) { case PN_NAMESERVICE: { switch ( message_id ) { case PNS_NAME_ADD_RESP: { LOG(" ==> PNS_NAME_ADD_RESP received"); OstTrace0( TRACE_NORMAL, DUP4_CDPMIF_RUNL, "CDpMif:: ==> PNS_NAME_ADD_RESP received" ); TUint8 reason( receivedMsg.Get8bit( ISI_HEADER_SIZE + PNS_NAME_ADD_RESP_OFFSET_REASON ) ); TInt error( KErrNone ); switch ( reason ) { case PN_NAME_OK: { LOG(" ==> PN_NAME_OK"); OstTrace0( TRACE_NORMAL, DUP5_CDPMIF_RUNL, "CDpMif:: ==> PN_NAME_OK" ); error = KErrNone; break; } default: { LOG1(" ==> reason: %d", reason ); OstTraceExt1( TRACE_NORMAL, DUP6_CDPMIF_RUNL, "CDpMif:: ==> reason: %hhu", reason ); error = KErrGeneral; } } iDataPort.SignalPif( error ); break; } case PNS_NAME_REMOVE_RESP: { LOG(" ==> PNS_NAME_REMOVE_RESP received"); OstTrace0( TRACE_NORMAL, DUP7_CDPMIF_RUNL, "CDpMif:: ==> PNS_NAME_REMOVE_RESP received" ); break; } default: { LOG1(" ==> Unknown message received. ID: %d", message_id ); OstTraceExt1( TRACE_NORMAL, DUP8_CDPMIF_RUNL, "CDpMif:: ==> Unknown message received. ID: %hhu", message_id ); } } break; } case PN_PIPE: { switch ( message_id ) { case PNS_PEP_CTRL_REQ: { LOG(" ==> PNS_PEP_CTRL_REQ received"); OstTrace0( TRACE_NORMAL, DUP9_CDPMIF_RUNL, "CDpMif:: ==> PNS_PEP_CTRL_REQ received" ); HandlePepCtrlReq( receivedMsg ); break; } case PNS_PEP_STATUS_IND: { LOG(" ==> PNS_PEP_STATUS_IND received"); OstTrace0( TRACE_NORMAL, DUP10_CDPMIF_RUNL, "CDpMif:: ==> PNS_PEP_STATUS_IND received" ); HandlePepStatusInd( receivedMsg ); break; } default: { LOG1(" ==> Unknown message received. ID: %d", message_id ); OstTraceExt1( TRACE_NORMAL, DUP11_CDPMIF_RUNL, "CDpMif:: ==> Unknown message received. ID: %hhu", message_id ); } } break; } default: { LOG1(" ==> Unknown message received. ID: %d", message_id ); OstTraceExt1( TRACE_NORMAL, DUP12_CDPMIF_RUNL, "CDpMif:: ==> Unknown message received. ID: %hhu", message_id ); } } iReceiveMessage.Zero(); // Check if pipe is removed if ( PNS_NAME_REMOVE_RESP == message_id && CDpPif::EDpPipeDisconnected == iPifDcs.PipeState() ) { // Check if DataPort is ready to be deleted if ( iDataPort.IsReadyToDestruct() ) { iDataPort.DeleteDataPort(); } //no else } else { // Renew read User::LeaveIfError( Read() ); } } }
int main(int argc, char *argv[]) { int errn; string *str; int complete = -1; int i; long ans; long logintimeout = 20; char *s; char *password; char *username; if(argc < 4) { fprintf(stderr, "Usage: %s user password connecstring\n", argv[0]); exit(1); } if((mes = new_message(0)) == NULL) { fprintf(stderr, "%s: Cannot open message queue\n", argv[0]); exit(1); } /* * I believe a fork duplicates malloced stuff, I am in the poo if it does not :-) */ errn = fork(); if(errn == -1) { fprintf(stderr, "%s: Cannot fork child process\n", argv[0]); exit(1); } else if(errn) { /* * This is the parent - which behaves like clien */ /* * Initially just a status message is snt back, zero string length * * Still needs a string to put it into */ str = new_string(); if(message_receive(mes, str, &complete, MES_SERVER_TO_CLIENT) < 0) { fprintf(stderr, "%s: %s\n", argv[0], string_s(str)); message_destroy(mes); message_delete(mes); string_delete(str); exit(1); } else { printf("%d\n",message_id(mes)) ; message_delete(mes); string_delete(str); exit(0); } } /* * All parents have exited now */ /* * This is all a child */ /* * I think I need to do this here... * I do not fully understand why, it just works! * otherwise shell parent hangs! */ setsid(); if(fork()) exit(0); close(0); close(1); close(2); /* * We are in daemon mode now */ /* * open the database */ str = new_string(); for(i=3;i<argc;i++) { string_cat(str, argv[i]); if(i < argc - 1) string_cat_c(str, ' '); } username = strdup(argv[1]); password = strdup(argv[2]); wipe(argv[2]); wipe(argv[1]); ans = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &(env)); if((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO)) { message_status(mes, 127, "ODBC: Cannot allocate environment handle\n", MES_SERVER_TO_CLIENT); message_delete(mes); free(username); free(password); exit(1); } ans = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); if ((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO)) { SQLFreeHandle(SQL_HANDLE_ENV, env); message_status(mes, 127, "ODBC: Cannot set environment handle attributes\n", MES_SERVER_TO_CLIENT); message_delete(mes); exit(1); } /* 2. allocate connection handle, set timeout */ ans = SQLAllocHandle(SQL_HANDLE_DBC, env, &(hdbc)); if ((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO)) { SQLFreeHandle(SQL_HANDLE_ENV, env); message_status(mes, 127, "ODBC: Cannot allocate database handle\n", MES_SERVER_TO_CLIENT); message_delete(mes); free(username); free(password); exit(1); } /* * TODO - Parameterize ODBC_TIMEOUT as environment variable */ s = getenv("ODBC_TIMEOUT"); if(s != NULL) { if(*s) { logintimeout = atol(s); } } SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)logintimeout, 0); /* 3. Connect to the datasource */ ans = SQLConnect(hdbc, (SQLCHAR*) string_s(str), SQL_NTS, (SQLCHAR*) username, SQL_NTS, (SQLCHAR*) password, SQL_NTS); if ((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO)) { message_status(mes, 127, "ODBC: Cannot connect to database\n", MES_SERVER_TO_CLIENT); message_delete(mes); /* SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, V_OD_stat, &V_OD_err,V_OD_msg,100,&V_OD_mlen); printf("%s (%d)\n",V_OD_msg,V_OD_err); */ SQLFreeHandle(SQL_HANDLE_DBC, hdbc); SQLFreeHandle(SQL_HANDLE_ENV, env); free(username); free(password); exit(1); } /* * Transmit to parent that we are hunky dory */ message_status(mes, 0, "", MES_SERVER_TO_CLIENT); /* * We are open for business - Lets go */ mainloop(); /* * At the end, tidy up */ SQLDisconnect(hdbc); SQLFreeHandle(SQL_HANDLE_DBC, hdbc); SQLFreeHandle(SQL_HANDLE_ENV, env); message_destroy(mes); message_delete(mes); free(username); free(password); exit(0); }
inline message_id local_actor::get_response_id() { auto id = m_current_node->mid; return (id.is_request()) ? id.response_id() : message_id(); }
inline message_id with_normal_priority() const { return message_id(value_ & ~high_prioity_flag_mask); }
inline message_id request_id() const { return message_id(value_ & request_id_mask); }
inline message_id with_high_priority() const { return message_id(m_value | high_prioity_flag_mask); }
// returns 0 if last_dequeued() is an asynchronous or sync request message, // a response id generated from the request id otherwise inline message_id get_response_id() const { auto mid = current_element_->mid; return (mid.is_request()) ? mid.response_id() : message_id(); }
int DistributeGadget::process(ACE_Message_Block* m) { int node_index = this->node_index(m); if (single_package_mode.value()) { node_index = ++started_nodes_; } if (node_index < 0) { GERROR("Negative node index received"); return GADGET_FAIL; } //If we are not supposed to use this node for compute, add one to make sure we are not on node 0 if (!use_this_node_for_compute.value()) { node_index = node_index+1; } if (node_index == 0) { //process locally if (this->next()->putq(m) == -1) { m->release(); GERROR("DistributeGadget::process, passing data on to next gadget\n"); return GADGET_FAIL; } return GADGET_OK; } //At this point, the node index is positive, so we need to find a suitable connector. mtx_.acquire(); auto n = node_map_.find(node_index); mtx_.release(); GadgetronConnector* con = 0; if (n != node_map_.end()) { //We have a suitable connection already. con = n->second; } else { std::vector<GadgetronNodeInfo> nl; CloudBus::instance()->get_node_info(nl); GDEBUG("Number of network nodes found: %d\n", nl.size()); GadgetronNodeInfo me; me.address = "127.0.0.1";//We may have to update this me.port = CloudBus::instance()->port(); me.uuid = CloudBus::instance()->uuid(); me.active_reconstructions = CloudBus::instance()->active_reconstructions(); //This would give the current node the lowest possible priority if (!use_this_node_for_compute.value()) { me.active_reconstructions = UINT32_MAX; } for (auto it = nl.begin(); it != nl.end(); it++) { if (it->active_reconstructions < me.active_reconstructions) { me = *it; } //Is this a free node if (me.active_reconstructions == 0) break; } con = new DistributionConnector(this); GadgetronXML::GadgetStreamConfiguration cfg; try { deserialize(node_xml_config_.c_str(), cfg); } catch (const std::runtime_error& e) { GERROR("Failed to parse Node Gadget Stream Configuration: %s\n", e.what()); return GADGET_FAIL; } //Configuration of readers for (auto i = cfg.reader.begin(); i != cfg.reader.end(); ++i) { GadgetMessageReader* r = controller_->load_dll_component<GadgetMessageReader>(i->dll.c_str(), i->classname.c_str()); if (!r) { GERROR("Failed to load GadgetMessageReader from DLL\n"); return GADGET_FAIL; } con->register_reader(i->slot, r); } for (auto i = cfg.writer.begin(); i != cfg.writer.end(); ++i) { GadgetMessageWriter* w = controller_->load_dll_component<GadgetMessageWriter>(i->dll.c_str(), i->classname.c_str()); if (!w) { GERROR("Failed to load GadgetMessageWriter from DLL\n"); return GADGET_FAIL; } con->register_writer(i->slot, w); } char buffer[10]; sprintf(buffer,"%d",me.port); if (con->open(me.address,std::string(buffer)) != 0) { GERROR("Failed to open connection to node %s : %d\n", me.address.c_str(), me.port); return GADGET_FAIL; } if (con->send_gadgetron_configuration_script(node_xml_config_) != 0) { GERROR("Failed to send XML configuration to compute node\n"); return GADGET_FAIL; } if (con->send_gadgetron_parameters(node_parameters_) != 0) { GERROR("Failed to send XML parameters to compute node\n"); return GADGET_FAIL; } mtx_.acquire(); node_map_[node_index] = con; mtx_.release(); } if (!con) { //Zero pointer for the connection means that either a) connection creation failed or b) using local chain. //Either way, we will send it down the chain. if (!use_this_node_for_compute.value()) { GERROR("This node cannot be used for computing and no other node is available\n"); m->release(); return GADGET_FAIL; } if (this->next()->putq(m) == -1) { m->release(); GERROR("DistributeGadget::process, passing data on to next gadget\n"); return GADGET_FAIL; } else { return GADGET_OK; } } else { //Let's make sure that we did not send a close message to this connector already auto c = std::find(closed_connectors_.begin(),closed_connectors_.end(),con); if (c != closed_connectors_.end()) { //This is a bad situation, we need to bail out. m->release(); GERROR("The valid connection for incoming data has already been closed. Distribute Gadget is not configured properly for this type of data\n"); return GADGET_FAIL; } //If nodes receive their data sequentially (default), we should see if we should be closing the previos connection if (nodes_used_sequentially.value() && !single_package_mode.value()) { //Is this a new connection, if so, send previous one a close if (prev_connector_ && prev_connector_ != con) { GDEBUG("Sending close to previous connector, not expecting any more data for this one\n"); auto mc = new GadgetContainerMessage<GadgetMessageIdentifier>(); mc->getObjectPtr()->id = GADGET_MESSAGE_CLOSE; if (prev_connector_->putq(mc) == -1) { GERROR("Unable to put CLOSE package on queue of previous connection\n"); return -1; } closed_connectors_.push_back(prev_connector_); } } //Update previous connection prev_connector_ = con; //We have a valid connector auto m1 = new GadgetContainerMessage<GadgetMessageIdentifier>(); m1->getObjectPtr()->id = message_id(m); m1->cont(m); if (con->putq(m1) == -1) { GERROR("Unable to put package on connector queue\n"); m1->release(); return GADGET_FAIL; } if (single_package_mode.value()) { auto m2 = new GadgetContainerMessage<GadgetMessageIdentifier>(); m2->getObjectPtr()->id = GADGET_MESSAGE_CLOSE; if (con->putq(m2) == -1) { GERROR("Unable to put CLOSE package on queue\n"); return -1; } closed_connectors_.push_back(con); } } return 0; }
int main(int argc, char *argv[]) { int errn; string *str; int complete = -1; int i; if(argc < 2) { fprintf(stderr, "Usage: %s connecstring\n", argv[0]); exit(1); } if((mes = new_message(0)) == NULL) { fprintf(stderr, "%s: Cannot open message queue\n", argv[0]); exit(1); } /* * I believe a fork duplicates malloced stuff, I am in the poo if it does not :-) */ errn = fork(); if(errn == -1) { fprintf(stderr, "%s: Cannot fork child process\n", argv[0]); exit(1); } else if(errn) { /* * This is the parent - which behaves like clien */ /* * Initially just a status message is snt back, zero string length * * Still needs a string to put it into */ str = new_string(); if(message_receive(mes, str, &complete, MES_SERVER_TO_CLIENT) < 0) { fprintf(stderr, "%s: %s\n", argv[0], string_s(str)); message_destroy(mes); message_delete(mes); string_delete(str); exit(1); } else { printf("%d\n",message_id(mes)) ; message_delete(mes); string_delete(str); exit(0); } } /* * All parents have exited now */ /* * This is all a child */ /* * I think I need to do this here... * I do not fully understand why, it just works! * otherwise shell parent hangs! */ setsid(); if(fork()) exit(0); close(0); close(1); close(2); /* * We are in daemon mode now */ /* * open the database */ str = new_string(); for(i=1;i<argc;i++) { string_cat(str, argv[i]); if((!strncasecmp(argv[i], "password", 8)) || (!strncasecmp(argv[i], "user", 4)) || (!strncasecmp(argv[i], "useriname", 8))) wipe(argv[i]); if(i < argc - 1) string_cat_c(str, ' '); } sqldb = PQconnectdb(string_s(str)); string_delete(str); if(sqldb == NULL) { message_status(mes, 127, "Error allocating connection\n", MES_SERVER_TO_CLIENT); message_delete(mes); exit(1); } if (PQstatus(sqldb) != CONNECTION_OK) { char ws[64]; snprintf(ws, 63, "Error opening postgres %s/%s\n", PQhost(sqldb), PQdb(sqldb)); ws[63] = 0; message_status(mes, 127, ws, MES_SERVER_TO_CLIENT); PQfinish(sqldb); message_delete(mes); exit(1); } /* * Transmit to parent that we are hunky dory */ message_status(mes, 0, "", MES_SERVER_TO_CLIENT); /* * We are open for business - Lets go */ mainloop(); /* * At the end, tidy up */ PQfinish(sqldb); message_destroy(mes); message_delete(mes); exit(0); }
int main(int, char**) { int failed = 0; // Basic AMQP types RUN_TEST(failed, simple_type_test(null())); RUN_TEST(failed, simple_type_test(false)); RUN_TEST(failed, simple_type_test(uint8_t(42))); RUN_TEST(failed, simple_type_test(int8_t(-42))); RUN_TEST(failed, simple_type_test(uint16_t(4242))); RUN_TEST(failed, simple_type_test(int16_t(-4242))); RUN_TEST(failed, simple_type_test(uint32_t(4242))); RUN_TEST(failed, simple_type_test(int32_t(-4242))); RUN_TEST(failed, simple_type_test(uint64_t(4242))); RUN_TEST(failed, simple_type_test(int64_t(-4242))); RUN_TEST(failed, simple_type_test(wchar_t('X'))); RUN_TEST(failed, simple_type_test(float(1.234))); RUN_TEST(failed, simple_type_test(double(11.2233))); RUN_TEST(failed, simple_type_test(timestamp(1234))); RUN_TEST(failed, simple_type_test(make_fill<decimal32>(0))); RUN_TEST(failed, simple_type_test(make_fill<decimal64>(0))); RUN_TEST(failed, simple_type_test(make_fill<decimal128>(0))); RUN_TEST(failed, simple_type_test(uuid::copy("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"))); RUN_TEST(failed, simple_type_test(std::string("xxx"))); RUN_TEST(failed, simple_type_test(symbol("aaa"))); RUN_TEST(failed, simple_type_test(binary("aaa"))); // Native int type that may map differently per platform to uint types. RUN_TEST(failed, simple_type_test(char(42))); RUN_TEST(failed, simple_type_test(short(42))); RUN_TEST(failed, simple_type_test(int(42))); RUN_TEST(failed, simple_type_test(long(42))); RUN_TEST(failed, simple_type_test(static_cast<signed char>(42))); RUN_TEST(failed, simple_type_test(static_cast<signed short>(42))); RUN_TEST(failed, simple_type_test(static_cast<signed int>(42))); RUN_TEST(failed, simple_type_test(static_cast<signed long>(42))); RUN_TEST(failed, simple_type_test(static_cast<unsigned char>(42))); RUN_TEST(failed, simple_type_test(static_cast<unsigned short>(42))); RUN_TEST(failed, simple_type_test(static_cast<unsigned int>(42))); RUN_TEST(failed, simple_type_test(static_cast<unsigned long>(42))); #if PN_CPP_HAS_LONG_LONG_TYPE RUN_TEST(failed, simple_type_test(static_cast<long long>(42))); RUN_TEST(failed, simple_type_test(static_cast<signed long long>(42))); RUN_TEST(failed, simple_type_test(static_cast<unsigned long long>(42))); #endif // value and scalar types, more tests in value_test and scalar_test. RUN_TEST(failed, simple_type_test(value("foo"))); RUN_TEST(failed, value v(23); simple_type_test(v)); RUN_TEST(failed, simple_type_test(scalar(23))); RUN_TEST(failed, simple_type_test(annotation_key(42))); RUN_TEST(failed, simple_type_test(message_id(42))); // Make sure we reject uncodable types RUN_TEST(failed, (uncodable_type_test<std::pair<int, float> >())); RUN_TEST(failed, (uncodable_type_test<std::pair<scalar, value> >())); RUN_TEST(failed, (uncodable_type_test<std::basic_string<wchar_t> >())); RUN_TEST(failed, (uncodable_type_test<internal::data>())); RUN_TEST(failed, (uncodable_type_test<pn_data_t*>())); return failed; }
int main(int argc, char *argv[]) { int errn; string *str; int complete = -1; int i; char *sqlname[] = { "_dummy", "host", "user", "password", "dbname", "port", "socket", "flag" }; sqlarg *sarg; /* * Username and password may be in the connection string */ long flag = 0; unsigned int port = 0; MYSQL *tdb; if(argc < 2) { fprintf(stderr, "Usage: %s connecstring\n", argv[0]); exit(1); } if((mes = new_message(0)) == NULL) { fprintf(stderr, "%s: Cannot open message queue\n", argv[0]); exit(1); } /* * I believe a fork duplicates malloced stuff, I am in the poo if it does not :-) */ errn = fork(); if(errn == -1) { fprintf(stderr, "%s: Cannot fork child process\n", argv[0]); exit(1); } else if(errn) { /* * This is the parent - which behaves like clien */ /* * Initially just a status message is snt back, zero string length * * Still needs a string to put it into */ str = new_string(); if(message_receive(mes, str, &complete, MES_SERVER_TO_CLIENT) < 0) { fprintf(stderr, "%s: %s\n", argv[0], string_s(str)); message_destroy(mes); message_delete(mes); string_delete(str); exit(1); } else { printf("%d\n",message_id(mes)) ; message_delete(mes); string_delete(str); exit(0); } } /* * All parents have exited now */ /* * This is all a child */ /* * I think I need to do this here... * I do not fully understand why, it just works! * otherwise shell parent hangs! */ setsid(); if(fork()) exit(0); close(0); close(1); close(2); /* * We are in daemon mode now */ /* * open the database */ str = new_string(); for(i=1;i<argc;i++) { string_cat(str, argv[i]); if((!strncasecmp(argv[i], "password", 8)) || (!strncasecmp(argv[i], "user", 4)) || (!strncasecmp(argv[i], "username", 8))) wipe(argv[i]); if(i < argc - 1) string_cat_c(str, ' '); } sarg = new_sqlarg(sqlname, string_s(str), SMYSQL_PARAMETERS); string_delete(str); if(sarg == NULL) { message_status(mes, 127, "Error allocating string parameters\n", MES_SERVER_TO_CLIENT); message_delete(mes); exit(1); } if(sqlargi(sarg, SMYSQL_PORT) != NULL) port = atoi(sqlargi(sarg, SMYSQL_PORT)); if(sqlargi(sarg, SMYSQL_FLAG) != NULL) flag = atol(sqlargi(sarg, SMYSQL_FLAG)); sqldb = mysql_init(NULL); if(sqldb == NULL) { message_status(mes, 127, "Error allocating connection\n", MES_SERVER_TO_CLIENT); sqlarg_delete(sarg); message_delete(mes); exit(1); } tdb = mysql_real_connect(sqldb, sqlargi(sarg, SMYSQL_HOST), sqlargi(sarg, SMYSQL_USER), sqlargi(sarg, SMYSQL_PASSWORD), sqlargi(sarg, SMYSQL_DBNAME), port, sqlargi(sarg, SMYSQL_SOCKET), flag); sqlarg_delete(sarg); if(tdb == NULL) { char ws[128]; snprintf(ws, 127, "Error opening mysql: %s\n", mysql_error(sqldb)); ws[127] = 0; message_status(mes, 127, ws, MES_SERVER_TO_CLIENT); mysql_close(sqldb); message_delete(mes); exit(1); } /* * Transmit to parent that we are hunky dory */ message_status(mes, 0, "", MES_SERVER_TO_CLIENT); /* * We are open for business - Lets go */ mainloop(); /* * At the end, tidy up */ mysql_close(sqldb); message_destroy(mes); message_delete(mes); exit(0); }