Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

int LTPBundleFindValueWithKey ( const char *  fileName,
const char *  tokenKey,
char *  tokenValue,
int  tokenIndice 
)

Find a key in a configuration file

Parameters:
fileName file name
tokenKey key value
[out] tokenValue token value (if key found)
tokenIndice indice of the desired key
Return values:
-1 configuration file not found
0 OK
1 key not found

Definition at line 1859 of file tokenparser.c.

{
      FILE *file = NULL;
      int ret = 0;

      desiredIndex  = tokenIndice;
      pcDesiredKey  = tokenKey;
      pcFinValue[0] = '\0';

      file = fopen(fileName, "r");

      if (!file)
      {
            Log3(PCSC_LOG_CRITICAL, "Could not open bundle file %s: %s",
                  fileName, strerror(errno));
            return 1;
      }

      tpin = file;

      do
      {
            tplex();
      } while (!feof(file));

      if (pcFinValue[0] == 0)
      {
            if (tokenIndice == 0)
            {
                  /* Not defined at all */
                  Log3(PCSC_LOG_CRITICAL, "Value/Key not defined for: %s in %s",
                        tokenKey, fileName);
            }
            ret = -1;
      }
      else
            strlcpy(tokenValue, pcFinValue, TOKEN_MAX_VALUE_SIZE);

      fclose(file);
      return ret;
}


Generated by  Doxygen 1.6.0   Back to index