4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
32 #include <dos/dostags.h>
34 #define MAXCOMMANDLEN 510
37 struct dopusfuncpar
*par
;
40 if (status_flags
&STATUS_IANSCRAP
) {
41 par
->which
=FLAG_OUTWIND
;
47 par
->which
=FLAG_OUTWIND
|FLAG_WB2F
|FLAG_DOPUSF
|FLAG_CDSOURCE
;
50 par
->key
=par
->qual
=par
->type
=0;
51 par
->pri
=config
->priority
; par
->stack
=8000;
54 void dofunctionstring(func
,name
,title
,pars
)
55 char *func
,*name
,*title
;
56 struct dopusfuncpar
*pars
;
59 int a
,b
,c
,lb
,ls
,run
=1,noloop
=0,norm
=1;
60 struct Directory
*curcf
;
61 struct function_data
*funcdata
;
63 D(bug("dofunctionstring(%s,%s,%s,%lx)\n",func
?func
:"<NULL>",name
?name
:"<NULL>",title
?title
:"<NULL>",pars
));
64 if (!func
|| !func
[0] ||
65 !(funcdata
=LAllocRemember(&general_key
,sizeof(struct function_data
),MEMF_CLEAR
))) return;
68 status_flags
&=~STATUS_VERIFYFAIL
;
69 if (Window
&& !(status_flags
&STATUS_FROMHOTKEY
)) busy();
71 funcdata
->activewin
=data_active_window
;
72 funcdata
->inactivewin
=1-data_active_window
;
74 funcdata
->file_request
.window
=Window
;
75 funcdata
->file_request
.lines
=15;
77 if (func_external_file
[0]) {
78 D(bug("file: %s\n",func_external_file
));
80 if ((ptr
=BaseName(func_external_file
)))
81 strcpy(func_single_file
,ptr
);
82 strcpy(funcdata
->source_path
,func_external_file
);
83 if ((ptr
=BaseName(funcdata
->source_path
))) *ptr
=0;
85 if (!status_iconified
)
86 strcpy(funcdata
->dest_path
,str_pathbuffer
[data_active_window
]);
87 funcdata
->activewin
=1-data_active_window
;
88 funcdata
->inactivewin
=data_active_window
;
90 else if (func_single_file
[0]) noloop
=1;
91 else if (status_iconified
) norm
=0;
92 else funcdata
->entry_first
=checkalltot(dopus_curwin
[funcdata
->activewin
]);
95 strcpy(funcdata
->source_path
,str_arcorgname
[0]?"T:":str_pathbuffer
[funcdata
->activewin
]);
96 strcpy(funcdata
->dest_path
,str_pathbuffer
[funcdata
->inactivewin
]);
99 status_justabort
=status_haveaborted
=0;
104 curcf
=funcdata
->entry_first
;
107 if (c
>0 && func
[b
]=='|' && lb
) {
108 fbuf
[c
-1]=0; if (ls
>-1) fbuf
[ls
]=0;
110 if (handlefunctionss(fbuf
,name
,title
,pars
,funcdata
) ||
111 status_flags
&STATUS_VERIFYFAIL
) {
117 if (c
>0 || !(_isspace(func
[b
]))) {
118 if (func
[b
]=='|' && func
[b
+1]=='|') lb
=1;
119 else if (_isspace(func
[b
])) {
128 fbuf
[c
]=0; if (ls
>-1) fbuf
[ls
]=0;
129 if (handlefunctionss(fbuf
,name
,title
,pars
,funcdata
) ||
130 status_flags
&STATUS_VERIFYFAIL
) run
=0;
132 if (!pars
|| !(pars
->which
&FLAG_DOALL
) || status_justabort
|| status_haveaborted
||
133 status_flags
&STATUS_VERIFYFAIL
|| !run
|| func_single_file
[0] || noloop
||
134 !funcdata
->external_flag
) break;
136 if (curcf
&& curcf
==funcdata
->entry_first
)
137 funcdata
->entry_first
=funcdata
->entry_first
->next
;
139 while (funcdata
->entry_first
) {
140 if (funcdata
->entry_first
->selected
) break;
141 funcdata
->entry_first
=funcdata
->entry_first
->next
;
144 if (!funcdata
->entry_first
) break;
145 funcdata
->arg_use
=funcdata
->arg_first
;
146 ++funcdata
->function_count
;
148 closescriptfile(pars
,run
,funcdata
);
149 func_single_file
[0]=0;
150 func_external_file
[0]=0;
151 LFreeRemEntry(&general_key
,(char *)funcdata
);
153 if (norm
&& Window
) {
154 for (a
=0;a
<2;a
++) check_old_buffer(a
);
158 int handlefunctionss(funcbuf
,name
,title
,pars
,funcdata
)
159 char *funcbuf
,*name
,*title
;
160 struct dopusfuncpar
*pars
;
161 struct function_data
*funcdata
;
163 int function
,abort
=0,a
,b
;
165 struct dopusfuncpar par
;
166 struct Directory
*didselect
=NULL
;
168 func_single_entry
=NULL
;
170 if (funcbuf
[0]==FC_INTERNAL
) {
172 for (a
=0;a
<b
;a
++) if (funcbuf
[a
]=='{') break;
174 char buf2
[256],newfunc
[MAXCOMMANDLEN
];
176 parserunline(funcbuf
,buf2
);
177 if (!(buildcustfunc(buf2
,strlen(funcbuf
),newfunc
,NULL
,0,0,0,funcdata
)))
181 if ((function
=getfunction(funcbuf
,&funcptr
))!=-1) {
182 if (function
!=FUNC_HELP
&& status_flags
&STATUS_HELP
) {
183 dohelp(name
,funcbuf
,pars
?pars
->key
:0,pars
?pars
->qual
:0,NULL
);
186 else if (function
==FUNC_ENDFUNCTION
) closescriptfile(pars
,1,funcdata
);
188 func_entry_deleted
=0;
189 if (func_single_file
[0]) {
190 if (func_external_file
[0]) {
191 if (filloutdummy(func_external_file
,&funcdata
->entry_external
)) {
192 funcdata
->entry_external
.selected
=0;
193 func_single_entry
=&funcdata
->entry_external
;
196 else if ((func_single_entry
=
197 findfile(dopus_curwin
[funcdata
->activewin
],func_single_file
,NULL
))) {
198 func_single_entry
->selected
=1;
199 updateselectinfo(func_single_entry
,funcdata
->activewin
,0);
200 didselect
=func_single_entry
;
204 global_swap_window
=FALSE
;
206 D(bug("handlefunctionss():funcbuf:\t%s\n\tname:\t%s\n\ttitle:\t%s\n\tfuncptr:\t%s\n",funcbuf
?funcbuf
:"<NULL>",name
?name
:"<NULL>",title
?title
:"<NULL>",funcptr
?funcptr
:"<NULL>"));
208 func_global_function
=function
;
209 rexxdisp(NULL
,NULL
,funcptr
);
210 if (func_global_function
)
211 abort
=internal_function(func_global_function
,rexx_global_flag
,
212 funcdata
->source_path
,funcdata
->dest_path
);
213 func_global_function
=0;
215 else abort
=internal_function(function
,0,funcdata
->source_path
,funcdata
->dest_path
);
217 if (global_swap_window
) {
218 funcdata
->activewin
=data_active_window
;
219 funcdata
->inactivewin
=1-data_active_window
;
221 strcpy(funcdata
->source_path
,str_pathbuffer
[funcdata
->activewin
]);
222 strcpy(funcdata
->dest_path
,str_pathbuffer
[funcdata
->inactivewin
]);
224 funcdata
->entry_first
=checkalltot(dopus_curwin
[funcdata
->activewin
]);
227 if (didselect
&& !func_entry_deleted
&& didselect
->selected
) {
228 didselect
->selected
=0;
229 updateselectinfo(didselect
,funcdata
->activewin
,0);
231 func_single_entry
=NULL
; func_entry_deleted
=0;
236 funcdata
->external_flag
=1;
237 if (status_flags
&STATUS_HELP
) {
238 dohelp(name
,funcbuf
,pars
?pars
->key
:0,pars
?pars
->qual
:0,NULL
);
242 if (pars
) CopyMem((char *)pars
,(char *)&par
,sizeof(struct dopusfuncpar
));
243 else defaultpar(&par
);
244 switch (funcbuf
[0]) {
245 case FC_WORKBENCH
: par
.type
=FT_WORKBENCH
; ++funcbuf
; break;
246 case FC_BATCH
: par
.type
=FT_BATCH
; ++funcbuf
; break;
247 case FC_AREXX
: par
.type
=FT_AREXX
; ++funcbuf
; break;
248 case FC_CHDIR
: par
.type
=FT_CHDIR
; ++funcbuf
; break;
249 default: par
.type
=FT_EXECUTABLE
; break;
251 if (!(customthing(name
,title
,funcbuf
,&par
,funcdata
))) abort
=1;
257 int getfunction(func
,funcptr
)
258 char *func
,**funcptr
;
262 if (funcptr
) *funcptr
=NULL
;
263 if (!func
) return(-1);
264 if (func
[0]==FC_INTERNAL
) {
267 if (commandlist
[b
].name
==NULL
) break;
268 a
=strlen(commandlist
[b
].name
);
269 if (Strnicmp(commandlist
[b
].name
,&func
[1],a
)==0 &&
270 (_isspace(func
[a
+1]) || func
[a
+1]==0)) {
271 if (funcptr
&& func
[a
+1]) *funcptr
=&func
[a
+1];
272 return((int)commandlist
[b
].function
);
280 int customthing(name
,title
,function
,par
,funcdata
)
281 char *name
,*title
,*function
;
282 struct dopusfuncpar
*par
;
283 struct function_data
*funcdata
;
285 int moretodo
,a
,b
,len
,retval
,type
,count
;
286 unsigned char buf
[256],*ptr
;
287 char buf2
[MAXCOMMANDLEN
],tbuf
[512];
288 struct args
*usearg
,*endarg
;
290 if ((!name
|| !name
[0]) && (!function
|| !function
[0])) return(1);
291 if (Window
&& !status_iconified
&& !(status_flags
&STATUS_FROMHOTKEY
)) {
292 if (title
) dostatustext(title
);
293 else if (name
) dostatustext(name
);
298 if (type==FT_AREXX) {
299 rexx_command(function,NULL);
303 if (type
!= FT_AREXX
)
305 if (!(openscriptfile(par
,funcdata
))) return(0);
306 if (type
==FT_CHDIR
) {
308 for (a
=1;a
<b
;a
++) if (function
[a
]=='!') break;
309 LStrnCpy(buf2
,&function
[1],a
-1);
310 lsprintf(tbuf
,"CD %s\n",buf2
);
311 Write(funcdata
->output_file
,tbuf
,strlen(tbuf
));
318 if (type
!= FT_AREXX
)
320 ptr
=(unsigned char *)name
;
322 if (*ptr
==';') *ptr
='\n';
325 lsprintf(tbuf
,"%s\n",name
);
326 Write(funcdata
->output_file
,tbuf
,strlen(tbuf
));
330 parserunline(function
,buf
);
333 if (*ptr
==';') *ptr
='\n';
336 len
=strlen((char *)buf
);
337 count
=funcdata
->function_count
;
338 endarg
=usearg
=funcdata
->arg_use
;
341 if (status_haveaborted
) {
342 if (type
!= FT_AREXX
) closescriptfile(NULL
,0,funcdata
);
348 if (!(buildcustfunc(buf
,len
,buf2
,&moretodo
,par
->which
&FLAG_RECURSE
,par
->which
&FLAG_RELOAD
,
349 ((par
->which
&FLAG_NOQUOTE
)?0:1),funcdata
))) {
350 if (type
!= FT_AREXX
) closescriptfile(NULL
,0,funcdata
);
354 D(bug("customthing(): buf2 = %s\n",buf2
));
355 if (type
== FT_AREXX
) rexx_command(buf2
,NULL
);
358 if (type
==FT_BATCH
) strcpy(tbuf
,"Execute ");
359 else if (type
==FT_WORKBENCH
) lsprintf(tbuf
,"\"%s\" -r ",str_dopusrt_path
);
361 Write(funcdata
->output_file
,tbuf
,strlen(tbuf
));
363 lsprintf(tbuf
,"%s\n",buf2
);
364 Write(funcdata
->output_file
,tbuf
,strlen(tbuf
));
366 //D(bug("customthing: moretodo=%ld, funcdata: entry_first=%lx, file_request.filearray=%lx\n",moretodo,funcdata->entry_first,funcdata->file_request.filearray));
368 (funcdata
->entry_first
|| funcdata
->file_request
.filearray
)) goto domorestuff
;
369 if (!funcdata
->recursive_path
) break;
371 //D(bug("customthing: domorestuff\n"));
372 funcdata
->function_count
=-1;
373 endarg
=funcdata
->arg_use
;
374 if (usearg
) funcdata
->arg_use
=usearg
->next
;
375 if (!funcdata
->arg_use
) funcdata
->arg_use
= usearg
? usearg
: funcdata
->arg_first
;
377 //D(bug("customthing: end loop\n"));
378 funcdata
->function_count
=count
;
379 funcdata
->arg_use
=endarg
;
380 if (funcdata
->activewin
>-1)
381 funcdata
->entry_first
=checkalltot(dopus_curwin
[funcdata
->activewin
]);
383 if (funcdata
->file_request
.filearray
) {
384 LFreeRemember(&funcdata
->file_request
.filearraykey
);
385 funcdata
->file_request
.filearray
=NULL
;
390 int buildcustfunc(function
,line_len
,buffer
,moretodo
,star
,reload
,quote
,funcdata
)
391 unsigned char *function
;
394 int *moretodo
,star
,reload
,quote
;
395 struct function_data
*funcdata
;
397 char buf3
[256],*ptr
,filebuf
[FILEBUF_SIZE
],dirbuf
[256],*spath
,defbuf
[256],titlebuf
[80];
398 int a
,pos
,bufpos
,d
,f
,sblen
,buftitpos
,h
,qad
,def
,tit
;
399 struct Directory
*cust
=NULL
,dummy
;
402 /*buffer[0]=buf3[0]=*/dirbuf
[0]=0;
405 bzero(buffer
,MAXCOMMANDLEN
);
407 // for (bufpos=0;bufpos<500;bufpos++) buffer[bufpos]=buf3[bufpos]=0;
410 sblen
=strlen(funcdata
->source_path
);
412 //D(bug("buildcustfunc: function = %s\n",function));
413 for (pos
=0;pos
<line_len
;pos
++) {
414 switch (function
[pos
]) {
416 case FUNC_ONEFILE_NO
:
417 if (!func_single_file
[0]) {
418 if (status_iconified
|| status_flags
&STATUS_FROMHOTKEY
) {
419 if (getdummyfile(&dummy
,dirbuf
,&funcdata
->file_request
)) cust
=&dummy
;
422 else /*if (!funcdata->recursive_path)*/ cust
=custgetfirst(funcdata
);
424 strcpy(funcdata
->last_file
,funcdata
->source_path
);
425 TackOn(funcdata
->last_file
,cust
->name
,256);
426 if (!funcdata
->recursive_path
&& cust
->type
>0) {
428 LFreeRemember(&rec_pathkey
);
429 funcdata
->entry_current
=cust
;
430 StrCombine(buf3
,funcdata
->source_path
,cust
->name
,256);
431 if (recursedir(buf3
,NULL
,R_STARDIR
,strlen(funcdata
->source_path
)))
433 setdirsize(cust
,dos_global_bytecount
,funcdata
->activewin
);
434 funcdata
->recursive_path
=rec_firstpath
;
438 bufpos
+=addfilename(buffer
,cust
->name
,NULL
,quote
);
439 if (function
[pos
]!=FUNC_ONEFILE_NO
) {
440 custunselect(cust
,reload
,funcdata
);
441 custnextsel(&funcdata
->entry_first
);
447 if (funcdata
->recursive_path
) {
448 bufpos
+=addfilename(buffer
,funcdata
->recursive_path
->path
,NULL
,quote
);
449 if (!(funcdata
->recursive_path
=funcdata
->recursive_path
->next
) &&
450 function
[pos
]!=FUNC_ONEFILE_NO
)
451 custunselect(funcdata
->entry_current
,reload
,funcdata
);
454 bufpos
+=addfilename(buffer
,cust
->name
,NULL
,quote
);
455 if (function
[pos
]!=FUNC_ONEFILE_NO
) {
456 custunselect(cust
,reload
,funcdata
);
457 custnextsel(&funcdata
->entry_first
);
464 strcpy(funcdata
->last_file
,func_single_file
);
465 bufpos
+=addfilename(buffer
,func_single_file
,NULL
,quote
);
470 case FUNC_ALLFILES_NO
:
471 if (!func_single_file
[0]) {
473 if (status_iconified
|| status_flags
&STATUS_FROMHOTKEY
) {
474 if (getdummyfile(&dummy
,dirbuf
,&funcdata
->file_request
)) cust
=&dummy
;
477 else cust
=custgetfirst(funcdata
);
478 while (a
<(MAXCOMMANDLEN
-1) && (cust
|| funcdata
->recursive_path
)) {
479 //if (cust) D(bug("cust->name: %s\n",cust->name));
480 if (funcdata
->recursive_path
|| (cust
->selected
&& cust
->type
!=0)) {
481 if (!funcdata
->recursive_path
&& cust
->type
>0) {
483 LFreeRemember(&rec_pathkey
);
484 funcdata
->entry_current
=cust
;
485 StrCombine(buf3
,funcdata
->source_path
,cust
->name
,256);
486 if (recursedir(buf3
,NULL
,R_STARDIR
,strlen(funcdata
->source_path
)))
488 setdirsize(cust
,dos_global_bytecount
,funcdata
->activewin
);
489 funcdata
->recursive_path
=rec_firstpath
;
493 if ((a
+strlen(cust
->name
)+qad
)>(MAXCOMMANDLEN
-1)) break;
494 addfilename(buffer
,cust
->name
,NULL
,quote
);
495 if (function
[pos
]!=FUNC_ALLFILES_NO
)
496 custunselect(cust
,reload
,funcdata
);
501 if (funcdata
->recursive_path
) {
502 if ((a
+strlen(funcdata
->recursive_path
->path
)+qad
)>(MAXCOMMANDLEN
-1)) break;
503 addfilename(buffer
,funcdata
->recursive_path
->path
,NULL
,quote
);
504 if (!(funcdata
->recursive_path
=funcdata
->recursive_path
->next
)) {
505 if (function
[pos
]!=FUNC_ALLFILES_NO
)
506 custunselect(funcdata
->entry_current
,reload
,funcdata
);
510 if ((a
+strlen(cust
->name
)+qad
)>(MAXCOMMANDLEN
-1)) break;
511 addfilename(buffer
,cust
->name
,NULL
,quote
);
512 if (function
[pos
]!=FUNC_ALLFILES_NO
)
513 custunselect(cust
,reload
,funcdata
);
516 StrConcat(buffer
," ",MAXCOMMANDLEN
);
519 if (!funcdata
->recursive_path
) {
520 if (cust
) cust
=cust
->next
;
522 //D(bug("buffer: %s\n",buffer));
524 if (!funcdata
->recursive_path
) {
525 //D(bug("funcdata->entry_first: %s\t",funcdata->entry_first->name));
526 custnextsel(&funcdata
->entry_first
);
527 //D(bug("->\tfuncdata->entry_first: %s\n",funcdata->entry_first->name));
530 if (moretodo
) *moretodo
=1;
533 bufpos
+=addfilename(buffer
,func_single_file
,NULL
,quote
);
534 StrConcat(buffer
," ",MAXCOMMANDLEN
);
540 case FUNC_ONEPATH_NO
:
541 //D(bug("buildcustfunc(): func_single_file=\"%s\"\n",func_single_file));
542 if (!func_single_file
[0]) {
543 if (status_iconified
|| status_flags
&STATUS_FROMHOTKEY
) {
544 if (getdummyfile(&dummy
,dirbuf
,&funcdata
->file_request
)) cust
=&dummy
;
546 TackOn(dirbuf
,NULL
,256);
550 /*if (!funcdata->recursive_path)*/ cust
=custgetfirst(funcdata
);
551 spath
=funcdata
->source_path
;
553 //D(bug("cust = %lx\n",cust));
555 strcpy(funcdata
->last_file
,spath
);
556 TackOn(funcdata
->last_file
,cust
->name
,256);
557 //D(bug("funcdata->last_file = %s\n",funcdata->last_file));
558 if (!funcdata
->recursive_path
&& cust
->type
>0) {
560 LFreeRemember(&rec_pathkey
);
561 funcdata
->entry_current
=cust
;
562 StrCombine(buf3
,spath
,cust
->name
,256);
563 //D(bug("recurse -> calling recursedir(%s)\n",buf3));
564 if (recursedir(buf3
,NULL
,R_STARDIR
,0)) return(0);
565 setdirsize(cust
,dos_global_bytecount
,funcdata
->activewin
);
566 funcdata
->recursive_path
=rec_firstpath
;
567 //D(bug("recursive_path = %s,%lx\n",funcdata->recursive_path->path,funcdata->recursive_path->next));
571 //D(bug("no recurse\n"));
572 bufpos
+=addfilename(buffer
,spath
,cust
->name
,quote
);
573 if (function
[pos
]!=FUNC_ONEPATH_NO
) {
574 custunselect(cust
,reload
,funcdata
);
575 custnextsel(&funcdata
->entry_first
);
581 if (funcdata
->recursive_path
) {
582 bufpos
+=addfilename(buffer
,funcdata
->recursive_path
->path
,NULL
,quote
);
583 funcdata
->recursive_path
=funcdata
->recursive_path
->next
;
584 if ((funcdata
->recursive_path
==NULL
) && (function
[pos
]!=FUNC_ONEPATH_NO
))
585 custunselect(funcdata
->entry_current
,reload
,funcdata
);
588 bufpos
+=addfilename(buffer
,spath
,cust
->name
,quote
);
589 if (function
[pos
]!=FUNC_ONEPATH_NO
) {
590 custunselect(cust
,reload
,funcdata
);
591 custnextsel(&funcdata
->entry_first
);
598 bufpos
+=addfilename(buffer
,funcdata
->source_path
,func_single_file
,quote
);
599 strcpy(funcdata
->last_file
,funcdata
->source_path
);
600 TackOn(funcdata
->last_file
,func_single_file
,256);
605 case FUNC_ALLPATHS_NO
:
606 if (!func_single_file
[0]) {
608 if (status_iconified
|| status_flags
&STATUS_FROMHOTKEY
) {
609 if (getdummyfile(&dummy
,dirbuf
,&funcdata
->file_request
)) cust
=&dummy
;
611 TackOn(dirbuf
,NULL
,256);
615 cust
=custgetfirst(funcdata
);
616 spath
=funcdata
->source_path
;
618 while (a
<MAXCOMMANDLEN
&& (cust
|| funcdata
->recursive_path
)) {
619 if (funcdata
->recursive_path
|| (cust
->selected
&& cust
->type
!=0)) {
620 if (!funcdata
->recursive_path
&& cust
->type
>0) {
622 LFreeRemember(&rec_pathkey
);
623 funcdata
->entry_current
=cust
;
624 StrCombine(buf3
,spath
,cust
->name
,256);
625 if (recursedir(buf3
,NULL
,R_STARDIR
,0)) return(0);
626 setdirsize(cust
,dos_global_bytecount
,funcdata
->activewin
);
627 funcdata
->recursive_path
=rec_firstpath
;
631 if ((a
+strlen(cust
->name
)+strlen(spath
)+qad
)>(MAXCOMMANDLEN
-1)) break;
632 addfilename(buffer
,spath
,cust
->name
,quote
);
633 if (function
[pos
]!=FUNC_ALLPATHS_NO
)
634 custunselect(cust
,reload
,funcdata
);
639 if (funcdata
->recursive_path
) {
640 if ((a
+strlen(funcdata
->recursive_path
->path
)+qad
)>(MAXCOMMANDLEN
-1)) break;
641 addfilename(buffer
,funcdata
->recursive_path
->path
,NULL
,quote
);
642 if (!(funcdata
->recursive_path
=funcdata
->recursive_path
->next
)) {
643 if (function
[pos
]!=FUNC_ALLPATHS_NO
)
644 custunselect(funcdata
->entry_current
,reload
,funcdata
);
648 if ((a
+strlen(cust
->name
)+strlen(spath
)+qad
)>(MAXCOMMANDLEN
-1)) break;
649 addfilename(buffer
,spath
,cust
->name
,quote
);
650 if (function
[pos
]!=FUNC_ALLPATHS_NO
)
651 custunselect(cust
,reload
,funcdata
);
654 StrConcat(buffer
," ",MAXCOMMANDLEN
);
657 if (!funcdata
->recursive_path
) {
658 if (cust
) cust
=cust
->next
;
659 // custnextsel(&funcdata->entry_first);
662 if (!funcdata
->recursive_path
) {
663 //D(bug("funcdata->entry_first: %s\t",funcdata->entry_first->name));
664 custnextsel(&funcdata
->entry_first
);
665 //D(bug("->\tfuncdata->entry_first: %s\n",funcdata->entry_first->name));
668 if (moretodo
) *moretodo
=1;
671 bufpos
+=addfilename(buffer
,funcdata
->source_path
,func_single_file
,quote
);
672 StrConcat(buffer
," ",MAXCOMMANDLEN
);
679 strcpy(buf3
,funcdata
->source_path
);
680 if ((status_iconified
|| status_flags
&STATUS_FROMHOTKEY
)) {
681 if (dirrequester(&funcdata
->file_request
,buf3
,
682 globstring
[STR_SELECT_SOURCE_DIR
])) {
686 StrConcat(buffer
,buf3
,MAXCOMMANDLEN
);
687 bufpos
=strlen(buffer
);
690 StrConcat(buffer
,funcdata
->source_path
,MAXCOMMANDLEN
);
693 case FUNC_NOSOURCE_RR
:
694 if (function
[pos
]!=FUNC_SOURCE
) funcdata
->rereadsource
=1;
699 if (!(check_dest_path(funcdata
))) return(0);
700 StrConcat(buffer
,funcdata
->dest_path
,MAXCOMMANDLEN
);
701 bufpos
+=strlen(funcdata
->dest_path
);
703 if (function
[pos
]!=FUNC_DEST
) funcdata
->rereaddest
=1;
706 case FUNC_SCREENNAME
:
707 StrConcat(buffer
,str_arexx_portname
,MAXCOMMANDLEN
);
708 bufpos
+=strlen(str_arexx_portname
);
716 switch (function
[pos
]) {
718 /* Public screen name */
720 data
=get_our_pubscreen();
723 /* ARexx port name */
725 data
=str_arexx_portname
;
730 data
=str_last_rexx_result
;
734 if (data
&& data
[0]) {
735 StrConcat(buffer
,data
,MAXCOMMANDLEN
);
736 bufpos
+=strlen(data
);
744 for (pos
++;pos
<line_len
;pos
++) {
745 if (function
[pos
]==FUNC_ENDARG
) break;
746 if (tit
<79) titlebuf
[tit
++]=function
[pos
];
750 // if (system_version2) {
751 if ((a
=GetVar(titlebuf
,buf3
,256,0))>0) {
752 StrConcat(buffer
,buf3
,MAXCOMMANDLEN
);
759 if (funcdata
->function_count
&& funcdata
->arg_use
) {
761 StrConcat(buffer
,funcdata
->arg_use
->argstring
,MAXCOMMANDLEN
);
762 bufpos
+=strlen(funcdata
->arg_use
->argstring
);
763 funcdata
->arg_use
=funcdata
->arg_use
->next
;
764 for (f
=pos
+1;f
<line_len
&& function
[f
]!=FUNC_ENDARG
;f
++);
769 if (funcdata
->function_count
==-1 && funcdata
->arg_use
) goto use_old_arg
;
774 for (f
=pos
+1;f
<line_len
;f
++) {
775 if (function
[f
]==FUNC_ENDARG
) break;
776 else if (buftitpos
==-1) {
777 if (function
[f
]==':') buftitpos
=f
+1;
778 else if (tit
<79) titlebuf
[tit
++]=function
[f
];
780 else if (def
<255) defbuf
[def
++]=function
[f
];
785 if (!titlebuf
[0]) ptr
=globstring
[STR_ENTER_ARGUMENTS
];
790 build_default_string(defbuf
,buf3
,funcdata
->last_file
,funcdata
->source_path
,funcdata
->dest_path
);
792 if (!(whatsit(ptr
,256,buf3
,NULL
))) {
797 if (function
[pos
]==FUNC_GETARG
) {
798 if (!(arg
=LAllocRemember(&funcdata
->arg_memkey
,sizeof(struct args
),MEMF_CLEAR
)))
800 if (!funcdata
->arg_first
) funcdata
->arg_first
=arg
;
801 else funcdata
->arg_current
->next
=arg
;
802 funcdata
->arg_current
=arg
;
803 strcpy(funcdata
->arg_current
->argstring
,buf3
);
805 StrConcat(buffer
,buf3
,MAXCOMMANDLEN
);
806 bufpos
+=strlen(buf3
);
811 if (funcdata
->file_request
.filearray
) {
813 while (bufpos
<MAXCOMMANDLEN
) {
814 if (funcdata
->file_request
.filearray
[funcdata
->fileargpos
][0]) {
815 if ((bufpos
+strlen(funcdata
->file_request
.filearray
[funcdata
->fileargpos
])+qad
)<MAXCOMMANDLEN
) {
816 bufpos
+=addfilename(buffer
,
817 funcdata
->file_request
.filearray
[funcdata
->fileargpos
],NULL
,quote
);
818 StrConcat(buffer
," ",MAXCOMMANDLEN
); ++bufpos
;
819 ++funcdata
->fileargpos
;
822 if (moretodo
) *moretodo
=1;
826 if (!funcdata
->file_request
.filearray
[funcdata
->fileargpos
][0]) {
827 LFreeRemember(&funcdata
->file_request
.filearraykey
);
828 funcdata
->file_request
.filearray
=NULL
;
832 for (f
=pos
+1;f
<line_len
;f
++)
833 if (function
[f
]==FUNC_ENDARG
|| function
[f
]==0) break;
838 switch (function
[pos
+1]) {
839 case 'f': h
=0; break;
840 case 'F': h
=DFRF_MULTI
; break;
841 case 'd': h
=DFRF_DIRREQ
; break;
842 case 'o': h
=DFRF_FONT
; break;
847 for (f
=pos
+1;f
<line_len
;f
++) {
848 if (function
[f
]==':' && buftitpos
==-1) {
852 if (function
[f
]==FUNC_ENDARG
) {
857 if (!function
[(pos
+1)]) funcdata
->file_request
.title
=globstring
[STR_FILE_REQUEST
];
858 else funcdata
->file_request
.title
=(char *)function
+pos
+1;
861 build_default_string(&function
[buftitpos
],buf3
,funcdata
->last_file
,funcdata
->source_path
,funcdata
->dest_path
);
862 else if (h
&DFRF_FONT
) strcpy(buf3
,"FONTS:");
863 funcdata
->file_request
.dirbuf
=buf3
;
864 funcdata
->file_request
.filebuf
=filebuf
; filebuf
[0]=0;
865 if (!(h
&DFRF_DIRREQ
)) {
868 if (ptr
[(strlen(ptr
)-1)]!='/') {
874 funcdata
->file_request
.flags
=h
;
875 if (FileRequest(&funcdata
->file_request
)) {
877 funcdata
->fileargpos
=0;
880 if (!funcdata
->file_request
.dirbuf
[0])
881 expand_path("",funcdata
->file_request
.dirbuf
);
882 if (!(h
&DFRF_DIRREQ
)) {
883 if (quote
) StrConcat(buffer
,"\"",MAXCOMMANDLEN
);
884 StrConcat(buffer
,funcdata
->file_request
.dirbuf
,MAXCOMMANDLEN
);
885 TackOn(buffer
,filebuf
,MAXCOMMANDLEN
);
886 if (quote
) StrConcat(buffer
,"\"",MAXCOMMANDLEN
);
888 else StrConcat(buffer
,funcdata
->file_request
.dirbuf
,MAXCOMMANDLEN
);
889 bufpos
=strlen(buffer
);
898 buffer
[bufpos
++]=function
[pos
];
901 if (bufpos
==MAXCOMMANDLEN
) break;
903 buffer
[MAXCOMMANDLEN
-1]=0;
907 int addfilename(buf
,part1
,part2
,quote
)
908 char *buf
,*part1
,*part2
;
913 //D(bug("addfilename(%s,%s,%s,%ld\n",buf,part1,part2,quote));
915 if (d
>0 && !(_isspace(buf
[d
-1]))) quote
=0;
918 StrConcat(buf
,"\"",MAXCOMMANDLEN
);
922 StrConcat(buf
,part1
,MAXCOMMANDLEN
);
926 StrConcat(buf
,part2
,MAXCOMMANDLEN
);
930 StrConcat(buf
,"\"",MAXCOMMANDLEN
);
933 //D(bug("buf(%ld): %s\n",strlen(buf),buf));
937 void parserunline(buf
,buf1
)
944 bzero(buf1
,256);//for (c=0;c<256;c++) buf1[c]=0;
954 if (buf
[(b
+1)]=='{') {
960 switch (buf
[(b
+1)]) {
964 if (buf
[(b
+1)]=='A') buf1
[c
]=FUNC_STDARG
;
966 if (buf
[(b
+1)]=='v') buf1
[c
]=FUNC_VARIABLE
;
968 if (buf
[(b
+1)]=='R') {
969 if (buf
[(b
+2)]=='s') {
973 else if (buf
[(b
+2)]=='S') {
977 else buf1
[c
]=FUNC_REQUESTER
;
980 for (d
=(b
+2);d
<a
;d
++) {
981 if (buf
[d
]=='}') break;
986 buf1
[c
++]=FUNC_ENDARG
;
991 buf1
[c
++]=FUNC_QUERYINFO
;
997 switch (buf
[(b
+2)]) {
999 if (buf
[(b
+1)]=='d') buf1
[c
]=FUNC_DEST_RR
;
1000 else if (buf
[(b
+1)]=='s') buf1
[c
]=FUNC_SOURCE_RR
;
1001 else if (buf
[(b
+1)]=='S') buf1
[c
]=FUNC_NOSOURCE_RR
;
1002 else if (buf
[(b
+1)]=='D') buf1
[c
]=FUNC_NODEST_RR
;
1007 if (buf
[(b
+1)]=='o') buf1
[c
]=FUNC_ONEFILE_NO
;
1008 else if (buf
[(b
+1)]=='O') buf1
[c
]=FUNC_ALLFILES_NO
;
1009 else if (buf
[(b
+1)]=='f') buf1
[c
]=FUNC_ONEPATH_NO
;
1010 else if (buf
[(b
+1)]=='F') buf1
[c
]=FUNC_ALLPATHS_NO
;
1015 switch (buf
[(b
+1)]) {
1016 case 'o': buf1
[c
]=FUNC_ONEFILE
; break;
1017 case 'O': buf1
[c
]=FUNC_ALLFILES
; break;
1018 case 's': buf1
[c
]=FUNC_SOURCE
; break;
1019 case 'd': buf1
[c
]=FUNC_DEST
; break;
1020 case 'f': buf1
[c
]=FUNC_ONEPATH
; break;
1021 case 'F': buf1
[c
]=FUNC_ALLPATHS
; break;
1022 case 'p': buf1
[c
]=FUNC_SCREENNAME
; break;
1034 void custunselect(dir
,rel
,funcdata
)
1035 struct Directory
*dir
;
1037 struct function_data
*funcdata
;
1039 struct recpath
*temp
;
1042 win
=funcdata
->activewin
;
1044 if (!status_iconified
&& !(status_flags
&STATUS_FROMHOTKEY
) && !func_external_file
[0]) {
1045 if (rel
&& dir
->name
[0]) {
1046 if ((temp
=LAllocRemember(&funcdata
->reload_memkey
,sizeof(struct recpath
),MEMF_CLEAR
)) &&
1047 (temp
->path
=LAllocRemember(&funcdata
->reload_memkey
,FILEBUF_SIZE
,MEMF_CLEAR
))) {
1048 strcpy(temp
->path
,dir
->name
);
1049 if (funcdata
->reload_current
) funcdata
->reload_current
->next
=temp
;
1050 funcdata
->reload_current
=temp
;
1051 if (!funcdata
->reload_first
) funcdata
->reload_first
=temp
;
1059 void doreloadfiles(funcdata
)
1060 struct function_data
*funcdata
;
1063 struct recpath
*rel
;
1066 rel
=funcdata
->reload_first
;
1067 off
=dopus_curwin
[funcdata
->activewin
]->offset
;
1069 StrCombine(buf
,funcdata
->source_path
,rel
->path
,256);
1070 reload_file(funcdata
->activewin
,buf
);
1073 dopus_curwin
[funcdata
->activewin
]->offset
=off
;
1074 refreshwindow(funcdata
->activewin
,0);
1077 struct Directory
*reload_file(win
,name
)
1081 struct FileInfoBlock __aligned fileinfo
;
1082 struct Directory
*cust
,*ret
=NULL
;
1084 if ((lockandexamine(name
,&fileinfo
))) {
1085 if ((cust
=findfile(dopus_curwin
[win
],fileinfo
.fib_FileName
,NULL
)))
1086 removefile(cust
,dopus_curwin
[win
],win
,FALSE
);
1087 ret
=(struct Directory
*)addfile(dopus_curwin
[win
],
1088 win
,fileinfo
.fib_FileName
,fileinfo
.fib_Size
,
1089 fileinfo
.fib_DirEntryType
,&(fileinfo
.fib_Date
),fileinfo
.fib_Comment
,
1090 fileinfo
.fib_Protection
,0,FALSE
,NULL
,NULL
,fileinfo
.fib_OwnerUID
,fileinfo
.fib_OwnerGID
);
1093 if ((cust
=findfile(dopus_curwin
[win
],BaseName(name
),NULL
)))
1094 removefile(cust
,dopus_curwin
[win
],win
,FALSE
);
1099 int openscriptfile(par
,funcdata
)
1100 struct dopusfuncpar
*par
;
1101 struct function_data
*funcdata
;
1103 struct FileInfoBlock __aligned fileinfo
;
1104 char buf
[256],buf2
[256];
1108 if (funcdata
->output_file
) return(1);
1110 if (par
->which
&FLAG_CDSOURCE
&& !funcdata
->source_path
[0]) {
1111 if (!(simplerequest(globstring
[STR_NO_SOURCE_SELECTED
],
1112 globstring
[STR_CONTINUE
],str_cancelstring
,NULL
))) {
1117 else if (par
->which
&FLAG_CDDEST
&& !funcdata
->dest_path
[0]) {
1118 if (!(simplerequest(globstring
[STR_NO_DESTINATION_SELECTED
],
1119 globstring
[STR_CONTINUE
],str_cancelstring
,NULL
))) {
1125 makereselect(&func_reselection
,funcdata
->activewin
);
1127 main_proc
->pr_WindowPtr
=(APTR
)-1;
1128 if (CheckExist("T:",NULL
)) strcpy(buf
,"T:");
1129 else strcpy(buf
,"RAM:");
1131 if ((lock
=Lock(buf
,ACCESS_READ
))) {
1132 Examine(lock
,&fileinfo
);
1133 if (ExNext(lock
,&fileinfo
)) {
1135 if (LStrnCmp(fileinfo
.fib_FileName
,"dopustemp",9)==0)
1136 lsprintf(funcdata
->scriptname
,"%s%s",buf
,fileinfo
.fib_FileName
);
1137 else funcdata
->scriptname
[0]=0;
1138 a
=ExNext(lock
,&fileinfo
);
1139 if (funcdata
->scriptname
[0]) DeleteFile(funcdata
->scriptname
);
1145 if (config
->errorflags
&ERROR_ENABLE_DOS
) main_proc
->pr_WindowPtr
=(APTR
)Window
;
1147 for (a
=0;a
<100;a
++) {
1148 lsprintf(funcdata
->scriptname
,"%sdopustemp.tmp%ld",buf
,(long int)a
);
1149 if ((funcdata
->output_file
=Open(funcdata
->scriptname
,MODE_NEWFILE
))) break;
1151 if (!funcdata
->output_file
) {
1156 lsprintf(funcdata
->tempfile
,"%sdopusout.tmp%ld",buf
,(long int)a
);
1160 lsprintf(buf
,"\"%s\" -s\n",str_dopusrt_path
);
1161 Write(funcdata
->output_file
,buf
,strlen(buf
));
1163 if (par
->which
&FLAG_SHELLUP
) {
1164 if (config
->shellstartup
[0]) StrCombine(buf
,"S:",config
->shellstartup
,40);
1165 else strcpy(buf
,"S:Shell-Startup");
1166 if (CheckExist(buf
,NULL
)) {
1167 lsprintf(buf2
,"Execute %s\n",buf
);
1168 Write(funcdata
->output_file
,buf2
,strlen(buf2
));
1171 if (par
->which
&FLAG_DOPUSUP
) {
1172 if (CheckExist("S:DOpus-Startup",NULL
))
1173 Write(funcdata
->output_file
,"Execute S:DOpus-Startup\n",24);
1174 else if (CheckExist("S:DOpusShell-Startup",NULL
))
1175 Write(funcdata
->output_file
,"Execute S:DOpusShell-Startup\n",29);
1177 Write(funcdata
->output_file
,"FailAt 999999\n",14);
1180 if (status_flags
&STATUS_FROMHOTKEY
) {
1181 expand_path("",buf2
);
1182 lsprintf(buf
,"CD \"%s\"\n",buf2
);
1185 if (par
->which
&FLAG_CDSOURCE
&& funcdata
->source_path
[0])
1186 lsprintf(buf
,"CD \"%s\"\n",funcdata
->source_path
);
1187 else if (par
->which
&FLAG_CDDEST
) {
1188 if (!(check_dest_path(funcdata
))) return(0);
1189 lsprintf(buf
,"CD \"%s\"\n",funcdata
->dest_path
);
1192 if (buf
[0]) Write(funcdata
->output_file
,buf
,strlen(buf
));
1194 lsprintf(buf
,"Stack %ld\n",(long int)((par
->stack
<4000)?4000:par
->stack
));
1195 Write(funcdata
->output_file
,buf
,strlen(buf
));
1198 lsprintf(buf
,"ChangeTaskPri %ld\n",(long int)par
->pri
);
1199 Write(funcdata
->output_file
,buf
,strlen(buf
));
1205 int closescriptfile(par
,run
,funcdata
)
1206 struct dopusfuncpar
*par
;
1208 struct function_data
*funcdata
;
1210 struct MsgPort
*msgport
;
1211 struct Message
*msg
;
1212 char buf
[256],buf2
[512],portname
[50],pubname
[140];
1213 int wb2f
,setcust
=0,otemp
=0,oldmodes
,okayflag
=0,bit
,flags
=0;
1216 if (run
>0 && par
&& funcdata
->output_file
) {
1218 if (flags
&FLAG_OUTFILE
&& status_flags
&STATUS_FROMHOTKEY
) {
1219 flags
&=~FLAG_OUTFILE
;
1220 flags
|=FLAG_OUTWIND
;
1224 wb2f
=flags
&FLAG_WB2F
;
1228 if (flags
&FLAG_OUTWIND
) {
1229 lsprintf(buf2
,"%s \"%s\" from %s",config
->outputcmd
,config
->output
,funcdata
->scriptname
);
1230 if (!(flags
&FLAG_ASYNC
)) {
1231 lsprintf(portname
,"dopus_run%ld",(long int)system_dopus_runcount
);
1232 if (!(msgport
=LCreatePort(portname
,0))) goto freeargs
;
1236 else lsprintf(buf2
,"%sExecute %s",(flags
&FLAG_ASYNC
)?"Run ":"",funcdata
->scriptname
);
1238 if (flags
&FLAG_OUTWIND
) {
1239 if (par
->delay
!=0) {
1240 lsprintf(buf
,"\"%s\" -w %ld \"%s\"\n",
1242 (long int)par
->delay
,
1243 globstring
[STR_PRESS_MOUSE_BUTTON
]);
1244 Write(funcdata
->output_file
,buf
,strlen(buf
));
1247 lsprintf(buf
,"\"%s\" -p %s\n",str_dopusrt_path
,portname
);
1248 Write(funcdata
->output_file
,buf
,strlen(buf
));
1250 Write(funcdata
->output_file
,"EndCLI >NIL:\n",13);
1253 if (str_arcorgname
[0])
1255 lsprintf(buf
,"Delete \"%s\"\n",funcdata
->last_file
);
1257 Write(funcdata
->output_file
,buf
,strlen(buf
));
1258 str_arcorgname
[0] = 0;
1261 Close(funcdata
->output_file
); funcdata
->output_file
=0;
1263 if (wb2f
&& (!(flags
&FLAG_ASYNC
) || !(flags
&FLAG_DOPUSF
)))
1265 if (flags
&FLAG_OUTWIND
&& !wb2f
&& MainScreen
) {
1266 // if (system_version2) {
1267 oldmodes
=SetPubScreenModes(SHANGHAI
);
1268 GetDefaultPubScreen(pubname
);
1269 SetDefaultPubScreen((UBYTE
*)str_arexx_portname
);
1273 MainScreen->Flags&=~CUSTOMSCREEN;
1274 MainScreen->Flags|=WBENCHSCREEN;
1280 if (flags
&FLAG_OUTFILE
&& (tnil
=Open(funcdata
->tempfile
,MODE_NEWFILE
))) otemp
=1;
1281 if (!tnil
) tnil
=Open("NIL:",MODE_NEWFILE
);
1283 // Execute(buf2,0,(BPTR)tnil);
1284 SystemTags(buf2
,SYS_Input
,Open("NIL:",MODE_OLDFILE
),SYS_Output
,tnil
,SYS_Asynch
,flags
&FLAG_ASYNC
,TAG_END
);
1286 if (flags
&FLAG_OUTWIND
&& !wb2f
&&
1288 !(status_flags
&STATUS_IANSCRAP
) &&
1291 // if (system_version2) {
1292 SetDefaultPubScreen(pubname
);
1293 SetPubScreenModes(oldmodes
);
1297 MainScreen->Flags&=~WBENCHSCREEN;
1298 MainScreen->Flags|=CUSTOMSCREEN;
1304 if (msgport
&& Window
) {
1305 SetSignal(0,INPUTSIG_ABORT
);
1307 if ((bit
=Wait(1<<msgport
->mp_SigBit
|rexx_signalbit
|INPUTSIG_ABORT
))
1309 status_justabort
=status_haveaborted
=0;
1312 if (bit
&rexx_signalbit
) {
1316 if ((msg
=GetMsg(msgport
))) {
1321 LDeletePort(msgport
);
1324 if (!(flags
&FLAG_ASYNC
) && tnil
) Close(tnil
);
1327 // if (system_version2) {
1328 SetDefaultPubScreen(pubname
);
1329 SetPubScreenModes(oldmodes
);
1333 MainScreen->Flags&=~WBENCHSCREEN;
1334 MainScreen->Flags|=CUSTOMSCREEN;
1339 if (flags
&FLAG_DOPUSF
) {
1340 if (MainScreen
) ScreenToFront(MainScreen
);
1341 if (Window
&& !Window
->Flags
&WFLG_BACKDROP
) WindowToFront(Window
);
1344 if (!status_iconified
&& !(status_flags
&STATUS_FROMHOTKEY
)) {
1345 if (funcdata
->rereadsource
|| flags
&FLAG_SCANSRCE
) {
1346 startgetdir(funcdata
->activewin
,0);
1347 funcdata
->reload_first
=NULL
;
1349 if (funcdata
->rereaddest
|| flags
&FLAG_SCANDEST
)
1350 startgetdir(funcdata
->inactivewin
,0);
1351 if (flags
&FLAG_RELOAD
&& funcdata
->reload_first
) doreloadfiles(funcdata
);
1356 if (funcdata
->output_file
) Close(funcdata
->output_file
);
1357 if ((funcdata
->output_file
|| okayflag
) && funcdata
->scriptname
[0] &&
1358 (!par
|| !(flags
&FLAG_ASYNC
)))
1359 DeleteFile(funcdata
->scriptname
);
1360 funcdata
->output_file
=NULL
;
1361 funcdata
->scriptname
[0]=0;
1362 funcdata
->rereaddest
=funcdata
->rereadsource
=0;
1364 LFreeRemember(&funcdata
->arg_memkey
);
1366 viewfile(funcdata
->tempfile
,globstring
[STR_TEMPORARY_OUTPUT_FILE
],FUNC_SMARTREAD
,NULL
,NULL
,1,0);
1367 DeleteFile(funcdata
->tempfile
);
1369 LFreeRemember(&rec_pathkey
);
1370 LFreeRemember(&funcdata
->reload_memkey
);
1372 if (Window
&& !(status_flags
&STATUS_FROMHOTKEY
)) unbusy();
1373 if (status_flags
&STATUS_VERIFYFAIL
) myabort();
1374 else if (okayflag
) {
1375 if (Window
&& !status_iconified
&& !(status_flags
&STATUS_FROMHOTKEY
)) okay();
1376 if (flags
&FLAG_ICONIFY
&& checkwindowquit()) iconify(2,0,0);
1377 else startnotifies();
1382 int getdummyfile(fbuf
,dirbuf
,freq
)
1383 struct Directory
*fbuf
;
1385 struct DOpusFileReq
*freq
;
1387 char file
[FILEBUF_SIZE
],buf
[300];
1390 freq
->title
=globstring
[STR_SELECT_A_FILE
]; file
[0]=0;
1391 freq
->dirbuf
=dirbuf
; freq
->filebuf
=file
;
1392 freq
->window
=Window
;
1393 freq
->lines
=15; freq
->flags
=0;
1394 if (!dirbuf
[0]) expand_path("",dirbuf
);
1395 if (!(FileRequest(freq
))) {
1399 if (!dirbuf
[0]) expand_path("",dirbuf
);
1401 strcpy(buf
,dirbuf
); TackOn(buf
,file
,256);
1402 return(filloutdummy(buf
,fbuf
));
1404 strcpy(func_single_file
,file
);
1408 int filloutdummy(name
,fbuf
)
1410 struct Directory
*fbuf
;
1412 struct FileInfoBlock __aligned fib
;
1414 if (!(lockandexamine(name
,&fib
))) return(0);
1415 fbuf
->last
=fbuf
->next
=NULL
;
1416 strcpy(fbuf
->name
,fib
.fib_FileName
);
1417 fbuf
->type
=fib
.fib_DirEntryType
;
1418 if (fbuf
->type
>=0) fbuf
->size
=-1;
1419 else fbuf
->size
=fib
.fib_Size
;
1421 fbuf
->protection
=fib
.fib_Protection
;
1422 fbuf
->comment
=fbuf
->dispstr
=NULL
;
1423 getprot(fbuf
->protection
,fbuf
->protbuf
);
1424 seedate(&fib
.fib_Date
,fbuf
->datebuf
,1);
1425 CopyMem((char *)&fib
.fib_Date
,&fbuf
->date
,sizeof(struct DateStamp
));
1430 int dirrequester(freq
,buf
,title
)
1431 struct DOpusFileReq
*freq
;
1434 if (title
) freq
->title
=title
;
1435 else freq
->title
=globstring
[STR_SELECT_A_DIRECTORY
];
1437 freq
->flags
=DFRF_DIRREQ
;
1438 if (!buf
[0]) expand_path("",buf
);
1439 if (FileRequest(freq
)) {
1440 if (!buf
[0]) expand_path("",buf
);
1446 void do_title_string(string
,buf
,ml
,name
)
1453 a
=strlen(string
); c
=0;
1455 if (string
[b
]=='%') {
1457 if (name
) strcat(buf
,name
);
1458 else addreqfilename(buf
,data_active_window
);
1462 if (ml
&& string
[b
]=='\\') buf
[c
]='\n';
1463 else buf
[c
]=string
[b
];
1466 if (c
==(256+(ml
*262))) break;
1471 void addreqfilename(buf
,win
)
1475 struct Directory
*dir
;
1477 if (func_single_file
[0]) strcat(buf
,func_single_file
);
1479 dir
=dopus_curwin
[win
]->firstentry
;
1481 if (dir
->selected
&& dir
->type
<0) break;
1484 if (dir
&& dir
->selected
&& dir
->type
<0) strcat(buf
,dir
->name
);
1488 struct Directory
*custgetfirst(funcdata
)
1489 struct function_data
*funcdata
;
1491 struct Directory
*file
;
1493 file
=funcdata
->entry_first
;
1495 if ((file
->type
!=0) && (file
->selected
) && (file
->type
!=ENTRY_CUSTOM
)) return(file
);
1501 void custnextsel(dir
)
1502 struct Directory
**dir
;
1505 if (!(*dir
=(*dir
)->next
)) break;
1506 if ((*dir
)->selected
) break;
1510 int check_dest_path(funcdata
)
1511 struct function_data
*funcdata
;
1513 if (funcdata
->dest_path
[0]) return(1);
1514 if ((status_iconified
|| status_flags
&STATUS_FROMHOTKEY
) &&
1515 ((dirrequester(&funcdata
->file_request
,
1516 funcdata
->dest_path
,globstring
[STR_SELECT_DESTINATION_DIR
])) ||
1517 !funcdata
->dest_path
[0])) {
1521 if (!funcdata
->dest_path
[0]) {
1522 dostatustext(globstring
[STR_NO_DESTINATION_SELECTED
]);
1523 simplerequest(globstring
[STR_NO_DESTINATION_SELECTED
],
1524 globstring
[STR_CONTINUE
],NULL
);
1530 int getdummypath(dir
,title
)
1534 struct DOpusFileReq freq
;
1540 if ((a
=dirrequester(&freq
,dir
,globstring
[title
])))
1541 if (!dir
[0]) expand_path("",dir
);
1545 void build_default_string(string
,buffer
,filename
,sourcepath
,destpath
)
1546 char *string
,*buffer
,*filename
,*sourcepath
,*destpath
;
1553 for (a
=0;a
<len
&& pos
<255;a
++) {
1554 if (string
[a
]=='[' && string
[a
+2]==']') {
1556 switch (string
[a
+1]) {
1558 LStrnCpy(&buffer
[pos
],filename
,255-pos
);
1561 if ((ptr
=BaseName(filename
))) LStrnCpy(&buffer
[pos
],ptr
,255-pos
);
1564 LStrnCpy(&buffer
[pos
],sourcepath
,255-pos
);
1567 LStrnCpy(&buffer
[pos
],destpath
,255-pos
);
1579 buffer
[pos
++]=string
[a
];