-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKMCOUTP.c
199 lines (162 loc) · 6.41 KB
/
PKMCOUTP.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
#include "PKIN.h"
#include "PKINDLOG.h"
/****openoutput()************************************************************/
int openoutput(void)
{
Point where;
SFReply reply; /*StandardFileReply outputfileinfo*/
int ireturn;
unsigned long mage1,mage2,mage3,mage4; /*OSType 4byte integer*/
FInfo filefinderinfo;
#define NOTNEWWAY
#define NOTNEWWAYTELL
#define OLDWAY
#define NOTOLDWAYTELL
mage1 = ('M'*16777216); /*shift <<24, doesn't work*/
mage2 = ('A'*65536); /*shift <<16, doesn't work*/
mage3 = ('G'<<8);
mage4 = 'E';
/*m*/ SetPt( &where, 85, 100 ); /* position of display box on screen */
/*m*/ CtoPstr(OutfileStr);
/* convert output file name from C to Pascal type string */
/* invoke the standard dialog for finding a file */
#ifdef OLDWAY
/*m*/ SFPutFile( where, "\p output kinemage file:",
(unsigned char *)OutfileStr, NULL, &reply );
#endif
#ifdef NEWWAY
/*m*/ StandardPutFile( "\p output kinemage file:",
(unsigned char *)OutfileStr, &outputfileinfo );
#endif
#ifdef OLDWAY
if( reply.good )
#endif
#ifdef NEWWAY
if( outputfileinfo.sfGood )
#endif
{/*good outputfile info*/
/* In newer hierarchical directory system, now the OLDWAY,*/
/*reply.vRefNum holds directory number */
#ifdef OLDWAY
/*m*/ SetVol( "\p", reply.vRefNum ); /* change to directory of file */
/*c*/ strcpy(OutfileStr, (const char *)reply.fName);
#endif
#ifdef NEWWAY
/*m*/ /*SetVol( "\p", outputfileinfo.sfFile.vRefNum );*/ /* change to directory of file */
/*m*/ /*SetVol( "\p", outputfileinfo.sfFile.parID );*/ /* change to directory of file */
/*outputfileinfo.sfType = mage1+mage2+mage3+mage4;*/
/*c*/ strcpy(OutfileStr, (const char *)outputfileinfo.sfFile.name);
/*store file name to be opened later*/
#endif
/*m*/ PtoCstr((unsigned char *)OutfileStr);
/* convert file name from Pascal to C type string */
#ifdef OLDWAYTELL
sprintf(alertstr,"OLDWAY: OutfileStr== %s\015 reply.vRefNum== %d"
,OutfileStr,reply.vRefNum);
DoReportDialog();
#endif
#ifdef NEWWAYTELL
sprintf(alertstr,"NEWWAY: OutfileStr== %s\015 outputfileinfo.sfFile.vRefNum== %d"
"\015 outputfileinfo.sfFile.parID== %d"
,OutfileStr,outputfileinfo.sfFile.vRefNum,outputfileinfo.sfFile.parID);
DoReportDialog();
#endif
/*if a previous file is open, close it*/
/*c*/ if(fpoutput != NULL) fclose(fpoutput);
if(Lappend)
fpoutput = fopen(OutfileStr,"a");
else
fpoutput = fopen(OutfileStr,"w");
if (fpoutput == NULL)
{
/*c*/ sprintf(alertstr,"Prekin failed to open file: \n%s ",OutfileStr);
/*Ms*/ DoReportDialog();
ireturn = 0;
}
else /* file opened, write header into it */
{
#ifdef OLDWAY
FSMakeFSSpec(reply.vRefNum, 0, reply.fName, &(outputfileinfo.sfFile));
FSpGetFInfo(&(outputfileinfo.sfFile), &filefinderinfo);
/*change creator*/
filefinderinfo.fdCreator = mage1+mage2+mage3+mage4;
FSpSetFInfo(&(outputfileinfo.sfFile), &filefinderinfo);
#endif
#ifdef NEWWAY
FSpGetFInfo(&(outputfileinfo.sfFile), &filefinderinfo);
/*change creator*/
filefinderinfo.fdCreator = mage1+mage2+mage3+mage4;
FSpSetFInfo(&(outputfileinfo.sfFile), &filefinderinfo);
#endif
if(Ltestprint)
{
/*c*/ sprintf(alertstr,"opened file: %s ",OutfileStr);
/*Ms*/ DoReportDialog();
}
Lfpoutput = 1; /*flag for successfully opened fpoutput*/
/* file opened, prepare to write header into it*/
Ldid_outfiletext = 0; /*DO NOT do the @text yet */
/*wait until chance to get Header stuff from PDB file*/
inittextblock(&headerstuff); /*PKINSCRT.c*/
/* disposetextblock(&headerstuff);*/ /*PKINSCRT.c*/
Lnewpass = 1;
AdjustMenus(); /*____MENU.C*/
/*and now go back into the masterloop*/
ireturn = 1;
}
Lgot_outfilename = 1; /*to keep book */
/*prepareoutputfile();*/ /*this is already done*/
Lfpoutput = 1; /* flag for successfully opened fpoutput*/
Lgot_outfileopen = 1; /*to keep book */
}/*good outputfile info*/
else
{
ireturn = 0; /*canceled file select procedure*/
}
return(ireturn);
}
/*___openoutput()___________________________________________________________*/
/****openscriptout()*********************************************************/
int openscriptout(void)
{
Point where;
SFReply reply;
int ireturn;
/*m*/ SetPt( &where, 85, 100 ); /* position of display box on screen */
/*m*/ CtoPstr(ScriptoutStr);
/* convert output file name from C to Pascal type string */
/* invoke the standard dialog for finding a file */
/*m*/ SFPutFile( where, "\p output Script file:",
(unsigned char *)ScriptoutStr, NULL, &reply );
if( reply.good )
{
/* In newer hierarchical directory system,*/
/* reply.vRefNum holds directory number */
/*m*/ SetVol( "\p", reply.vRefNum ); /* change to directory of file */
/*c*/ strcpy(ScriptoutStr, (const char *)reply.fName);
/* store file name to be opened later */
/*m*/ PtoCstr((unsigned char *)ScriptoutStr);
/* convert input file name from Pascal to C type string */
/*if a previous file is open, close it*/
/*c*/ if(fpscriptout != NULL) fclose(fpscriptout);
/*c*/ if ((fpscriptout = fopen(ScriptoutStr,"w")) == NULL)
{
/*c*/ sprintf(alertstr,"Prekin failed to open file: \n%s "
,ScriptoutStr);
/*Ms*/ DoReportDialog();
ireturn = 0;
}
else /* file opened, write header into it */
{
/*c*/ fprintf(fpscriptout,"{script for coord file: %s }"EOLO,NameStr);
ireturn = 1;
}
}
else
{
ireturn = 0; /*canceled file select procedure*/
}
return(ireturn);
}
/*___openscriptout()________________________________________________________*/