- put mkso into the normal build directories instead of it being a

special case
- modified mkso to put files in an alternate (presumably HFS) directory,
  if necessary
This commit is contained in:
gdr 1997-12-21 22:39:13 +00:00
parent 1e28540ab0
commit 4cdec01660
5 changed files with 291 additions and 7 deletions

15
sbin/mkso/Makefile Normal file
View File

@ -0,0 +1,15 @@
#
# $Id: Makefile,v 1.1 1997/12/21 22:39:13 gdr Exp $
#
# Devin Reade, 1997
#
# Program name
PROG = mkso
# Add -D__STACK_CHECK__ to print, on exit, the amount of stack used
CFLAGS += # -D__STACK_CHECK__
STACK = 1024
BINDIR = /sbin
.INCLUDE: /src/gno/prog.mk

116
sbin/mkso/mkso.8 Normal file
View File

@ -0,0 +1,116 @@
.\" Devin Reade, 1997
.\"
.\" $Id: mkso.8,v 1.1 1997/12/21 22:39:13 gdr Exp $
.\"
.TH MKSO 8 "21 December 1997" GNO "System Administration"
.SH NAME
.BR mkso
\- maintain manual page source links
.SH SYNOPSIS
.BR mkso
[
.BR -dhv
] [
.BI -H dir
]
.I datafile
.SH DESCRIPTION
Manual pages will often document more than one program, subroutine,
or topic. When this occurs, it is normal to create "links" for each
documented program or subroutine to the original manual page. For
example, the
.BR getcwd (3)
manual page also documents
.BR getwd (3).
Assuming both of these functions are described in the file
.BR man3/getcwd.3 ,
then the file
.BR man3/getwd.3
would consist of the single line
.nf
\.so man3/getcwd.3
.fi
This would result in the same manual page being shown for both functions,
without duplicating the manual page.
.LP
While these source link files may be maintained by hand, doing so is tedious
for large distributions, such as the GNO base distribution.
.LP
.BR mkso
was written for the GNO base distribution to automate the creation and
deletion of these source links. By default,
.BR mkso
will create the links relative to the current directory as specified in
.IR datafile .
.IR datafile
must have the following format:
.nf
# Any blank line or line that has a "#" in the first
# column is a comment and is ignored.
#
# Pathnames must be delimited by "/", not ":".
#
# There are two columns here, delimited by spaces or tabs.
# The first is the "real" manual page (no check is done
# to verify that it does in fact exist). The second column
# is the source link that will be created.
#
man2/alarm.2 man2/alarm10.2
man5/utmp.5 man5/wtmp.5
#
# This next one cannot be created on a ProDOS volume; see
# description of the -H flag.
#
man2/getpgrp.2 man2/_getpgrp.2
.fi
.LP
.BR mkso
does not create missing directories; the current directory should already
contain the subdirectories
.BR man1 ,
.BR man2 ,
.BR man3 ,
.BR man4 ,
.BR man5 ,
.BR man6 ,
.BR man7 ,
and
.BR man8 .
.SH OPTIONS
.IP "\fB-d\fR"
Delete source links rather than creating them. Source links will only
be deleted if they contain a "magic number" which is inserted during
link creation.
.IP "\fB-h\fR"
Print usage information and exit.
.IP "\fB-H\fR \fIdir\fR"
If the source link does not follow ProDOS filename conventions, then the
link will be created in the directory given by
.IR dir
rather than the current directory.
.IR dir
is presumably a directory on an HFS volume. The link itself will reference
the full- rather than partial-pathname of the original file, so that
.BR man (1)
will be able to locate the original page.
.sp 1
As with the default behavior,
.BR mkso
does not create subdirectories, so ensure that
.IR dir
already contains the same list of subdirectories as the current directory.
.IP "\fB-v\fR"
Verbose operation.
.SH VERSION
This manual page documents
.BR mkso
version 1.0.
.SH AUTHOR
Devin Reade, 1997.
.SH "SEE ALSO"
.BR man (1),
.BR nroff (1)

View File

@ -1,5 +1,8 @@
/*
* $Id: mkso.c,v 1.1 1997/01/21 15:34:02 gdr Exp $
* mkso is used for maintaining manual page ".so links" for the GNO
* base distribution. See the manual page for details.
*
* $Id: mkso.c,v 1.2 1997/12/21 22:39:13 gdr Exp $
*
* Devin Reade, 1997.
*/
@ -9,10 +12,17 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <ctype.h>
#ifdef __GNO__
#include <gno/gno.h>
#endif
#define BUFFERSIZE 1024
#define DELIM " \t"
static int isProdosFileName(const char *name);
char *progname = NULL;
int deleteFiles = 0;
int verbose = 0;
@ -21,29 +31,93 @@ void
usage (void) {
printf("This program is part of the GNO installation package.\n");
printf("It creates .so (nroff source files) for the man package\n\n");
printf("Usage: %s [-dhv] datafile\n", progname);
printf("Usage: %s [-dhv] [-H dir] datafile\n", progname);
printf("\t-H dir\tspecify alternate directory for non-ProDOS links\n");
printf("\t-h\tprint usage information\n");
printf("\t-d\tdelete instead of create files (safe)\n");
printf("\t-v\tverbose operation\n");
exit(1);
}
#ifdef __STACK_CHECK__
static void printstack(void) {
fprintf(stderr, "Stack Usage: %d bytes\n", _endStackCheck());
}
#endif
int main(int argc, char **argv) {
static char dataBuffer[BUFFERSIZE];
static char magicBuffer[BUFFERSIZE];
static char hfsdir[PATH_MAX];
static char cwd[PATH_MAX];
static char *magic = ".\\\" This file is auto-generated by mkso.\n";
FILE *fp, *outfp;
char *p, *file, *new, *org;
char *p, *file, *new, *org, *hfsptr;
int line = 0;
int H_flag = 0;
int c;
char *magic = ".\\\" This file is auto-generated by mkso.\n";
int useHFSdir, hfsdirlen, sawColon, sawSlash;
#ifdef __STACK_CHECK__
_beginStackCheck();
atexit(printstack);
#endif
#ifdef __GNO__
_setPathMapping(1);
#endif
progname = argv[0];
while ((c = getopt(argc, argv, "dhv")) != EOF) {
hfsdir[0] = '\0';
hfsptr = hfsdir;
while ((c = getopt(argc, argv, "dhvH:")) != EOF) {
switch (c) {
case 'd':
deleteFiles = 1;
break;
case 'H':
if (H_flag) {
fprintf(stderr, "-H flag can only be specified once. Second and "
"subsequent invocations ignored\n");
break;
}
H_flag++;
hfsdirlen = strlen(optarg);
if (hfsdirlen > PATH_MAX-2) {
fprintf(stderr, "pathname for -H flag too long\n");
exit(1);
}
p = optarg;
sawColon = sawSlash = 0;
while (*p) {
switch (*p) {
case ':':
sawColon=1;
if (sawSlash) {
goto die; /* piss off; I know it's bad form */
}
*hfsptr++ = '/'; /* map to '/' */
break;
case '/':
sawSlash=1;
if (sawColon) {
die:
fprintf(stderr, "you cannot use pathnames that contain both '/' "
"and ':' in this program\n");
exit(1);
}
/*FALLTHROUGH*/
default:
*hfsptr++ = *p++;
}
}
*hfsptr++ = '/';
hfsdirlen++;
if (getcwd(cwd, PATH_MAX) == NULL) {
perror("couldn't determine current directory");
exit(1);
}
break;
case 'v':
verbose = 1;
break;
@ -79,6 +153,20 @@ int main(int argc, char **argv) {
fprintf(stderr, "missing new file name at line %d of %s", line, file);
continue;
}
if (!H_flag || isProdosFileName(new)) {
useHFSdir = 0;
} else {
int len;
len = strlen(new);
if (len + hfsdirlen + 1 > PATH_MAX-1) {
fprintf(stderr, "pathname for %s too long\n", new);
exit(1);
}
strcpy(hfsptr, new);
new = hfsdir;
useHFSdir = 1;
}
if (deleteFiles) {
if ((outfp = fopen(new, "r")) == NULL) {
@ -117,7 +205,11 @@ int main(int argc, char **argv) {
new, line, strerror(errno));
continue;
}
fprintf(outfp, ".so %s\n", org);
if (useHFSdir) {
fprintf(outfp, ".so %s/%s\n", cwd, org);
} else {
fprintf(outfp, ".so %s\n", org);
}
fprintf(outfp, magic);
fclose(outfp);
}
@ -131,3 +223,38 @@ int main(int argc, char **argv) {
fclose(fp);
return 0;
}
/*
* returns 1 if <name> follows ProDOS conventions, zero otherwise.
*/
static int
isProdosFileName (const char *name)
{
const char *p;
int len, c;
p = basename(name);
/* special case the first character */
c = tolower(*p);
if (! ((c >= 'a') && (c <= 'z'))) {
return 0;
}
p++;
len = 1;
while(*p) {
len++;
if (len > 15) {
return 0;
}
c = *p;
if (isalnum(c) || c == '.') {
p++;
} else {
return 0;
}
}
return 1;
}

9
sbin/mkso/mkso.desc Normal file
View File

@ -0,0 +1,9 @@
Name: mkso
Version: 1.0 (21 Dec 97)
Shell: GNO
Author: Devin Reade
Contact: gdr@eddore.myrias.com
Where: /sbin
FTP: trenco.myrias.com
Maintains manual page source (.so) links.

17
sbin/mkso/mkso.rez Normal file
View File

@ -0,0 +1,17 @@
/*
* $Id: mkso.rez,v 1.1 1997/12/21 22:39:13 gdr Exp $
*/
#include "Types.Rez"
resource rVersion (0x1, purgeable3, nocrossbank) {
{ 1, 0, 0, /* version 1.0.0 */
release, /* development|alpha|beta|final|release */
0 /* non-final release number */
},
verUS,
"mkso",
"Maintain manual page source links.\n"
"Written by Devin Reade for GNO v2.0.6"
};