summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-11-25 10:08:06 +0200
committerAlon Levy <alevy@redhat.com>2010-12-09 13:35:38 +0200
commit6771c60dcfdd9349b81f16fe64db659ad90394a7 (patch)
treee87d98067dce8f91ecf121710572336b5767b10b
parent2c290fda9e9cbd2c35c22efd0d08711b367542ba (diff)
libcaccard: coding style: more 80 width
-rw-r--r--vcard_emul_nss.c89
-rw-r--r--vcard_emul_type.c7
-rw-r--r--vscclient.c61
3 files changed, 97 insertions, 60 deletions
diff --git a/vcard_emul_nss.c b/vcard_emul_nss.c
index 6f32d79..66e392f 100644
--- a/vcard_emul_nss.c
+++ b/vcard_emul_nss.c
@@ -441,7 +441,8 @@ vcard_emul_get_atr(VCard *card, unsigned char *atr, int *atr_len)
*/
static VCard *
vcard_emul_make_card(VReader *reader,
- unsigned char * const *certs, int *cert_len, VCardKey *keys[], int cert_count)
+ unsigned char * const *certs, int *cert_len,
+ VCardKey *keys[], int cert_count)
{
VCardEmul *vcard_emul;
VCard *vcard;
@@ -507,7 +508,8 @@ vcard_emul_mirror_card(VReader *vreader)
/* count the certs */
cert_count=0;
- for (thisObj = firstObj; thisObj; thisObj = PK11_GetNextGenericObject(thisObj)) {
+ for (thisObj = firstObj; thisObj;
+ thisObj = PK11_GetNextGenericObject(thisObj)) {
cert_count++;
}
@@ -524,18 +526,21 @@ vcard_emul_mirror_card(VReader *vreader)
/* fill in the arrays */
cert_count = 0;
- for (thisObj = firstObj; thisObj; thisObj = PK11_GetNextGenericObject(thisObj)) {
+ for (thisObj = firstObj; thisObj;
+ thisObj = PK11_GetNextGenericObject(thisObj)) {
SECItem derCert;
CERTCertificate *cert;
SECStatus rv;
- rv = PK11_ReadRawAttribute(PK11_TypeGeneric, thisObj, CKA_VALUE, &derCert);
+ rv = PK11_ReadRawAttribute(PK11_TypeGeneric, thisObj,
+ CKA_VALUE, &derCert);
if (rv != SECSuccess) {
continue;
}
- /* create floating temp cert. This gives us a cert structure even if the token isn't
- * logged in */
- cert = CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &derCert, NULL, PR_FALSE, PR_TRUE);
+ /* create floating temp cert. This gives us a cert structure even if
+ * the token isn't logged in */
+ cert = CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &derCert,
+ NULL, PR_FALSE, PR_TRUE);
SECITEM_FreeItem(&derCert, PR_FALSE);
if (cert == NULL) {
continue;
@@ -556,7 +561,8 @@ static VCardEmulType default_card_type = VCARD_EMUL_NONE;
static const char *default_type_params = "";
/*
- * This thread looks for card and reader insertions and puts events on the event queue
+ * This thread looks for card and reader insertions and puts events on the
+ * event queue
*/
static void
vcard_emul_event_thread(void *arg)
@@ -575,8 +581,10 @@ vcard_emul_event_thread(void *arg)
vreader = vcard_emul_find_vreader_from_slot(slot);
if (vreader == NULL) {
/* new vreader */
- vreader_emul = vreader_emul_new(slot, default_card_type, default_type_params);
- vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul, vreader_emul_delete);
+ vreader_emul = vreader_emul_new(slot, default_card_type,
+ default_type_params);
+ vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul,
+ vreader_emul_delete);
PK11_FreeSlot(slot);
slot = NULL;
vreader_add_reader(vreader);
@@ -626,13 +634,15 @@ vcard_emul_init_series(VReader *vreader, VCard *vcard)
}
/*
- * each module has a separate wait call, create a thread for each module that we are using.
+ * each module has a separate wait call, create a thread for each module that
+ * we are using.
*/
static void
vcard_emul_new_event_thread(SECMODModule *module)
{
PR_CreateThread(PR_SYSTEM_THREAD, vcard_emul_event_thread,
- module, PR_PRIORITY_HIGH, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);
+ module, PR_PRIORITY_HIGH, PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD, 0);
}
static const VCardEmulOptions default_options = {
@@ -646,9 +656,10 @@ static const VCardEmulOptions default_options = {
/*
- * NSS needs the app to supply a password prompt. In our case the only time the password is
- * supplied is as part of the Login APDU. The actual password is passed in the pw_arg in that
- * case. In all other cases pw_arg should be NULL.
+ * NSS needs the app to supply a password prompt. In our case the only time
+ * the password is supplied is as part of the Login APDU. The actual password
+ * is passed in the pw_arg in that case. In all other cases pw_arg should be
+ * NULL.
*/
static char *
vcard_emul_get_password(PK11SlotInfo *slot, PRBool retries, void *pw_arg)
@@ -744,7 +755,8 @@ vcard_emul_init(const VCardEmulOptions *options)
/* Set password callback function */
PK11_SetPasswordFunc(vcard_emul_get_password);
- /* set up soft cards emulated by software certs rather than physical cards */
+ /* set up soft cards emulated by software certs rather than physical cards
+ * */
for (i = 0; i < options->vreader_count; i++) {
int j;
int cert_count;
@@ -757,21 +769,25 @@ vcard_emul_init(const VCardEmulOptions *options)
if (slot == NULL) {
continue;
}
- vreader_emul = vreader_emul_new(slot, options->vreader[i].card_type,
+ vreader_emul = vreader_emul_new(slot, options->vreader[i].card_type,
options->vreader[i].type_params);
- vreader = vreader_new(options->vreader[i].vname, vreader_emul, vreader_emul_delete);
+ vreader = vreader_new(options->vreader[i].vname, vreader_emul,
+ vreader_emul_delete);
vreader_add_reader(vreader);
cert_count = options->vreader[i].cert_count;
- ret = vcard_emul_alloc_arrays(&certs, &cert_len, &keys, options->vreader[i].cert_count);
+ ret = vcard_emul_alloc_arrays(&certs, &cert_len, &keys,
+ options->vreader[i].cert_count);
if (ret == PR_FALSE) {
continue;
}
cert_count = 0;
for (j=0; j < options->vreader[i].cert_count; j++) {
- /* we should have a better way of identifying certs than by nickname here */
- CERTCertificate *cert = PK11_FindCertFromNickname(options->vreader[i].cert_name[j],
- NULL);
+ /* we should have a better way of identifying certs than by
+ * nickname here */
+ CERTCertificate *cert = PK11_FindCertFromNickname(
+ options->vreader[i].cert_name[j],
+ NULL);
if (cert == NULL) {
continue;
}
@@ -783,7 +799,8 @@ vcard_emul_init(const VCardEmulOptions *options)
cert_count++;
}
if (cert_count) {
- VCard *vcard = vcard_emul_make_card(vreader, certs, cert_len, keys, cert_count);
+ VCard *vcard = vcard_emul_make_card(vreader, certs, cert_len,
+ keys, cert_count);
vreader_insert_card(vreader, vcard);
vcard_emul_init_series(vreader, vcard);
/* allow insertion and removal of soft cards */
@@ -816,11 +833,14 @@ vcard_emul_init(const VCardEmulOptions *options)
if (need_module) {
SECMODModule *module;
- module = SECMOD_LoadUserModule((char*)"library=libcoolkeypk11.so name=Coolkey", NULL, PR_FALSE);
+ module = SECMOD_LoadUserModule(
+ (char*)"library=libcoolkeypk11.so name=Coolkey",
+ NULL, PR_FALSE);
if (module == NULL) {
return VCARD_EMUL_FAIL;
}
- SECMOD_DestroyModule(module); /* free our reference, Module will still be on the list.
+ SECMOD_DestroyModule(module); /* free our reference, Module will still
+ * be on the list.
* until we destroy it */
}
@@ -846,8 +866,10 @@ vcard_emul_init(const VCardEmulOptions *options)
if (slot == NULL || !PK11_IsRemovable(slot) || !PK11_IsHW(slot)) {
continue;
}
- vreader_emul = vreader_emul_new(slot, options->hw_card_type, options->hw_type_params);
- vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul, vreader_emul_delete);
+ vreader_emul = vreader_emul_new(slot, options->hw_card_type,
+ options->hw_type_params);
+ vreader = vreader_new(PK11_GetSlotName(slot), vreader_emul,
+ vreader_emul_delete);
vreader_add_reader(vreader);
has_readers = PR_TRUE;
@@ -919,7 +941,8 @@ static const char *
strip(const char *str)
{
for(;*str; str++) {
- if ((*str != ' ') && (*str != '\n') && (*str != '\t') && (*str != '\r')) {
+ if ((*str != ' ') && (*str != '\n') &&
+ (*str != '\t') && (*str != '\r')) {
break;
}
}
@@ -930,7 +953,8 @@ static const char *
find_blank(const char *str)
{
for(;*str; str++) {
- if ((*str == ' ') || (*str == '\n') || (*str == '\t') || (*str == '\r')) {
+ if ((*str == ' ') || (*str == '\n') ||
+ (*str == '\t') || (*str == '\r')) {
break;
}
}
@@ -939,8 +963,8 @@ find_blank(const char *str)
/*
- * We really want to use some existing argument parsing library here. That would give
- * us a consistant look */
+ * We really want to use some existing argument parsing library here. That
+ * would give us a consistant look */
static VCardEmulOptions options;
#define READER_STEP 4
@@ -1027,7 +1051,8 @@ vcard_emul_options(const char *args)
if (opts->vreader_count >= reader_count) {
reader_count += READER_STEP;
- vreaderOpt = realloc(opts->vreader, reader_count*sizeof(*vreaderOpt));
+ vreaderOpt = realloc(opts->vreader,
+ reader_count*sizeof(*vreaderOpt));
if (vreaderOpt == NULL) {
return opts; /* we're done */
}
diff --git a/vcard_emul_type.c b/vcard_emul_type.c
index dd5956c..adbc54b 100644
--- a/vcard_emul_type.c
+++ b/vcard_emul_type.c
@@ -1,7 +1,8 @@
/*
- * This file contains utility functions which abstract the different card types.
- * The goal is that new card types can easily be added by simply changing this file and
- * vcard_emul_type.h. It is currently not a requirement to dynamically add new card types.
+ * This file contains utility functions which abstract the different card
+ * types. The goal is that new card types can easily be added by simply
+ * changing this file and vcard_emul_type.h. It is currently not a requirement
+ * to dynamically add new card types.
*/
#include <strings.h>
diff --git a/vscclient.c b/vscclient.c
index 82e734c..7aa2ead 100644
--- a/vscclient.c
+++ b/vscclient.c
@@ -76,7 +76,8 @@ SendMsg (
MUTEX_LOCK(write_lock);
if (verbose > 10) {
- printf("sending type=%d id=%d, len =%d (0x%x)\n", type, reader_id, length, length);
+ printf("sending type=%d id=%d, len =%d (0x%x)\n",
+ type, reader_id, length, length);
}
mhHeader.type = type;
@@ -133,18 +134,21 @@ event_thread(void *arg)
break;
}
reader_id = vreader_get_id(event->reader);
- if (reader_id == VSCARD_UNDEFINED_READER_ID && event->type != VEVENT_READER_INSERT) {
+ if (reader_id == VSCARD_UNDEFINED_READER_ID &&
+ event->type != VEVENT_READER_INSERT) {
/* ignore events from readers qemu has rejected */
- /* if qemu is still deciding on this reader, wait to see if need to forward this
- * event */
+ /* if qemu is still deciding on this reader, wait to see if need to
+ * forward this event */
MUTEX_LOCK(pending_reader_lock);
if (!pending_reader || (pending_reader != event->reader)) {
- /* wasn't for a pending reader, this reader has already been rejected by qemu */
+ /* wasn't for a pending reader, this reader has already been
+ * rejected by qemu */
MUTEX_UNLOCK(pending_reader_lock);
vevent_delete(event);
continue;
}
- /* this reader hasn't been told it's status from qemu yet, wait for that status */
+ /* this reader hasn't been told it's status from qemu yet, wait for
+ * that status */
while (pending_reader != NULL) {
CONDITION_WAIT(pending_reader_condition,pending_reader_lock);
}
@@ -162,7 +166,8 @@ event_thread(void *arg)
case VEVENT_READER_INSERT:
/* tell qemu to insert a new CCID reader */
/* wait until qemu has responded to our first reader insert
- * before we send a second. That way we won't confuse the responses */
+ * before we send a second. That way we won't confuse the responses
+ * */
MUTEX_LOCK(pending_reader_lock);
while (pending_reader != NULL) {
CONDITION_WAIT(pending_reader_condition,pending_reader_lock);
@@ -195,7 +200,8 @@ event_thread(void *arg)
);
break;
case VEVENT_CARD_INSERT:
- /* get the ATR (intended as a response to a power on from the reader */
+ /* get the ATR (intended as a response to a power on from the
+ * reader */
atr_len = MAX_ATR_LEN;
vreader_power_on(event->reader, atr, &atr_len);
/* ATR call functions as a Card Insert event */
@@ -257,17 +263,18 @@ do_command(void)
string = fgets(inbuf, sizeof(inbuf), stdin);
if (string != NULL) {
if (strncmp(string,"exit",4) == 0) {
- /* remove all the readers */
- VReaderList *list = vreader_get_reader_list();
- VReaderListEntry *reader_entry;
- printf("Active Readers:\n");
- for (reader_entry = vreader_list_get_first(list); reader_entry;
- reader_entry = vreader_list_get_next(reader_entry)) {
+ /* remove all the readers */
+ VReaderList *list = vreader_get_reader_list();
+ VReaderListEntry *reader_entry;
+ printf("Active Readers:\n");
+ for (reader_entry = vreader_list_get_first(list); reader_entry;
+ reader_entry = vreader_list_get_next(reader_entry)) {
VReader *reader = vreader_list_get_reader(reader_entry);
VReaderID reader_id;
reader_id=vreader_get_id(reader);
if (reader_id == -1) continue;
- /* be nice and signal card removal first (qemu probably should do this itself) */
+ /* be nice and signal card removal first (qemu probably should
+ * do this itself) */
if (vreader_card_is_present(reader) == VREADER_OK) {
SendMsg (
VSC_CardRemove,
@@ -302,7 +309,8 @@ do_command(void)
: "invalid reader", error);
} else if (strncmp(string,"select",6) == 0) {
if (string[6] == ' ') {
- reader_id = get_id_from_string(&string[7], VSCARD_UNDEFINED_READER_ID);
+ reader_id = get_id_from_string(&string[7],
+ VSCARD_UNDEFINED_READER_ID);
}
if (reader_id != VSCARD_UNDEFINED_READER_ID) {
reader = vreader_get_reader_by_id(reader_id);
@@ -320,11 +328,11 @@ do_command(void)
}
printf ("debug level = %d\n", verbose);
} else if (strncmp(string,"list",4) == 0) {
- VReaderList *list = vreader_get_reader_list();
- VReaderListEntry *reader_entry;
- printf("Active Readers:\n");
- for (reader_entry = vreader_list_get_first(list); reader_entry;
- reader_entry = vreader_list_get_next(reader_entry)) {
+ VReaderList *list = vreader_get_reader_list();
+ VReaderListEntry *reader_entry;
+ printf("Active Readers:\n");
+ for (reader_entry = vreader_list_get_first(list); reader_entry;
+ reader_entry = vreader_list_get_next(reader_entry)) {
VReader *reader = vreader_list_get_reader(reader_entry);
VReaderID reader_id;
reader_id=vreader_get_id(reader);
@@ -478,8 +486,9 @@ main (
if (!passthru && cert_count > 0) {
char *new_args;
int len, i;
- /* if we've given some -c options, we clearly we want do so some software emulation.
- * add that emulation now. this is NSS Emulator specific */
+ /* if we've given some -c options, we clearly we want do so some
+ * software emulation. add that emulation now. this is NSS Emulator
+ * specific */
if (emul_args == NULL) {
emul_args = "db=\"/etc/pki/nssdb\"";
}
@@ -531,7 +540,8 @@ main (
#endif
vcard_emul_init(command_line_options);
- /* launch the event_thread. This will trigger reader adds for all the existing readers */
+ /* launch the event_thread. This will trigger reader adds for all the
+ * existing readers */
rv = pthread_create(&thread_id, NULL, event_thread, reader);
if (rv < 0) {
perror("pthread_create");
@@ -626,7 +636,8 @@ if (verbose) {
);
}
vreader_free(reader);
- reader = NULL; /* we've freed it, don't use it by accident again */
+ reader = NULL; /* we've freed it, don't use it by accident
+ again */
break;
case VSC_Reconnect:
{