コード例 #1
0
ファイル: panaly.c プロジェクト: hezeyu/CDMA2000_GRE
void IPCP_handler(u_char *frame, struct framehdr *fh, struct msidhash *mh, struct radiushash *rh){
	if(frame[0]==IPCP_CON_NAK){
		u_char c[4]={frame[9],frame[8],frame[7],frame[6]};
		_Int32 *i = (_Int32 *)c;
		int hash_pos = HASH(fh->ip->src+fh->ip->dst+fh->gre->key, MSID_HASH_ACC);
		struct TK_MSID *t = mh->idlist[hash_pos];
		hash_pos = HASH(*i+fh->gre->key, RADIUS_HASH_ACC);
		struct RADIUS_MSG *r = rh->rdslist[hash_pos];
		while(t!=NULL){
			if(fh->gre->key==t->key && fh->ip->src==t->dip && fh->ip->dst==t->sip){
				while(r!=NULL){
					if(fh->gre->key==r->key && *i==r->mip){
						struct sql_msg msg_t = {r->msisdn,t->msid,t->meid,*i,t->key,t->bsid,t->sip,t->time};
						sql_insert(&msg_t);
						printf("\rthe number of UE be found : %d", ++ue_acc);
						fflush(stdout);
						return;
					}
					r = r->next;
				}
			}
			t = t->next;
		}
	}
}
コード例 #2
0
ファイル: mp3_scan.cpp プロジェクト: Simmiyy/mp3scan
// get the ID3tag from the file
void get_id3_tag( const char* pFileName, off_t size ){

	static char szTitle[31]      = {'\0'};
	static char szArtist[31]     = {'\0'};
	static char szAlbum[31]      = {'\0'};
	static char szYear[5]        = {'\0'};
	static char szPath[PATH_MAX] = {'\0'};

	if( bRelPath )
		strcpy( szPath, szRelativePath );
	else
		getcwd( szPath, PATH_MAX );
			
	if( bFsInfo )													// Save file size
		size_count( size );

	get_tags( pFileName, szTitle, szArtist, szAlbum, szYear );		// Try to get all tags

	if( szTitle[0] == '\0' && szArtist[0] == '\0' && szAlbum[0] == '\0' && szYear[0] == '\0' ){
		
		if( bUseFileName ){											// Use file name to get song infos			
			filename_to_field( pFileName, szTitle, szArtist, szAlbum, szYear );
				
		} else {													// print a warning message and return
			if( bVerbose )
				print_message( WARNING, "%s has no id3 Tag\n", pFileName );
		}
	}

	sql_insert( szTitle, szArtist, szAlbum, szYear, pFileName, szPath, size );
}
コード例 #3
0
ファイル: pModel.cpp プロジェクト: carriercomm/corvus
pModel::oid pModel::getNamespace(pStringRef ns) {

    std::stringstream ins;
    ins << "INSERT INTO namespace VALUES ('" << ns.str() << "')";
    return sql_insert("getNamespace", ins.str().c_str());

}
コード例 #4
0
ファイル: pModel.cpp プロジェクト: carriercomm/corvus
pModel::oid pModel::getSourceModule(pStringRef realPath) {

    std::stringstream ins;
    ins << "INSERT INTO sourceModule VALUES ('" << realPath.str() << "', '')";
    return sql_insert("getSourceModule", ins.str().c_str());

}
コード例 #5
0
ファイル: position.c プロジェクト: Eventide/cliprobe
void *get_pos(void *arg)
{
	struct timeval ti;

	int ret;
	struct ap_t *ap;
	int i, j, k, num = 0;
	long interval;
	struct point_t *pi = NULL;
	double a,b;

replay:
	for(i = 0; i < MAX_CLI; i++) {
		if(clihead[i].key == IDLE_CLI)
			continue;

		now(&ti);
		if((ti.tv_sec - clihead[i].timestamp.tv_sec) > 
			argument.losttime) {
			cli_del(&clihead[i]);
			continue;
		}

		pthread_mutex_lock(&clihead[i].lock);
		if(clihead[i].key == IDLE_CLI)
			goto unlock;

		clr_bit(&clihead[i].bitmap);
		num = 0;

		for(j = 0; j < MAX_AP; j++) {
			ap = &clihead[i].ap[j];
			interval = ti.tv_sec - ap->timestamp.tv_sec;

			if((ap->valid) && (interval < argument.agetime)) {
				num++;
				set_bit(&clihead[i].bitmap, j);
			}
		}

		if(num < 3) goto unlock;

		pi = malloc(sizeof(struct point_t) * num);
		if(pi == NULL) {
			sys_warn("Malloc memory failed: %s\n",
				strerror(errno));
			continue;
		}

		for(j = 0, k = 0; j < MAX_AP && k < num; j++) {
			if(isset(&clihead[i].bitmap, j)) {
				ret = getap_pos(clihead[i].ap[j].apmac, pi + k);
				if(ret < 0) goto free;
				pi[k].d = distance(clihead[i].ap[j].signal);
				mac_debug(MAC(clihead[i].climac), 
					"(%lf, %lf, %lf) sig: %d dist: %lf\n", 
					pi[k].x, pi[k].y, pi[k].z,
					clihead[i].ap[j].signal, pi[k].d);
				k++;
			}
		}

		ret = get_point(pi, num, &a, &b);
		if(ret < 0 || a < 0 || b < 0) goto free;
		ajust_pos(&clihead[i], &ti, &a, &b);
		mac_debug(MAC(clihead[i].climac), "%lf %lf %lf\n", a, b, pi->z);
#ifndef DISABLE_MYSQL
		sql_insert(&sql, clihead[i].climac, a, b, pi->z);
#endif
free:
		free(pi);
unlock:
		pthread_mutex_unlock(&clihead[i].lock);
	}
	sleep(2);
	goto replay;
	return NULL;
}
コード例 #6
0
ファイル: add_campaign.cpp プロジェクト: bubi-luka/BubiLink
void add_campaign::on_btn_save_clicked() {

    // check if we have a campaign name set, otherwise sent warning and abort
    if ( ui->txt_campaign_name->text() !="" ) {
        QString app_path = QApplication::applicationDirPath();
        QString dbase_path = app_path + "/base.bz";

        {
            QSqlDatabase base = QSqlDatabase::addDatabase("QSQLITE", "create-new-campaign");
            base.setDatabaseName(dbase_path);
            base.open();
            if(base.isOpen() != true) {
                QMessageBox msgbox;
                msgbox.setText("There was a problem with the database");
                msgbox.setInformativeText("Due to unknown reason there was a problem with opening the database.\nThe problem accured during initial opening of the database.");
                msgbox.exec();
            }
            else {
                // the database is open

                // scroll through profiles to determinate if this is really new profile or not
                QSqlQuery sql_check(base);
                sql_check.prepare("SELECT * FROM campaign WHERE user LIKE '" + vApp->id_user() + "' AND profile LIKE '" + vApp->id_profile() + "'"
                                  " AND campaign_name LIKE '" + ui->txt_campaign_name->text() + "' AND id NOT LIKE '" + ui->txt_campaign_id->text() + "'");
                sql_check.exec();
                if ( !sql_check.next() ) { // the campaign name is unique
                    QSqlQuery sql_insert(base);
                    if ( ui->txt_campaign_id->text() == "" ) { // insert new campaign
                        sql_insert.prepare("INSERT INTO campaign (user, profile, campaign_name, campaign_description) VALUES (?, ?, ?, ?)");
                    }
                    else { // update current campaign
                        sql_insert.prepare("UPDATE campaign SET user = ?, profile = ?, campaign_name = ?, campaign_description = ? "
                                           "WHERE id LIKE '" + ui->txt_campaign_id->text() + "'");
                    }
                    sql_insert.bindValue(0, vApp->id_user());
                    sql_insert.bindValue(1, vApp->id_profile());
                    sql_insert.bindValue(2, ui->txt_campaign_name->text());
                    sql_insert.bindValue(3, ui->txt_campaign_description->toPlainText());
                    sql_insert.exec();

                    // change global campaign
                    QSqlQuery sql_get_id(base);
                    sql_get_id.prepare("SELECT * FROM campaign WHERE user LIKE '" + vApp->id_user() + "' AND profile LIKE '" + vApp->id_profile() + "'"
                                       " AND campaign_name LIKE '" + ui->txt_campaign_name->text() + "'");
                    sql_get_id.exec();
                    if ( sql_get_id.next() ) { // the campaign was succesfully saved
                        QMessageBox msgbox;
                        msgbox.setText("Kampanija je bila uspesno shranjen!");
                        msgbox.exec();

                        vApp->set_id_campaign(sql_get_id.value(sql_get_id.record().indexOf("id")).toString());

                        // send signal to the main window to refresh campaign combo box
                        send("refresh-campaign");
                    }
                    else { // there was an error while saving the campaign
                        QMessageBox msgbox;
                        msgbox.setText("Pri shranjevanju kampanije je prislo do napake!");
                        msgbox.exec();
                    }
                }
                else { // there already is campaign with this name
                    QMessageBox msgbox;
                    msgbox.setText("Kampanija s tem imenom ze obstaja! Prosim, spremenite ga!");
                    msgbox.exec();
                }
            }
            base.close();
        }
        QSqlDatabase::removeDatabase("create-new-campaign");
    }
    else { // the profile name field is empty
        QMessageBox msgbox;
        msgbox.setText("Prosim vnesite ime kampanije!");
        msgbox.exec();
    }

}