Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
wbuild.c File Reference
#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libit/stat.h>
#include <libit/unistd.h>
#include <libit/string.h>
#include <varargs.h>
#include <stdio.h>
#include <libit/getopt.h>
#include <wbuild.h>
#include <wsym.h>
#include <libit/ctype.h>
#include <libintl.h>
#include <libit/malloc.h>

Go to the source code of this file.

Defines

#define _(String)   gettext(String)

Functions

int yyparse ()
void get_filetime (char *filename, time_t *result)
int yywrap ()
char * build_filename (char *dir, char *name, char *ext)
char * build_guard (char *prefix, char *filename, char *ending)
void process_file (Class c, char *include_dir, char *c_dir, char *doc_dir, char *prefix, int lines, int force)
int main (int argc, char *argv[])
void err (va_alist)

Variables

char * optarg
int optind
static char ** arguments
static int nrarguments
char * filename
FILE * yyin
int lineno
int nerrors = 0
time_t filetime

Define Documentation

#define _ (   String)    gettext(String)

Definition at line 41 of file wbuild.c.


Function Documentation

char* build_filename ( char *  dir,
char *  name,
char *  ext 
)

Definition at line 97 of file wbuild.c.

{
       char *tmp;
       int dirlen, namelen, extlen;

       dirlen = strlen(dir);
       namelen = strlen(name);
       extlen = strlen(ext);

       tmp = malloc(dirlen + namelen + extlen + 2);
       strcpy(tmp, dir);
       tmp[dirlen] = '/';
       strcpy(tmp + dirlen + 1, name);
       strcpy(tmp + dirlen + namelen + 1, ext);
       return tmp;
}

Here is the caller graph for this function:

char* build_guard ( char *  prefix,
char *  filename,
char *  ending 
)

Definition at line 114 of file wbuild.c.

{
       char *tmp, *s;
       int prefixlen, filenamelen, endinglen;

       prefixlen = strlen(prefix);
       filenamelen = strlen(filename);
       endinglen = strlen(ending);

       tmp = malloc(prefixlen + filenamelen + endinglen + 3);
       tmp[0] = '_';
       strcpy(tmp + 1, prefix);
       tmp[prefixlen + 1] = '_';
       strcpy(tmp + prefixlen + 2, filename);
       strcpy(tmp + prefixlen + filenamelen + 2, ending);

       s = tmp;
       while (*s) {
              if (ISALPHA(*s)) {
                     *s = toupper(*s);
              } else if (!isdigit(*s)) {
                     *s = '_';
              }
              s++;
       }
       return tmp;
}

Here is the caller graph for this function:

void err ( va_alist  )

Definition at line 335 of file wbuild.c.

{
       va_list ap;
       int fatal;  
       char *format;
       va_start(ap);
       fatal = va_arg(ap, int);
       format = va_arg(ap, char*);
#else /* HAVE_STDARG_H */
#ifdef __STDC__
void err(int fatal, char *format,...)
{
       va_list ap;
       va_start(ap, format);
#else /* not __STDC__ */
void err(fatal, format) int fatal; char *format;
{
       va_list ap;
       va_start(ap, format);
#endif /* not __STDC__ */
#endif /* HAVE_STDARG_H */
       nerrors++;
       (void) fprintf(stderr, "%s:%d: ", filename, lineno);
       (void) vfprintf(stderr, format, ap);
       if (fatal) exit(1);
       va_end(ap);
}  

Here is the call graph for this function:

void get_filetime ( char *  filename,
time_t *  result 
)

Definition at line 61 of file wbuild.c.

{
       struct stat s;
       int status;

       *result = (time_t) 0;
       status = stat(filename, &s);
       if (status == 0)
              *result = s.st_mtime;
}

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 232 of file wbuild.c.

{
       char *include_dir = "../include/Xfwf";
       char *c_dir = "../lib";
       char *doc_dir = 0;
       char *prefix = "Xfwf";
       char *only = 0;
       int lines = 1;
       int help = 0, version = 0;
       int force = 0;
       int init_file = 1;
       int c;
       Class class;

       symbol_init();

       arguments = argv;
       nrarguments = argc;

       while ((c = getopt_long(argc, argv, "lhvp:O:i:c:d:", longopts,
                     /*& optind */ 0)) != -1)
              switch (c) {
                     case 'l': lines = 0; break;
                     case 'h': help = 1; break;
                     case 'v': version = 1; break;
                     case 'p': prefix = optarg; break;
                     case 'O': only = optarg; break;
                     case 'i': include_dir = optarg; break;
                     case 'c': c_dir = optarg; break;
                     case 'd': doc_dir = optarg; break;
                     case 257: init_file = 0; break;
                     case 258: force = 1; break;
                     case '?': help = 1; break;
              }
       if (help) {
              fprintf(stderr, _("wbuild usage:\n"
                     "wbuild [options] input-files\n"
                     "-v, --version\t\tPrint version and exit\n"
                     "-h, --help\t\tPrint this message and exit\n"
                     "-l, --no-lines\t\tDon't generate #line directives\n"
                     "-p, --include-prefix\tSpecify prefix for generated #include directives\n"
                     "-O, --only\t\tSet class to output code for\n"
                     "-i, --include-dir\tdirectory for generated include files\n"
                     "-c, --c-dir\t\tdirectory for generated c files\n"
                     "-d, --doc-dir, --documentation-dir\n"
                     "\t\t\tdirectory for generated documentation files\n"
                     "    --force\t\tForce regeneration of all files, ignoring timestamps\n"
                     "    --no-init-file\tDo not read initialization file\n"
                     "\n"
                     "Report bugs to free-widgets-bugs@let.rug.nl\n"
                     ));
              return 0;
       } else if (version) {
       fprintf (stderr, "wbuild - FWF %s %s\n", "???", "3.2");
       fprintf (stderr, _("\
Copyright (C) %s Joel N. Weber II\n\
This is free software; see the source for copying conditions.  There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"), "1996");
       fprintf (stderr, _("Written by %s\n"),
              "Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>");
              return 0;
       }
       if (init_file) {
              yyin = fopen(PKGDATADIR "/init.w", "r");
              if (!yyin) {
                     perror(PKGDATADIR "/init.w");
                     return 1;
              }
       } else {
              yyin = fopen("/dev/null", "r");
              if (!yyin) {
                     perror("/dev/null");
                     return 1;
              }
              yywrap();
       }
       lineno = 1;
       yyparse();
       if (nerrors)
              return 1;
       nerrors = set_hierarchy();
       if (nerrors)
              return 1;
       for (class = classes; class; class = class->next)
              if (!only || (!strcmp(only, get(class->name))))
                     process_file(class, include_dir, c_dir, doc_dir,
                            prefix, lines, force);
       if (nerrors)
              return 1;
       return 0;
}

Here is the call graph for this function:

void process_file ( Class  c,
char *  include_dir,
char *  c_dir,
char *  doc_dir,
char *  prefix,
int  lines,
int  force 
)

Definition at line 142 of file wbuild.c.

{
       char *name, *filename, *guard;
       time_t desttime;
       Doctype doctype;
       FILE *f;

       if (c->filenamepart)
              name = get(c->filenamepart);
       else
              name = get(c->name);

       if (!c->nocode) {
              filename = build_filename(include_dir, name, ".h");
              get_filetime(filename, &desttime);
              if (force || (desttime < c->filetime)) {
                     guard = build_guard(prefix, name, "_H");
                     f = fopen(filename, "w");
                     public_header(f, c, prefix, guard);
                     fclose(f);
                     free(guard);
              }
              free(filename);

              filename = build_filename(include_dir, name, "P.h");
              get_filetime(filename, &desttime);
              if (force || (desttime < c->filetime)) {
                     guard = build_guard(prefix, name, "P_H");
                     f = fopen(filename, "w");
                     generate_private_header(f, c, prefix, guard);
                     fclose(f);
                     free(guard);
              }
              free(filename);

              filename = build_filename(c_dir, name, ".c");
              get_filetime(filename, &desttime);
              if (force || (desttime < c->filetime)) {
                     f = fopen(filename, "w");
                     generatec(f, c, prefix, lines);
                     fclose(f);
              }
              free(filename);
       }

       if (c->nodoc)
              return;

       for (doctype = doctypes; doctype; doctype = doctype->next) {
              if (doc_dir)
                     filename = build_filename(doc_dir, name,
                            doctype->tag[t_filename][1]);
              else
                     filename = build_filename(
                            doctype->tag[t_filename][0],
                            name, doctype->tag[t_filename][1]);
              get_filetime(filename, &desttime);
              if (force || (desttime < c->filetime)) {
                     f = fopen(filename, "w");
                     generate_doc(f, &(doctype->tag), c, doctype->shortdoc);
                     fclose(f);
              }
              free(filename);
       }
}

Here is the call graph for this function:

int yyparse ( )

Here is the caller graph for this function:

int yywrap ( )

Definition at line 72 of file wbuild.c.

{
       fclose(yyin);
       lineno = 1;
       if (optind < nrarguments) {
              if (arguments[optind][0] == '-' && arguments[optind][1] == '\0') {
                     filename = "<stdin>";
                     filetime = 0;
                     yyin = stdin;
                     optind++;
                     return 0;
              } else if (! (yyin = fopen(arguments[optind], "r"))) {
                     perror(arguments[optind]);
                     return 1;
              } else {
                     filename = arguments[optind];
                     get_filetime(filename, &filetime);
                     optind++;
                     return 0;
              }
       } else {
              return 1;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char** arguments [static]

Definition at line 53 of file wbuild.c.

char* filename

Definition at line 133 of file cdjpeg.h.

time_t filetime

Definition at line 580 of file scan.c.

int nerrors = 0

Definition at line 58 of file wbuild.c.

int nrarguments [static]

Definition at line 54 of file wbuild.c.

char* optarg

Definition at line 111 of file getopt.c.

Definition at line 126 of file getopt.c.

FILE* yyin