Merge branch 'ical'
[alpine.git] / pith / escapes.c
blob0ec00ebd679a4b3d41e18b87e3cd2e0c3fbaf2d4
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: escapes.c 761 2007-10-23 22:35:18Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2013-2017 Eduardo Chappa
8 * Copyright 2006 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 /*======================================================================
21 escapes.c
22 Implements known escape code matching
24 ====*/
27 #include "../pith/headers.h"
28 #include "../pith/escapes.h"
32 /*------------------------------------------------------------------
33 This list of known escape sequences is taken from RFC's 1486 and 1554
34 and draft-apng-cc-encoding, and the X11R5 source with only a remote
35 understanding of what this all means...
37 NOTE: if the length of these should extend beyond 4 chars, fix
38 MAX_ESC_LEN in filter.c
39 ----*/
40 #ifdef _WINDOWS
41 static char *known_escapes[] = {
42 "(B", "(J", "$@", "$B", /* RFC 1468 */
43 "(H",
44 NULL};
45 #else
46 static char *known_escapes[] = {
47 "(B", "(J", "$@", "$B", /* RFC 1468 */
48 "(H",
49 "$A", "$(C", "$(D", ".A", ".F", /* added by RFC 1554 */
50 "$)C", "$)A", "$*E", "$*X", /* those in apng-draft */
51 "$+G", "$+H", "$+I", "$+J", "$+K",
52 "$+L", "$+M",
53 ")I", "-A", "-B", "-C", "-D", /* codes form X11R5 source */
54 "-F", "-G", "-H", "-L", "-M",
55 "-$(A", "$(B", "$)B", "$)D",
56 NULL};
57 #endif
60 int
61 match_escapes(char *esc_seq)
63 char **p;
64 int n;
66 for(p = known_escapes; *p && strncmp(esc_seq, *p, n = strlen(*p)); p++)
69 return(*p ? n + 1 : 0);