1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/* ++++++++++++++++++++++++++++++++++++++++++++++++++
30
.IDENTIFICATION main module HELPER
31
.AUTHOR K. Banse ESO - Garching
32
.ENVIRONMENT VMS + UNIX
33
.KEYWORDS help facility
35
display help information
37
real work is done in function `helpme' (in file helpme.c)
39
the following keywords are used:
41
IN_A/C/1/60 help command/qualif help_string (=command/qualif)
42
or ^context_name if called from context.prg
43
in that case, save context dir in FORGRxy.CTX
44
INPUTC/C/1/80 currently enabled contexts
45
OUTPUTC/C/1/80 currently enabled contexts
47
.VERSION [9.00] 920423: split up into more subroutines + prepare for UIMX
50
-------------------------------------------------- */
67
static int nolns, exemod, ulevl, lcount;
75
int ec, ed, el, ln0, ln1;
76
int iav, logfl[11], nullo, nlog, mmod[2];
81
char versio[16], conxt[10], cbufa[82], cbuf[82], lina[80], *pbuf;
85
/* get into MIDAS, save current error values + do not stop on errors */
87
(void)SCSPRO("HELPER");
88
(void)SCECNT("GET",&ec,&el,&ed);
90
(void)SCECNT("PUT",&ln1,&ln0,&ln0);
93
/* get log flags + user level */
95
(void)SCKRDI("MID$MODE",3,2,&iav,mmod,&unit,&nullo);
97
(void)SCKRDI("AUX_MODE",1,8,&iav,logfl,&unit,&nullo);
99
(void)SCKRDI("LOG",1,11,&iav,logfl,&unit,&nullo);
102
nolns = logfl[10] - 2;
103
if ((prlog == 0) && (logfl[2] == 0)) SCKWRI("LOG",&logfl[2],1,1,&unit);
105
(void)SCKRDI("ERROR",2,1,&iav,&ln0,&unit,&nullo);
107
if ((mmod[1] > 0) || (prlog != 0))
108
ulevl = 2; /* force to expert in batch + printmode */
110
lcount = 0; /* init line count */
111
(void)SCKGETC("MID$SESS",11,2,&iav,versio); /* get Midas unit */
112
pbuf = getenv("MIDVERS");
113
(void) strcpy(&versio[2],pbuf); /* append Midas version */
116
/* get enabled contexts */
118
memset((void *)cbufa,32,(size_t)80);
120
(void)SCKRDC("INPUTC",1,1,80,&iav,cbufa,&unit,&nullo);
122
(void)SCKRDC("OUTPUTC",1,1,80,&iav,cbuf,&unit,&nullo);
125
/* get command line */
127
(void)SCKGETC("IN_A",1,60,&iav,lina);
130
/* is it ^blabla from context.prg or normal help command ? */
132
if (lina[0] == '^') /* special context dir command */
135
char ctxdir[104], frame[120], record[120], mwdir[100];
137
(void) strncpy(conxt,&lina[1],8); /* get 8 char context name */
139
mm = CGN_INDEXC(conxt,'.'); /* abc.ctx */
142
for (kk=mm; kk<8; kk++) conxt[kk] = ' ';
147
/* get full context specs + isolate directory */
149
(void) SCKGETC("FULLFILE",1,100,&iav,ctxdir);
150
ctxdir[iav-mm-4] = '\0';
152
(void) OSY_TRNLOG("MID_WORK",mwdir,99,&iav);
153
(void) strcpy(frame,mwdir);
154
(void) strcpy(lina,"FORGR .CTX");
157
(void) strcat(frame,lina);
159
fp = CGN_OPEN(frame,READ); /* just to see, if file exists */
162
fp = CGN_OPEN(frame,WRITE); /* create new file */
165
sprintf(frame,"Could not open FORGR%c%c.CTX in MID_WORK...",
166
versio[0],versio[1]);
171
(void) strncpy(record,conxt,8);
172
(void) strcpy(&record[8],ctxdir);
173
(void) osawrite(fp,record,(int)strlen(record));
182
(void) strcpy(grame,frame);
183
(void) strcat(grame,"new");
184
gp = CGN_OPEN(grame,WRITE); /* open new file for copying */
188
memset((void *)record,32,(size_t)100);
189
iav = osaread(fp,record,100); /* look for context in file */
192
{ /* not found, so add to the end */
195
{ /* append new record */
196
(void) strncpy(record,conxt,8);
197
(void) strcpy(&record[8],ctxdir);
198
(void) osawrite(gp,record,(int)strlen(record));
201
(void) osfrename(grame,frame);
205
if (strncmp(conxt,record,8) == 0)
207
(void) strcpy(&record[8],ctxdir); /* direc could have changed */
209
} /* copy to new frame */
210
(void) osawrite(gp,record,(int)strlen(record));
216
else /* we do everything in helpme */
217
helpme(1,versio,lina,cbufa,cbuf);
220
logfl[0] = nlog; /* reset key LOG(1) */
221
(void)SCKWRI("LOG",logfl,1,1,&unit);
230
/* this function must be synchronized with the one in dspout.c !!! */
233
char *record; /* IN: string to be displayed */
243
/* throw away the '\' and '|' characters */
245
if (record[0] != '\0')
248
for (nr=0; nr<99; nr++)
250
if (record[nr] == '\0')
252
else if ( (record[nr] == '\\') &&
253
((record[nr+1] != 'a') || (record[nr+2] != 'g')) )
255
if (nr == 0) return (0); /* new line */
257
else if (record[nr] == '|')
260
return (0); /* new line */
261
else if (record[nr-1] == '\\')
262
reco[n++] = record[nr]; /* "\|" -> "|" */
263
else if ( (record[nr-1] != ' ') && (record[nr+1] != ' ') )
264
reco[n++] = record[nr]; /* x|y is o.k. */
267
reco[n++] = record[nr]; /* copy character */
277
SCTPUT(reco); /* display on terminal + log */
280
/* if exemod != 1, check no. of lines on terminal screen ... */
295
/* for novice + user level we ask */
297
(void)printf("\n\rhit return to continue, 'q' + return to quit ");
300
if ((reco[0] == 'Q') || (reco[0] == 'q'))
301
return (1); /* indicate, that we quit */
312
/* this function must be synchronized with the one in dspout.c !!! */
314
void prepmem(yourpntr)