Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
argpin.c File Reference
#include <stdio.h>
#include <string.h>
#include "argpin.h"

Go to the source code of this file.

Classes

struct  SVRCOREArgPinObj

Functions

void echoOff (int fd)
void echoOn (int fd)
SVRCOREError SVRCORE_CreateArgPinObj (SVRCOREArgPinObj **out, const char *tokenName, const char *password, SVRCOREPinObj *pinObj)
void SVRCORE_DestroyArgPinObj (SVRCOREArgPinObj *obj)
static void destroyObject (SVRCOREPinObj *obj)
static char * getPin (SVRCOREPinObj *obj, const char *tokenName, PRBool retry)

Variables

static struct SVRCOREPinMethods
static const SVRCOREPinMethods vtable

Class Documentation

struct SVRCOREArgPinObj

Definition at line 50 of file argpin.c.

Class Members
SVRCOREPinObj * alt
SVRCOREPinObj base
char * password
char * tokenName

Function Documentation

static void destroyObject ( SVRCOREPinObj *  obj) [static]

Definition at line 133 of file argpin.c.

Here is the call graph for this function:

void echoOff ( int  fd)

Definition at line 70 of file argpin.c.

{
}

Here is the caller graph for this function:

void echoOn ( int  fd)

Definition at line 74 of file argpin.c.

{
}

Here is the caller graph for this function:

static char* getPin ( SVRCOREPinObj *  obj,
const char *  tokenName,
PRBool  retry 
) [static]

Definition at line 138 of file argpin.c.

{
    SVRCOREArgPinObj *p = (SVRCOREArgPinObj*)obj;

    if (tokenName == NULL) return NULL;

    /* On first attempt, return the password if the token name
     * matches.
     */
    if (!retry && strcmp(p->tokenName, tokenName) == 0)
    {
      return strdup(p->password);
    }

    if (p->alt != NULL) return SVRCORE_GetPin(p->alt, tokenName, retry);

    return (NULL);
}
SVRCOREError SVRCORE_CreateArgPinObj ( SVRCOREArgPinObj **  out,
const char *  tokenName,
const char *  password,
SVRCOREPinObj *  pinObj 
)

Definition at line 81 of file argpin.c.

{
  SVRCOREError err = 0;
  SVRCOREArgPinObj *obj = 0;

  do {
    obj = (SVRCOREArgPinObj*)malloc(sizeof (SVRCOREArgPinObj));
    if (!obj) { err = 1; break; }

    obj->base.methods = &vtable;
    obj->tokenName=NULL;
    obj->password=NULL;
    obj->alt=pinObj;

    if ( tokenName == NULL) {
      PK11SlotInfo *slot = PK11_GetInternalKeySlot();

      obj->tokenName = strdup(PK11_GetTokenName(slot));
      PK11_FreeSlot(slot);
    }
    else
    {
      obj->tokenName = strdup(tokenName);
    }
    if (obj->tokenName == NULL) { err = 1; break; }

    obj->password = strdup(password);
    if (obj->password == NULL) { err = 1; break; }
  } while(0);

  if (err)
  {
    SVRCORE_DestroyArgPinObj(obj);
    obj = 0;
  }

  *out = obj;
  return err;
}

Here is the call graph for this function:

Definition at line 122 of file argpin.c.

{
  if (obj->tokenName) free(obj->tokenName);
  if (obj->password)
  {
    memset(obj->password, 0, strlen(obj->password));
    free(obj->password);
  }
  if (obj) free(obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct SVRCOREPinMethods [static]

Definition at line 58 of file argpin.c.

Initial value:
{ 0, 0, destroyObject, getPin }

Definition at line 160 of file argpin.c.