Skip to content

Commit

Permalink
upgrade code to be used against libnfc 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
neomilium committed Nov 22, 2010
1 parent cc96d8c commit 22fe643
Show file tree
Hide file tree
Showing 13 changed files with 843 additions and 109 deletions.
8 changes: 3 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT(nfc-eventd, 0.1.2, rconty@il4p.fr)
AC_INIT(nfc-eventd, 0.1.4, rconty@il4p.fr)

AC_CONFIG_HEADER(config.h)

Expand Down Expand Up @@ -71,11 +71,9 @@ AC_MSG_RESULT($enable_dbus)
AC_PATH_PROG(PKG_CONFIG, pkg-config, [AC_MSG_ERROR([pkg-config not found.])])

## libnfc
PKG_CHECK_MODULES(LIBNFC, libnfc, [WITH_NFC=1], [WITH_NFC=0])
LIBNFC_REQUIRED_VERSION="1.4.0"
PKG_CHECK_MODULES([LIBNFC], [libnfc >= $LIBNFC_REQUIRED_VERSION], [], [AC_MSG_ERROR([libnfc >= $LIBNFC_REQUIRED_VERSION is mandatory.])])

if test x"$WITH_NFC" = "x0"; then
AC_MSG_ERROR([libnfc is mandatory.])
fi
AC_SUBST(LIBNFC_LIBS)
AC_SUBST(LIBNFC_CFLAGS)

Expand Down
7 changes: 5 additions & 2 deletions src/debug/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
INCLUDES = $(all_includes)
METASOURCES = AUTO

noinst_LTLIBRARIES = libdebug.la
libdebug_la_SOURCES = debug.c
noinst_HEADERS = debug.h
noinst_HEADERS = debug.h nfc-utils.h

libdebug_la_SOURCES = debug.c nfc-utils.c

34 changes: 3 additions & 31 deletions src/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <unistd.h>

#include "../types.h"
#include "nfc-utils.h"

/* current debug level */
static int debug_level = 0;
Expand Down Expand Up @@ -76,36 +77,7 @@ void debug_print(int level, const char *file, int line, const char *format, ...)
}
}

void _debug_print_tag(const tag_t* tag)
void _debug_print_tag(const nfc_target_t* tag)
{
switch (tag->modulation) {
case NM_ISO14443A_106: {
/*
printf ( "The following (NFC) ISO14443A tag was found:\n\n" );
printf ( " ATQA (SENS_RES): " ); print_hex ( ti.nai.abtAtqa,2 );
printf ( " UID (NFCID%c): ", ( ti.nai.abtUid[0]==0x08?'3':'1' ) ); print_hex ( ti.nai.abtUid,ti.nai.szUidLen );
printf ( " SAK (SEL_RES): " ); print_hex ( &ti.nai.btSak,1 );
if ( ti.nai.uiAtsLen )
{
printf ( " ATS (ATR): " );
print_hex ( ti.nai.abtAts,ti.nai.uiAtsLen );
}
*/
uint32_t uiPos;
char *uid = malloc(tag->ti.nai.szUidLen*sizeof(char));
char *uid_ptr = uid;
for (uiPos=0; uiPos < tag->ti.nai.szUidLen; uiPos++) {
sprintf(uid_ptr, "%02x",tag->ti.nai.abtUid[uiPos]);
uid_ptr += 2;
}
uid_ptr[0]='\0';

printf( "ISO14443A (MIFARE) tag with uid=%s", uid );
free(uid);
}
break;
default:
DBG( "%s", "Debug this kind of modulation is not yet supported." );

}
print_nfc_target(*tag, false);
}
20 changes: 11 additions & 9 deletions src/debug/debug.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*
* PKCS #11 PAM Login Module
* Copyright (C) 2003 Mario Strasser <mast@gmx.net>,
* debug routines for nfc-eventd
* Copyright (C) 2010 Romuald Conty <rconty@il4p.fr>,
*
* based on PKCS #11 PAM Login Module
* Copyright (C) 2003 Mario Strasser <mast@gmx.net>,
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -12,20 +15,19 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* $Id: debug.h 246 2007-04-12 10:09:12Z ludovic.rousseau $
*/

/**
*@def DEBUG
* This module contains macros for generate debugging messages
* Will be compiled an linked only when -DDEBUG CFLAG is used
*/
*@def DEBUG
* This module contains macros for generate debugging messages
* Will be compiled an linked only when -DDEBUG CFLAG is used
*/

#ifndef __DEBUG_H_
#define __DEBUG_H_

#ifdef HAVE_CONFIG_H
#include <config.h>
#include <config.h>
#endif

#define ERR(x,...) debug_print(-1, __FILE__, __LINE__, x, ## __VA_ARGS__ )
Expand Down Expand Up @@ -74,7 +76,7 @@ DEBUG_EXTERN void debug_print(int level, const char *file, int line, const char

#ifdef DEBUG
#include "../types.h"
void _debug_print_tag(const tag_t* tag);
void _debug_print_tag(const nfc_target_t* tag);
#define debug_print_tag( X ) \
printf("%s:%s:%d: ", "\033[34mDEBUG", __FILE__, __LINE__); \
_debug_print_tag( X ); \
Expand Down
Loading

0 comments on commit 22fe643

Please sign in to comment.