1 /*
2  *	mkreadmes.h
3  *
4  *	$Id: mkreadmes.h,v 1.53 2012/05/04 20:53:10 conrads Exp $
5  *
6  *****************************************************************************/
7 
8 #define	PROGRAM			"mkreadmes"
9 #define	VERSION			"1.3"		/* output by the "-V" option */
10 
11 /*	The basic rule of thumb used here for the naming of directories and files
12  *	is very simple:
13  *
14  *	Since all of the system calls that munge pathnames -- dirname(), getcwd(),
15  *	realpath() -- do *not* include a trailing slash on directory names, follow
16  *	their lead and do the same
17  *
18  *	So then, directories, which will have other names appended to them during
19  *	the program's running life, do *not* include a trailing slash
20  *
21  *	Whereas files, which are to be appended to directory pathnames, *do*
22  *	include *leading* slash
23  *
24  *	This makes creating the final, complete pathname a simple matter of just
25  *	slapping one name onto the end of another
26  *
27  *	This is one case where consistency definitely pays off.  Otherwise, things
28  *	*could* become a tad confusing and messy.
29  */
30 
31 /* default top-level ports directory */
32 #define	PORTSTOP		"/usr/ports"
33 
34 /* default install prefix */
35 #define	PREFIX			"/usr/local"	/* port Makefile will edit this line,
36 											if necessary, to the install
37 											${PREFIX}
38 										 */
39 /* trailing portion of the default templates directory, to be appended to
40  *	${PREFIX} at runtime -- use the program's custom templates by default
41  */
42 #define	TEMPLATESDIR	"/share/mkreadmes/Templates"
43 
44 /* index file name; OS release number will be determined and added at runtime */
45 #define	INDEXNAME		"/INDEX-"
46 
47 /* top-level or category Makefile name */
48 #define	MAKEFILENAME	"/Makefile"
49 
50 /* top-level or category Makefile.local name */
51 #define	MAKEFILELOCALNAME	"/Makefile.local"
52 
53 /* filename of the final output HTML files */
54 #define	READMENAME		"/README.html"
55 
56 /* template filename minus the extension ("top", "category" or "port") */
57 #define TEMPLATENAME	"/README."
58 
59 #define	FIELDSEPCHAR	'|'		/* field separator in an index line (char)*/
60 #define	FIELDSEPSTR		"|"		/* field separator in an index line (string) */
61 #define	CATSEPARATOR	" |"	/* separator characters within category field */
62 
63 #define	MAXINDEXLINE	32768	/* buffer size for a single index line */
64 #define	NUMINDEXFIELDS	13		/* number of fields in an index line */
65 
66 #define	MAXCATNAME		32		/* longest category basename */
67 #define MAXCATEGORIES	64		/* maximum number of categories in ports tree */
68 
69 /* size of the categories list */
70 #define MAXCATLIST		(MAXCATNAME * MAXCATEGORIES)
71 
72 #define MAXPORTNAME		32		/* longest port basename */
73 #define MAXPORTS		4096	/* maximum number of ports in a category */
74 
75 /* size of a category's ports list */
76 #define MAXPORTSLIST	(MAXPORTNAME * MAXPORTS)
77 
78 /* README.html output buffer sizes */
79 #define	MAXREADME_CAT	524288	/* size of category output buffer */
80 #define	MAXREADME_PORT	32768	/* size of port output buffer */
81 #define	MAXREADME_TOP	8192	/* size of top output buffer */
82 
83 /* mode setting (rw-r--r-- or 0644) for output files */
84 #define	MODE			S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH
85 
86 /*	A few fields the port template refers to may be empty in a given port's
87  *	index entry, so the template mustn't contain any hard-coded strings before
88  *	or after their placeholder that wouldn't make any sense if the item they
89  *	refer to is absent.
90  *
91  *	So, define a few strings to use in our output when they are present, and
92  *	add a little code to the make_readme_port routine to handle them.
93  */
94 
95 /* strings used to preface BUILD_DEPENDS and RUN_DEPENDS lists */
96 #define	BUILD_DEPS	"This port requires the following ports to build:<br><br>"
97 #define	RUN_DEPS	"This port requires the following ports to run:<br><br>"
98 
99 /* use a prologue and an epilogue for WEBSITE */
100 #define	WWW_BEFORE	" or <a href=\""
101 #define WWW_AFTER	"\">visit the website</a>"
102 
103 /* define index values for the index_field[] and placeholder[] arrays */
104 #define	PKG				0
105 #define	PORT			1
106 #define	INSTALLPREFIX	2
107 #define	COMMENT			3
108 #define	DESCR			4
109 #define	EMAIL			5
110 #define	CATEGORY		6
111 #define	BUILD_DEPENDS	7
112 #define	RUN_DEPENDS		8
113 #define	WEBSITE			9
114 #define	TOP				10		/* these last two aren't actually index */
115 #define	SUBDIR			11		/* fields, but they do exist in the     */
116 								/* placeholder[] array                  */
117 
118 /*
119  *	Macro definitions
120  */
121 
122 /*	copy the string pointed to by 'src' to the buffer pointed to by 'dest',
123  *	leaving 'dest' pointing to the location one past the last character copied
124  */
125 #define	addstr(dest, src)	dest = stpcpy(dest, src)
126 
127 /* display a suggestion if user tries an unrecognized option character */
128 
129 #define suggest_help fprintf(stderr, \
130 	"Try \"mkreadmes -h\" or \"man mkreadmes\" for more information.\n")
131 
132