summaryrefslogtreecommitdiff
path: root/support/vvcode/vvutils.h
blob: c4d45e688599defc838471ee19dd0a37534dbbae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*-
******************************************************************************
******************************************************************************
**
**  ARCHIVE HEADER INFORMATION
**
**  @C-file{
**      FILENAME    = "vvutils.h",
**      VERSION     = "1.00",
**      DATE        = "",
**      TIME        = "",
**
**      AUTHOR      = "Niel Kempson",
**      ADDRESS     = "25 Whitethorn Drive, Cheltenham, GL52 5LL, England",
**      TELEPHONE   = "+44-242 579105",
**      EMAIL       = "kempson@tex.ac.uk (Internet)",
**
**      SUPPORTED   = "yes",
**      ARCHIVED    = "tex.ac.uk, ftp.tex.ac.uk",
**      KEYWORDS    = "VVcode",
**
**      CODETABLE   = "ISO/ASCII",
**      CHECKSUM    = "51492 1481 5732 57976",
**
**      DOCSTRING   = { This file is part of VVcode.
**                  }
**  }
**
**  MODULE CONTENTS
**
**      allocate_buffer         Allocate memory for a buffer.
**      display_comment         Display a VVE file comment.
**      f_close                 Close a file.
**      getc_format             Get the format specified on the command line.
**      getc_mode               Get the mode specified on the command line.
**      getc_reclen             Get the maximum record length specified on
**                              the command line.
**      getc_timestamp          Get the timestamp specified on the command 
**                              line.
**      header_type             Look for a header string in a list of headers.
**      init_crc32_table        Initialize the 32 bit CRC table.
**      lookup_key              Look for a string in a list of keywords.
**      make_time               Convert a 'tm' structure into a Unix style
**                              time_t value.
**      open_log_file           Open the log file for writing.
**      parse_header            Extract the value of a VVE/XLT header line.
**      pars_time               Parse a string in VVcode timestamp format and
**                              convert it to a Unix style time_t value.
**      pars_xlt_tbl            Parse a character set translation table.
**      rd_enc_tbl              Read and check an encoding table from a
**                              specified file.
**      rd_xlt_tbl              Read and check a character set translation 
**                              table from a specified file.
**      set_dec_tbl             Invert an encoding table to form a decoding 
**                              table.
**      set_xlt_tbl             Setup the character set translation table.
**      show_file_context       Show the context in which a file processing
**                              error occurred.
**      vstrchr                 Search a string for the first occurrence of a 
**                              specified character.
**      vstricmp                Compare two strings ignoring case differences.
**      vstrnicmp               Compare at most 'n' characters of two strings
**                              ignoring case differences.
**      vstrrchr                Search a string for the last occurrence of a 
**                              specified character.
**      vstrrstr                Search a string for the last occurrence of
**                              any of a list of specified characters.
**      vstrstr                 Search a string for the first occurrence of
**                              any of a list of specified characters.
**      vv_timestamp            Convert a Unix style time_t value into a 
**                              VVcode format timestamp string.
**      vstrdup                 Duplicate a string, allocating memory for the
**                              copy.
**      vstrtrws                Strip trailing whitespace from a string.
**
**  COPYRIGHT
**
**      Copyright (c) 1991-1993 by Niel Kempson <kempson@tex.ac.uk>
**
**      This program is free software; you can redistribute it and/or
**      modify it under the terms of the GNU General Public License as
**      published by the Free Software Foundation; either version 1, or
**      (at your option) any later version.
**
**      This program is distributed in the hope that it will be useful,
**      but WITHOUT ANY WARRANTY; without even the implied warranty of
**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**      General Public License for more details.
**
**      You should have received a copy of the GNU General Public License
**      along with this program; if not, write to the Free Software
**      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
**      In other words, you are welcome to use, share and improve this
**      program.  You are forbidden to forbid anyone else to use, share
**      and improve what you give them.   Help stamp out software-hoarding!  
**
**  CHANGE LOG
**
******************************************************************************
******************************************************************************
*/


/*
**----------------------------------------------------------------------------
** Forward declarations of functions in the file 'vvutils.c'
**----------------------------------------------------------------------------
*/
char *allocate_buffer           ARGS ((CONST SIZE_T buf_len,
                                    CONST char *buf_name));
void display_comment            ARGS ((CONST File_Info *ip_file,
                                    CONST char *line_ptr,
                                    Header_Struct *hdr_struct));
void f_close                    ARGS ((File_Info *file));
Int16 getc_format               ARGS ((CONST Qualifier_Struct *qual_format,
                                    CONST char *fmt_str_array[]));
Int16 getc_mode                 ARGS ((CONST Qualifier_Struct *qual_mode,
				    CONST char *mode_str_array[]));
Int32 getc_reclen               ARGS ((CONST Qualifier_Struct *qual_reclen,
                                    CONST File_Info *ip_file));
TIME_T getc_timestamp           ARGS ((CONST Qualifier_Struct *qual_timestamp));
Int16 header_type               ARGS ((CONST File_Info *ip_file,
                                    CONST char *line_ptr,
                                    CONST Header_Struct *hdr_array));
void init_crc32_table           ARGS ((CONST Int16 crc_table_size,
                                    CONST Unsigned32 crc_polynomial,
                                    Unsigned32 *crc_table));
Int16 lookup_key                ARGS ((CONST char *key_list[],
                                    CONST char *key_string,
                                    CONST Int16 allow_abbrevs,
                                    CONST Int16 case_sensitivity));
TIME_T make_time                ARGS ((CONST struct tm *t_struct));
void open_log_file              ARGS ((CONST Qualifier_Struct *log_qualifier,
                                    CONST char *def_file_name,
                                    CONST Int16 overwrite_flag,
                                    File_Info *log_file));
void parse_header               ARGS ((CONST File_Info *ip_file,
                                    CONST char *line_ptr,
                                    Header_Struct *hdr_struct));
TIME_T pars_time                ARGS ((CONST char *time_str));
Boolean pars_xlt_tbl            ARGS ((CONST char *xlt_buffer,
                                    Xlt_Struct *xlt_tbl,
                                    Int16 subst_char));
Boolean rd_enc_tbl              ARGS ((File_Info *enc_file,
				    CONST Int16 enc_tbl_len,
				    char *encode_table));
Int16 rd_xlt_tbl                ARGS ((Header_Struct *xlt_hdr_array,
				    File_Info *xlt_file,
				    Xlt_Struct *xlt_tbl));
void set_dec_tbl                ARGS ((CONST Int16 enc_tbl_len,
				    CONST char *encode_table,
				    CONST Int16 dec_tbl_len,
                                    Int16 *decode_table));
void set_xlt_tbl                ARGS ((File_Info *xlt_file,
                                    Xlt_Struct *xlt_table,
				    Header_Struct *xlt_hdr_array));
void show_file_context          ARGS ((CONST File_Info *file,
                                    CONST char *file_text));
char *vstrchr                   ARGS ((CONST char *str,
                                    CONST int ch));
int vstricmp                    ARGS ((CONST char *str1,
                                    CONST char *str2));
int vstrncmp                    ARGS ((CONST char *str1,
                                    CONST char *str2,
                                    CONST int max_chars));
int vstrnicmp                   ARGS ((CONST char *str1,
                                    CONST char *str2,
                                    CONST int max_chars));
char *vstrrchr                  ARGS ((CONST char *str,
                                    CONST int ch));
char *vstrrstr                  ARGS ((CONST char *str,
                                    CONST char *search_str));
char *vstrstr                   ARGS ((CONST char *str,
                                    CONST char *search_str));
char *vv_timestamp              ARGS ((TIME_T time_val));
char *vstrdup                   ARGS ((CONST char *str));
char *vstrtrws                  ARGS ((char *str));