# headers this depends on, not to be installed
noinst_HEADERS = amd.h sun_map.h
+# sources which get auto-built (from yacc/lex)
+BUILT_SOURCES = \
+ conf_parse.c conf_parse.h conf_tok.c \
+ sun_map_parse.c sun_map_parse.h sun_map_tok.c
+AM_YFLAGS = -d
+
# *.y must be listed before *.l, because of a bug in automake-1.2
# which will not generate the .h needs for the lex file from the yacc file.
# I took out the conf .y/.l files b/c of bad interaction between bsd44 make
# get_args.c is handled separately
amd_SOURCES = \
conf_parse.y \
+ sun_map_parse.y \
conf_tok.l \
+ sun_map_tok.l \
\
am_ops.c \
amd.c \
# filesystem types this system supports.
# 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
+EXTRA_amd_OBJECTS = @AMD_FS_OBJS@ @AMD_INFO_OBJS@
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@
-# custom yacc/lex rules for the Sun map parser
-sun_map_parse.o : sun_map_parse.c
-
-sun_map_parse.c : sun_map_parse.y
- $(YACC) -d -psun_map_ -o$@ $<
-
-sun_map_tok.o : sun_map_tok.c
-
-sun_map_tok.c : sun_map_tok.l
- $(LEX) -Psun_map_ -o$@ $<
-
# additional files to distribute and clean
EXTRA_DIST = ops_TEMPLATE.c $(man_MANS) $(TESTS)
-CLEANFILES = conf_tok.c conf_parse.c conf_parse.h sun_map_parse.c sun_map_tok.c sun_map_parse.h
+CLEANFILES = $(BUILT_SOURCES)
DISTCLEANFILES = build_version.h
# do not distribute files that should be generated by lex/yacc locally
dist-hook:
- (cd $(distdir) && rm -f conf_parse.c conf_parse.h conf_tok.c)
+ (cd $(distdir) && rm -f $(BUILT_SOURCES))
INCLUDES = -I$(top_srcdir)/include
# allow users to add their own flags via "configure --enable-am-flags=ARG"
AMU_CFLAGS = @AMU_CFLAGS@
AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS)
-AM_YFLAGS = -d
# dependencies
$(PROGRAMS): $(LDADD)
/*
- * Copyright (c) 2005 Daniel Ottavio
* Copyright (c) 1997-2005 Erez Zadok
+ * Copyright (c) 2005 Daniel P. Ottavio
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
}
%token NEWLINE COMMENT WSPACE
-%token <strval> WORD
+%token <strval> WORD
%%
| entries
;
-entries : entry
+entries : entry
| entry new_lines
| entry new_lines entries
;
struct sun_list *list;
struct sun_entry *entry;
-
+
/* allocate an entry */
entry = sun_entry_alloc();
-
- /*
+
+ /*
* Assign the global location list to this entry and reset the
* global pointer. Reseting the global pointer will create a new
* list instance next time get_sun_location_list() is called.
list = get_sun_location_list();
entry->location_list = (struct sun_location *)list->first;
sun_location_list = NULL;
-
+
/* Add this entry to the entry list. */
sun_list_add(get_sun_entry_list(),(qelem *)entry);
}
struct sun_list *list;
struct sun_entry *entry;
-
+
entry = sun_entry_alloc();
/* An fstype may have been defined in the 'options'. */
entry->fstype = tmpFsType;
tmpFsType = NULL;
}
-
- /*
+
+ /*
* Assign the global location list to this entry and reset the
* global pointer. Reseting the global pointer will create a new
* list instance next time get_sun_location_list() is called.
list = get_sun_location_list();
entry->location_list = (struct sun_location *)list->first;
sun_location_list = NULL;
-
- /*
+
+ /*
* Assign the global opt list to this entry and reset the global
* pointer. Reseting the global pointer will create a new list
* instance next time get_sun_opt_list() is called.
sun_list_add(get_sun_entry_list(),(qelem *)entry);
}
-
| mountpoints {
struct sun_list *list;
struct sun_entry *entry;
-
+
/* allocate an entry */
entry = sun_entry_alloc();
-
- /*
+
+ /*
* Assign the global mountpt list to this entry and reset the global
* pointer. Reseting the global pointer will create a new list
* instance next time get_mountpt_list() is called.
struct sun_list *list;
struct sun_entry *entry;
-
+
/* allocate an entry */
- entry = sun_entry_alloc();
+ entry = sun_entry_alloc();
/* An fstype may have been defined in the 'options'. */
if(tmpFsType != NULL) {
entry->fstype = tmpFsType;
tmpFsType = NULL;
}
-
- /*
+
+ /*
* Assign the global mountpt list to this entry and reset the global
* pointer. Reseting the global pointer will create a new list
* instance next time get_mountpt_list() is called.
list = get_mountpt_list();
entry->mountpt_list = (struct sun_mountpt *)list->first;
mountpt_list = NULL;
-
- /*
+
+ /*
* Assign the global opt list to this entry and reset the global
* pointer. Reseting the global pointer will create a new list
* instance next time get_sun_opt_list() is called.
list = get_sun_opt_list();
entry->opt_list = (struct sun_opt *)list->first;
sun_opt_list = NULL;
-
+
/* Add this entry to the entry list. */
sun_list_add(get_sun_entry_list(),(qelem *)entry);
}
| '+' WORD {
-
+
struct sun_opt *include = sun_opt_alloc();
include->str = strdup($2);
-
+
sun_list_add(get_sun_include_list(),(qelem *)include);
}
-;
+;
mountpoints : mountpoint
| mountpoint WSPACE mountpoints
/* allocate a mountpt */
mountpt = sun_mountpt_alloc();
-
- /*
+
+ /*
* Assign the global loaction list to this entry and reset the
* global pointer. Reseting the global pointer will create a new
* list instance next time get_sun_location_list() is called.
list = get_sun_location_list();
mountpt->location_list = (struct sun_location *)list->first;
sun_location_list = NULL;
-
+
mountpt->path = strdup($1);
-
+
/* Add this mountpt to the mountpt list. */
sun_list_add(get_mountpt_list(),(qelem *)mountpt);
}
struct sun_list *list;
struct sun_mountpt *mountpt;
-
+
/* allocate a mountpt */
mountpt = sun_mountpt_alloc();
-
- /*
+
+ /*
* Assign the global loaction list to this entry and reset the
* global pointer. Reseting the global pointer will create a new
* list instance next time get_sun_location_list() is called.
list = get_sun_location_list();
mountpt->location_list = (struct sun_location *)list->first;
sun_location_list = NULL;
-
- /*
+
+ /*
* Assign the global opt list to this entry and reset the global
* pointer. Reseting the global pointer will create a new list
* instance next time get_sun_opt_list() is called.
list = get_sun_opt_list();
mountpt->opt_list = (struct sun_opt *)list->first;
sun_opt_list = NULL;
-
+
mountpt->path = strdup($1);
-
+
/* Add this mountpt to the mountpt list. */
sun_list_add(get_mountpt_list(),(qelem *)mountpt);
}
;
-locations : location
+locations : location
| location WSPACE locations
;
location : hosts ':' WORD {
-
+
struct sun_list *list;
struct sun_location *location;
-
+
/* allocate a new location */
location = sun_location_alloc();
-
- /*
+
+ /*
* Assign the global opt list to this entry and reset the global
* pointer. Reseting the global pointer will create a new list
* instance next time get_sun_opt_list() is called.
list = get_sun_host_list();
location->host_list = (struct sun_host *)list->first;
sun_host_list = NULL;
-
+
location->path = strdup($3);
-
+
/* Add this location to the location list. */
sun_list_add(get_sun_location_list(),(qelem *)location);
}
| ':' WORD {
-
+
struct sun_location *location;
-
+
/* allocate a new location */
location = sun_location_alloc();
-
+
location->path = strdup($2);
-
+
/* Add this location to the location list. */
sun_list_add(get_sun_location_list(),(qelem *)location);
}
;
host : WORD {
-
+
/* allocate a new host */
struct sun_host *host = sun_host_alloc();
-
+
host->name = strdup($1);
-
+
/* Add this host to the host list. */
sun_list_add(get_sun_host_list(),(qelem *)host);
}
* list.
*/
struct sun_host *host = (struct sun_host *)sun_host_list->last;
-
+
host->name = strdup($1);
}
;
weight : '(' WORD ')' {
-
+
int val;
/* allocate a new host */
struct sun_host *host = sun_host_alloc();
-
+
val = atoi($2);
-
+
host->weight = val;
/* Add this host to the host list. */
}
;
-options : option
+options : option
| option ',' options
;
-
+
/* file system type option */
option : 'fstype='WORD {
-
+
tmpFsType = strdup($2);
}
/* all other fs options */
| WORD {
-
+
struct sun_opt *opt = sun_opt_alloc();
opt->str = strdup($1);
sun_list_add(get_sun_opt_list(),(qelem *)opt);
}
-;
+;
%%
-struct sun_entry *sun_map_parse_read(const char *map_data) {
-
+struct sun_entry *
+sun_map_parse_read(const char *map_data)
+{
struct sun_entry *retval = NULL;
/* pass map_data to lex */
sun_map_tok_setbuff(map_data);
-
+
/* call yacc */
sun_map_parse();
-
+
if (sun_entry_list != NULL) {
/* return the first Sun entry in the list */
retval = (struct sun_entry*)sun_entry_list->first;
else {
plog(XLOG_ERROR,"Sun map parser did not produce data structs.");
}
-
+
return retval;
}
-static struct sun_list *get_sun_include_list() {
- if(sun_include_list == NULL) {
+
+static struct sun_list *
+get_sun_include_list(void)
+{
+ if (sun_include_list == NULL) {
sun_include_list = sun_list_alloc();
}
return sun_include_list;
}
-static struct sun_list *get_sun_entry_list() {
- if(sun_entry_list == NULL) {
+
+static struct sun_list *
+get_sun_entry_list(void)
+{
+ if (sun_entry_list == NULL) {
sun_entry_list = sun_list_alloc();
}
return sun_entry_list;
}
-static struct sun_list *get_mountpt_list() {
- if(mountpt_list == NULL) {
+
+static struct sun_list *
+get_mountpt_list(void)
+{
+ if (mountpt_list == NULL) {
mountpt_list = sun_list_alloc();
}
return mountpt_list;
}
-static struct sun_list *get_sun_location_list() {
- if(sun_location_list == NULL) {
+
+static struct sun_list *
+get_sun_location_list(void)
+{
+ if (sun_location_list == NULL) {
sun_location_list = sun_list_alloc();
}
return sun_location_list;
}
-static struct sun_list *get_sun_host_list() {
- if(sun_host_list == NULL) {
+
+static struct sun_list *
+get_sun_host_list(void)
+{
+ if (sun_host_list == NULL) {
sun_host_list = sun_list_alloc();
}
return sun_host_list;
}
-static struct sun_list *get_sun_opt_list() {
- if(sun_opt_list == NULL) {
+
+static struct sun_list *
+get_sun_opt_list(void)
+{
+ if (sun_opt_list == NULL) {
sun_opt_list = sun_list_alloc();
}
return sun_opt_list;
/*
- * Copyright (c) 2005 Daniel Ottavio
* Copyright (c) 1997-2005 Erez Zadok
+ * Copyright (c) 2005 Daniel P. Ottavio
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
#include <amd.h>
-
-
-#include <string.h>
#include <sun_map_parse.h>
-/*
- * We need to configure lex to parse from a string
+/*
+ * We need to configure lex to parse from a string
* instead of a file. Each version of lex has it's
- * own way of doing this(sigh).
- */
+ * own way of doing this (sigh).
+ */
#ifdef FLEX_SCANNER
/* assign the buffer to parse */
const char *sun_map_tok_pos = NULL;
/* size of the buffer */
-const char *sun_map_tok_end = NULL;
+const char *sun_map_tok_end = NULL;
/* copies the current position + maxsize into buff */
int sun_map_yyinput(char *buff, int maxsize);
-# undef YY_INPUT
+# undef YY_INPUT
# define YY_INPUT(buff,result,maxsize) (result = sun_map_yyinput(buff,maxsize))
-#else
+#else /* not FLEX_SCANNER */
# warning "Currently flex is the only supported version of lex."
-#endif /* FLEX_SCANNER */
+#endif /* not FLEX_SCANNER */
int sun_map_line = 1;
int sun_map_tokpos = 1;
NEWLINE_REX [ \t]*\n
CONTINUE_REX "\\"\n
-/*
+/*
* This option causes Solaris lex to fail. Use flex. See BUGS file
- * no need to use yyunput()
+ * no need to use yyunput()
*/
%option nounput
%%
-{WORD_REX} {
- sun_map_tokpos += yyleng;
- strncpy(sun_map_lval.strval,yytext,sizeof(sun_map_lval.strval));
- sun_map_lval.strval[sizeof(sun_map_lval.strval) - 1] = '\0';
+{WORD_REX} {
+ sun_map_tokpos += yyleng;
+ strncpy(yylval.strval,yytext,sizeof(yylval.strval));
+ yylval.strval[sizeof(yylval.strval) - 1] = '\0';
return WORD;
}
{WSPACE_REX} {
- sun_map_tokpos += yyleng;
+ sun_map_tokpos += yyleng;
return WSPACE;
- }
+ }
{NEWLINE_REX} {
- sun_map_tokpos = 0;
- sun_map_line++;
+ sun_map_tokpos = 0;
+ sun_map_line++;
return NEWLINE;
}
{CONTINUE_REX} {
- sun_map_tokpos = 0;
+ sun_map_tokpos = 0;
sun_map_line++;
}
%%
-int sun_map_error(const char* s) {
+
+int
+sun_map_error(const char* s)
+{
plog(XLOG_ERROR,"sun2amd : parsing error : line %d, column %d\n",
sun_map_line,sun_map_tokpos);
return 1;
}
-int sun_map_wrap() {
+
+int
+sun_map_wrap(void)
+{
return 1;
}
+
#ifdef FLEX_SCANNER
-void sun_map_tok_setbuff(const char* buff) {
-
+void
+sun_map_tok_setbuff(const char* buff)
+{
sun_map_tok_end = buff + strlen(buff);
sun_map_tok_pos = buff;
sun_map_tok_buff = buff;
}
-int sun_map_yyinput(char *buff, int maxsize) {
-
+
+int
+sun_map_yyinput(char *buff, int maxsize)
+{
int size = MIN(maxsize, (sun_map_tok_end - sun_map_tok_pos));
if (size > 0) {
memcpy(buff,sun_map_tok_pos,size);