Initial snark14m import
[snark14.git] / src / snark / errorc.c
1 /*
2  ***********************************************************
3  $SNARK_Header: S N A R K  1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4  $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/errorc.c $
5  $LastChangedRevision: 85 $
6  $Date: 2014-07-02 16:07:08 -0400 (Wed, 02 Jul 2014) $
7  $Author: agulati $
8  ***********************************************************
9
10  Previously part of SuperSNARK
11  */
12
13 #include "stdlib.h"
14 #include "string.h"
15 #include "experimenter.h"
16 #include "errorc.h"
17
18 /* ------------------------ error_message.c ------------------------ */
19
20 /* function to handle error messages */
21
22 void errorc(char* str1, char* str2)
23 {
24         char message[MAXLINESIZE];
25
26         strcpy(message, str1);
27         strcat(message, str2);
28         strcat(message, "\n");
29         fprintf(stderr, message);
30         exit(1);
31 }
32
33 //bug 269 - jklukowska
34 //returns true if the line should be skipped (because it is blank
35 //or starts with a * - comment line)
36 int isSkip(char * line)
37 {
38         int i = 0;
39         while (line[i] == ' ' || line[i] == '\t' || line[i] == '\n')
40                 i++;
41         //if the next character is null return true
42         if (line[i] == '\0')
43                 return 1;
44         //or if the first non white space character is a star
45         else if (line[i] == '*')
46                 return 1;
47         else
48                 return 0;
49 }
50
51 int isBlank(char * line)
52 {
53         int i = 0;
54         while (line[i] == ' ' || line[i] == '\t' || line[i] == '\n')
55                 i++;
56         //if the next character is null return true
57         if (line[i] == '\0')
58                 return 1;
59         else
60                 return 0;
61 }
62
63 int isComment(char * line)
64 {
65         int i = 0;
66         while (line[i] == ' ' || line[i] == '\t' || line[i] == '\n')
67                 i++;
68         //if the first non white space character is a star
69         if (line[i] == '*')
70                 return 1;
71         else
72                 return 0;
73 }
74
75 int isValidObject(char * line)
76 {
77         if (strncasecmp(line, "elip", 4) == 0 || strncasecmp(line, "rect", 4) == 0
78                         || strncasecmp(line, "tria", 4) == 0
79                         || strncasecmp(line, "segm", 4) == 0
80                         || strncasecmp(line, "sect", 4) == 0)
81                 return 1;
82         else
83                 return 0;
84 }
85