aboutsummaryrefslogtreecommitdiff
path: root/ine_io.c
diff options
context:
space:
mode:
authorbremner <bremner@09fa754a-f411-0410-976a-da6bfa213b30>2006-07-11 11:15:40 +0000
committerbremner <bremner@09fa754a-f411-0410-976a-da6bfa213b30>2006-07-11 11:15:40 +0000
commitfc9b18afa66eca90d15302af3161a09e942c3a37 (patch)
tree88fca046e389959214bc20bf1b81139dcaca4d8d /ine_io.c
parentf2f3ec70cd3c86583c1eb03b0da63f74b6aefe05 (diff)
git-svn-id: file:///export/data/bremner/svn/trunk/inetools@5465 09fa754a-f411-0410-976a-da6bfa213b30
Diffstat (limited to 'ine_io.c')
-rw-r--r--ine_io.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/ine_io.c b/ine_io.c
new file mode 100644
index 0000000..46d1716
--- /dev/null
+++ b/ine_io.c
@@ -0,0 +1,53 @@
+#include <stdio.h>
+#include <errno.h>
+
+void scan_for_begin(int *m_p, int *n_p, char **type_p){
+ char buf[BUFSIZ];
+ char *cursor;
+ int m,n;
+
+ while ( fgets(buf,BUFSIZ,stdin) !=NULL ) {
+ fputs(buf,stdout);
+ for (cursor=buf; isblank(*cursor); cursor++);
+ if (strncmp(cursor,"begin",5)==0) break;
+ }
+
+ if (fgets(buf,BUFSIZ,stdin)==NULL) {
+ fprintf(stderr,"No parameter line");
+ exit(1);
+ }
+
+ m=strtol(buf,&cursor,10);
+ if (errno==ERANGE || m==0){
+ fprintf(stderr,"Missing or absurd row count");
+ exit(1);
+ }
+ *m_p=m;
+
+ n=strtol(cursor,&cursor,10);
+ if (errno==ERANGE || m==0){
+ fprintf(stderr,"Missing or absurd column count");
+ exit(1);
+ }
+
+ *n_p=n;
+
+ while (isblank(*cursor)){
+ cursor++;
+ }
+
+ *type_p=cursor;
+
+}
+
+void check_type( char *type, char *ok[], int count){
+ int i;
+ for (i=0; i< count; i++){
+ if (strncmp(type,ok[i],strlen(ok[i]))==0)
+ return;
+ }
+
+ fprintf(stderr,"Type %s not permitted\n",
+ type);
+ exit(1);
+}