]>
git.cameronkatri.com Git - mandoc.git/blob - strings.c
1 /* $Id: strings.c,v 1.9 2009/01/17 16:15:27 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
)
128 (void)memset(&tm
, 0, sizeof(struct tm
));
130 if (0 == strptime(p
, "%b %d %Y", &tm
))
132 if (0 == strptime(p
, "%b %d, %Y", &tm
))
140 mdoc_atomsec(const char *p
)
143 if (0 == strcmp(p
, "1"))
145 else if (0 == strcmp(p
, "2"))
147 else if (0 == strcmp(p
, "3"))
149 else if (0 == strcmp(p
, "3f"))
151 else if (0 == strcmp(p
, "3p"))
153 else if (0 == strcmp(p
, "4"))
155 else if (0 == strcmp(p
, "5"))
157 else if (0 == strcmp(p
, "6"))
159 else if (0 == strcmp(p
, "7"))
161 else if (0 == strcmp(p
, "8"))
163 else if (0 == strcmp(p
, "9"))
165 else if (0 == strcmp(p
, "X11"))
167 else if (0 == strcmp(p
, "X11R6"))
169 else if (0 == strcmp(p
, "local"))
171 else if (0 == strcmp(p
, "n"))
173 else if (0 == strcmp(p
, "unass"))
175 else if (0 == strcmp(p
, "draft"))
177 else if (0 == strcmp(p
, "paper"))
180 return(MSEC_DEFAULT
);
185 mdoc_atovol(const char *p
)
188 if (0 == strcmp(p
, "AMD"))
190 else if (0 == strcmp(p
, "IND"))
192 else if (0 == strcmp(p
, "KM"))
194 else if (0 == strcmp(p
, "LOCAL"))
196 else if (0 == strcmp(p
, "PRM"))
198 else if (0 == strcmp(p
, "PS1"))
200 else if (0 == strcmp(p
, "SMM"))
202 else if (0 == strcmp(p
, "URM"))
204 else if (0 == strcmp(p
, "USD"))
212 mdoc_atoarch(const char *p
)
215 if (0 == strcmp(p
, "alpha"))
217 else if (0 == strcmp(p
, "amd64"))
219 else if (0 == strcmp(p
, "amiga"))
221 else if (0 == strcmp(p
, "arc"))
223 else if (0 == strcmp(p
, "arm"))
225 else if (0 == strcmp(p
, "armish"))
227 else if (0 == strcmp(p
, "aviion"))
229 else if (0 == strcmp(p
, "hp300"))
231 else if (0 == strcmp(p
, "hppa"))
233 else if (0 == strcmp(p
, "hppa64"))
235 else if (0 == strcmp(p
, "i386"))
237 else if (0 == strcmp(p
, "landisk"))
238 return(ARCH_landisk
);
239 else if (0 == strcmp(p
, "luna88k"))
240 return(ARCH_luna88k
);
241 else if (0 == strcmp(p
, "mac68k"))
243 else if (0 == strcmp(p
, "macppc"))
245 else if (0 == strcmp(p
, "mvme68k"))
246 return(ARCH_mvme68k
);
247 else if (0 == strcmp(p
, "mvme88k"))
248 return(ARCH_mvme88k
);
249 else if (0 == strcmp(p
, "mvmeppc"))
250 return(ARCH_mvmeppc
);
251 else if (0 == strcmp(p
, "pmax"))
253 else if (0 == strcmp(p
, "sgi"))
255 else if (0 == strcmp(p
, "socppc"))
257 else if (0 == strcmp(p
, "sparc"))
259 else if (0 == strcmp(p
, "sparc64"))
260 return(ARCH_sparc64
);
261 else if (0 == strcmp(p
, "sun3"))
263 else if (0 == strcmp(p
, "vax"))
265 else if (0 == strcmp(p
, "zaurus"))
268 return(ARCH_DEFAULT
);
273 mdoc_atoatt(const char *p
)
277 if (0 == strcmp(p
, "v1"))
279 else if (0 == strcmp(p
, "v2"))
281 else if (0 == strcmp(p
, "v3"))
283 else if (0 == strcmp(p
, "v4"))
285 else if (0 == strcmp(p
, "v5"))
287 else if (0 == strcmp(p
, "v6"))
289 else if (0 == strcmp(p
, "v7"))
291 else if (0 == strcmp(p
, "32v"))
293 else if (0 == strcmp(p
, "V.1"))
295 else if (0 == strcmp(p
, "V.2"))
297 else if (0 == strcmp(p
, "V.3"))
299 else if (0 == strcmp(p
, "V.4"))
307 mdoc_type2a(enum mdoc_type type
)
315 return("block-head");
317 return("block-body");
319 return("block-tail");