* amd/Makefile.am: Added new files sun_map.h, sun_map.c,
sun_map_parse.y, and sun_map_tok.l. These files add support for
parsing Sun style maps. The yacc/lex files needed custom rules so
- they don't cause symbol conflicts with each other.
-
+ they don't cause symbol conflicts with each other.
+
* amd/amd.h: Added "#define INFO_MAX_LINE_LEN" that specifies the
line limit for info services.
added support for parsing Sun style maps. The support for Sun
maps is done using the sun_entry2amd() function. This function is
called for each entry line that is read only when Sun parsing is
- enabled. For each entry line that is passed to the function a copy of
- the Amd equivalent is returned.
+ enabled. For each entry line that is passed to the function a
+ copy of the Amd equivalent is returned.
* amd/sun_map.h: new header file for Sun style map support
2005-08-06 Erez Zadok <ezk@cs.sunysb.edu>
+ * amd/info_file.c (file_search, file_reload): pass mnt_map to
+ file_search_or_reload.
+ (file_search_or_reload): ensure that mnt_map is never NULL.
+
+ * amd/info_nis.c (nis_search): call sun_entry2amd() if
+ sun_map_syntax=yes.
+
+ * amd/info_ldap.c (amu_ldap_search): call sun_entry2amd() if
+ sun_map_syntax=yes.
+
+ * amd/info_hesiod.c (hesiod_search): call sun_entry2amd() if
+ sun_map_syntax=yes.
+
+ * amd/info_ndbm.c (ndbm_search): pass mnt_map to search_ndbm.
+ (search_ndbm): call sun_entry2amd() if sun_map_syntax=yes.
+
+ * amd/info_nisplus.c (nisplus_search): call sun_entry2amd() if
+ sun_map_syntax=yes.
+
+ * amd/info_exec.c (exec_search): pass mnt_map to
+ exec_parse_qanswer.
+ (exec_parse_qanswer): call sun_entry2amd() if sun_map_syntax=yes.
+
* doc/am-utils.texi (sun_map_syntax Parameter): document new
common parameter.
sched.c \
srvr_amfs_auto.c \
srvr_nfs.c \
- \
- sun_map.c
+ sun_map.c
# the complete list of all optional sources
EXTRA_amd_SOURCES = \
# AMD_INFO_OBJS: a list of info_*.o objects added, depending on which map
# types this system supports.
EXTRA_amd_OBJECTS = @AMD_FS_OBJS@ @AMD_INFO_OBJS@ sun_map_parse.o sun_map_tok.o
-LDADD = $(EXTRA_amd_OBJECTS) get_args.o ../libamu/libamu.la
+LDADD = $(EXTRA_amd_OBJECTS) get_args.o ../libamu/libamu.la
# must manually add f/lex library to LIBS, and not to LDADD.
LIBS = @LIBS@ @LEXLIB@ @WRAPLIB@
sun_map_parse.o : sun_map_parse.c
sun_map_parse.c : sun_map_parse.y
- $(YACC) -d -psun_map_ -o$@ $<
+ $(YACC) -d -psun_map_ -o$@ $<
sun_map_tok.o : sun_map_tok.c
# auto-generate build number
build_version.h: $(amd_OBJECTS) $(EXTRA_amd_OBJECTS) get_args.c
$(top_srcdir)/m4/update_build_version
-
* that support mtab on file.
*/
#ifdef MOUNT_TABLE_ON_FILE
-# define DEBUG_MNTTAB_FILE "/tmp/mnttab"
+# define DEBUG_MNTTAB_FILE "/tmp/mnttab"
#endif /* MOUNT_TABLE_ON_FILE */
/* Max line length that info services can handle */
-#define INFO_MAX_LINE_LEN 1500
+#define INFO_MAX_LINE_LEN 1500
/* options for amd.conf */
#define CFM_BROWSABLE_DIRS 0x00000001
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amd.h>
+#include <sun_map.h>
/* forward declarations */
* Try to locate a value in a query answer
*/
static int
-exec_parse_qanswer(int fd, char *map, char *key, char **pval, time_t *tp)
+exec_parse_qanswer(mnt_map *m, int fd, char *map, char *key, char **pval, time_t *tp)
{
char qanswer[INFO_MAX_LINE_LEN], *dc = 0;
int chuck = 0;
/*
* Return a copy of the data
*/
- dc = strdup(cp);
+ if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
+ dc = sun_entry2amd(cp);
+ else
+ dc = strdup(cp);
*pval = dc;
dlog("%s returns %s", key, dc);
if (tp)
*tp = clocktime();
- return exec_parse_qanswer(mapfd, map, key, pval, tp);
+ return exec_parse_qanswer(m, mapfd, map, key, pval, tp);
}
return errno;
#include <amd.h>
#include <sun_map.h>
+
/* forward declarations */
int file_init_or_mtime(mnt_map *m, char *map, time_t *tp);
int file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *));
* Try to locate a key in a file
*/
static int
-file_search_or_reload(FILE *fp,
+file_search_or_reload(mnt_map *m,
+ FILE *fp,
char *map,
char *key,
char **val,
- mnt_map *m,
void (*fn) (mnt_map *m, char *, char *))
{
char key_val[INFO_MAX_LINE_LEN];
int
file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *))
{
- FILE *mapf = file_open(map, (time_t *) 0);
+ FILE *mapf = file_open(map, (time_t *) NULL);
if (mapf) {
- int error = file_search_or_reload(mapf, map, 0, 0, m, fn);
+ int error = file_search_or_reload(m, mapf, map, NULL, NULL, fn);
(void) fclose(mapf);
return error;
}
*tp = t;
error = -1;
} else {
- error = file_search_or_reload(mapf, map, key, pval, 0, 0);
+ error = file_search_or_reload(m, mapf, map, key, pval, NULL);
}
(void) fclose(mapf);
return error;
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amd.h>
+#include <sun_map.h>
#define HES_PREFIX "hesiod."
#define HES_PREFLEN 7
* it (and free subsequent replies)
*/
if (rvec && *rvec) {
- *pval = *rvec;
+ if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) {
+ *pval = sun_entry2amd(*rvec);
+ XFREE(*rvec);
+ } else
+ *pval = *rvec;
while (*++rvec)
XFREE(*rvec);
return 0;
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amd.h>
+#include <sun_map.h>
/*
}
dlog("Map %s, %s => %s\n", map, key, vals[0]);
if (vals[0]) {
- *pval = strdup(vals[0]);
+ if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
+ *pval = sun_entry2amd(vals[0]);
+ else
+ *pval = strdup(vals[0]);
err = 0;
} else {
plog(XLOG_USER, "Empty value for %s in map %s\n", key, map);
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amd.h>
+#include <sun_map.h>
/* forward declarations */
int ndbm_init(mnt_map *m, char *map, time_t *tp);
static int
-search_ndbm(DBM *db, char *key, char **val)
+search_ndbm(mnt_map *m, DBM *db, char *key, char **val)
{
datum k, v;
k.dsize = strlen(key) + 1;
v = dbm_fetch(db, k);
if (v.dptr) {
- *val = strdup(v.dptr);
+ if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)
+ *val = sun_entry2amd(v.dptr);
+ else
+ *val = strdup(v.dptr);
return 0;
}
return ENOENT;
*tp = stb.st_mtime;
error = -1;
} else {
- error = search_ndbm(db, key, pval);
+ error = search_ndbm(m, db, key, pval);
}
(void) dbm_close(db);
return error;
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amd.h>
+#include <sun_map.h>
/*
* Try to locate a key using NIS.
*/
int
-nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp)
+nis_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp)
{
int outlen;
int res;
/*
* Lookup key
*/
- res = yp_match(gopt.nis_domain, map, key, strlen(key), val, &outlen);
+ res = yp_match(gopt.nis_domain, map, key, strlen(key), pval, &outlen);
+ if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) {
+ char *oldval = *pval;
+ *pval = sun_entry2amd(oldval);
+ XFREE(*pval); /* yp_match malloc's *pval above */
+ }
/*
* Do something interesting with the return code
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amd.h>
+#include <sun_map.h>
#define NISPLUS_KEY "key="
#define NISPLUS_ORGDIR ".org_dir"
if (value != NULL)
data.value = strnsave(ENTRY_VAL(value, 1), ENTRY_LEN(value, 1));
}
- *val = data.value;
+
+ if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) {
+ *val = sun_entry2amd(data.value);
+ XFREE(data.value); /* strnsave malloc'ed it above */
+ } else
+ *val = data.value;
if (*val) {
error = 0;