/** * \brief Set a mapping of private Template ID to shared Template ID * \param[in,out] src Flow source * \param[in] old_id Private Template ID * \param[in] new_id Shared Template ID */ static void fwd_src_mapping_set(fwd_source_t *src, uint16_t old_id, uint16_t new_id) { // Set the mapping uint16_t *group = src->map[old_id / GROUP_SIZE]; if (!group) { // Not found -> create a new group uint16_t **new_grp = &src->map[old_id / GROUP_SIZE]; *new_grp = calloc(GROUP_SIZE, sizeof(*group)); if (*new_grp == NULL) { MSG_ERROR(msg_module, "Memory allocation failed (%s:%d)", __FILE__, __LINE__); return; } group = *new_grp; } if (fwd_odid_template_increment(src->maintainer, new_id)) { MSG_ERROR(msg_module, "Unable to update a number of references to " "a template (ID: %" PRIu16 ").", new_id); } MSG_DEBUG(msg_module, "A new template mapping of a source with ODID " "%" PRIu32 " (private: %" PRIu16 " -> share: %" PRIu16 ").", src->odid, old_id, new_id); group[old_id % GROUP_SIZE] = new_id; }
/** * \brief Create a template record * \param[in] rec Binary template record * \param[in] length Length of the binary template record (octets) * \param[in] type Type of the template (#TM_TEMPLATE or #TM_OPTIONS_TEMPLATE) * \param[in] new_id New Template ID * \return Pointer or NULL */ static fwd_tmplt_t *fwd_tmplt_create(const struct ipfix_template_record *rec, size_t length, int type, uint16_t new_id) { fwd_tmplt_t *res = calloc(1, sizeof(*res)); if (!res) { MSG_ERROR(msg_module, "Memory allocation failed (%s:%d)", __FILE__, __LINE__); return NULL; } // Copy the template record res->rec = malloc(length); if (!res->rec) { MSG_ERROR(msg_module, "Memory allocation failed (%s:%d)", __FILE__, __LINE__); free(res); return NULL; } memcpy(res->rec, rec, length); res->rec->template_id = htons(new_id); res->length = length; res->id = new_id; res->ref_cnt = 0; res->type = type; return res; }
int KULLANICILAR_FORMU::CHECK_UPDATE (int p_kullanici_id ) { SQL_QUERY sql_query ( G_YONETIM_DB ); sql_query.PREPARE_SELECT ( "ynt_kullanicilar","kullanici_id","kullanici_kodu = :kullanici_kodu " "AND silinmis_mi = :silinmis_mi ","" ); sql_query.SET_VALUE ( ":kullanici_kodu" , m_ui->lineEdit_kullanici_kodu->text() ); sql_query.SET_VALUE ( ":silinmis_mi" ,0 ); if ( sql_query.SELECT() > 0 ) { sql_query.NEXT(); if ( sql_query.VALUE(0).toInt() NE p_kullanici_id ) { MSG_ERROR(tr ( "There are registered users in the system with this code." ) , NULL);//bu kodla kullanıcı sistemde mevcut return ADAK_FAIL; } } if ( m_ui->check_box_sifre->isChecked() EQ true ) { if ( m_ui->line_edit_yeni_sifre->text() NE m_ui->line_edit_yeni_sifre_tekrar->text() ) { MSG_ERROR("New and repeat passwords do not match,Please check.",m_ui->line_edit_yeni_sifre);//Girdiğiniz yeni şifre ve tekrarı uyuşmuyor Lütfen kontrol ediniz. return ADAK_FAIL; } } ADAK_MSG_ENUM answer = MSG_YES_NO_CANCEL( tr ( "Do you approve of the changes you made?" ) , NULL);//Yapılan değişiklikleri onaylıyor musunuz? if ( answer EQ ADAK_CANCEL OR answer EQ ADAK_NO ) { return ADAK_FAIL; } return ADAK_OK; }
/** * \brief Initialize Intermediate Process. */ int ip_init(struct intermediate *conf, uint32_t ip_id) { int ret; /* Initialize plugin */ xmlChar *ip_params = NULL; xmlDocDumpMemory(conf->xml_conf->xmldata, &ip_params, NULL); conf->intermediate_init((char *) ip_params, conf, ip_id, template_mgr, &(conf->plugin_config)); if (conf->plugin_config == NULL) { MSG_ERROR(msg_module, "Unable to initialize intermediate process"); return -1; } free(ip_params); /* start main thread */ ret = pthread_create(&(conf->thread_id), NULL, ip_loop, (void *)conf); if (ret != 0) { MSG_ERROR(msg_module, "Unable to create thread for intermediate process"); return -1; } return 0; }
/*=========================================================================== * * FUNCTION: secapi_oem_csprng_seed_get () * * DESCRIPTION: * * See header file * ===========================================================================*/ secerrno_enum_type secapi_oem_csprng_seed_get (uint8* seed_ptr, uint16 seed_len) { secerrno_enum_type stat = E_NOT_AVAILABLE; uint8 *_seed_ptr = (uint8*)seed_ptr; if ((NULL == seed_ptr) || (0 == seed_len)) { return E_INVALID_ARG; } stat = secutil_get_nv_item( NV_SEC_CSPRNG_INIT_SEED_I, _seed_ptr, seed_len ); if( E_SUCCESS == stat ) { MSG_MED("sec_oem_util: nv data for csprng! retrieved", 0, 0, 0); } else if( stat == E_NO_DATA ) { MSG_ERROR("sec_oem_util: no nv data for csprng!", 0, 0, 0); } else { MSG_ERROR("sec_oem_util: error reading nv data for csprng (%d)!", stat, 0, 0); } return stat; }
/** * \brief Initialize a group structure for channels or profiles * * \param[out] grp Pointer to the group * \param[in] items_cnt Number of items (can be re-sized in the future) * \return On success returns 0. Otherwise returns a non-zero value and the * content of the structure is undefined. */ static int group_init(struct pevents_group *grp, size_t items_cnt) { if (items_cnt == 0) { return 1; } // Clear everything memset(grp, 0, sizeof(*grp)); // Allocate an array of items grp->all_prealloc = items_cnt; grp->all_ptr = calloc(items_cnt, sizeof(*(grp->all_ptr))); if (!grp->all_ptr) { MSG_ERROR(msg_module, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__); return 1; } // Prepare a bitset grp->bitset = bitset_create(items_cnt); if (!grp->bitset) { MSG_ERROR(msg_module, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__); free(grp->all_ptr); return 1; } return 0; }
// Create a template manager fwd_tmplt_mgr_t *tmplts_create() { fwd_tmplt_mgr_t *res = calloc(1, sizeof(*res)); if (!res) { MSG_ERROR(msg_module, "Memory allocation failed (%s:%d)", __FILE__, __LINE__); return NULL; } res->odid_arr_size = 0; res->odid_arr_max = ARRAY_DEF_SIZE; res->odid_arr = calloc(res->odid_arr_max, sizeof(*res->odid_arr)); if (!res->odid_arr) { MSG_ERROR(msg_module, "Memory allocation failed (%s:%d)", __FILE__, __LINE__); free(res); return NULL; } res->src_arr_size = 0; res->src_arr_max = ARRAY_DEF_SIZE; res->src_arr = calloc(res->src_arr_max, sizeof(*res->src_arr)); if (!res->src_arr) { MSG_ERROR(msg_module, "Memory allocation failed (%s:%d)", __FILE__, __LINE__); free(res->odid_arr); free(res); return NULL; } return res; }
/** * \brief Remove a template definition * \param[in,out] odid Observation Domain (ODID) maintainer * \param[in] id Template ID */ static void fwd_odid_template_remove(fwd_odid_t *odid, uint16_t id) { fwd_tmplt_t **group = odid->tmplts[id / GROUP_SIZE]; fwd_tmplt_t *rec = NULL; if (group) { rec = group[id % GROUP_SIZE]; } if (!rec) { MSG_ERROR(msg_module, "Unable to find and delete a shared template " "record (ID %" PRIu16 ") from ODID %" PRIu32 ".", id, odid->odid); return; } MSG_DEBUG(msg_module, "A template (ID: %" PRIu16 ") removed from ODID " "%" PRIu32 ".", id, odid->odid); switch (rec->type) { case TM_TEMPLATE: odid->templates_normal--; break; case TM_OPTIONS_TEMPLATE: odid->templates_options--; break; default: MSG_ERROR(msg_module, "Internal error: Invalid type (%d) of a template " "(ODID: %" PRIu32 ", Template ID: %" PRIu16 ")", rec->type, odid->odid, rec->id); break; } fwd_tmplt_destroy(rec); group[id % GROUP_SIZE] = NULL; }
/** * \brief Initiate internal configuration file - open, get xmlDoc and prepare * XPathContext. Also register namespace "urn:cesnet:params:xml:ns:yang:ipfixcol-internals" * with given namespace name. * * @param[in] ns_name Name for the "urn:cesnet:params:xml:ns:yang:ipfixcol-internals" * namespace in xpath queries. * @return XPath Context for the internal XML configuration. Caller will need to * free it including separated free of return->doc. */ static xmlXPathContextPtr ic_init(xmlChar* ns_name, char *internal_cfg) { int fd; xmlDocPtr doc = NULL; xmlXPathContextPtr ctxt = NULL; /* open and prepare internal XML configuration file */ if ((fd = open(internal_cfg, O_RDONLY)) == -1) { MSG_ERROR(msg_module, "Unable to open internal configuration file %s (%s)", internal_cfg, strerror(errno)); return (NULL); } if ((doc = xmlReadFd(fd, NULL, NULL, XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NOBLANKS)) == NULL) { MSG_ERROR(msg_module, "Unable to parse internal configuration file %s", internal_cfg); close(fd); return (NULL); } close(fd); /* create xpath evaluation context of internal configuration file */ if ((ctxt = xmlXPathNewContext(doc)) == NULL) { MSG_ERROR(msg_module, "Unable to create XPath context for internal configuration (%s:%d)", __FILE__, __LINE__); xmlFreeDoc(doc); return (NULL); } /* register namespace for the context of internal configuration file */ if (xmlXPathRegisterNs (ctxt, ns_name, BAD_CAST "urn:cesnet:params:xml:ns:yang:ipfixcol-internals") != 0) { MSG_ERROR(msg_module, "Unable to register namespace for internal configuration file (%s:%d)", __FILE__, __LINE__); xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); return (NULL); } return (ctxt); }
/** * \brief Start Output Manager's thread(s) * * @return 0 on success */ int output_manager_start() { int retval; /* Create Output Manager thread */ retval = pthread_create(&(conf->thread_id), NULL, &output_manager_plugin_thread, (void *) conf); if (retval != 0) { MSG_ERROR(msg_module, "Unable to create Output Manager thread"); free(conf); return -1; } conf->running = 1; if (conf->stat_interval > 0) { retval = pthread_create(&(conf->stat_thread), NULL, &statistics_thread, (void *) conf); if (retval != 0) { MSG_ERROR(msg_module, "Unable to create statistics thread"); free(conf); return -1; } } return 0; }
/** * \brief Storage plugin initialization. * * \param[in] params parameters for this storage plugin * \param[out] config the plugin specific configuration structure * \return 0 on success, negative value otherwise */ int storage_init(char *params, void **config) { MSG_INFO(msg_module, "Dummy plugin: storage_init called"); struct dummy_config *conf; xmlDocPtr doc; xmlNodePtr cur; /* allocate space for config structure */ conf = (struct dummy_config *) malloc(sizeof(*conf)); if (conf == NULL) { MSG_ERROR(msg_module, "Not enough memory (%s:%d)", __FILE__, __LINE__); return -1; } /* try to parse configuration file */ doc = xmlReadMemory(params, strlen(params), "nobase.xml", NULL, 0); if (doc == NULL) { MSG_ERROR(msg_module, "Plugin configuration parsing failed"); goto err_read_conf; } cur = xmlDocGetRootElement(doc); if (cur == NULL) { MSG_ERROR(msg_module, "Empty configuration"); goto err_init; } if (xmlStrcmp(cur->name, (const xmlChar *) "fileWriter")) { MSG_ERROR(msg_module, "Root node != fileWriter"); goto err_init; } /* default delay */ conf->delay = 0; cur = cur->xmlChildrenNode; while (cur != NULL) { /* find out the desired delay */ if ((!xmlStrcmp(cur->name, (const xmlChar *) "delay"))) { conf->delay = atoi((char *) xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); break; } cur = cur->next; } MSG_INFO(msg_module, "Dummy plugin: delay set to %ius", conf->delay); /* we don't need this xml tree anymore */ xmlFreeDoc(doc); /* pass config to core */ *config = conf; return 0; err_init: xmlFreeDoc(doc); err_read_conf: free(conf); return -1; }
int SQL_TABLOLAR_FISI::CHECK_UPDATE_LINE ( int p_tablo_id, int p_row_number ) { if ( KAYIT_GUNCELLEME_YETKISI_VAR_MI( KULLANICI_ID() ) EQ 0 ) { MSG_ERROR(tr("This user has no authority for Update registration."),m_ui->lineEdit_tablo_adi);//Bu kullanıcının kayıt güncelleme yetkisi yok return ADAK_FAIL; } QLineEdit * alan_adi_lineEdit = ( QLineEdit * ) m_ui->tablewidget_tablo_satirlari->cellWidget( p_row_number, ALAN_ADI_COLUMN ); int row_id = m_ui->tablewidget_tablo_satirlari->item( p_row_number, ROW_ID_COLUMN )->text().toInt(); SQL_QUERY sql_query (DB); sql_query.PREPARE_SELECT( "sql_alanlar","alan_id","tablo_id = :tablo_id AND alan_adi = :alan_adi" ); sql_query.SET_VALUE ( ":tablo_id", p_tablo_id ); sql_query.SET_VALUE ( ":alan_adi" , alan_adi_lineEdit->text() ); if ( sql_query.SELECT() EQ 0 ) { return ADAK_OK; } sql_query.NEXT(); if ( sql_query.VALUE(0).toInt() NE row_id ) { MSG_ERROR(tr("This field name used for another field in this table."),alan_adi_lineEdit); return ADAK_FAIL; } return ADAK_OK; }
int SQL_TABLOLAR_FISI::CHECK_LINE_EMPTY ( int p_row_number ) { QCommaEdit * dizi_boyutu_commaEdit = ( QCommaEdit * ) m_ui->tablewidget_tablo_satirlari->cellWidget ( p_row_number, DIZI_BOYUT_COLUMN ); QLineEdit * alan_adi_lineEdit = ( QLineEdit * ) m_ui->tablewidget_tablo_satirlari->cellWidget ( p_row_number, ALAN_ADI_COLUMN ); QCheckBox * dizi_mi_checkbox = ( QCheckBox * ) m_ui->tablewidget_tablo_satirlari->cellWidget ( p_row_number, DIZI_MI_COLUMN ); QCommaEdit * commaEdit_alan_boyutu = ( QCommaEdit * ) m_ui->tablewidget_tablo_satirlari->cellWidget ( p_row_number, ALAN_BOYUT_COLUMN ); QComboBox * comboBox_alan_tipi = ( QComboBox * ) m_ui->tablewidget_tablo_satirlari->cellWidget ( p_row_number, ALAN_TIPI_COLUMN ); if ( dizi_mi_checkbox->isChecked() EQ true ) { if ( dizi_boyutu_commaEdit->GET_INTEGER () < 2 ) { MSG_ERROR(tr("Array size must be greater than 1 "),dizi_mi_checkbox);//Dizi boyutu 1 den büyük olmalıdır return ADAK_FAIL; } } if ( alan_adi_lineEdit->text().isEmpty() EQ true ) { MSG_ERROR(tr ("Field name must not be empty."),alan_adi_lineEdit);//Alan adı boş bırakılamaz return ADAK_FAIL; } if ( GET_ADAK_SQL_ENUM ( comboBox_alan_tipi->currentText() ) EQ TEXT ) { if ( commaEdit_alan_boyutu->GET_INTEGER () < 1 ) { MSG_ERROR(tr("Field length must be entered for a field of type TEXT."),commaEdit_alan_boyutu);//TEXT tipinde bir alan için alan uzunluğu girilmek zorundadır return ADAK_FAIL; } } return ADAK_OK; }
/** * \brief Remove all templates of a defined type from a Flow source * \param[in,out] src Flow source * \param[in] type Type of the templates (#TM_TEMPLATE or #TM_OPTIONS_TEMPLATE) */ static void fwd_src_withdraw_type(fwd_source_t *src, int type) { const unsigned int min = IPFIX_MIN_RECORD_FLOWSET_ID; const unsigned int max = FWD_MAX_RECORD_FLOWSET_ID; if (type != TM_TEMPLATE && type != TM_OPTIONS_TEMPLATE) { MSG_ERROR(msg_module, "Trying to delete invalid type of templates."); return; } unsigned int private_id; for (private_id = min; private_id <= max; ++private_id) { // Get a mapping of the ID uint16_t shared_id = fwd_src_mapping_get(src, private_id); if (shared_id == 0) { continue; } // Check a type of a template const fwd_tmplt_t *tmplt; tmplt = fwd_odid_template_get(src->maintainer, shared_id); if (!tmplt) { MSG_ERROR(msg_module, "Unable to get a reference to a shared " "template (ID: %" PRIu16 ").", shared_id); continue; } if (tmplt->type != type) { continue; } fwd_src_mapping_remove(src, private_id); } }
int load_types_from_xml(struct fastbit_config *conf) { pugi::xml_document doc; pugi::xml_parse_result result; uint32_t en; uint16_t id; enum store_type type; std::string str_value; result = doc.load_file("/etc/ipfixcol/ipfix-elements.xml"); /* Check for errors */ if (!result) { MSG_ERROR(MSG_MODULE, "/etc/ipfixcol/ipfix-elements.xml parsed with errors!"); MSG_ERROR(MSG_MODULE, "Error description: %s", result.description()); return -1; } pugi::xpath_node_set elements = doc.select_nodes("/ipfix-elements/element"); for (pugi::xpath_node_set::const_iterator it = elements.begin(); it != elements.end(); ++it) { //pugi::xpath_node node = *it; str_value = it->node().child_value("enterprise"); en = strtoul(str_value.c_str(),NULL,0); str_value = it->node().child_value("id"); id = strtoul(str_value.c_str(),NULL,0); str_value = it->node().child_value("dataType"); if (str_value =="unsigned8" or str_value =="unsigned16" or str_value =="unsigned32" or str_value =="unsigned64" or \ str_value =="dateTimeSeconds" or str_value =="dateTimeMilliseconds" or str_value =="dateTimeMicroseconds" or \ str_value =="dateTimeNanoseconds" or str_value =="ipv4Address" or str_value =="macAddress" or str_value == "boolean") { type =UINT; } else if (str_value =="signed8" or str_value =="signed16" or str_value =="signed32" or str_value =="signed64" ) { type = INT; } else if (str_value =="ipv6Address") { type = IPv6; } else if (str_value =="float32" or str_value =="float64") { type = FLOAT; } else if (str_value =="string") { type = TEXT; } else if (str_value =="octetArray" or str_value =="basicList" or str_value =="subTemplateList" or str_value=="subTemplateMultiList") { type = BLOB; } else { type = UNKNOWN; } //conf->elements_types->insert(std::make_pair(en , std::make_pair(id, type))); (*conf->elements_types)[en][id] = type; //std::cout << "el loaded: " << en << ":" << id <<":"<< type << std::endl; } return 0; }
int KULLANICILAR_FORMU::CHECK_EMPTY () { if ( m_ui->lineEdit_kullanici_kodu->text().isEmpty() EQ true ) { MSG_ERROR(tr ( "User code can not be empty." ) , m_ui->lineEdit_kullanici_kodu );//Kullanıcı kodu boş bırakılamaz return ADAK_FAIL; } if ( m_ui->lineEdit_kullanici_adi->text().isEmpty() EQ true ) { MSG_ERROR(tr ( "User name can not be empty." ) , m_ui->lineEdit_kullanici_adi); return ADAK_FAIL; } return ADAK_OK; }
int SQL_TABLOLAR_FISI::CHECK_FIS_FORM_EMPTY() { if ( m_ui->lineEdit_tablo_adi->text().isEmpty() EQ true ) { MSG_ERROR(tr("Table name must not be empty."),m_ui->lineEdit_tablo_adi);//Tablo ismi boş bırakılamaz return ADAK_FAIL; } if ( m_ui->lineEdit_alan_adi->text().isEmpty() EQ true ) { MSG_ERROR(tr ("The Column name which in UNIQUE ID must not be empty. "),m_ui->lineEdit_alan_adi);//UNIQUE ID olan kolonun adı boş bırakılamaz return ADAK_FAIL; } return ADAK_OK; }
/** * \brief Insert a template definition * * Find an unused Template ID among shared templates in ODID and then insert * the template with this new ID to the ODID maintainer. * \param[in,out] odid Observation Domain (ODID) maintainer * \param[in] rec Template record * \param[in] rec_len Length of the template record * \param[in] rec_type Type of the template (#TM_TEMPLATE or #TM_OPTIONS_TEMPLATE) * \return On success returns new Template ID assigned to the template (>= 256). * Otherwise returns 0. */ static uint16_t fwd_odid_template_insert(fwd_odid_t *odid, const struct ipfix_template_record *rec, size_t rec_len, int rec_type) { // Create a template record const uint16_t old_id = ntohs(rec->template_id); const uint16_t new_id = fwd_odid_template_unused_id(odid, old_id); if (new_id == 0) { MSG_ERROR(msg_module, "Unable to add a new template to the Observation " "Domain ID %" PRIu32 ". All available Template IDs are already " "used. Some flows will be definitely lost.", odid->odid); return 0; } if (rec_type != TM_TEMPLATE && rec_type != TM_OPTIONS_TEMPLATE) { MSG_ERROR(msg_module, "Unable to add a new template to the Observation " "Domain ID %" PRIu32 ". Invalid type (%d) of the template .", odid->odid, rec_type); return 0; } fwd_tmplt_t *tmplt = fwd_tmplt_create(rec, rec_len, rec_type, new_id); if (!tmplt) { return 0; } // Store the template fwd_tmplt_t **group = odid->tmplts[new_id / GROUP_SIZE]; if (!group) { // Not found -> create a new group fwd_tmplt_t ***new_grp = &odid->tmplts[new_id / GROUP_SIZE]; *new_grp = calloc(GROUP_SIZE, sizeof(*group)); if (*new_grp == NULL) { MSG_ERROR(msg_module, "Memory allocation failed (%s:%d)", __FILE__, __LINE__); fwd_tmplt_destroy(tmplt); return 0; } group = *new_grp; } odid->to_remove++; // There are no references to this template yet if (rec_type == TM_TEMPLATE) { odid->templates_normal++; } else { odid->templates_options++; } MSG_DEBUG(msg_module, "New template (ID: %" PRIu16 ") added to ODID " "%" PRIu32 ".", new_id, odid->odid); group[new_id % GROUP_SIZE] = tmplt; return new_id; }
/*=========================================================================== FUNCTION gstk_send_ss_cnf_cleanup DESCRIPTION This function cleans up any allocated pointer on the stack. PARAMETERS send_ss_cnf_ptr: [Input] Pointer to message that is required to be processed and sent to UIM STK_response_ptr: [Input] Pointer to the STK intermediate message has_cc : [Input] has call control has_ussd_string : [Input] contains ussd string DEPENDENCIES None RETURN VALUE None COMMENTS None SIDE EFFECTS None SEE ALSO None ===========================================================================*/ static void gstk_send_ss_cnf_cleanup( gstk_send_ss_cnf_type *send_ss_cnf_ptr, setup_call_send_ss_terminal_response_type *STK_response_ptr, boolean has_cc, boolean has_ussd_string) { if(STK_response_ptr == NULL) { MSG_ERROR("STK_response_ptr ERR:NULL",0,0,0); return; } if(send_ss_cnf_ptr == NULL) { MSG_ERROR("send_ss_cnf_ptr ERR:NULL",0,0,0); return; } /* free the text string byte pointer from STK_response_ptr and send_ss_cnf_ptr */ /* STK_response_ptr: cc_req_action: ussd string, alpha text string 2 result 2's additional info */ gstk_util_release_upper_layer_cmd_memory( (gstk_cmd_type*)send_ss_cnf_ptr);/*lint !e826 area too small */ if (has_cc) { if (STK_response_ptr->cc_req_action.alpha.alpha != NULL) { gstk_free(STK_response_ptr->cc_req_action.alpha.alpha); STK_response_ptr->cc_req_action.alpha.alpha = NULL; } if (STK_response_ptr->result2_for_cc.additional_info != NULL) { gstk_free(STK_response_ptr->result2_for_cc.additional_info); STK_response_ptr->result2_for_cc.additional_info = NULL; } if (has_ussd_string) { if (STK_response_ptr->cc_req_action.gstk_address_string_tlv.ussd_string.text != NULL) { gstk_free(STK_response_ptr->cc_req_action.gstk_address_string_tlv.ussd_string.text); STK_response_ptr->cc_req_action.gstk_address_string_tlv.ussd_string.text = NULL; } if (STK_response_ptr->cc_mod_text2.text != NULL) { gstk_free(STK_response_ptr->cc_mod_text2.text); STK_response_ptr->cc_mod_text2.text = NULL; } } } if (STK_response_ptr->header.result.additional_info != NULL) { gstk_free(STK_response_ptr->header.result.additional_info); } } /* gstk_send_ss_cnf_cleanup */
/** * \brief Initialize the iterator of IPFIX elements over a XML document * * After success intilialization call #elem_iter_next to get first element. * \param[in] fd An opened file descriptor of XML document * \return On success returns pointer to the initialized iterator. Otherwise * returns NULL. */ static struct elem_xml_iter *elem_iter_init(int fd) { struct elem_xml_iter *iter; iter = (struct elem_xml_iter *) calloc(1, sizeof(struct elem_xml_iter)); if (!iter) { MSG_ERROR(msg_module, "CALLOC FAILED! (%s:%d)", __FILE__, __LINE__); return NULL; } // Load XML document iter->doc = xmlReadFd(fd, NULL, NULL, XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NOBLANKS | XML_PARSE_BIG_LINES); if (!iter->doc) { MSG_ERROR(msg_module, "Unable to parse XML document with IPFIX " " elements."); free(iter); return NULL; } // Get XPath context and evaluate expression iter->xpath_ctx = xmlXPathNewContext(iter->doc); if (!iter->xpath_ctx) { MSG_ERROR(msg_module, "Unable to get XPath context of XML document " "with IPFIX elements."); xmlFreeDoc(iter->doc); free(iter); return NULL; } iter->xpath_obj = xmlXPathEvalExpression(BAD_CAST ELEM_XML_XPATH, iter->xpath_ctx); if (!iter->xpath_obj) { MSG_ERROR(msg_module, "Unable to evaluate XPath expression."); xmlXPathFreeContext(iter->xpath_ctx); xmlFreeDoc(iter->doc); free(iter); return NULL; } if (xmlXPathNodeSetIsEmpty(iter->xpath_obj->nodesetval)) { MSG_ERROR(msg_module, "No IPFIX elements in XML document."); xmlXPathFreeObject(iter->xpath_obj); xmlXPathFreeContext(iter->xpath_ctx); xmlFreeDoc(iter->doc); free(iter); return NULL; } return iter; }
/*=========================================================================== FUNCTION DS707_DATA_SESSION_REG_IFACE_EVENTS DESCRIPTION This function registers for iface up and iface down event for v4 iface. PARAMETERS None DEPENDENCIES None RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ void ds707_data_session_reg_iface_events(void) { ps_iface_type * iface_ptr; /* ptr to 1x iface */ void * iface_buf_ptr; /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ iface_ptr = GET_PS_IFACE_PTR( DS707_DEF_PKT_INSTANCE ); if( iface_ptr == NULL ) { MSG_ERROR(" NULL iface pointer ",0,0,0); ASSERT(0); } /*----------------------------------------------------------------------- Initialize and register the iface down ind callback info. -----------------------------------------------------------------------*/ iface_buf_ptr = ps_iface_alloc_event_cback_buf ( ds707_data_session_iface_event_cb, (void *)DS707_DEF_PKT_INSTANCE ); if ( iface_buf_ptr == NULL ) { MSG_ERROR("Event buf allocation failed",0,0,0); ASSERT(0); } if( ps_iface_event_cback_reg( iface_ptr, IFACE_DOWN_EV, iface_buf_ptr ) < 0 ) { MSG_ERROR("IFACE_DOWN event reg failed", 0, 0, 0 ); } /*----------------------------------------------------------------------- Initialize and register the iface up ind callback info. -----------------------------------------------------------------------*/ iface_buf_ptr = ps_iface_alloc_event_cback_buf ( ds707_data_session_iface_event_cb, (void *)DS707_DEF_PKT_INSTANCE ); if ( iface_buf_ptr == NULL ) { MSG_ERROR("Event buf allocation failed",0,0,0); ASSERT(0); } if( ps_iface_event_cback_reg( iface_ptr, IFACE_UP_EV, iface_buf_ptr ) < 0 ) { MSG_ERROR( "IFACE_UP event reg failed", 0, 0, 0 ); } }
/*=========================================================================== FUNCTION MIP_EVENT_ALLOC() DESCRIPTION This function will allocate a MIP event information structure and register callback functions. PARAMETERS mip_cb_f: callback function to call user_data: user data to be returned with the callback fn. RETURN VALUE NULL on error handle to the MIP event information structure on success DEPENDENCIES None SIDE EFFECTS Allocates a MIP event information structure and places it on the event queue. Initializes event masks and registers callbacks for MIP protocol. ===========================================================================*/ void *mip_event_alloc ( mip_event_cback_f_ptr_type mip_cb_f, void *user_data ) { mip_event_info_s_type *event_info_ptr = NULL; mip_session_info_type *mip_session; /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*------------------------------------------------------------------------- Check that the callback is not NULL. -------------------------------------------------------------------------*/ if( NULL == mip_cb_f ) { MSG_ERROR("NULL functions passed", 0, 0, 0); ASSERT( 0 ); return NULL; } /*------------------------------------------------------------------------- Get default MIP session -------------------------------------------------------------------------*/ mip_session = &mip_ses_info_array[0]; if( mip_session->mip_event_client_cnt >= MIP_EVENT_CLIENT_MAX ) { MSG_ERROR("Couldn't allocate event info structure", 0, 0, 0); ASSERT( 0 ); } else { /*------------------------------------------------------------------------- Get a new event information structure -------------------------------------------------------------------------*/ event_info_ptr = &mip_event_buf[mip_session->mip_event_client_cnt++]; /*----------------------------------------------------------------------- Initialize the event information structure -----------------------------------------------------------------------*/ memset( event_info_ptr, 0, sizeof(mip_event_info_s_type) ); /*----------------------------------------------------------------------- Fill the structure with the passed callbacks and user_data cookies -----------------------------------------------------------------------*/ event_info_ptr->cback = mip_cb_f; event_info_ptr->user_data = user_data; } return event_info_ptr; } /* mip_event_alloc() */
void ADRES_RAPOR_FILTRESI_BATCH::RUN_BATCH() { switch ( m_adres_rapor_turu ) { case ADRES_ILETISIM_RAPORU : default : if ( RAPOR_VERILERINI_OLUSTUR() EQ false ) { return; } OPEN_REPORT_SHOWER ( OPEN_ADRES_KAYITLARI_RAPORU ( ADRES_ILETISIM_RAPORU, m_adres_kayit_turu, M_ADRES_KAYIT_RAPORU_BILGILERI), nativeParentWidget() ); break; case ADRES_BILGILERI_RAPORU: if ( RAPOR_VERILERINI_OLUSTUR() EQ false ) { return; } OPEN_REPORT_SHOWER ( OPEN_ADRES_KAYITLARI_RAPORU ( ADRES_BILGILERI_RAPORU,m_adres_kayit_turu, M_ADRES_ETIKET_BILGILERI ), nativeParentWidget() ); break; case ADRES_ETIKETLERI_RAPORU : if ( RAPOR_VERILERINI_OLUSTUR() EQ false ) { return; } OPEN_ADRES_ETIKETLERI_BATCH ( M_ADRES_ETIKET_BILGILERI, this ); break; case TOPLU_MAIL_GONDERIMI : if ( RAPOR_VERILERINI_OLUSTUR() EQ false ) { return; } if ( M_TOPLU_MAIL_BILGILERI.isEmpty() EQ true ) { MSG_ERROR ( "E-Posta gönderilebilecek kayıt bulunamadı." , NULL ); return; } OPEN_ADRES_TOPLU_MAIL_GONDERIMI_BATCH ( M_TOPLU_MAIL_BILGILERI, this ); break; case TOPLU_SMS_GONDERIMI: if ( RAPOR_VERILERINI_OLUSTUR() EQ false ) { return; } if ( M_SMS_BILGILERI.isEmpty() EQ true ) { MSG_ERROR ( "SMS gönderilebilecek kayıtlı bir cep telefon bulunamadı." , NULL ); return; } else { MSG_INFO (QString("SMS Gönderilecek Numaralar:\n%1").arg(M_SMS_BILGILERI),NULL); } SHOW_SMS_GUI("",M_SMS_BILGILERI,"",this); break; } }
//----------------------------------------------------------------------------- // Purpose: Parse another file specified in argument //----------------------------------------------------------------------------- void GlobalVars::ExecFileCmds(string line) { typedef tokenizer<char_separator<char>> my_tok; char_separator<char> sep(" "); my_tok tok(line, sep); vector<string> str; for (my_tok::const_iterator i = tok.begin(); i != tok.end(); i++) { str.push_back(*i); } ifstream file(str[1].c_str()); if (file) { string line; while (getline(file, line)) { if (file.fail()) { MSG_ERROR("An exception has occurred in the file"); } if (line.find("//") == string::npos) { if (line.find("=") != string::npos) { SplitString(line); } if (line.find("exec") != string::npos) { ExecFileCmds(line); } } } file.close(); } else { MSG_ERROR("Couldn't open the file"); } }
Object_3DS::Object_3DS(const char* filename):file(NULL) { #ifdef HAS_LIB3DS file=lib3ds_file_load(filename); if(!file) { MSG_ERROR("Can't load 3ds file %s",filename); } else lib3ds_file_eval(file,0); #else MSG_ERROR("Object_3DS can't be used. Please ensure lib3ds is linked correctly!"); #endif }
int GRUP_KERNEL::CHECK_DELETE_ITEM (QStringList item) { int item_id = -1; if ( item.size() NE 0 ) { item_id = item.at( m_grp_id_column ).toInt(); } if ( item_id EQ -1 ) { return ADAK_FAIL; } if ( item.at(2).toInt() NE 0 ) { MSG_ERROR(tr ( "You must delete sub-group for deleting this group. "),NULL);//Grubu silebilmek için,önce grubun alt gruplarını silmelisiniz!.. return ADAK_FAIL; } ADAK_MSG_ENUM answer = MSG_YES_NO(tr ( "Group will be deleted '%1 %2'" ).arg(item.at(7)).arg(item.at(1)),NULL); if ( answer EQ ADAK_NO OR answer EQ ADAK_CANCEL) { return ADAK_FAIL; } SQL_QUERY select_query ( m_db ); QString table_name = ""; QString column_name = ""; QString where_name = ""; QString order_by = ""; CREATE_SELECT_QUERY(&table_name,&column_name,&where_name,&order_by,item.at( 5 ).toInt()); select_query.PREPARE_SELECT ( table_name,column_name,where_name,"" ); if ( select_query.SELECT(order_by) EQ 1 ) { if ( item.at(3).toInt() NE 0 ) { m_grubu_parentine_aktar = true; } return ADAK_OK; } if ( item.at( 3 ).toInt() NE 0 ) { MSG_ERROR(tr ( "It was recorded in the group. You can not delete the group..." ),NULL);//Gruba kayıt yapılmış. Grubu silemezsiniz.. return ADAK_FAIL; } return ADAK_OK; }
int SQL_TABLOLAR_FISI::CHECK_FIS_RECORD_ADD() { if ( KAYIT_EKLEME_YETKISI_VAR_MI ( KULLANICI_ID() ) EQ 0 ) { MSG_ERROR(tr("This user has no authority to add records. "),m_ui->lineEdit_tablo_adi);//Bu kullanıcının kayıt ekleme yetkisi yok return ADAK_FAIL; } SQL_QUERY sql_query ( DB ); sql_query.PREPARE_SELECT("sql_tablolar","tablo_id","tablo_adi = :tablo_adi"); sql_query.SET_VALUE ( ":tablo_adi", m_ui->lineEdit_tablo_adi->text()); if ( sql_query.SELECT() > 0 ) { MSG_ERROR(tr("This table name is used for another table."),m_ui->lineEdit_tablo_adi);//Bu isimle bir tablo sistemde mevcut return ADAK_FAIL; } return ADAK_OK; }
/* Open a file and put its content in a variable ('str' accept printf-like format) */ int fopen_to_str(char **buffer, char *str, ...) { char tmp[MAXSTR]; char *file_str = NULL; FILE *file_descr = NULL; va_list aptr; va_start(aptr, str); vasprintf(&file_str, str, aptr); va_end(aptr); if(access(file_str, R_OK)) { free(file_str); return -1; } if((file_descr = fopen(file_str, "r")) == NULL) goto error; if(fgets(tmp, MAXSTR, file_descr) == NULL) goto error; tmp[strlen(tmp) - 1] = '\0'; asprintf(buffer, tmp); free(file_str); return fclose(file_descr); error: MSG_ERROR(_("an error occurred while opening file '%s'"), file_str); free(file_str); return (file_descr == NULL) ? 1 : 2 + fclose(file_descr); }
int storage_init (char *params, void **config) { struct json_conf *conf; try { /* Create configuration */ conf = new struct json_conf; /* Create storage */ conf->storage = new Storage(); /* Process params */ process_startup_xml(conf, params); /* Configure metadata processing */ conf->storage->setMetadataProcessing(conf->metadata); /* Save configuration */ *config = conf; } catch (std::exception &e) { *config = NULL; MSG_ERROR(msg_module, "%s", e.what()); /* Free allocated memory */ delete conf->storage; delete conf; return 1; } MSG_DEBUG(msg_module, "initialized"); return 0; }
SOCKET connectDroidCam(char * ip, int port) { struct sockaddr_in sin; SOCKET sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if(sock == INVALID_SOCKET) { MSG_LASTERROR("Error"); } else { sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(ip); sin.sin_port = htons(port); printf("connect IP='%x' (%s); p:%d\n", sin.sin_addr.s_addr, ip, port); if (connect(sock, (struct sockaddr*)&sin, sizeof(sin)) < 0) { printf("connect failed %d '%s'\n", errno, strerror(errno)); MSG_ERROR("Connect failed, please try again.\nCheck IP and Port.\nCheck network connection."); close(sock); sock = INVALID_SOCKET; } } return sock; }