/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* SASL Config file API
* Rob Siemborski
* Tim Martin (originally in Cyrus distribution)
* $Id: config.c,v 1.13 2003/02/13 19:55:54 rjs3 Exp $
*/
/*
* Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The name "Carnegie Mellon University" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For permission or any other legal
* details, please contact
* Office of Technology Transfer
* Carnegie Mellon University
* 5000 Forbes Avenue
* Pittsburgh, PA 15213-3890
* (412) 268-4387, fax: (412) 268-7395
* tech-transfer@andrew.cmu.edu
*
* 4. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by Computing Services
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
*
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Current Valid keys:
*
* canon_user_plugin: <string>
* pwcheck_method: <string>
* auto_transition: <boolean>
* plugin_list: <string>
*
* srvtab: <string>
*/
#include "sasl.h"
#include "saslint.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "config.h" /* _SUN_SDK_ */
struct configlist {
char *key;
char *value;
};
#ifndef _SUN_SDK_
static int nconfiglist;
#endif /* !_SUN_SDK_ */
#ifdef _SUN_SDK_
#else
int sasl_config_init(const char *filename)
#endif /* _SUN_SDK_ */
{
int lineno = 0;
int alloced = 0;
char *p, *key;
int result;
#ifdef _SUN_SDK_
int invalid_line = 0;
gctx->nconfiglist=0;
#else
nconfiglist=0;
#endif /* _SUN_SDK_ */
if (!infile) {
return SASL_CONTINUE;
}
#ifdef _SUN_SDK_
goto done;
#endif /* _SUN_SDK_ */
lineno++;
if (!*p || *p == '#') continue;
key = p;
p++;
}
if (*p != ':') {
#ifdef _SUN_SDK_
invalid_line = 1;
goto done;
#else
return SASL_FAIL;
#endif /* _SUN_SDK_ */
}
*p++ = '\0';
while (*p && isspace((int) *p)) p++;
if (!*p) {
#ifdef _SUN_SDK_
invalid_line = 1;
goto done;
#else
return SASL_FAIL;
#endif /* _SUN_SDK_ */
}
#ifdef _SUN_SDK_
#else
if (nconfiglist == alloced) {
#endif /* _SUN_SDK_ */
#ifdef _SUN_SDK_
alloced * sizeof(struct configlist));
result = SASL_NOMEM;
goto done;
}
#else
alloced * sizeof(struct configlist));
#endif /* _SUN_SDK_ */
}
#ifdef _SUN_SDK_
NULL);
goto done;
#else
NULL);
#endif /* _SUN_SDK_ */
#ifdef _SUN_SDK_
result = _sasl_strdup(p,
NULL);
goto done;
}
#else
result = _sasl_strdup(p,
NULL);
#endif /* _SUN_SDK_ */
#ifdef _SUN_SDK_
(gctx->nconfiglist)++;
#else
nconfiglist++;
#endif /* _SUN_SDK_ */
}
#ifdef _SUN_SDK_
done:
if (invalid_line) {
}
return result;
#else
return SASL_OK;
#endif /* _SUN_SDK_ */
}
#ifdef _SUN_SDK_
/* Releases the resources acquired in sasl_config_init() */
{
int i;
return;
for (i = 0; i < gctx->nconfiglist; i++) {
}
gctx->nconfiglist = 0;
}
{
int opt;
}
return def;
}
#else
{
int opt;
}
return def;
}
#endif /* _SUN_SDK_ */
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
{
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
}
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
{
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
return 0;
}
return 1;
}
return def;
}