-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccp.c
1509 lines (1400 loc) · 35.1 KB
/
ccp.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifdef RLI
#include "diverge.h"
#endif
/*--------------------------------------------------------------*\
| ccp.c CONSOLE COMMAND PROCESSOR v1.1 |
| ========================= |
| |
| CP/M 68k: A CP/M derived operating system |
| |
| *==================================================* |
| *==================================================* |
| *THIS IS THE DUAL PROCESSOR,ROMABLE CP/M-68K SYSTEM* |
| *==================================================* |
| *==================================================* |
| |
| Description: |
| ----------- |
| The Console Command Processor is a |
| distinct program which references |
| the BDOS to provide a human-oriented |
| interface for the console user to the |
| information maintained by the BDOS on |
| disk storage. |
| |
| created by : Tom Saulpaugh Date created: 7/13/82 |
| ---------- ------------ |
| last modified: 03/17/84 sw St. Patrick's Day!!! |
| ------------- Chain hack -------------------- |
| |
| (c) COPYRIGHT Digital Research 1983, 1984 |
| all rights reserved |
| |
\*--------------------------------------------------------------*/
/*--------------------------------------------------------------*\
| CCP Macro Definitions |
\*--------------------------------------------------------------*/
#include "ccpdef.h" /* include CCP defines */
/*--------------------------------------------------------------*\
| CP/M Builtin Command Table |
\*--------------------------------------------------------------*/
struct _cmd_tbl
{
BYTE *ident; /* command identifer field */
UWORD cmd_code; /* command code field */
}
#if 0
cmd_tbl[8] = /* declare CP/M built-in table */
#endif
cmd_tbl[] =
{
"DIR",DIRCMD,
"DIRS",DIRSCMD,
"TYPE",TYPECMD,
"REN",RENCMD,
"ERA",ERACMD,
"USER",UCMD,
"SUBMIT",SUBCMD,
#ifdef RLI
"EXIT",RLI_EXIT,
"IMPORT",RLI_IMPORT,
"EXPORT",RLI_EXPORT,
#endif
NULL,-1
};
/*--------------------------------------------------------------*\
| CP/M-68K COMMAND FILE LOADER TABLE |
\*--------------------------------------------------------------*/
extern struct _filetyps
{
BYTE *typ;
UWORD (*loader) ();
BYTE user_c;
BYTE user_0;
}
load_tbl[];
/*--------------------------------------------------------------*\
| Table of User Prompts and Messages |
\*--------------------------------------------------------------*/
BYTE msg[] = "NON-SYSTEM FILE(S) EXIST$";
BYTE msg2[] = "Enter Filename: $";
BYTE msg3[] = "Enter Old Name: $";
BYTE msg4[] = "Enter New Name: $";
BYTE msg5[] = "File already exists$";
BYTE msg6[] = "No file$";
BYTE msg7[] = "No wildcard filenames$";
BYTE msg8[] = "Syntax: REN Newfile=Oldfile$";
BYTE msg9[] = "Confirm(Y/N)? $";
BYTE msg10[] = "Enter User No: $";
BYTE msg11[] = ".SUB file not found$";
BYTE msg12[] = "User # range is [0-15]$";
BYTE msg13[] = "Too many arguments: $";
BYTE lderr1[] = "Insufficient memory or bad file header$";
BYTE lderr2[] = "Read error on program load$";
BYTE lderr3[] = "Bad relocation information bits$";
BYTE lderror[] = "Program load error$";
/*--------------------------------------------------------------*\
| Global Arrays & Variables |
\*--------------------------------------------------------------*/
/********************************/
BYTE load_try; /* flag to mark a load try */
BYTE first_sub; /* flag to save current cmd ptr */
BYTE chain_sub; /* submit chaining flag */
extern BYTE submit; /* submit file flag */
BYTE end_of_file; /* submit end of file flag */
BYTE dirflag; /* used by fill_fcb(? or blanks)*/
BYTE subprompt; /* submit file was prompted for */
extern BYTE morecmds; /* command after warmboot flag */
UWORD sub_index; /* index for subdma buffer */
UWORD index; /* index into cmd argument array*/
UWORD sub_user; /* submit file user number */
UWORD user; /* current default user number */
UWORD cur_disk; /* current default disk drive */
BYTE subcom[CMD_LEN+1]; /* submit command buffer */
BYTE subdma[CMD_LEN]; /* buffer to fill from sub file */
extern BYTE usercmd[CMD_LEN+2]; /* user command buffer */
BYTE *user_ptr; /* next user command to execute */
BYTE *glb_index; /* points to current command */
BYTE save_sub[CMD_LEN+1]; /* saves cur cmd line for submit*/
BYTE subfcb[FCB_LEN]; /* global fcb for sub files */
BYTE cmdfcb[FCB_LEN]; /* global fcb for 68k files */
BYTE *tail; /* pointer to command tail */
extern BYTE autost; /* autostart flag */
BYTE autorom; /* needed for ROM system autost */
BYTE dma[DMA_LEN+3]; /* 128 byte dma buffer */
BYTE parm[MAX_ARGS][ARG_LEN]; /* cmd argument array */
BYTE *chainp; /*sw -> User-specified command */
BYTE del[] = /* CP/M-68K set of delimeters */
{'>','<','.',',','=','[',']',';','|','&','/','(',')','+','-','\\'};
/********************************/
/*--------------------------------------------------------------*\
| Function Definitions |
\*--------------------------------------------------------------*/
/********************************/
extern UWORD bdos(); /* this returns a word */
extern UWORD load68k(); /* this returns a word(1-3) */
BYTE *scan_cmd(); /* this returns a ptr to a byte */
UWORD strcmp(); /* this returns a word */
UWORD decode(); /* this returns a word */
UWORD delim(); /* this returns a word */
BYTE true_char(); /* this returns a byte */
UWORD fill_fcb(); /* this returns a word */
UWORD too_many(); /* this returns a word */
UWORD find_colon(); /* this returns a word */
UWORD chk_colon(); /* this returns a word */
UWORD user_cmd(); /* this returns a word */
UWORD cmd_file(); /* this returns a word */
UWORD sub_read(); /* this returns a word */
UWORD dollar(); /* this returns a word */
UWORD comments(); /* this returns a word */
UWORD submit_cmd(); /* this returns a word */
/********************************/
/********************************/
VOID cr_lf() /* print a CR and a Linefeed */
/********************************/
{
bdos(CONSOLE_OUTPUT,CR);
bdos(CONSOLE_OUTPUT,LF);
}
/********************************/
VOID cpy(source,dest) /* copy source to destination */
/********************************/
REG BYTE *source;
REG BYTE *dest;
{
while(*dest++ = *source++);
}
/********************************/
UWORD strcmp(s1,s2) /* compare 2 char strings */
/********************************/
REG BYTE *s1,*s2;
{
while(*s1)
{
if(*s1 > *s2)
return(1);
if(*s1 < *s2)
return(-1);
s1++; s2++;
}
return((*s2 == NULL) ? 0 : -1);
}
/********************************/
VOID copy_cmd(com_index) /* Save the command which */
/* started a submit file */
/* Parameter substituion will */
/* need this command tail. */
/* The buffer save_sub is used */
/* to store the command. */
/********************************/
REG BYTE *com_index;
{
REG BYTE *t1,*temp;
temp = save_sub;
if(subprompt)
{
t1 = (void *)parm;
while(*t1)
*temp++ = *t1++;
*temp++ = ' ';
subprompt = FALSE;
}
while(*com_index && *com_index != EXLIMPT)
*temp++ = *com_index++;
*temp = NULL;
}
/********************************/
VOID prompt() /* print the CCP prompt */
/********************************/
{
REG UWORD cur_drive,cur_user_no;
BYTE buffer[3];
cur_user_no = bdos(GET_USER_NO,(long)255);
cur_drive = bdos(RET_CUR_DISK,(long)0);
cur_drive += 'A';
cr_lf();
if(cur_user_no)
{
if(cur_user_no >= 10)
{
buffer[0] = '1';
buffer[1] = ((cur_user_no-10) + '0');
buffer[2] = '$';
}
else
{
buffer[0] = (cur_user_no + '0');
buffer[1] = '$';
}
bdos(PRINT_STRING,buffer);
}
bdos(CONSOLE_OUTPUT,(long)cur_drive);
bdos(CONSOLE_OUTPUT,ARROW);
}
/********************************/
VOID echo_cmd(cmd,mode) /* echo any multiple commands */
/* or any illegal commands */
/********************************/
REG BYTE *cmd;
REG UWORD mode;
{
if(mode == GOOD && (!(autost && autorom)))
prompt();
while(*cmd && *cmd != EXLIMPT)
bdos(CONSOLE_OUTPUT,(long)*cmd++);
if(mode == BAD)
bdos(CONSOLE_OUTPUT,(long)'?');
else
cr_lf();
}
/********************************/
UWORD decode(cmd) /* Recognize the command as: */
/* --------- */
/* 1. Builtin */
/* 2. File */
/********************************/
REG BYTE *cmd;
{
REG UWORD i,n;
/****************************************/
/* Check for a CP/M builtin command */
/****************************************/
#if 0
for(i = 0; i < 7;i++)
#endif
for(i = 0; cmd_tbl[ i ].ident != NULL; i++ )
if (strcmp(cmd,cmd_tbl[i].ident) == MATCH)
return(cmd_tbl[i].cmd_code);
/********************************************************/
/* Check for a change of disk drive command */
/********************************************************/
i = 0;
while(i < (ARG_LEN-1) && parm[0][i] != ':')
i++;
if(i == 1 && parm[0][2] == NULL && parm[1][0] == NULL)
if((parm[0][0] >= 'A') && (parm[0][0] <= 'P'))
return(CH_DISK);
if(i == 1 && ((parm[0][0] < 'A') || (parm[0][0] > 'P')))
return(-1);
if(i != 1 && parm[0][i] == ':')
return(-1);
/*****************************************************/
/* Check for Wildcard Filenames */
/* Check Filename for a Delimeter */
/*****************************************************/
if(fill_fcb(0,cmdfcb) > 0)
return(-1);
if(i == 1)
i = 2;
else
i = 0;
if(delim(&parm[0][i]))
return(-1);
for(n = 0;n < ARG_LEN-1 && parm[0][n];n++)
if(parm[0][n] < ' ')
return(-1);
return(FILE);
}
/************************/
VOID check_cmd(tcmd) /* Check end of cmd */
/* for an '!' which */
/* starts another cmd */
REG BYTE *tcmd; /************************/
{
while(*tcmd && *tcmd != EXLIMPT)
tcmd++;
/*----------------------------*/
/* check for multiple command */
/* in case of a warmboot */
/*----------------------------*/
if(*tcmd++ == EXLIMPT && *tcmd)
{
morecmds = TRUE;
while(*tcmd == ' ')
tcmd++;
user_ptr = tcmd;
}
else
if(submit) /* check original cmd line */
{
if(!(end_of_file))
morecmds = TRUE;
/*--------------------------*/
else /* restore cmd to where user*/
/* ptr points to. User_ptr */
/* always points to next */
/* console command to exec */
{ /*--------------------------*/
submit = FALSE;
if(*user_ptr)
morecmds = TRUE;
}
}
else
morecmds = FALSE;
}
/************************/
VOID get_cmd(cmd,max_chars) /* Read in a command */
/*Strip off extra blanks*/
/************************/
REG BYTE *cmd;
REG long max_chars;
{
REG BYTE *c;
max_chars += ((int)cmd - 1);
dma[0] = CMD_LEN; /* set maximum chars to read */
bdos(READ_CONS_BUF,dma); /* then read console */
if(dma[1] != 0 && dma[2] != ';')
cr_lf();
dma[((UWORD)dma[1] & 0xFF)+2] = '\n'; /* tack on end of line char */
if(dma[2] == ';') /* ';' denotes a comment */
dma[2] = '\n';
c = &dma[2];
while(*c == ' ' || *c == TAB)
c++;
while(*c != '\n' && (int)cmd < max_chars)
{
*cmd++ = toupper(*c);
if(*c == ' ' || *c == TAB)
while(*++c == ' ' || *c == TAB);
else
c++;
}
*cmd = NULL; /* tack a null character on the end*/
}
/************************/
BYTE *scan_cmd(com_index) /* move ptr to next cmd */
/* in the command line */
/************************/
REG BYTE *com_index;
{
while((*com_index != EXLIMPT) &&
(*com_index))
com_index++;
while(*com_index == EXLIMPT || *com_index == ' ' ||
*com_index == TAB)
com_index++;
return(com_index);
}
/************************/
VOID get_parms(cmd) /* extract cmd arguments*/
/* from command line */
REG BYTE *cmd; /************************/
{
/************************************************/
/* This function parses the command line */
/* read in by get_cmd(). The expected command */
/* from that line is put into parm[0]. All */
/* parmeters associated with the command are put*/
/* in in sequential order in parm[1],parm[2], */
/* and parm[3]. A command ends at a NULL or */
/* an exlimation point. */
/************************************************/
REG BYTE *line; /* pointer to parm array */
REG UWORD i; /* Row Index */
REG UWORD j; /* Column Index */
line = (void *)parm;
for(i = 0; i < (MAX_ARGS * ARG_LEN); i++)
*line++ = NULL;
i = 0;
/***************************************************/
/* separate command line at blanks,exlimation pts */
/***************************************************/
while(*cmd != NULL &&
*cmd != EXLIMPT &&
i < MAX_ARGS)
{
j = 0;
while(*cmd != EXLIMPT &&
*cmd != ' ' &&
*cmd != TAB &&
*cmd)
{
if(j < (ARG_LEN-1))
parm[i][j++] = *cmd;
cmd++;
}
parm[i++][j] = NULL;
if(*cmd == ' ' || *cmd == TAB)
cmd++;
if(i == 1)
tail = cmd; /* mark the beginning of the tail */
}
}
/************************/
UWORD delim(ch) /* check ch to see */
/* if it's a delimeter */
/************************/
REG BYTE *ch;
{
REG UWORD i;
if(*ch <= ' ')
return(TRUE);
for(i = 0;i < sizeof (del);i++)
if(*ch == del[i]) return(TRUE);
return(FALSE);
}
/************************/
BYTE true_char(ch) /* return the desired */
/* character for fcb */
/************************/
REG BYTE *ch;
{
if(*ch == '*') return('?'); /* wildcard */
if(!delim(ch)) /* ascii character */
{
index++; /* increment cmd index */
return(*ch);
}
return(' '); /* pad field with blank */
}
/************************/
UWORD fill_fcb(which_parm,fcb) /* fill the fields of */
/* the file control blk */
/************************/
REG UWORD which_parm;
REG BYTE *fcb;
{
REG BYTE *ptr;
REG BYTE fillch;
REG UWORD j,k;
*fcb = 0;
for(k = 12;k <= 35; k++) /* fill fcb with zero */
fcb[k] = ZERO;
for(k = 1;k <= 11;k++)
fcb[k] = BLANK; /* blank filename+type */
/*******************************************/
/* extract drivecode,filename and filetype */
/* from parmeter blk */
/*******************************************/
if(dirflag)
fillch = '?';
else
fillch = ' ';
index = ZERO;
ptr = fcb;
if(parm[which_parm][index] == NULL) /* no parmemters */
{
ptr++;
for(j = 1;j <= 11;j++)
*ptr++ = fillch;
*fcb = (bdos(RET_CUR_DISK,(long)0)+1);
if(dirflag)
return(11);
else
return(0);
}
if(parm[which_parm][index+1] == ':')
{
*ptr = parm[which_parm][index] - 'A' + 1;
index += 2;
if(parm[which_parm][index] == NULL)
{
ptr = &fcb[1];
for(j = 1;j <= 11;j++)
*ptr++ = fillch;
if(dirflag)
return(11);
else
return(0);
}
}
else /* fill drivecode with the default disk */
*fcb = (bdos(RET_CUR_DISK,(long)0) + 1);
ptr = fcb;
ptr++; /* set pointer to fcb filename */
for(j = 1;j <= 8;j++) /* get filename */
*ptr++ = true_char(&parm[which_parm][index]);
while((!(delim(&parm[which_parm][index])))) index++;
if(parm[which_parm][index] == PERIOD)
{
index++;
for(j = 1;j <= 3;j++) /* get extension */
*ptr++ = true_char(&parm[which_parm][index]);
}
k = 0;
for(j = 1;j <= 11;j++)
if(fcb[j] == '?') k++;
return(k); /* return the number of question marks */
}
/************************/
UWORD too_many() /* too many args ? */
{ /************************/
if(parm[2][0])
{
bdos(PRINT_STRING,msg13);
echo_cmd(&parm[2][0],BAD);
return(TRUE);
}
return(FALSE);
}
/************************/
UWORD find_colon() /* search for a colon */
{ /************************/
REG UWORD i;
i = 0;
while(parm[1][i] && parm[1][i] != ':') i++;
return(i);
}
/************************/
UWORD chk_colon(j) /* check the position of*/
UWORD j; /* the colon and for */
{ /* a legal drive letter */
if(parm[1][j] == ':') /************************/
{
if(j != 1 || parm[1][0] < 'A' || parm[1][0] > 'P')
{
echo_cmd(&parm[1][0],BAD);
return(FALSE);
}
}
return(TRUE);
}
/************************/
VOID dir_cmd(attrib) /* print out a */
/* directory listing */
/*----------------------*/
/* attrib->1 (sysfiles) */
/* attrib->0 (dirfiles) */
/************************/
REG UWORD attrib;
{
BYTE needcr_lf;
REG UWORD dir_index,file_cnt;
REG UWORD save,j,k,curdrive,exist;
exist = FALSE; needcr_lf = FALSE;
if(too_many()) return;
j = find_colon();
if(!chk_colon(j)) return;
fill_fcb(1,cmdfcb);
curdrive = (cmdfcb[0] + 'A' - 1);
dir_index = bdos(SEARCH_FIRST,cmdfcb);
if(dir_index == 255)
bdos(PRINT_STRING,msg6);
save = (32 * dir_index) + 1;
file_cnt = 0;
while(dir_index != 255)
{
if(((attrib) && (dma[save+9] & 0x80)) ||
(!(attrib) && (!(dma[save+9] & 0x80))))
{
if(needcr_lf)
{
cr_lf();
needcr_lf = FALSE;
}
if(file_cnt == 0)
bdos(CONSOLE_OUTPUT,(long)curdrive);
}
else
{
exist = TRUE;
dir_index = bdos(SEARCH_NEXT);
save = (32 * dir_index) + 1;
continue;
}
dir_index = (32 * dir_index) + 1;
bdos(CONSOLE_OUTPUT,COLON);
bdos(CONSOLE_OUTPUT,BLANKS);
j = 1;
while(j <= 11)
{
if(j == 9)
bdos(CONSOLE_OUTPUT,BLANKS);
bdos(CONSOLE_OUTPUT,(long)(dma[dir_index++] & CMASK));
j++;
}
bdos(CONSOLE_OUTPUT,BLANKS);
dir_index = bdos(SEARCH_NEXT);
if(dir_index == 255)
break;
file_cnt++;
save = (32 * dir_index) + 1;
if(file_cnt == 5)
{
file_cnt = 0;
if((attrib && (dma[save+9] & 0x80)) ||
(!(attrib) && (!(dma[save+9] & 0x80))))
cr_lf();
else
needcr_lf = TRUE;
}
} /*----------------------------------------*/
if(exist) /* if files exist that were not displayed */
/* print out a message to the console */
{ /*----------------------------------------*/
cr_lf();
if(attrib)
bdos(PRINT_STRING,msg);
else
bdos(PRINT_STRING,&msg[4]);
}
}
/************************/
VOID type_cmd() /* type out a file */
/* to the console */
/************************/
{
REG UWORD i;
if(parm[1][0] == NULL) /*prompt user for filename*/
{
bdos(PRINT_STRING,msg2);
get_cmd(&parm[1][0],(long)(ARG_LEN-1));
}
if(too_many())
return;
i = find_colon();
if(!chk_colon(i)) return;
i = fill_fcb(1,cmdfcb); /*fill a file control block*/
if(i == 0 && parm[1][0] && (bdos(OPEN_FILE,cmdfcb) <= 3))
{
while(bdos(READ_SEQ,cmdfcb) == 0)
{
for(i = 0;i <= 127;i++)
if(dma[i] != EOF)
bdos(CONSOLE_OUTPUT,(long)dma[i]);
else
break;
}
bdos(RESET_DRIVE,(long)cmdfcb[0]);
} else
if(parm[1][0])
{
if(i > 0)
bdos(PRINT_STRING,msg7);
else
bdos(PRINT_STRING,msg6);
}
}
/************************/
VOID ren_cmd() /* rename a file */
/************************/
{
BYTE new_fcb[FCB_LEN];
REG UWORD i,j,k,bad_cmd;
bad_cmd = FALSE; /*-------------------------*/
if(parm[1][0] == NULL) /*prompt user for filenames*/
{ /*-------------------------*/
bdos(PRINT_STRING,msg3);
get_cmd(&parm[3][0],(long)(ARG_LEN-1));
if(parm[3][0] == NULL)
return;
bdos(PRINT_STRING,msg4);
get_cmd(&parm[1][0],(long)(ARG_LEN-1));
parm[2][0] = '=';
} /*--------------------------------*/
else /*check for correct command syntax*/
{ /*--------------------------------*/
i = 0;
while(parm[1][i] != '=' && parm[1][i]) i++;
if(parm[1][i] == '=')
{
if(!(i > 0 && parm[1][i+1] &&
parm[2][0] == NULL))
bad_cmd = TRUE;
}
else
if(!(parm[2][0] == '=' &&
parm[2][1] == NULL &&
parm[3][0]))
bad_cmd = TRUE;
if(!bad_cmd && parm[1][i] == '=')
{
parm[1][i] = NULL;
i++;
j = 0;
while((parm[3][j++] = parm[1][i++]) != NULL);
parm[2][0] = '=';
}
}
for(j = 1;j < 4;j += 2)
{
k = 0;
while(parm[j][k] != ':' && parm[j][k])
k++;
if(k > 1 && parm[j][k] == ':')
bad_cmd = TRUE;
for(i = 0;i < sizeof del;i++)
if(parm[j][0] == del[i])
{
echo_cmd(&parm[j][0],BAD);
return;
}
}
if(!bad_cmd && parm[1][0] && parm[3][0])
{
i = fill_fcb(1,new_fcb);
j = fill_fcb(3,cmdfcb);
if(i == 0 && j == 0)
{
if(new_fcb[0] != cmdfcb[0])
{
if(parm[1][1] == ':' && parm[3][1] != ':')
cmdfcb[0] = new_fcb[0];
else
if(parm[1][1] != ':' && parm[3][1] == ':')
new_fcb[0] = cmdfcb[0];
else
bad_cmd = TRUE;
}
if(new_fcb[0] < 1 || new_fcb[0] > 16)
bad_cmd = TRUE;
if(!(bad_cmd) && bdos(SEARCH_FIRST,new_fcb) != 255)
bdos(PRINT_STRING,msg5);
else{
k = 0;
for(i = 16;i <= 35;i++)
cmdfcb[i] = new_fcb[k++];
if(cmdfcb[0] < 0 || cmdfcb[0] > 15)
bad_cmd = TRUE;
if(!(bad_cmd) &&
bdos(RENAME_FILE,cmdfcb) > 0)
bdos(PRINT_STRING,msg6);
}
}
else
bdos(PRINT_STRING,msg7);
}
if(bad_cmd)
bdos(PRINT_STRING,msg8);
}
/************************/
VOID era_cmd() /* erase a file from */
/* the directory */
/************************/
{
REG UWORD i;
/*----------------------*/
if(parm[1][0] == NULL) /* prompt for a file */
{ /*----------------------*/
bdos(PRINT_STRING,msg2);
get_cmd(&parm[1][0],(long)(ARG_LEN-1));
}
if(parm[1][0] == NULL)
return;
if(too_many())
return;
i = find_colon();
if(!chk_colon(i))
return;
else
if(parm[1][1] == ':' && parm[1][2] == NULL)
{
echo_cmd(&parm[1][0],BAD);
return;
}
i = fill_fcb(1,cmdfcb); /* fill an fcb */
if(i > 0 && !(submit)) /* no confirmation */
{ /* if submit file */
bdos(PRINT_STRING,msg9);
parm[2][0] = bdos(CONIN,(long)0);
parm[2][0] = toupper(parm[2][0]);
cr_lf();
if(parm[2][0] != 'N' && parm[2][0] != 'Y')
return;
}
if(parm[2][0] != 'N')
if(bdos(DELETE_FILE,cmdfcb) > 0)
bdos(PRINT_STRING,msg6);
}
/************************/
UWORD user_cmd() /* change user number */
/************************/
{
REG UWORD i;
if(parm[1][0] == NULL) /* prompt for a number */
{
bdos(PRINT_STRING,msg10);
get_cmd(&parm[1][0],(long)(ARG_LEN-1));
}
if(parm[1][0] == NULL)
return(TRUE);
if(too_many())
return(TRUE);
if(parm[1][0] < '0' || parm[1][0] > '9')
return(FALSE);
i = (parm[1][0] - '0');
if(i > 9)
return(FALSE);
if(parm[1][1])
i = ((i * 10) + (parm[1][1] - '0'));
if(i < 16 && parm[1][2] == NULL)
bdos(GET_USER_NO,(long)i);
else
return(FALSE);
return(TRUE);
}
UWORD cmd_file(mode)
/************************/
/* */
/* SEARCH ORDER */
/* ============ */
/* */
/* 1. 68K type on the */
/* current user # */
/* 2. BLANK type on */
/* current user # */
/* 3. SUB type on the */
/* current user # */
/* 4. 68K type on */
/* user 0 */
/* 5. BLANK type on the */
/* user 0 */
/* 6. SUB type on */
/* user 0 */
/* */
/*----------------------*/
/* */
/* If a filetype is */
/* specified then I */
/* search the current */
/* user # then user 0 */
/* */
/************************/
UWORD mode;
{
BYTE done,open,sub_open;
BYTE found;
REG UWORD i,n;
UWORD (*ldrpgm) ();
REG BYTE *top;
REG struct _filetyps *p;
dirflag = FALSE;
load_try = TRUE;
done = FALSE;
found = FALSE;
sub_open = FALSE;
open = FALSE;
user = bdos(GET_USER_NO,(long)255);
cur_disk = bdos(RET_CUR_DISK,(long)0);
if(mode == SEARCH) i = 0; else i = 1;
i = fill_fcb(i,cmdfcb);
if(i > 0)
{
bdos(PRINT_STRING,msg7);
return(FALSE);
}
p = (void *)&load_tbl;
top = p->typ;
if(cmdfcb[9] == ' ')
{
while(*(p->typ)) /* clear flags in table */
{
p->user_c = p->user_0 = FALSE;
p++;
}
bdos(SELECT_DISK,(long)(cmdfcb[0]-1));
cmdfcb[0] = '?'; cmdfcb[12] = NULL;
i = bdos(SEARCH_FIRST,cmdfcb);
while(i != 255 && !(done))
{
i *= 32;
if(dma[i] == 0 || dma[i] == user)
{
for(n = 9;n <= 11;n++) dma[i+n] &= CMASK;
dma[i+12] = NULL;
p = (void *)&load_tbl;
while(*(p->typ))
{
cpy(p->typ,&cmdfcb[9]);
if(strcmp(&cmdfcb[1],&dma[i+1]) == MATCH)
{
found = TRUE;
if(dma[i] == user) p->user_c = TRUE;
else p->user_0 = TRUE;
if(mode == SEARCH &&
strcmp(p->typ,top) == MATCH && p->user_c)
done = TRUE;
}
p++;
}
}
i = bdos(SEARCH_NEXT);
}
if(!(found))