Beispiel #1
0
main()
{
    logfile_type lf;
    logfile_init(&lf,"logfile.log");
    logfile_print(&lf,"Testando %d",123);
    printf("Espere um tempo e entre com um numero: ");
    getchar();
    logfile_print(&lf,"Testando %d",456);
    logfile_print(&lf,"Testando %d",457);
    logfile_print(&lf,"Testando %d",458);
    logfile_print(&lf,"Testando %d",459);
    logfile_close(&lf);
}
Beispiel #2
0
static void logfile_log (int severity, const char *msg)
{
	if (severity > log_level)
		return;

	logfile_print (msg, time (NULL));
} /* void logfile_log (int, const char *) */
Beispiel #3
0
static int logfile_notification (const notification_t *n)
{
	char  buf[1024] = "";
	char *buf_ptr = buf;
	int   buf_len = sizeof (buf);
	int status;

	status = ssnprintf (buf_ptr, buf_len, "Notification: severity = %s",
			(n->severity == NOTIF_FAILURE) ? "FAILURE"
			: ((n->severity == NOTIF_WARNING) ? "WARNING"
				: ((n->severity == NOTIF_OKAY) ? "OKAY" : "UNKNOWN")));
	if (status > 0)
	{
		buf_ptr += status;
		buf_len -= status;
	}

#define APPEND(bufptr, buflen, key, value) \
	if ((buflen > 0) && (strlen (value) > 0)) { \
		int status = ssnprintf (bufptr, buflen, ", %s = %s", key, value); \
		if (status > 0) { \
			bufptr += status; \
			buflen -= status; \
		} \
	}
	APPEND (buf_ptr, buf_len, "host", n->host);
	APPEND (buf_ptr, buf_len, "plugin", n->plugin);
	APPEND (buf_ptr, buf_len, "plugin_instance", n->plugin_instance);
	APPEND (buf_ptr, buf_len, "type", n->type);
	APPEND (buf_ptr, buf_len, "type_instance", n->type_instance);
	APPEND (buf_ptr, buf_len, "message", n->message);

	buf[sizeof (buf) - 1] = '\0';

	logfile_print (buf, n->time);

	return (0);
} /* int logfile_notification */
int CUBS_Match_IBM_Hash(ptrFPTemplate hRef, ptrFPTemplate hTst, 
							   MatchResult*	pMatchResult, MatchResultEx* pResultEx)
{
//    MatchResult* pResult = NULL;
//	MatchResultEx* pResultEx = NULL;
    Minutiae* pMRef;
    Minutiae* pMTest;
    SFeature* pSFVRef = NULL;
    SFeature* pSFVTest = NULL;
	NeighborInfo NeighborListRef[CUBS_MAX_MINUTIAE];
	NeighborInfo NeighborListTest[CUBS_MAX_MINUTIAE];
	QUADSFVMAP RefQuadSFVList;       // SFV vectors for every quadrant of reference fingerprint
	QUADSFVMAP TestQuadSFVList;      // SFV vectors for every quadrant of test fingerprint


    int       nCntRef, nCntTest, i;
	int       nSFVCntRef;
	int       nSFVCntTest;
    int       ret = ERR_NO_ERROR;
    bool      MatchPerformed = false;
    double    similarity       = 0.0;
    int       pass = 1;

	logfile_print("Beginning CUBS_MatchFeaturesInternal().\n");
    //Get parameters
    //GetParams();

	if(hRef==NULL || hRef->nCnt<2 || hRef->nCnt>CUBS_MAX_MINUTIAE )
		return ERR_MISSING_MINUTIAE;
	pMRef   = (Minutiae*)hRef->marr;
    nCntRef = hRef->nCnt;
	for(i=0;i<nCntRef;i++)
		// matching algorithm asssumes there is an index here, 
		//not the type of minutia (as NIST minutia algorithm outputs)
		pMRef[i].m_nFeatureNo=i;  
	if(hTst==NULL || hTst->nCnt<2 || hTst->nCnt>CUBS_MAX_MINUTIAE )
		return ERR_MISSING_MINUTIAE;
	pMTest  = (Minutiae*)hTst->marr;
    nCntTest= hTst->nCnt;
	for(i=0;i<nCntTest;i++)
		// matching algorithm asssumes there is an index here, 
		//not the type of minutia (as NIST minutia algorithm outputs)
		pMTest[i].m_nFeatureNo=i;
   
    pass = 1;

    while(pass <= 1 /*MatchingParams.nT_Tries*/)
    {
		// pSFVRef has to be allocated inside Minutiae2SFeature
#ifdef FV_IDX
		// jea050305 start
		//ret = Minutiae2SFeature(nCntRef, pMRef, CUBS_NUM_OF_NEIGHBORS, 0, &nSFVCntRef, &pSFVRef, NeighborListRef, RefQuadSFVList);
		if(nCntRef > 30)
			ret = Minutiae2SFeature(nCntRef, pMRef, CUBS_NUM_OF_NEIGHBORS, 0, &nSFVCntRef, &pSFVRef, NeighborListRef, RefQuadSFVList);
		else if(nCntRef > 20 && nCntRef <= 30)
			ret = Minutiae2SFeature(nCntRef, pMRef, 7, 0, &nSFVCntRef, &pSFVRef, NeighborListRef, RefQuadSFVList);
		else
			ret = Minutiae2SFeature(nCntRef, pMRef, 10, 0, &nSFVCntRef, &pSFVRef, NeighborListRef, RefQuadSFVList);

		// jea050305 end
#else
		ret = Minutiae2SFeature(nCntRef, pMRef, CUBS_NUM_OF_NEIGHBORS, 0, &nSFVCntRef, &pSFVRef, NeighborListRef);
#endif
		logfile_print("CUBS_MatchFeaturesInternal(): extracted %d features from ref template\n", nSFVCntRef);
        if(ret != ERR_NO_ERROR){
            return ret;
        }

#ifdef FV_IDX
		// jea050305 start
        //ret = Minutiae2SFeature(nCntTest, pMTest, CUBS_NUM_OF_NEIGHBORS, 0, &nSFVCntTest, &pSFVTest, NeighborListTest, TestQuadSFVList);
		if(nCntTest > 30)
			ret = Minutiae2SFeature(nCntTest, pMTest, CUBS_NUM_OF_NEIGHBORS, 0, &nSFVCntTest, &pSFVTest, NeighborListTest, TestQuadSFVList);
		else if(nCntTest > 20 && nCntTest <=30)
			ret = Minutiae2SFeature(nCntTest, pMTest, 7, 0, &nSFVCntTest, &pSFVTest, NeighborListTest, TestQuadSFVList);
		else
			ret = Minutiae2SFeature(nCntTest, pMTest, 10, 0, &nSFVCntTest, &pSFVTest, NeighborListTest, TestQuadSFVList);
		// jea050305 end
#else
		ret = Minutiae2SFeature(nCntTest, pMTest, CUBS_NUM_OF_NEIGHBORS, 0, &nSFVCntTest, &pSFVTest, NeighborListTest);
#endif
		logfile_print("CUBS_MatchFeaturesInternal(): extracted %d features from test template\n", nSFVCntTest);

        if(ret != ERR_NO_ERROR){
			free(pSFVRef);
            return ret;
        }
        
		memset(pResultEx, 0, sizeof(MatchResultEx));

        //----------------------------------------------------
        //Do some matching here
        //----------------------------------------------------
		pResultEx->NumOfMinutiae_a = nCntTest;
		pResultEx->NumOfMinutiae_b = nCntRef;
		ret = SFV_VerifyMatch(nCntTest, pMTest, NeighborListTest,
			                  nCntRef, pMRef, NeighborListRef,
			                  pSFVTest, nSFVCntTest,
#ifdef FV_IDX
							  TestQuadSFVList,
#endif
							  pSFVRef, nSFVCntRef,
#ifdef FV_IDX
							  RefQuadSFVList,
#endif
			                  &MatchPerformed, &similarity, pResultEx);
        if(ret != ERR_NO_ERROR){
            free(pSFVRef);
            free(pSFVTest);
			free(pResultEx);
            return ret;
        }
        free(pSFVRef);
        free(pSFVTest);
        if(similarity > 0.0)
            break;
        pass++;
    }
    
    pMatchResult->MatchPerformed = MatchPerformed;
    pMatchResult->similarity = similarity;
		
	logfile_print("CUBS_MatchFeaturesInternal(): similarity=%f\n", similarity);


    return ERR_NO_ERROR;
}