# | Line 4 | Line 4 | |
---|---|---|
4 | ||
5 | #include "atom_parser.h" | |
6 | ||
7 | + | #define MK_STR(s) # s |
8 | + | #define STR_DEFINE(t, s) t = MK_STR(s) |
9 | ||
10 | + | |
11 | struct linked_atom *head_main; | |
12 | struct linked_atom *head_inUse; | |
13 | int n_inUse; | |
# | Line 18 | Line 21 | void initializeParser(){ | |
21 | const int buffer_size = 300; | |
22 | char lineBuffer[buffer_size]; | |
23 | ||
24 | < | char *in_filename; |
24 | > | char in_filenameStd[500]; |
25 | > | char tempString[500]; |
26 | > | char *atPath; |
27 | > | char *in_filenameSet; |
28 | char *in_file_env = "_xyz2pov_AtomTypes_"; | |
29 | FILE *in_file; | |
30 | ||
# | Line 30 | Line 36 | void initializeParser(){ | |
36 | ||
37 | n_inUse = 0; | |
38 | ||
39 | < | in_filename = getenv(in_file_env); |
40 | < | |
41 | < | in_file = fopen(in_filename, "r"); |
42 | < | |
43 | < | if(in_file == NULL){ |
44 | < | |
45 | < | printf("Error reading AtomTypes file, is the _xyz2pov_AtomTypes_\n" |
46 | < | "enviorment variable set?\n"); |
47 | < | exit(8); |
39 | > | // generate the AtomTypes Name |
40 | > | |
41 | > | strcpy( in_filenameStd, "AtomTypes" ); |
42 | > | |
43 | > | // attempt to open the file in the current directory first. |
44 | > | |
45 | > | in_file = fopen( in_filenameStd, "r" ); |
46 | > | |
47 | > | if( in_file == NULL ){ |
48 | > | |
49 | > | // next see if the force path enviorment variable is set |
50 | > | |
51 | > | in_filenameSet = getenv( in_file_env ); |
52 | > | if( in_filenameSet != NULL ) { |
53 | > | |
54 | > | in_file = fopen(in_filenameSet, "r"); |
55 | > | |
56 | > | if(in_file == NULL){ |
57 | > | |
58 | > | fprintf(stderr, |
59 | > | "Error reading AtomTypes file. The _xyz2pov_AtomTypes_\n" |
60 | > | "enviorment variable was set incorrectly.\n"); |
61 | > | exit(8); |
62 | > | } |
63 | > | } |
64 | > | else{ |
65 | > | STR_DEFINE(atPath, TYPES_PATH ); |
66 | > | |
67 | > | strcpy( tempString, atPath ); |
68 | > | strcat( tempString, "/" ); |
69 | > | strcat( tempString, in_filenameStd ); |
70 | > | strcpy( in_filenameStd, tempString ); |
71 | > | |
72 | > | in_file = fopen( in_filenameStd, "r" ); |
73 | > | |
74 | > | if( in_file == NULL ){ |
75 | > | |
76 | > | fprintf(stderr, |
77 | > | "Error opening the AtomTypes definition file: %s\n" |
78 | > | "Have you tried setting the _xyz2pov_AtomTypes_ environment " |
79 | > | "vairable?\n", |
80 | > | in_filenameStd ); |
81 | > | exit(8); |
82 | > | } |
83 | > | } |
84 | } | |
85 | + | |
86 | ||
87 | while(fgets(lineBuffer, sizeof(lineBuffer), in_file) != NULL){ | |
88 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |