aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbzsub.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/tbtables/tbzsub.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/tbtables/tbzsub.x')
-rw-r--r--pkg/tbtables/tbzsub.x54
1 files changed, 54 insertions, 0 deletions
diff --git a/pkg/tbtables/tbzsub.x b/pkg/tbtables/tbzsub.x
new file mode 100644
index 00000000..2162a14b
--- /dev/null
+++ b/pkg/tbtables/tbzsub.x
@@ -0,0 +1,54 @@
+include <tbset.h> # for subtype codes
+include "tbtables.h"
+include "tbltext.h"
+
+# tbzsub -- determine text table subtype
+#
+# Phil Hodge, 7-Jun-1999 Subroutine created.
+
+procedure tbzsub (tp, buf, maxch, line, line_type, subtype)
+
+pointer tp # i: pointer to table info structure
+char buf[ARB] # o: buffer for the line that was read
+int maxch # i: size of line buffer
+int line # io: line number in input file
+int line_type # o: type of line read by tbzlin
+int subtype # o: subtype of text table
+#--
+int fd # fd for the file
+bool read_enough # true if we have read enough to determine the subtype
+int nchar, tbzlin()
+errchk tbzlin
+
+begin
+ fd = TB_FILE(tp)
+ read_enough = false
+ subtype = TBL_SUBTYPE_UNKNOWN
+
+ while (!read_enough) {
+
+ nchar = tbzlin (fd, buf, maxch, line, line_type)
+
+ if (nchar == EOF) {
+ subtype = TBL_SUBTYPE_SIMPLE
+ read_enough = true
+ buf[1] = EOS
+
+ } else if (line_type == COLDEF_LINE) {
+ subtype = TBL_SUBTYPE_EXPLICIT
+ read_enough = true
+
+ } else if (line_type == KEYWORD_LINE) {
+ call tbzkey (tp, buf, 0) # append to list of keywords
+ buf[1] = EOS # done with this line
+
+ } else if (line_type == COMMENT_LINE) {
+ call tbbcmt (tp, buf) # append to comment buffer
+ buf[1] = EOS # done with this line
+
+ } else { # data
+ subtype = TBL_SUBTYPE_SIMPLE
+ read_enough = true
+ }
+ }
+end