version 1.71, 2015/03/19 09:53:35 |
version 1.72, 2018/11/13 08:45:29 |
|
|
#if defined(__linux__) || defined(__MINT__) |
#if defined(__linux__) || defined(__MINT__) |
# define _GNU_SOURCE /* memmem */ |
# define _GNU_SOURCE /* memmem */ |
#endif |
#endif |
|
|
|
#include <sys/stat.h> |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <getopt.h> |
#include <getopt.h> |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <time.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#include "extern.h" |
#include "extern.h" |
|
|
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
struct texi texi; |
struct texi texi; |
int c; |
char date[32]; |
|
struct stat st; |
char *dirpath, *dir, *ccp; |
char *dirpath, *dir, *ccp; |
const char *progname, *Idir, *cp; |
const char *progname, *Idir, *cp; |
|
time_t t; |
|
int c; |
|
|
progname = strrchr(argv[0], '/'); |
progname = strrchr(argv[0], '/'); |
if (progname == NULL) |
if (progname == NULL) |
Line 2357 main(int argc, char *argv[]) |
|
Line 2364 main(int argc, char *argv[]) |
|
texi.seenvs = -1; |
texi.seenvs = -1; |
Idir = NULL; |
Idir = NULL; |
|
|
while (-1 != (c = getopt(argc, argv, "C:I:"))) |
while (-1 != (c = getopt(argc, argv, "C:d:I:"))) |
switch (c) { |
switch (c) { |
case ('C'): |
case ('C'): |
texi.chapters = optarg; |
texi.chapters = optarg; |
break; |
break; |
|
case ('d'): |
|
texi.date = optarg; |
|
break; |
case ('I'): |
case ('I'): |
Idir = optarg; |
Idir = optarg; |
break; |
break; |
Line 2393 main(int argc, char *argv[]) |
|
Line 2403 main(int argc, char *argv[]) |
|
*ccp = '\0'; |
*ccp = '\0'; |
texi.dirs = parsedirs(&texi, dir, Idir, &texi.dirsz); |
texi.dirs = parsedirs(&texi, dir, Idir, &texi.dirsz); |
free(dirpath); |
free(dirpath); |
|
if (NULL == texi.date) { |
|
t = stat(argv[0], &st) == 0 ? st.st_mtime : time(NULL); |
|
strftime(date, sizeof(date), |
|
"%B %e, %Y", localtime(&t)); |
|
texi.date = date; |
|
} |
parsefile(&texi, argv[0], 1); |
parsefile(&texi, argv[0], 1); |
} else { |
} else { |
texi.title = strdup("Unknown Manual"); |
texi.title = strdup("Unknown Manual"); |
texi.dirs = parsedirs(&texi, NULL, Idir, &texi.dirsz); |
texi.dirs = parsedirs(&texi, NULL, Idir, &texi.dirsz); |
|
if (NULL == texi.date) { |
|
t = time(NULL); |
|
strftime(date, sizeof(date), |
|
"%B %e, %Y", localtime(&t)); |
|
texi.date = date; |
|
} |
parsestdin(&texi); |
parsestdin(&texi); |
} |
} |
|
|
texiexit(&texi); |
texiexit(&texi); |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
usage: |
usage: |
fprintf(stderr, "usage: %s [-Cdir] [-Idirs] [file]\n", progname); |
fprintf(stderr, "usage: %s [-C dir] [-d date] [-I dirs] [file]\n", |
|
progname); |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |