aboutsummaryrefslogtreecommitdiff
path: root/vendor/voclient/libvoclient/vocUtil_f77.c
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/voclient/libvoclient/vocUtil_f77.c')
-rw-r--r--vendor/voclient/libvoclient/vocUtil_f77.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/vendor/voclient/libvoclient/vocUtil_f77.c b/vendor/voclient/libvoclient/vocUtil_f77.c
new file mode 100644
index 00000000..0d05e8aa
--- /dev/null
+++ b/vendor/voclient/libvoclient/vocUtil_f77.c
@@ -0,0 +1,110 @@
+/**
+ *
+ * VOCUTIL_F77.C -- Utility routines to support Fortran bindings.
+ *
+ * @file vocUtil_f77.c
+ * @author Michael Fitzpatrick
+ * @version June 2006
+ *
+ *************************************************************************
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+
+#define _VOCLIENT_LIB_
+#include "VOClient.h"
+
+
+/**
+ * Local interface declarations.
+ */
+char *sstrip (char *instr, int len);
+void spad (char *outstr, int len);
+int typecode (char *typestr);
+
+
+
+/**
+ * SSTRIP -- Strip trailing blanks from a string and add null terminator.
+ *
+ * @brief Strip trailing blanks from a string and add null terminator
+ * @fn outstr = sstrip (char *instr, int len)
+ *
+ * @param instr string to strip
+ * @param len length of input string
+ * @returns stripped output string
+ */
+#define SZ_LINE 1024
+
+char *sstrip (char *instr, int len)
+{
+ if (len > 0 && instr) {
+ char *newstr = calloc (1, len+1);
+ int i = len;
+
+ strncpy (newstr, instr, len);
+
+ /* trim trailing blanks */
+ for (i=len; newstr[i] == ' ' || newstr[i] == '\0'; i--)
+ newstr[i] = '\0';
+
+ return (newstr);
+ }
+ return ((char *) NULL);
+}
+
+
+/**
+ * SPAD -- Pad a string to length 'len' with blanks, as Fortran requires.
+ *
+ * @brief Pad a string to length 'len' with blanks, as Fortran requires.
+ * @fn spad (char *outstr, int len)
+ *
+ * @param outstr string to pad
+ * @param len pad string to this length
+ * @returns nothing
+ */
+void spad (char *outstr, int len)
+{
+ int i=0;
+
+#ifndef _NO_SPAD_
+ for (i = strlen(outstr); i < len; i++)
+ outstr[i] = ' ';
+#endif
+}
+
+
+/**
+ * TYPECODE -- Convert a DAL type string to a code value.
+ *
+ * @brief Convert a DAL type string to a code value.
+ * @fn val = typecode (char *typestr)
+ *
+ * @param typestr DAL type string
+ * @returns DAL type code
+ */
+
+#define SZ_TYPECODE 32
+
+int typecode (char *typestr)
+{
+ char type[SZ_TYPECODE];
+ int i = 0;
+
+ memset (type, 0, SZ_TYPECODE);
+ for (i=0; typestr[i] && i < SZ_TYPECODE; i++)
+ type[i] = tolower (typestr[i]);
+
+ if (strcmp (type, "dal") == 0) return (DAL_CONN);
+ if (strcmp (type, "cone") == 0) return (CONE_CONN);
+ if (strcmp (type, "siap") == 0) return (SIAP_CONN);
+ if (strcmp (type, "ssap") == 0) return (SSAP_CONN);
+ if (strcmp (type, "slap") == 0) return (SLAP_CONN);
+
+ return (ERR);
+}