Remove flag SCCONF_OPTIONAL, add SCCONF_MANDATORY
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@410 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
2fbf01e87d
commit
b2a10c12e7
|
@ -445,7 +445,7 @@ static int parse_entries(scconf_context * config, const scconf_block * block, sc
|
||||||
r = 0;
|
r = 0;
|
||||||
blocks = getblocks(config, block, e);
|
blocks = getblocks(config, block, e);
|
||||||
if (!blocks) {
|
if (!blocks) {
|
||||||
if (e->flags & SCCONF_OPTIONAL) {
|
if (!(e->flags & SCCONF_MANDATORY)) {
|
||||||
if (config->debug)
|
if (config->debug)
|
||||||
fprintf(stderr, "optional configuration entry '%s' not present\n",
|
fprintf(stderr, "optional configuration entry '%s' not present\n",
|
||||||
e->name);
|
e->name);
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct _scconf_entry {
|
||||||
|
|
||||||
/* Entry flags */
|
/* Entry flags */
|
||||||
#define SCCONF_PRESENT 0x00000001
|
#define SCCONF_PRESENT 0x00000001
|
||||||
#define SCCONF_OPTIONAL 0x00000002
|
#define SCCONF_MANDATORY 0x00000002
|
||||||
#define SCCONF_ALLOC 0x00000004
|
#define SCCONF_ALLOC 0x00000004
|
||||||
#define SCCONF_ALL_BLOCKS 0x00000008
|
#define SCCONF_ALL_BLOCKS 0x00000008
|
||||||
#define SCCONF_VERBOSE 0x00000010 /* For debugging purposes only */
|
#define SCCONF_VERBOSE 0x00000010 /* For debugging purposes only */
|
||||||
|
|
|
@ -32,14 +32,14 @@ static int ldap_cb(scconf_context * config, const scconf_block * block, scconf_e
|
||||||
{
|
{
|
||||||
scconf_entry ldap_entry[] =
|
scconf_entry ldap_entry[] =
|
||||||
{
|
{
|
||||||
{"ldaphost", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"ldaphost", SCCONF_STRING, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{"ldapport", SCCONF_INTEGER, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"ldapport", SCCONF_INTEGER, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{"scope", SCCONF_INTEGER, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"scope", SCCONF_INTEGER, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{"binddn", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"binddn", SCCONF_STRING, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{"passwd", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"passwd", SCCONF_STRING, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{"base", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"base", SCCONF_STRING, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{"attributes", SCCONF_LIST, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"attributes", SCCONF_LIST, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{"filter", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_VERBOSE, NULL, NULL},
|
{"filter", SCCONF_STRING, SCCONF_VERBOSE, NULL, NULL},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
char *cardprefix = (char *) entry->arg;
|
char *cardprefix = (char *) entry->arg;
|
||||||
|
@ -61,7 +61,7 @@ static int card_cb(scconf_context * config, const scconf_block * block, scconf_e
|
||||||
char *str = scconf_list_strdup(block->name, " ");
|
char *str = scconf_list_strdup(block->name, " ");
|
||||||
scconf_entry card_entry[] =
|
scconf_entry card_entry[] =
|
||||||
{
|
{
|
||||||
{"ldap", SCCONF_CALLBACK, SCCONF_OPTIONAL | SCCONF_VERBOSE | SCCONF_ALL_BLOCKS, (void *) ldap_cb, str},
|
{"ldap", SCCONF_CALLBACK, SCCONF_VERBOSE | SCCONF_ALL_BLOCKS, (void *) ldap_cb, str},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ int main(int argc, char **argv)
|
||||||
scconf_context *conf = NULL;
|
scconf_context *conf = NULL;
|
||||||
scconf_entry entry[] =
|
scconf_entry entry[] =
|
||||||
{
|
{
|
||||||
{"ldap", SCCONF_CALLBACK, SCCONF_OPTIONAL | SCCONF_VERBOSE | SCCONF_ALL_BLOCKS, (void *) ldap_cb},
|
{"ldap", SCCONF_CALLBACK, SCCONF_VERBOSE | SCCONF_ALL_BLOCKS, (void *) ldap_cb},
|
||||||
{"card", SCCONF_CALLBACK, SCCONF_OPTIONAL | SCCONF_VERBOSE | SCCONF_ALL_BLOCKS, (void *) card_cb},
|
{"card", SCCONF_CALLBACK, SCCONF_VERBOSE | SCCONF_ALL_BLOCKS, (void *) card_cb},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
char *in = NULL, *out = NULL;
|
char *in = NULL, *out = NULL;
|
||||||
|
|
|
@ -76,14 +76,14 @@ static int ldap_cb(scconf_context * config, const scconf_block * block, scconf_e
|
||||||
scldap_param_entry *lentry = (scldap_param_entry *) &ctx->entry[ctx->entries];
|
scldap_param_entry *lentry = (scldap_param_entry *) &ctx->entry[ctx->entries];
|
||||||
scconf_entry centry[] =
|
scconf_entry centry[] =
|
||||||
{
|
{
|
||||||
{"ldaphost", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_ALLOC, &lentry->ldaphost, NULL},
|
{"ldaphost", SCCONF_STRING, SCCONF_ALLOC, &lentry->ldaphost, NULL},
|
||||||
{"ldapport", SCCONF_INTEGER, SCCONF_OPTIONAL | SCCONF_ALLOC, &lentry->ldapport, NULL},
|
{"ldapport", SCCONF_INTEGER, SCCONF_ALLOC, &lentry->ldapport, NULL},
|
||||||
{"scope", SCCONF_INTEGER, SCCONF_OPTIONAL | SCCONF_ALLOC, &lentry->scope, NULL},
|
{"scope", SCCONF_INTEGER, SCCONF_ALLOC, &lentry->scope, NULL},
|
||||||
{"binddn", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_ALLOC, &lentry->binddn, NULL},
|
{"binddn", SCCONF_STRING, SCCONF_ALLOC, &lentry->binddn, NULL},
|
||||||
{"passwd", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_ALLOC, &lentry->passwd, NULL},
|
{"passwd", SCCONF_STRING, SCCONF_ALLOC, &lentry->passwd, NULL},
|
||||||
{"base", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_ALLOC, &lentry->base, NULL},
|
{"base", SCCONF_STRING, SCCONF_ALLOC, &lentry->base, NULL},
|
||||||
{"attributes", SCCONF_CALLBACK, SCCONF_OPTIONAL, (void *) attrs_cb, lentry},
|
{"attributes", SCCONF_CALLBACK, 0, (void *) attrs_cb, lentry},
|
||||||
{"filter", SCCONF_STRING, SCCONF_OPTIONAL | SCCONF_ALLOC, &lentry->filter, NULL},
|
{"filter", SCCONF_STRING, SCCONF_ALLOC, &lentry->filter, NULL},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
char *ldapsuffix = NULL;
|
char *ldapsuffix = NULL;
|
||||||
|
@ -92,13 +92,18 @@ static int ldap_cb(scconf_context * config, const scconf_block * block, scconf_e
|
||||||
if (ctx->entries >= SCLDAP_MAX_ENTRIES)
|
if (ctx->entries >= SCLDAP_MAX_ENTRIES)
|
||||||
return 0; /* Hard limit reached, just return OK */
|
return 0; /* Hard limit reached, just return OK */
|
||||||
ldapsuffix = scconf_list_strdup(block->name, " ");
|
ldapsuffix = scconf_list_strdup(block->name, " ");
|
||||||
|
if (!ldapsuffix) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (cardprefix) {
|
if (cardprefix) {
|
||||||
len = strlen(cardprefix) + 1;
|
len = strlen(cardprefix) + 1;
|
||||||
}
|
}
|
||||||
len += strlen(ldapsuffix) + 1;
|
len += strlen(ldapsuffix) + 1;
|
||||||
lentry->entry = malloc(len);
|
lentry->entry = malloc(len);
|
||||||
if (!lentry->entry)
|
if (!lentry->entry) {
|
||||||
|
free(ldapsuffix);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
memset(lentry->entry, 0, len);
|
memset(lentry->entry, 0, len);
|
||||||
snprintf(lentry->entry, len, "%s%s%s", cardprefix ? cardprefix : "", cardprefix ? " " : "", ldapsuffix);
|
snprintf(lentry->entry, len, "%s%s%s", cardprefix ? cardprefix : "", cardprefix ? " " : "", ldapsuffix);
|
||||||
free(ldapsuffix);
|
free(ldapsuffix);
|
||||||
|
@ -119,7 +124,7 @@ static int card_cb(scconf_context * config, const scconf_block * block, scconf_e
|
||||||
cb_data *trans = (cb_data *) entry->arg;
|
cb_data *trans = (cb_data *) entry->arg;
|
||||||
scconf_entry card_entry[] =
|
scconf_entry card_entry[] =
|
||||||
{
|
{
|
||||||
{"ldap", SCCONF_CALLBACK, SCCONF_OPTIONAL | SCCONF_ALL_BLOCKS, (void *) ldap_cb, trans},
|
{"ldap", SCCONF_CALLBACK, SCCONF_ALL_BLOCKS, (void *) ldap_cb, trans},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -154,8 +159,8 @@ scldap_context *scldap_parse_parameters(const char *filename)
|
||||||
cb_data trans = {ctx, NULL};
|
cb_data trans = {ctx, NULL};
|
||||||
scconf_entry entry[] =
|
scconf_entry entry[] =
|
||||||
{
|
{
|
||||||
{"ldap", SCCONF_CALLBACK, SCCONF_OPTIONAL | SCCONF_ALL_BLOCKS, (void *) ldap_cb, &trans},
|
{"ldap", SCCONF_CALLBACK, SCCONF_ALL_BLOCKS, (void *) ldap_cb, &trans},
|
||||||
{"card", SCCONF_CALLBACK, SCCONF_OPTIONAL | SCCONF_ALL_BLOCKS, (void *) card_cb, &trans},
|
{"card", SCCONF_CALLBACK, SCCONF_ALL_BLOCKS, (void *) card_cb, &trans},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
ctx->conf = scconf_new(filename);
|
ctx->conf = scconf_new(filename);
|
||||||
|
|
Loading…
Reference in New Issue