Esempio n. 1
0
static int
processdir(char *pathname)
{
    DIR *dir;
    struct dirent *d;
    char procdir[LN_PATH_MAX];

    if (chdir(pathname) < 0) {
	ln_log(LNLOG_SERR, LNLOG_CTOP, "cannot chdir to %s: %m\n", pathname);
	return -1;
    }
    if (!getcwd(procdir, LN_PATH_MAX)) {
	ln_log(LNLOG_SERR, LNLOG_CTOP, "cannot getcwd %s: %m\n", procdir);
	return -1;
    }
    if (!(dir = opendir("."))) {
	ln_log(LNLOG_SERR, LNLOG_CTOP, "cannot open %s: %m\n", pathname);
	return -1;
    }
    while ((d = readdir(dir))) {
	/* don't process dotfiles */
	if (d->d_name[0] != '.') {
	    (void)processfile(d->d_name);
	    /* storearticle uses chdir! */
	    if (chdir(procdir) < 0) {
		/* Yes, I'm paranoid */
		ln_log(LNLOG_SERR, LNLOG_CTOP, "cannot chdir to %s: %m\n",
		       procdir);
		return -1;
	    }
	}
    }
    closedir(dir);
    return 0;
}
Esempio n. 2
0
 //==============================================================
 // process each input file
 void doifile(void)
 {
    char *pcat;
 
    // does the input file name have an extension?
    if ((pcat=strrchr(ifilename,'.'))== NULL || (pcat &&  
         strchr(pcat,fdiv)))
       strcat(ifilename,".mob"); // add ".mob" to input file name
 #ifdef SPARC
    in_stream = fopen(ifilename, "r");
 #endif
 #ifdef LINUX
    in_stream = fopen(ifilename, "r");
 #endif
 #ifdef DOS
    in_stream = fopen(ifilename, "rb");
 #endif
 
    if (!in_stream) {
       printf("ERROR: Cannot open input file %s\n", ifilename);
       exit(1);
    }
 
    if (!ofopen) {
       ofopen = 1;
       strcpy (ofilename, ifilename);
       // form output file name from first input file name
       strcpy (strrchr(ofilename,'.'),".mac"); 
 
 #ifdef SPARC
       out_stream = fopen(ofilename,"w");
 #endif
 #ifdef LINUX
       out_stream = fopen(ofilename,"w");
 #endif
 #ifdef DOS
       out_stream = fopen(ofilename, "wb");
 #endif
 
        if (!out_stream) {
           printf("ERROR: Cannot open output file %s\n",
                   ofilename);
           exit(1);
        }
    }
 
    filesize = fread(file_buffer, 1, FILE_BUF_SIZE, in_stream);
    fclose(in_stream);
    if (filesize == FILE_BUF_SIZE) {
       printf("Input file %s too big\n", ifilename);
       exit(1);
    }
    processfile();
 }
Esempio n. 3
0
int main()
{
    FILE *fp;
    char inputfile[50];
    int len;
    fp=fopen("imagelist.txt", "rt");
    mkdir("output2");
    system("cp output1/* .");
    while (fgets(inputfile, 50, fp))
    {
        len=strlen(inputfile);
        inputfile[len-1]='\0';
        strcat(inputfile, ".txt");
        processfile(inputfile);
        remove(inputfile);
    }
    fclose(fp);
}
Esempio n. 4
0
int main(int argc, char **argv){
	int pipeflag = 0;
	char filename[200];
	if(argc<3) {
					pipeflag = 1;
	}
	if(argc<2) {
					printf("mygrep takes atleast 2 arguments\n"); 
					return 1;
	}
	int argvpos = handleoptions(argc, argv);
	//printf("optind : %d %s\n", argvpos, argv[optind]);
	if(argvpos) {
		//if(invflag) printf("Invert flag set\n");
		//if(maxcount>0) printf("Max flag set\n");
	}
	if(!pipeflag) strcpy(filename, argv[optind+1]);
	else strcpy(filename, "stdin");
	processfile((const char*)argv[optind], filename, pipeflag);
	if(argvpos == 0) perror("mygrep");
	return 0;
}
Esempio n. 5
0
LIST *svnrevinfo( FRAME *frame, int flags )
{
    LIST* filepaths = lol_get( frame->args, 0 );
    LIST* revision_info;
    LISTITER iter = list_begin( filepaths ), end = list_end( filepaths );

    int warnonmissing = lol_get( frame->args, 1 ) ? 1 : 0;
    int printrevisioninfo = lol_get( frame->args, 2 ) ? 1 : 0;

    int max_build, accum_build;
    int max_year, max_month, max_day;
    int modifiedfiles, filemodified;

    max_build = 0;
    accum_build = 0; /* for RCS / CVS */
    max_year = max_month = max_day = 0;
    modifiedfiles = 0;
    for (; iter != end; iter = list_next( iter ) )
    {
        /* phase 1: scan through all files and get the highest build number */

        filemodified = 0;
        processfile(object_str(list_item( iter )),
                    0, warnonmissing, printrevisioninfo, 
                    &max_build, &accum_build, &max_year, &max_month, &max_day,
                    &filemodified);
        modifiedfiles += filemodified;
    } /* for */

    revision_info = list_push_back(L0, outf_int(max_build));
    revision_info = list_push_back(revision_info, outf_int(max_year));
    revision_info = list_push_back(revision_info, outf_int(max_month));
    revision_info = list_push_back(revision_info, outf_int(max_day));
    revision_info = list_push_back(revision_info, outf_int(modifiedfiles));

    return revision_info;
}
Esempio n. 6
0
LIST *svnrevinfo( FRAME *frame, int flags )
{
    LIST* filepaths = lol_get( frame->args, 0 );
    LIST* revision_info;

    int warnonmissing = lol_get( frame->args, 1 ) ? 1 : 0;
    int printrevisioninfo = lol_get( frame->args, 2 ) ? 1 : 0;

    int max_build, accum_build;
    int max_year, max_month, max_day;
    int modifiedfiles, filemodified;

    max_build = 0;
    accum_build = 0; /* for RCS / CVS */
    max_year = max_month = max_day = 0;
    modifiedfiles = 0;
    for (; filepaths; filepaths = filepaths->next)
    {
        /* phase 1: scan through all files and get the highest build number */

        filemodified = 0;
        processfile(object_str(filepaths->value),
                    0, warnonmissing, printrevisioninfo, 
                    &max_build, &accum_build, &max_year, &max_month, &max_day,
                    &filemodified);
        modifiedfiles += filemodified;
    } /* for */

    revision_info = list_new(0, outf_int(max_build));
    revision_info = list_new(revision_info, outf_int(max_year));
    revision_info = list_new(revision_info, outf_int(max_month));
    revision_info = list_new(revision_info, outf_int(max_day));
    revision_info = list_new(revision_info, outf_int(modifiedfiles));

    return revision_info;
}
Esempio n. 7
0
int
main(int argc, char *argv[])
{
    char *ptr;
    char option;
    struct stat st;
    char *conffile = NULL;
    const char *const myname = "rnews";

    ln_log_open(myname);
    if (!initvars(argv[0], 0))
	init_failed(myname);

    while ((option = getopt(argc, argv, GLOBALOPTS "")) != -1) {
	if (parseopt(myname, option, optarg, &conffile))
	    continue;
	switch(option) {
	    default:
		usage();
		exit(EXIT_FAILURE);
	}
    }

    if (readconfig(conffile) != 0) {
	ln_log(LNLOG_SERR, LNLOG_CTOP, "Reading configuration failed: %m.\n");
	exit(2);
    }
    if (conffile)
	free(conffile);

    if (filterfile && !readfilter(filterfile)) {
	ln_log(LNLOG_SERR, LNLOG_CTOP,
		"%s: Cannot read filterfile %s, aborting.",
		argv[0], filterfile);
	log_unlink(lockfile, 0);
	exit(EXIT_FAILURE);
    }

    if (!init_post())
	init_failed(myname);

    umask((mode_t) 077);

    if (attempt_lock(LOCKWAIT)) {
	exit(EXIT_FAILURE);
    }

    rereadactive();
    readlocalgroups();
    if (!argv[optind])
	fprocessfile(stdin);	/* process stdin */
    while ((ptr = argv[optind++])) {
	if (stat(ptr, &st) == 0) {
	    if (S_ISDIR(st.st_mode))
		processdir(ptr);
	    else if (S_ISREG(st.st_mode))
		processfile(ptr);
	    else
		ln_log(LNLOG_SERR, LNLOG_CTOP,
		       "%s: cannot open %s\n", argv[0], ptr);
	} else
	    ln_log(LNLOG_SERR, LNLOG_CTOP,
		   "%s: cannot stat %s\n", argv[0], ptr);
    }
    writeactive();		/* write groupinfo file */
    freeallfilter(filter);
    log_unlink(lockfile, 0);
    exit(0);
}
Esempio n. 8
0
int main(int argc, char *argv[])
{
  char *outname = NULL;
  FILE *fp;
  int index;
  int process_self = 0;
  int verbose = 0;
  int ignore_eol = 0;
  int max_build, accum_build;
  int max_year, max_month, max_day;
  int ismodified, filemodified, modificationcount;
  char prefix[MAX_SYMBOLLENGTH], suffix[MAX_SYMBOLLENGTH];
  char *const_basename = NULL;
  char modified_suffix[2];
  int output_language = LANG_C_CPP;   /* flag for C/C++, Java or C# output */
  char *namespace_name = NULL;        /* java package or C# namespace to put revision info in */
  char *propname = NULL;
  char *startComment = NULL;
  char *endComment = NULL;
  char *continueComment = NULL;

  if (argc <= 1)
    about();

  /* collect the options */
  prefix[0] = '\0';
  suffix[0] = '\0';

  for (index = 1; index < argc; index++) {
    /* check for options */
    if (argv[index][0] == '-'
#if defined __WIN32__ || defined _Win32 || defined _WIN32
     || argv[index][0] == '/'
#endif
    )
    {
      switch (argv[index][1]) {
      case 'f': {
        size_t len;
        char *ptr = strchr(&argv[index][2], '#');
        len = (ptr != NULL) ? (int)(ptr - &argv[index][2]) : (int)strlen(&argv[index][2]);
        if (len >= MAX_SYMBOLLENGTH)
          len = MAX_SYMBOLLENGTH - 1;
        strncpy(prefix, &argv[index][2], len);
        prefix[len] = '\0';
        ptr = (ptr != NULL) ? ptr + 1 : strchr(argv[index], '\0');
        len = strlen(ptr);
        if (len >= MAX_SYMBOLLENGTH)
          len = MAX_SYMBOLLENGTH - 1;
        strncpy(suffix, ptr, len);
        suffix[len] = '\0';
        break;
      } /* case */
      case 'i':
        process_self = 1;
        break;
      case 'j':
        output_language = LANG_JAVA;
        namespace_name = &argv[index][2];
        break;
      case 'c':
        output_language = LANG_CS;
        namespace_name = &argv[index][2];
        break;
      case 'P':
        output_language = LANG_PROP;
        break;
      case 'O':
        output_language = LANG_ORACLE;
        namespace_name = &argv[index][2];
        break;
      case 'p':
        propname = &argv[index][2];
        break;
      case 'm':
        const_basename = &argv[index][2];
        break;
      case 'o':
        outname = &argv[index][2];
        break;
      case 'v':
        verbose = 1;
        break;
      case 'n':
        ignore_eol = 1;
        break;
      default:
        fprintf(stderr, "Invalid option '%s'\n", argv[index]);
        about();
      } /* switch */
    } /* if */
  } /* for */

  if (outname == NULL) {
    switch (output_language) {
    case LANG_C_CPP:
      outname = "svnrev.h";
      break;
    case LANG_JAVA:
      outname = "SvnRevision.java";
      break;
    case LANG_CS:
      outname = "SvnRevision.cs";
      break;
    case LANG_PROP:
      outname = "svnrev.property";
      break;
    case LANG_ORACLE:
      outname = "svnrev.sql";
      break;
    } /* switch */
  } /* if */

  /* scan through the existing svnrev file to find the "build" count */
  if (const_basename == NULL || *const_basename == '\0')
    const_basename = "SVN_REV";
  assert(outname != NULL);
  modificationcount = scanmodifications(outname, const_basename);
  if (!process_self && *outname != '\0')
    remove(outname);

  /* phase 1: scan through all files and get the highest build number */
  max_build = 0;
  accum_build = 0;      /* for RCS / CVS */
  max_year = max_month = max_day = 0;
  ismodified = 0;
  for (index = 1; index < argc; index++) {
    /* skip the options (already handled) */
    if (argv[index][0] == '-'
#if defined __WIN32__ || defined _Win32 || defined _WIN32
     || argv[index][0] == '/'
#endif
    )
      continue;

    filemodified = 0;
    if (strcasecmp(argv[index], outname)!=0)
      processfile(argv[index], 0, ignore_eol, &max_build, &accum_build, &max_year, &max_month, &max_day, &filemodified);
    if (filemodified && verbose)
      fprintf(stderr, "\tNotice: modified file '%s'\n", argv[index]);
    ismodified = ismodified || filemodified;
  } /* for */

  /* also run over the existing header file, if any */
  if (process_self && *outname != '\0')
    processfile(outname, 1, ignore_eol, &max_build, &accum_build, &max_year, &max_month, &max_day, NULL/*&ismodified*/);

  if (accum_build > max_build)
    max_build = accum_build;
  modified_suffix[0] = (char)(ismodified ? 'M' : '\0');
  modified_suffix[1] = '\0';

  /* phase 2: write a file with this highest build number */
  if (*outname == '\0') {
    fp = stdout;
  } else if ((fp = fopen(outname, "w")) == NULL) {
    fprintf(stderr, "Failed to create output file '%s'\n", outname);
    return 2;
  } /* if */
  if (*outname != '\0') {
    switch (output_language) {
    case LANG_C_CPP:
    case LANG_JAVA:
    case LANG_CS:
      startComment = "/* ";
      endComment = " */";
      continueComment = " * ";
      break;
    case LANG_ORACLE:
      startComment = "-- ";
      endComment = "-- ";
      continueComment = "-- ";
      break;
    case LANG_PROP:
      startComment = "# ";
      endComment = "# ";
      continueComment = "# ";
      break;
    } /* switch */
    /* don't print the comments to stdout */
    fprintf(fp, "%sThis file was generated by the \"svnrev\" utility\n"
                "%s(http://www.compuphase.com/svnrev.htm).\n"
                "%sYou should not modify it manually, as it may be re-generated.\n"
                "%s\n"
                "%s$Revision: %d%s$\n"
                "%s$Date: %04d-%02d-%02d$\n"
                "%s\n\n", startComment, continueComment, continueComment, continueComment,
                  continueComment,  max_build,
              modified_suffix, continueComment, max_year, max_month, max_day,endComment);
  } /* if */

  switch (output_language) {
  case LANG_C_CPP:
    fprintf(fp, "#ifndef %s_H\n", const_basename);
    fprintf(fp, "#define %s_H\n\n", const_basename);
    fprintf(fp, "#define %s\t\t%d\n", const_basename, max_build);
    fprintf(fp, "#define %sSTR\t\"%s%d%s%s\"\n", const_basename, prefix, max_build, modified_suffix, suffix);
    fprintf(fp, "#define %sDATE\t\"%04d-%02d-%02d\"\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "#define %sSTAMP\t%04d%02d%02dL\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "#define %sMODIFIED\t%d\n", const_basename, ismodified ? modificationcount + 1 : 0);
    fprintf(fp, "\n#endif /* %s_H */\n", const_basename);
    break;
  case LANG_JAVA:
    if (namespace_name == NULL || *namespace_name == '\0')
      namespace_name = "com.compuphase";
    fprintf(fp, "package %s;\n\n", namespace_name);
    fprintf(fp, "public interface SvnRevision\n");
    fprintf(fp, "{\n");
    fprintf(fp, "    public final static int %s = %d;\n", const_basename, max_build);
    fprintf(fp, "    public final static String %sSTR = \"%s%d%s%s\";\n", const_basename, prefix, max_build, modified_suffix, suffix);
    fprintf(fp, "    public final static String %sDATE = \"%04d-%02d-%02d\";\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "    public final static long %sSTAMP = %04d%02d%02dL;\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "    public final static int %sMODIFIED = %d;\n", const_basename, ismodified ? modificationcount + 1 : 0);
    fprintf(fp, "}\n\n");
    break;
  case LANG_CS: {
    char *cls;
    if (namespace_name == NULL || (cls = strrchr(namespace_name, '.')) == NULL) {
      namespace_name = "compuphase";
      cls = "svnrev";
    } else {
      *cls++ = '\0';
    } /* if */
    fprintf(fp, "using System;\n\n");
    fprintf(fp, "namespace %s\n{\n", namespace_name);
    fprintf(fp, "\tpublic static partial class %s\n", cls);
    fprintf(fp, "\t{\n");
    fprintf(fp, "\t\tpublic const Int32  %s = %d;\n", const_basename, max_build);
    fprintf(fp, "\t\tpublic const String %sSTR = \"%s%d%s%s\";\n", const_basename, prefix, max_build, modified_suffix, suffix);
    fprintf(fp, "\t\tpublic const String %sDATE = \"%04d-%02d-%02d\";\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "\t\tpublic const Int64  %sSTAMP = %04d%02d%02d;\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "\t\tpublic const Int32  %sMODIFIED = %d;\n", const_basename, ismodified ? modificationcount + 1 : 0);
    fprintf(fp, "\t}\n}\n");
    update_prop_file(propname, max_build);
    break;
  } /* case */
  case LANG_PROP:
    fprintf(fp, "%s = %d\n", const_basename, max_build);
    fprintf(fp, "%sSTR = %s%d%s%s\n", const_basename, prefix, max_build, modified_suffix, suffix);
    fprintf(fp, "%sDATE = %04d-%02d-%02d\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "%sSTAMP = %04d%02d%02dL\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "%sMODIFIED = %d\n", const_basename, ismodified ? modificationcount + 1 : 0);
    break;
  case LANG_ORACLE:
    if (namespace_name == NULL || *namespace_name == '\0')
      namespace_name = "compuphase";
    fprintf( fp, "create or replace package %s\n", namespace_name);
    fprintf( fp, "as\n" );
    fprintf(fp, "\t%s CONSTANT INT := %d;\n", const_basename, max_build);
    fprintf(fp, "\t%sSTR CONSTANT VARCHAR2(200) := \"%s%d%s%s\";\n", const_basename, prefix, max_build, modified_suffix, suffix);
    fprintf(fp, "\t%sDATE CONSTANT DATE := TO_DATE('%04d-%02d-%02d','YYYY-MM-DD');\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "\t%sSTAMP CONSTANT INT := %04d%02d%02d;\n", const_basename, max_year, max_month, max_day);
    fprintf(fp, "\t%sMODIFIED CONSTANT INT := %d;\n", const_basename, ismodified ? modificationcount + 1 : 0);
    fprintf(fp, "END %s;\n/\n\nshow errors\n\n", namespace_name);
    break;
  } /* switch */

  if (*outname != '\0')
    fclose(fp);

  return 0;
}
Esempio n. 9
0
int main(int argc, char *argv[]) {
    FILE *srcfile, *destfile;
    char *end, *sfile;
    int i, passflags, codelen, nfiles;

    printf("6502 Cross Assembler, version 0.7\n");
    inittree();
    codebuf=(unsigned char *)malloc(512);
    i=1;
    codeorig=0;
    machine=0;
    passflags=0;
    sfile=NULL;
    while(*argv[i]=='-' && i<argc) {
        switch(argv[i][1]) {
        case 'o':
            codeorig=strtol(argv[i+1], &end, 16);
            i++;
            break;
        case 'l':
            passflags|=1;
            break;
        case 't':
            passflags|=4;
            break;
        case 's':
            sfile=argv[i]+2;
            break;
        case 'm':
            switch(argv[i][2]) {
            case 'c':
                machine=8;
                break;
            case 'r':
                machine=16;
                break;
            default:
                machine=0;
            }
            break;
        }
        i++;
    }
    codelen=0;
    nfiles=0;
    if(sfile != NULL)
        listfile=fopen(sfile, "w");
    else
        listfile=stdout;
    while(i<argc) {
        printf("Assembling file %s:\n", argv[i]);
        srcfile=fopen(argv[i++], "r");
        codelen=processfile(srcfile, codelen, passflags);
        fclose(srcfile);
        nfiles++;
    }
    destfile=fopen("asmout", "wb");
    fwrite(codebuf, sizeof(unsigned char), destadr, destfile);
    fclose(destfile);
    printf("Assembly complete, processed %d files, output size %d bytes\n", nfiles, codelen);
    deletetree(symboltab);
    return(0);
}
Esempio n. 10
0
int main(int argc, char *argv[])
{
  char *outname = NULL;
  FILE *fp;
  FILE *input_file;
  char *input_file_name = NULL;
  char *path_prefix = NULL;
  int index;
  int process_self = 0;
  int verbose = 0;
  int max_build, accum_build;
  int max_year, max_month, max_day;
  int ismodified, filemodified;
  char prefix[MAX_SYMBOLLENGTH], suffix[MAX_SYMBOLLENGTH];
  char modified_suffix[2];
  int write_java = 0;   /* flag for Java output, 0=.h output, 1=.java output */
  /* java package to put revision info in.
   * REVIEW - I assume if you want Java output you will specify a package. */
  char *java_package = NULL;

  if (argc <= 1)
    about();

  /* collect the options */
  prefix[0] = '\0';
  suffix[0] = '\0';
  
  for (index = 1; index < argc; index++) {
    /* check for options */
    if (argv[index][0] == '-'
#if defined __WIN32__ || defined _Win32 || defined _WIN32
     || argv[index][0] == '/'
#endif
    )
    {
      switch (argv[index][1]) {
      case 'f': {
        int len;
        char *ptr = strchr(&argv[index][2], '#');
        len = (ptr != NULL) ? (int)(ptr - &argv[index][2]) : (int)strlen(&argv[index][2]);
        if (len >= MAX_SYMBOLLENGTH)
          len = MAX_SYMBOLLENGTH - 1;
        strncpy(prefix, &argv[index][2], len);
        prefix[len] = '\0';
        ptr = (ptr != NULL) ? ptr + 1 : strchr(argv[index], '\0');
        len = (int)strlen(ptr);
        if (len >= MAX_SYMBOLLENGTH)
          len = MAX_SYMBOLLENGTH - 1;
        strncpy(suffix, ptr, len);        
        suffix[len] = '\0';
        break;
      } /* case */
      case 'i':
        process_self = 1;
        break;
      case 'j':
        write_java=1;
        java_package = &argv[index][2];
        break;
      case 'o':
        outname = &argv[index][2];
        break;
      case 'r':
        input_file_name = &argv[index][2];
        break;
      case 'p':
        path_prefix = &argv[index][2];
        break;
      case 'v':
        verbose = 1;
        break;
      default:
        fprintf(stderr, "Invalid option '%s'\n", argv[index]);
        about();
      } /* switch */
    } /* if */
  } /* for */

  if (outname == NULL)
    outname = write_java ? "SvnRevision.java" : "uni_revision.h";
  if (!process_self && *outname != '\0')
    remove(outname);

  /* phase 1: scan through all files and get the highest build number */

  max_build = 0;
  accum_build = 0;      /* for RCS / CVS */
  max_year = max_month = max_day = 0;
  ismodified = 0;

  if(input_file_name) {
    input_file = fopen(input_file_name, "r");
    if (input_file != NULL) {
      apr_dir_t *dir;
      apr_finfo_t finfo;
      apr_status_t rv;
      apr_pool_t *pool;
      char *file_path;
      char dir_path[256]; /* line */
      int offset = 0;
      if(path_prefix)
        offset = sprintf(dir_path, "%s", path_prefix);
      else
        offset = sprintf(dir_path, "../../");
      
      apr_initialize();
      apr_pool_create(&pool,NULL);
      while (fgets(dir_path + offset, sizeof(dir_path) - offset, input_file) != NULL ) { /* read a line */ 
        size_t len = strlen(dir_path)-1;
        if(dir_path[len] == '\n') 
          dir_path[len] = 0;
        rv = apr_dir_open(&dir,dir_path,pool);
        if(rv == APR_SUCCESS) {
          while (apr_dir_read(&finfo, APR_FINFO_NAME, dir) == APR_SUCCESS) { /* get next file */
            if(finfo.filetype != APR_REG) continue;

            apr_filepath_merge(&file_path,dir_path,finfo.name,0,pool);

            filemodified = 0;
            if (strcasecmp(file_path, outname)!=0)
              processfile(file_path, 0, &max_build, &accum_build, &max_year, &max_month, &max_day, &filemodified);
            if (filemodified && verbose)
              fprintf(stderr, "\tNotice: modified file '%s'\n", file_path);
            ismodified = ismodified || filemodified;
          }
          apr_dir_close(dir);
        }
        else {
          fprintf(stderr, "No such directory '%s'\n", dir_path);
        }
      }
      fclose (input_file);
      apr_pool_destroy(pool);
      apr_terminate();
    }
    else {
      fprintf(stderr, "No such input file '%s'\n", input_file_name);
    }
  }
  else {
    for (index = 1; index < argc; index++) {
      /* skip the options (already handled) */
      if (argv[index][0] == '-'
#if defined __WIN32__ || defined _Win32 || defined _WIN32
       || argv[index][0] == '/'
#endif
      )
        continue;

      filemodified = 0;
      if (strcasecmp(argv[index], outname)!=0)
        processfile(argv[index], 0, &max_build, &accum_build, &max_year, &max_month, &max_day, &filemodified);
      if (filemodified && verbose)
        fprintf(stderr, "\tNotice: modified file '%s'\n", argv[index]);
      ismodified = ismodified || filemodified;
    } /* for */
  }

  /* also run over the existing header file, if any */
  if (process_self && *outname != '\0')
    processfile(outname, 1, &max_build, &accum_build, &max_year, &max_month, &max_day, NULL/*&ismodified*/);

  if (accum_build > max_build)
    max_build = accum_build;
  modified_suffix[0] = ismodified ? 'M' : '\0';
  modified_suffix[1] = '\0';

  /* phase 2: write a file with this highest build number */
  if (*outname == '\0') {
    fp = stdout;
  } else if ((fp = fopen(outname, "w")) == NULL) {
    fprintf(stderr, "Failed to create output file '%s'\n", outname);
    return 2;
  } /* if */
  if (*outname != '\0') {
    /* don't print the comments to stdout */
    fprintf(fp, "/* This file was generated by the \"svnrev\" utility\n"
                " * (http://www.compuphase.com/svnrev.htm).\n"
                " * You should not modify it manually, as it may be re-generated.\n"
                " *\n"
                " * $Revision: %d%s$\n"
                " * $Date: %04d-%02d-%02d$\n"
                " */\n\n", max_build, modified_suffix, max_year, max_month, max_day);
  } /* if */

  fprintf(fp, "#ifndef UNI_REVISION_H\n");
  fprintf(fp, "#define UNI_REVISION_H\n\n");
  fprintf(fp, "#define UNI_REVISION\t\t%d\n", max_build);
  fprintf(fp, "#define UNI_REVISION_STRING\t\"%s%d%s%s\"\n", prefix, max_build, modified_suffix, suffix);
  fprintf(fp, "#define UNI_REVISION_DATE\t\"%04d-%02d-%02d\"\n", max_year, max_month, max_day);
  fprintf(fp, "#define UNI_REVISION_STAMP\t%04d%02d%02dL\n", max_year, max_month, max_day);
  fprintf(fp, "#define UNI_REVISION_MODIFIED\t%d\n", ismodified);
  fprintf(fp, "\n#endif /* UNI_REVISION_H */\n");

  if (*outname != '\0')
    fclose(fp);

  return 0;
}