]>
git.cameronkatri.com Git - mandoc.git/blob - strings.c
1 /* $Id: strings.c,v 1.13 2009/02/21 21:00:06 kristaps Exp $ */
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
31 extern char *strptime(const char *, const char *, struct tm
*);
72 mdoc_isdelim(const char *p
)
79 return(mdoc_iscdelim(*p
));
84 mdoc_atosec(const char *p
)
88 if (0 == strcmp(p
, "NAME"))
90 else if (0 == strcmp(p
, "RETURN VALUES"))
91 return(SEC_RETURN_VALUES
);
92 else if (0 == strcmp(p
, "SEE ALSO"))
94 else if (0 == strcmp(p
, "SYNOPSIS"))
96 else if (0 == strcmp(p
, "DESCRIPTION"))
97 return(SEC_DESCRIPTION
);
98 else if (0 == strcmp(p
, "ENVIRONMENT"))
99 return(SEC_ENVIRONMENT
);
100 else if (0 == strcmp(p
, "FILES"))
102 else if (0 == strcmp(p
, "EXAMPLES"))
103 return(SEC_EXAMPLES
);
104 else if (0 == strcmp(p
, "DIAGNOSTICS"))
105 return(SEC_DIAGNOSTICS
);
106 else if (0 == strcmp(p
, "ERRORS"))
108 else if (0 == strcmp(p
, "STANDARDS"))
109 return(SEC_STANDARDS
);
110 else if (0 == strcmp(p
, "HISTORY"))
112 else if (0 == strcmp(p
, "AUTHORS"))
114 else if (0 == strcmp(p
, "CAVEATS"))
116 else if (0 == strcmp(p
, "BUGS"))
124 mdoc_atotime(const char *p
)
129 (void)memset(&tm
, 0, sizeof(struct tm
));
131 if (xstrcmp(p
, "$Mdocdate: February 21 2009 $"))
133 if ((pp
= strptime(p
, "$Mdocdate: February 21 2009 $", &tm
)) && 0 == *pp
)
135 /* XXX - this matches "June 1999", which is wrong. */
136 if ((pp
= strptime(p
, "%b %d %Y", &tm
)) && 0 == *pp
)
138 if ((pp
= strptime(p
, "%b %d, %Y", &tm
)) && 0 == *pp
)
146 mdoc_atomsec(const char *p
)
149 if (0 == strcmp(p
, "1"))
151 else if (0 == strcmp(p
, "2"))
153 else if (0 == strcmp(p
, "3"))
155 else if (0 == strcmp(p
, "3f"))
157 else if (0 == strcmp(p
, "3p"))
159 else if (0 == strcmp(p
, "4"))
161 else if (0 == strcmp(p
, "5"))
163 else if (0 == strcmp(p
, "6"))
165 else if (0 == strcmp(p
, "7"))
167 else if (0 == strcmp(p
, "8"))
169 else if (0 == strcmp(p
, "9"))
171 else if (0 == strcmp(p
, "X11"))
173 else if (0 == strcmp(p
, "X11R6"))
175 else if (0 == strcmp(p
, "local"))
177 else if (0 == strcmp(p
, "n"))
179 else if (0 == strcmp(p
, "unass"))
181 else if (0 == strcmp(p
, "draft"))
183 else if (0 == strcmp(p
, "paper"))
186 return(MSEC_DEFAULT
);
191 mdoc_atovol(const char *p
)
194 if (0 == strcmp(p
, "AMD"))
196 else if (0 == strcmp(p
, "IND"))
198 else if (0 == strcmp(p
, "KM"))
200 else if (0 == strcmp(p
, "LOCAL"))
202 else if (0 == strcmp(p
, "PRM"))
204 else if (0 == strcmp(p
, "PS1"))
206 else if (0 == strcmp(p
, "SMM"))
208 else if (0 == strcmp(p
, "URM"))
210 else if (0 == strcmp(p
, "USD"))
218 mdoc_atoarch(const char *p
)
221 if (0 == strcmp(p
, "alpha"))
223 else if (0 == strcmp(p
, "amd64"))
225 else if (0 == strcmp(p
, "amiga"))
227 else if (0 == strcmp(p
, "arc"))
229 else if (0 == strcmp(p
, "arm"))
231 else if (0 == strcmp(p
, "armish"))
233 else if (0 == strcmp(p
, "aviion"))
235 else if (0 == strcmp(p
, "hp300"))
237 else if (0 == strcmp(p
, "hppa"))
239 else if (0 == strcmp(p
, "hppa64"))
241 else if (0 == strcmp(p
, "i386"))
243 else if (0 == strcmp(p
, "landisk"))
244 return(ARCH_landisk
);
245 else if (0 == strcmp(p
, "luna88k"))
246 return(ARCH_luna88k
);
247 else if (0 == strcmp(p
, "mac68k"))
249 else if (0 == strcmp(p
, "macppc"))
251 else if (0 == strcmp(p
, "mvme68k"))
252 return(ARCH_mvme68k
);
253 else if (0 == strcmp(p
, "mvme88k"))
254 return(ARCH_mvme88k
);
255 else if (0 == strcmp(p
, "mvmeppc"))
256 return(ARCH_mvmeppc
);
257 else if (0 == strcmp(p
, "pmax"))
259 else if (0 == strcmp(p
, "sgi"))
261 else if (0 == strcmp(p
, "socppc"))
263 else if (0 == strcmp(p
, "sparc"))
265 else if (0 == strcmp(p
, "sparc64"))
266 return(ARCH_sparc64
);
267 else if (0 == strcmp(p
, "sun3"))
269 else if (0 == strcmp(p
, "vax"))
271 else if (0 == strcmp(p
, "zaurus"))
274 return(ARCH_DEFAULT
);
279 mdoc_atoatt(const char *p
)
283 if (0 == strcmp(p
, "v1"))
285 else if (0 == strcmp(p
, "v2"))
287 else if (0 == strcmp(p
, "v3"))
289 else if (0 == strcmp(p
, "v4"))
291 else if (0 == strcmp(p
, "v5"))
293 else if (0 == strcmp(p
, "v6"))
295 else if (0 == strcmp(p
, "v7"))
297 else if (0 == strcmp(p
, "32v"))
299 else if (0 == strcmp(p
, "V.1"))
301 else if (0 == strcmp(p
, "V.2"))
303 else if (0 == strcmp(p
, "V.3"))
305 else if (0 == strcmp(p
, "V.4"))
313 mdoc_type2a(enum mdoc_type type
)
321 return("block-head");
323 return("block-body");
325 return("block-tail");
340 mdoc_arch2a(enum mdoc_arch arch
)
408 mdoc_vol2a(enum mdoc_vol vol
)
413 return("OpenBSD Ancestral Manual Documents");
415 return("OpenBSD Manual Master Index");
417 return("OpenBSD Kernel Manual");
419 return("OpenBSD Local Manual");
421 return("OpenBSD Programmer's Manual");
423 return("OpenBSD Programmer's Supplementary Documents");
425 return("OpenBSD System Manager's Manual");
427 return("OpenBSD Reference Manual");
429 return("OpenBSD User's Supplementary Documents");
442 mdoc_msec2a(enum mdoc_msec msec
)