]>
git.cameronkatri.com Git - mandoc.git/blob - strings.c
1 /* $Id: strings.c,v 1.8 2009/01/16 12:23:25 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(size_t sz
, const char **p
)
91 if (0 == strcmp(*p
, "RETURN") &&
92 0 == strcmp(*(p
+ 1), "VALUES"))
93 return(SEC_RETURN_VALUES
);
94 if (0 == strcmp(*p
, "SEE") &&
95 0 == strcmp(*(p
+ 1), "ALSO"))
100 if (0 == strcmp(*p
, "NAME"))
102 else if (0 == strcmp(*p
, "SYNOPSIS"))
103 return(SEC_SYNOPSIS
);
104 else if (0 == strcmp(*p
, "DESCRIPTION"))
105 return(SEC_DESCRIPTION
);
106 else if (0 == strcmp(*p
, "ENVIRONMENT"))
107 return(SEC_ENVIRONMENT
);
108 else if (0 == strcmp(*p
, "FILES"))
110 else if (0 == strcmp(*p
, "EXAMPLES"))
111 return(SEC_EXAMPLES
);
112 else if (0 == strcmp(*p
, "DIAGNOSTICS"))
113 return(SEC_DIAGNOSTICS
);
114 else if (0 == strcmp(*p
, "ERRORS"))
116 else if (0 == strcmp(*p
, "STANDARDS"))
117 return(SEC_STANDARDS
);
118 else if (0 == strcmp(*p
, "HISTORY"))
120 else if (0 == strcmp(*p
, "AUTHORS"))
122 else if (0 == strcmp(*p
, "CAVEATS"))
124 else if (0 == strcmp(*p
, "BUGS"))
132 mdoc_atotime(const char *p
)
136 (void)memset(&tm
, 0, sizeof(struct tm
));
138 if (0 == strptime(p
, "%b %d %Y", &tm
))
140 if (0 == strptime(p
, "%b %d, %Y", &tm
))
148 mdoc_atomsec(const char *p
)
151 if (0 == strcmp(p
, "1"))
153 else if (0 == strcmp(p
, "2"))
155 else if (0 == strcmp(p
, "3"))
157 else if (0 == strcmp(p
, "3f"))
159 else if (0 == strcmp(p
, "3p"))
161 else if (0 == strcmp(p
, "4"))
163 else if (0 == strcmp(p
, "5"))
165 else if (0 == strcmp(p
, "6"))
167 else if (0 == strcmp(p
, "7"))
169 else if (0 == strcmp(p
, "8"))
171 else if (0 == strcmp(p
, "9"))
173 else if (0 == strcmp(p
, "X11"))
175 else if (0 == strcmp(p
, "X11R6"))
177 else if (0 == strcmp(p
, "local"))
179 else if (0 == strcmp(p
, "n"))
181 else if (0 == strcmp(p
, "unass"))
183 else if (0 == strcmp(p
, "draft"))
185 else if (0 == strcmp(p
, "paper"))
188 return(MSEC_DEFAULT
);
193 mdoc_atovol(const char *p
)
196 if (0 == strcmp(p
, "AMD"))
198 else if (0 == strcmp(p
, "IND"))
200 else if (0 == strcmp(p
, "KM"))
202 else if (0 == strcmp(p
, "LOCAL"))
204 else if (0 == strcmp(p
, "PRM"))
206 else if (0 == strcmp(p
, "PS1"))
208 else if (0 == strcmp(p
, "SMM"))
210 else if (0 == strcmp(p
, "URM"))
212 else if (0 == strcmp(p
, "USD"))
220 mdoc_atoarch(const char *p
)
223 if (0 == strcmp(p
, "alpha"))
225 else if (0 == strcmp(p
, "amd64"))
227 else if (0 == strcmp(p
, "amiga"))
229 else if (0 == strcmp(p
, "arc"))
231 else if (0 == strcmp(p
, "arm"))
233 else if (0 == strcmp(p
, "armish"))
235 else if (0 == strcmp(p
, "aviion"))
237 else if (0 == strcmp(p
, "hp300"))
239 else if (0 == strcmp(p
, "hppa"))
241 else if (0 == strcmp(p
, "hppa64"))
243 else if (0 == strcmp(p
, "i386"))
245 else if (0 == strcmp(p
, "landisk"))
246 return(ARCH_landisk
);
247 else if (0 == strcmp(p
, "luna88k"))
248 return(ARCH_luna88k
);
249 else if (0 == strcmp(p
, "mac68k"))
251 else if (0 == strcmp(p
, "macppc"))
253 else if (0 == strcmp(p
, "mvme68k"))
254 return(ARCH_mvme68k
);
255 else if (0 == strcmp(p
, "mvme88k"))
256 return(ARCH_mvme88k
);
257 else if (0 == strcmp(p
, "mvmeppc"))
258 return(ARCH_mvmeppc
);
259 else if (0 == strcmp(p
, "pmax"))
261 else if (0 == strcmp(p
, "sgi"))
263 else if (0 == strcmp(p
, "socppc"))
265 else if (0 == strcmp(p
, "sparc"))
267 else if (0 == strcmp(p
, "sparc64"))
268 return(ARCH_sparc64
);
269 else if (0 == strcmp(p
, "sun3"))
271 else if (0 == strcmp(p
, "vax"))
273 else if (0 == strcmp(p
, "zaurus"))
276 return(ARCH_DEFAULT
);
281 mdoc_atoatt(const char *p
)
285 if (0 == strcmp(p
, "v1"))
287 else if (0 == strcmp(p
, "v2"))
289 else if (0 == strcmp(p
, "v3"))
291 else if (0 == strcmp(p
, "v4"))
293 else if (0 == strcmp(p
, "v5"))
295 else if (0 == strcmp(p
, "v6"))
297 else if (0 == strcmp(p
, "v7"))
299 else if (0 == strcmp(p
, "32v"))
301 else if (0 == strcmp(p
, "V.1"))
303 else if (0 == strcmp(p
, "V.2"))
305 else if (0 == strcmp(p
, "V.3"))
307 else if (0 == strcmp(p
, "V.4"))
315 mdoc_type2a(enum mdoc_type type
)
323 return("block-head");
325 return("block-body");
327 return("block-tail");