<commit_before>/*
 * Copyright 2015 <NAME>
 * Licensed under MIT license, see included file LICENSE or
 * http://opensource.org/licenses/MIT
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <pthread.h>
#include <vector>

#define NXP_HW_SELF_TEST
#include "linux_nfc_factory_api.h"
#include "linux_nfc_api.h"

#define MAX_UID_LENGTH 32
#define MAIN_SLEEP 10000

static int do_poll = 1;
static std::vector <nfc_tag_info_t*> v_tags;
static pthread_mutex_t mutex;

static void interrupted(int signal)
{
    do_poll = 0;
}

static void tagArrived(nfc_tag_info_t *p_taginfo)
{
    pthread_mutex_lock(&mutex);

    nfc_tag_info_t *temp = (nfc_tag_info_t *) malloc(sizeof(nfc_tag_info_t));
    memcpy(temp, p_taginfo, sizeof(nfc_tag_info_t));
    v_tags.push_back(temp);

    pthread_mutex_unlock(&mutex);
}

static void tagDeparted() { }

static void printTagUID(nfc_tag_info_t *p_tag)
{
    char uid[3*MAX_UID_LENGTH+1];
    int len = p_tag->uid_length;
    if(len > MAX_UID_LENGTH)
        len = MAX_UID_LENGTH;

    for(int i = 0; i < len; i++) {
        sprintf(uid + (i*3), "%02x ", p_tag->uid[i]);
    }
    uid[len*3] = '\0';

    printf("UID: %s\n", uid);
}

int main(int argc, char ** argv)
{
    struct sigaction act;
    memset(&act, '\0', sizeof(act));
    act.sa_handler = &interrupted;

    if (sigaction(SIGINT, &act, NULL) < 0 || sigaction(SIGTERM, &act, NULL)) {
        perror("sigaction");
        exit(1);
    }

    pthread_mutex_init(&mutex, NULL);


    // initialize nfcManager
    int result = nfcManager_doInitialize();
    if(result != 0)
    {
        printf("nfcManager_doInitialize failed with error code %d", result);
        exit(result);
    }

    // try to get versions
    #ifdef NXP_HW_SELF_TEST
    printf("nfcFactory_GetMwVersion:\t0x%x\n", nfcFactory_GetMwVersion());
    #endif<commit_msg>opening braces on new lines<commit_after>/*
 * Copyright 2015 <NAME>
 * Licensed under MIT license, see included file LICENSE or
 * http://opensource.org/licenses/MIT
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <pthread.h>
#include <vector>

#define NXP_HW_SELF_TEST
#include "linux_nfc_factory_api.h"
#include "linux_nfc_api.h"

#define MAX_UID_LENGTH 32
#define MAIN_SLEEP 10000

static int do_poll = 1;
static std::vector <nfc_tag_info_t*> v_tags;
static pthread_mutex_t mutex;

static void interrupted(int signal)
{
    do_poll = 0;
}

static void tagArrived(nfc_tag_info_t *p_taginfo)
{
    pthread_mutex_lock(&mutex);

    nfc_tag_info_t *temp = (nfc_tag_info_t *) malloc(sizeof(nfc_tag_info_t));
    memcpy(temp, p_taginfo, sizeof(nfc_tag_info_t));
    v_tags.push_back(temp);

    pthread_mutex_unlock(&mutex);
}

static void tagDeparted() { }

static void printTagUID(nfc_tag_info_t *p_tag)
{
    char uid[3*MAX_UID_LENGTH+1];
    int len = p_tag->uid_length;
    if(len > MAX_UID_LENGTH)
        len = MAX_UID_LENGTH;

    for(int i = 0; i < len; i++)
    {
        sprintf(uid + (i*3), "%02x ", p_tag->uid[i]);
    }
    uid[len*3] = '\0';

    printf("UID: %s\n", uid);
}

int main(int argc, char ** argv)
{
    struct sigaction act;
    memset(&act, '\0', sizeof(act));
    act.sa_handler = &interrupted;

    if (sigaction(SIGINT, &act, NULL) < 0 || sigaction(SIGTERM, &act, NULL))
    {
        perror("sigaction");
        exit(1);
    }

    pthread_mutex_init(&mutex, NULL);


    // initialize nfcManager
    int result = nfcManager_doInitialize();
    if(result != 0)
    {
        printf("nfcManager_doInitialize failed with error code %d", result);
        exit(result);
    }

    // try to get versions
    #ifdef NXP_HW_SELF_TEST
    printf("nfcFactory_GetMwVersion:\t0x%x\n", nfcFactory_GetMwVersion());
    #endif
{'fraction_non_alphanumeric': 0.1380400421496312, 'fraction_numerical': 0.0136986301369863, 'mean_word_length': 3.681874229346486, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '593375', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1441, 'n_words': 305}