aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbznew.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /pkg/tbtables/tbznew.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/tbtables/tbznew.x')
-rw-r--r--pkg/tbtables/tbznew.x50
1 files changed, 50 insertions, 0 deletions
diff --git a/pkg/tbtables/tbznew.x b/pkg/tbtables/tbznew.x
new file mode 100644
index 00000000..21798ad9
--- /dev/null
+++ b/pkg/tbtables/tbznew.x
@@ -0,0 +1,50 @@
+include "tbtables.h"
+include "tbltext.h"
+
+# tbznew -- Create a new table
+# This opens the file for a new table of type text file.
+# It also allocates memory for each column for storing the column values
+# while the table is open.
+#
+# Phil Hodge, 14-Jan-1992 Subroutine created.
+# Phil Hodge, 5-Mar-1993 Check if comment buffer is already allocated.
+# Phil Hodge, 7-Jun-1999 Allocate space for the list of keywords.
+
+procedure tbznew (tp)
+
+pointer tp # i: pointer to table descriptor
+#--
+pointer cp # pointer to a column descriptor
+int colnum # column number
+int fd # fd for table file
+int open()
+errchk open, tbzadd
+
+begin
+ # This was split into two lines so that if the open fails,
+ # TB_FILE(tp) will be unchanged (should be NULL).
+ fd = open (TB_NAME(tp), TB_IOMODE(tp), TEXT_FILE)
+ TB_FILE(tp) = fd
+
+ # If a size hasn't been set for the number of rows, assign a default.
+ if (TB_ALLROWS(tp) < 1)
+ TB_ALLROWS(tp) = 100 # default value
+
+ # Allocate memory for each column.
+ do colnum = 1, TB_NCOLS(tp) {
+ cp = TB_COLINFO(tp,colnum)
+ call tbzadd (tp, cp)
+ }
+
+ # Allocate space for the list of keywords.
+ if (TB_MAXPAR(tp) <= 0)
+ TB_MAXPAR(tp) = INCR_N_KEYWORDS
+ call calloc (TB_KEYLIST_PTR(tp), TB_MAXPAR(tp), TY_POINTER)
+
+ # Allocate space for the comment buffer.
+ if (TB_COMMENT(tp) == NULL) {
+ call calloc (TB_COMMENT(tp), SZ_LINE, TY_CHAR)
+ TB_SZ_COMMENT(tp) = SZ_LINE
+ Memc[TB_COMMENT(tp)] = EOS
+ }
+end