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