~ubuntu-branches/ubuntu/karmic/axiom/karmic

« back to all changes in this revision

Viewing changes to src/etc/asq.c.pamphlet

  • Committer: Bazaar Package Importer
  • Author(s):
  • Date: 2005-02-21 17:08:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050221170837-34vm4j33v4t9hsk4
Tags: 20050201-1
* New upstream release
* Bug fix: "axiom graphics missing?", thanks to Daniel Lakeland (Closes:
  #277692).
* Bug fix: "axiom: Feb 2005 release for sarge would be nice", thanks to
  Balbir Thomas (Closes: #295000).

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
/* asq is a mini browser for the AXIOM databases                            */
58
58
 
59
 
#define VERSION 6
 
59
#define VERSION 7
 
60
/* 040206007 tpd fix anal compiler warnings                                 */
60
61
/* 030710006 tpd remove share directory                                     */
61
62
/* 940112005 tpd cleanup of printinfo                                       */
62
63
/* 931228004 tpd more output to stdout                                      */
134
135
#include <stdio.h>
135
136
#include <string.h>
136
137
 
 
138
/* we need to predeclare some functions so their signatures are known */
 
139
int printandor(char *list);
 
140
int printlist(char *list);
 
141
int pprintobject(char *list);
 
142
int pprintcond(int seekpt,char *path);
 
143
 
 
144
/* this bogucity is apparently due to the introduction of unicode */
 
145
/* since we don't use unicode we default to the K&R C signatures  */
 
146
int isdigit(int c);
 
147
int isspace(int c);
 
148
 
137
149
/*defvar*/  char *AXIOM;         /* the AXIOM shell variable    */
138
150
 
139
151
/*defvar*/ char interppath[256]; /* where the file is           */
199
211
  return ((n<=0 && n>-Nct) ? ct[-n] : "the unknown thing");
200
212
}
201
213
 
202
 
/*defun*/ echoargs(int argc, char *argv[])
 
214
/*defun*/ int echoargs(int argc, char *argv[])
203
215
/* echo the arguments */
204
216
205
217
 int i;
209
221
 return 0;
210
222
}
211
223
 
212
 
/*defun*/ printnoquotes(char *chars)
 
224
/*defun*/ int printnoquotes(char *chars)
213
225
{ int i;
214
226
  for (i=0; chars[i] != '\0'; i++) 
215
227
   if (chars[i] != '\"') putchar(chars[i]);
216
228
  putchar('\n');
 
229
  return(0);
217
230
}
218
231
 
219
 
/*defun*/ printenter(char *name)
 
232
/*defun*/ int printenter(char *name)
220
233
/* debugging...print on entry */
221
234
{ int i;
222
235
  printf("\n>enter %s >",name); 
223
236
  for (i=0; i < 10; i++) printf("%c",list2[ppcount+i]); 
224
237
  printf("<\n");
 
238
  return(0);
225
239
}
226
240
 
227
 
/*defun*/ printexit(char *name)
 
241
/*defun*/ int printexit(char *name)
228
242
/* debugging...print on exit */
229
243
{ int i;
230
244
  printf("\n<exit  %s >",name); 
231
245
  for (i=0; i < 10; i++) printf("%c",list2[ppcount+i]); 
232
246
  printf("<\n");
 
247
  return(0);
233
248
}
234
249
 
235
 
/*defun*/ readlist(FILE *file)
 
250
/*defun*/ int readlist(FILE *file)
236
251
/* read the key information as a list (uses global list var) */
237
252
/* note: this function assumes the caller has done an fseek and read  */
238
253
/* one character which was an '(', starting a list                    */
246
261
    else list[listptr++]=(char)c;}
247
262
 list[listptr++]=')'; 
248
263
 list[listptr]='\0';
 
264
 return(0);
249
265
}
250
266
 
251
 
/*defun*/ readstring2(FILE *file)
 
267
/*defun*/ int readstring2(FILE *file)
252
268
/* read a string (including escape chars) uses (global list2 var)     */
253
269
/* note: this function assumes the caller has done an fseek and read  */
254
270
/* one character which was a '"', starting a string                   */
261
277
     else list2[listptr2++]=(char)c;}
262
278
  list2[listptr2++]='"'; 
263
279
  list2[listptr2]='\0';
 
280
  return(0);
264
281
}
265
282
 
266
 
/*defun*/ readlist2(FILE *file)
 
283
/*defun*/ int readlist2(FILE *file)
267
284
/* read a list without smashing the main list (uses global list2 var) */
268
285
/* note: this function assumes the caller has done an fseek and read  */
269
286
/* one character which was an '(', starting a list                    */
278
295
    else list2[listptr2++]=(char)c;}
279
296
 list2[listptr2++]=')';
280
297
 list2[listptr2]='\0';
 
298
 return(0);
281
299
}
282
300
 
283
 
/*defun*/ pprintatom(char *list)
 
301
/*defun*/ int pprintatom(char *list)
284
302
/* print anything but a list */
285
303
/* note: this function assumes that list[ppcount] is an atom */
286
304
287
305
  char c; 
288
306
  /*printenter("pprintatom");*/
289
 
  while (c=list[ppcount])
 
307
  while ((c=list[ppcount]) != 0)
290
308
    { 
291
309
      if (c == '-') {
292
310
        printf("%s",N2S(atoi(list+ppcount)));
306
324
      else
307
325
        printf("%c",list[ppcount++]);}; 
308
326
  /*printexit("pprintatom");*/
309
 
}
310
 
 
311
 
/*defun*/ printlist(char *list)
 
327
  return(0);
 
328
}
 
329
 
 
330
/*defun*/ int printob(char *list) 
 
331
/* recursively print an object */
 
332
{ char c;
 
333
  while ((c=list[ppcount]) != 0)
 
334
   {if (list[ppcount] == '(' ) printlist(list);
 
335
    else if (list[ppcount] == ')' ) return(0);
 
336
     else 
 
337
      pprintatom(list);}
 
338
  return(0);
 
339
}
 
340
 
 
341
/*defun*/ int printlist(char *list)
312
342
/* recursively print a list object */
313
343
/* note: this function assumes that list[ppcount] is a '(' */
314
344
{ printf("%c",list[ppcount++]);
315
345
  printob(list);
316
346
  printf("%c",list[ppcount++]);
 
347
  return(0);
317
348
}
318
349
 
319
 
/*defun*/ pprintlist(char *list)
 
350
/*defun*/ int pprintlist(char *list)
320
351
/* recursively pprint a list object */
321
352
/* note: this function assumes that list[ppcount] is a '('    */
322
353
/* it assumes that indent and ppcount have been properly set  */
328
359
  pprintobject(list);
329
360
  printf("%c",list[ppcount++]);
330
361
  indent=indent-2; 
331
 
}
332
 
 
333
 
/*defun*/ printob(char *list) 
334
 
/* recursively print an object */
335
 
{ char c;
336
 
  while (c=list[ppcount])
337
 
   {if (list[ppcount] == '(' ) printlist(list);
338
 
    else if (list[ppcount] == ')' ) return;
339
 
     else 
340
 
      pprintatom(list);}
341
 
}
342
 
 
343
 
/*defun*/ pprintobject(char *list)
344
 
/* recursively print an object */
345
 
{ char c;
346
 
  while (c=list[ppcount])
 
362
  return(0);
 
363
}
 
364
 
 
365
/*defun*/ int pprintobject(char *list)
 
366
/* recursively print an object */
 
367
{ char c;
 
368
  while ((c=list[ppcount]) != 0)
347
369
   {if (list[ppcount] == '(' ) pprintlist(list);
348
 
    else if (list[ppcount] == ')' ) return;
 
370
    else if (list[ppcount] == ')' ) return(0);
349
371
     else 
350
372
      pprintatom(list);}
 
373
  return(0);
351
374
}
352
375
 
353
 
/*defun*/ skiplist(char *list)
 
376
/*defun*/ int skiplist(char *list)
354
377
/* skip over a list we don't want to print */
355
378
{ while (list[ppcount++] != '(');
356
379
  while(list[ppcount] !=')')
359
382
     else
360
383
      ppcount++;}
361
384
   ppcount++;
 
385
  return(0);
362
386
}
363
387
 
364
 
/*defun*/ pprintalist(int seekpt,char *path)
 
388
/*defun*/ int pprintalist(int seekpt,char *path)
365
389
/* read an alist and prettyprint it                   */
366
390
/* note: we reopen the file due to a DJGPP fseek bug  */
367
391
{ char c;
396
420
         ppcount++;
397
421
      ppcount++;}; 
398
422
  /*printexit("printalist");*/
 
423
  return(0);
399
424
}
400
425
 
401
426
 
402
 
/*defun*/ pprint(int seekpt,char *path)
 
427
/*defun*/ int pprint(int seekpt,char *path)
403
428
/* prettyprint the information at a given pointer     */
404
429
/* note: we reopen the file due to a DJGPP fseek bug  */
405
430
{ char c;
417
442
  ppcount=0; 
418
443
  pprintobject(list2);
419
444
  printf("\n");
 
445
  return(0);
420
446
}
421
447
 
422
 
/*defun*/ printdomain()
 
448
/*defun*/ int printdomain()
423
449
/* prints the domain name */
424
450
425
451
  printf("%s\n",N2S(atoi(domain)));
 
452
  return(0);
426
453
}
427
454
 
428
 
/*defun*/ printobject(int all)
 
455
/*defun*/ int printobject(int all)
429
456
/* print the object file name */
430
457
{ char stripped[256];
431
458
  int i;
438
465
    else
439
466
    printf("%s/algebra/%s.o\n",AXIOM,stripped);
440
467
    */
 
468
  return(0);
441
469
}
442
470
 
443
 
/*defun*/ printconstructorkind(int all)
 
471
/*defun*/ int printconstructorkind(int all)
444
472
/* print the constructorkind data */
445
473
{if (all == 1)
446
474
  printf("...is a %s\n",N2S(atoi(constructorkind)));
447
475
 else
448
476
  printf("%s\n",N2S(atoi(constructorkind)));
 
477
 return(0);
449
478
}
450
479
 
451
 
/*defun*/ printniladic(int all)
 
480
/*defun*/ int printniladic(int all)
452
481
/* print the niladic property */
453
482
{ if (niladic[0] == 'T')
454
483
   if (all == 1)
460
489
     printf("...is not niladic\n");
461
490
    else
462
491
     printf("padic\n");
 
492
  return(0);
463
493
}
464
494
 
465
 
/*defun*/ printabbreviation(int all)
 
495
/*defun*/ int printabbreviation(int all)
466
496
/* print the abbreviation */
467
497
{ if (all == 1)
468
498
    printf("...is abbreviated as %s\n",abbreviation);
469
499
   else
470
500
    printf("%s\n",abbreviation);
 
501
  return(0);
471
502
}
472
503
 
473
 
/*defun*/ printsourcefile(int all)
 
504
/*defun*/ int printsourcefile(int all)
474
505
/* print the source file */
475
506
{ if (all == 1)
476
507
    printf("...is defined in the source file %s\n",bsourcefile);
477
508
   else
478
 
    printnoquotes(bsourcefile);}
 
509
    printnoquotes(bsourcefile);
 
510
  return(0);
 
511
}
479
512
 
480
 
/*defun*/ printdefaultdomain(int all)
 
513
/*defun*/ int printdefaultdomain(int all)
481
514
/* print the default domain */
482
515
{ int i;
483
516
  if (strcmp(defaultdomain,"NIL") == 0)
493
526
     else
494
527
       {for (i=1; defaultdomain[i] != '|'; i++) putchar(defaultdomain[i]);
495
528
        printf("\n");}
 
529
  return(0);
496
530
}
497
531
 
498
 
/*defun*/ printancestors(int pretty)
 
532
/*defun*/ int printancestors(int pretty)
499
533
/* print the ancestors */
500
534
{ if (strcmp(ancestors,"NIL") == 0)
501
535
    printf("...has no ancestors\n");
508
542
       printf("\n");}
509
543
     else
510
544
      printf("%d\n",seekinterp);}
 
545
  return(0);
511
546
}
512
547
 
513
 
/*defun*/ printoperationalist(int pretty)
 
548
/*defun*/ int printoperationalist(int pretty)
514
549
/* print the operationalist */
515
550
{ /*printenter("printoperationalist");*/
516
551
  if (strcmp(operationalist,"NIL") == 0)
524
559
      else
525
560
       printf("%d\n",seekinterp);};
526
561
 /*printexit("printoperationalist");*/
 
562
  return(0);
527
563
}
528
564
 
529
 
/*defun*/ printhas(char *list)
 
565
/*defun*/ int printhas(char *list)
530
566
/* print a has clause */
531
567
/* note: assumes ppcount points at the |has| */
532
568
{ /*printenter("printhas");*/
545
581
    pprintatom(list2);
546
582
  ppcount++; 
547
583
  /*printexit("printhas");*/
 
584
  return(0);
548
585
}
549
586
 
550
 
/*defun*/ printand(char *list)
 
587
/*defun*/ int printand(char *list)
551
588
/* print an and clause */
552
589
/* note: assumes ppcount points at the AND */
553
590
{ /*printenter("printand");*/
561
598
    printandor(list2);
562
599
    ppcount++;}
563
600
  /*printexit("printand");*/
 
601
  return(0);
564
602
}
565
603
 
566
 
/*defun*/ printor(char *list)
 
604
/*defun*/ int printor(char *list)
567
605
/* print an or clause */
568
606
/* note: assumes ppcount points at the OR */
569
607
{ /*printenter("printor");*/
576
614
    printandor(list2);
577
615
    ppcount++;}
578
616
 /*printexit("printor");*/
 
617
  return(0);
579
618
}
580
619
 
581
 
/*defun*/ printandor(char *list)
 
620
/*defun*/ int printandor(char *list)
582
621
/* print an and/or clause */
583
622
/* note: this function assumes that list[ppcount] is a '(' */
584
623
{ /*printenter("printandor");*/
587
626
  if (list2[ppcount] == 'A') printand(list2);
588
627
  if (list2[ppcount] == 'O') printor(list2); 
589
628
  /*printexit("printandor");*/
 
629
  return(0);
590
630
}
591
631
 
592
 
/*defun*/ pprintcond(int seekpt,char *path)
 
632
/*defun*/ int pprintcond(int seekpt,char *path)
593
633
/* prettyprint a list of conditions                   */
594
634
/* note: we reopen the file due to a DJGPP fseek bug  */
595
635
{ char c;
624
664
        printandor(list2);              /* and print the non-T ones */
625
665
       else
626
666
        while(list2[ppcount++] !=')');}; /* skip the . T ) */
 
667
  return(0);
627
668
}
628
669
 
629
 
 
630
 
/*defun*/ printattributes(int pretty)
 
670
/*defun*/ int printattributes(int pretty)
631
671
/* print the attributes */
632
672
{if (strcmp(battributes,"NIL") == 0)
633
673
   printf("...has no attributes\n");
639
679
      printf("\n");}
640
680
     else
641
681
      printf("%d\n",seekbrowse);};
 
682
  return(0);
642
683
}
643
684
 
644
 
/*defun*/ printcosig()
 
685
/*defun*/ int printcosig()
645
686
/* print the cosig property */
646
687
{ printf("...has the cosig: %s\n",cosig);
 
688
  return(0);
647
689
}
648
690
 
649
 
/*defun*/ printconstructorform(int pretty)
 
691
/*defun*/ int printconstructorform(int pretty)
650
692
/* print the constructorform property */
651
693
{ FILE *file; 
652
694
  /*printenter("printconstructorform");*/
665
707
   else
666
708
    printf("%d\n",seekbrowse); 
667
709
  /*printexit("printconstructorform");*/
 
710
  return(0);
668
711
}
669
712
 
670
 
/*defun*/ printconstructormodemap(int pretty)
 
713
/*defun*/ int printconstructormodemap(int pretty)
671
714
/* print the constructormodemap property */
672
715
{ FILE *file; 
673
716
  /*printenter("printconstructormodemap"); */
686
729
    else
687
730
     printf("%d\n",seekinterp);
688
731
  /*printexit("printconstructormodemap");*/
 
732
  return(0);
689
733
}
690
734
 
691
 
/*defun*/ printmodemaps(int pretty)
 
735
/*defun*/ int printmodemaps(int pretty)
692
736
/* print the modemaps property */
693
737
{ FILE *file; 
694
738
  /*printenter("printmodemaps"); */
709
753
    else
710
754
     printf("%d\n",seekinterp);
711
755
 /* printexit("printmodemaps");*/
 
756
  return(0);
712
757
}
713
758
 
714
 
/*defun*/ printconstructorcategory(int pretty)
 
759
/*defun*/ int printconstructorcategory(int pretty)
715
760
/* print the constructorcategory property */
716
761
{ FILE *file; 
717
762
  /*printenter("printconstructorcategory"); */
730
775
    else
731
776
     printf("%d\n",seekinterp);
732
777
  /*printexit("printconstructorcategory");*/
 
778
  return(0);
733
779
}
734
780
 
735
 
/*defun*/ printdocumentation(int pretty)
 
781
/*defun*/ int printdocumentation(int pretty)
736
782
/* print the documentation property */
737
783
{ FILE *file; 
738
784
  /*printenter("printdocumentation");*/
753
799
   else
754
800
    printf("%d\n",seekbrowse); 
755
801
  /*printexit("printdocumentation");*/
 
802
  return(0);
756
803
}
757
804
 
758
 
/*defun*/ printpredicates(int pretty)
 
805
/*defun*/ int printpredicates(int pretty)
759
806
/* print the predicates */
760
807
{ FILE *file;
761
808
  /*printenter("printpredicates");*/
776
823
     else
777
824
      printf("%d\n",seekbrowse);};
778
825
 /*printexit("printpredicates");*/
 
826
  return(0);
779
827
}
780
828
 
781
 
/*defun*/ opencompress()
 
829
/*defun*/ int opencompress()
782
830
/* open the compress.daase file and point at the first key */
783
831
{ char line[256];
784
832
  char other[256];
798
846
   else
799
847
     for (i=1; ! isspace(line[i]); i++) other[i-1]=line[i];
800
848
  seekcompress=atoi(other)+2; 
 
849
  return(0);
801
850
}
802
851
 
803
 
/*defun*/ openinterp()
 
852
/*defun*/ int openinterp()
804
853
/* open the interp.daase file and point at the first key */
805
854
{ char line[256];
806
855
  char other[256];
820
869
   else
821
870
     for (i=1; ! isspace(line[i]); i++) other[i-1]=line[i];
822
871
  seekinterp=atoi(other)+2; 
 
872
  return(0);
823
873
}
824
874
 
825
 
/*defun*/ parseinterp()
 
875
/*defun*/ int parseinterp()
826
876
/* parse the key gotten from interp.daase */
827
877
{ int i;
828
878
  int j;
829
 
  char line[256];
830
 
  int count = 256;
831
879
  for ((i=1, j=0); ! isspace(list[i]); (i++,j++)) 
832
880
    domain[j]=list[i];
833
881
  domain[j]='\0'; 
866
914
  for ((i++,j=0); (list[i] != ')'); (i++,j++)) 
867
915
    ancestors[j]=list[i]; 
868
916
  ancestors[j]='\0';
 
917
  return(0);
869
918
}
870
919
 
871
920
 
872
 
/*defun*/ openbrowse()
 
921
/*defun*/ int openbrowse()
873
922
/* open the browse.daase file and point at the first key */
874
923
875
924
  char line[256];
890
939
   else
891
940
     for (i=1; ! isspace(line[i]); i++) other[i-1]=line[i];
892
941
  seekbrowse=atoi(other)+2; 
 
942
  return(0);
893
943
}
894
944
 
895
 
/*defun*/ parsebrowse()
 
945
/*defun*/ int parsebrowse()
896
946
/* parse the key gotten from browse.daase */
897
947
{ int i;
898
948
  int j;
899
 
  char line[256];
900
 
  int count = 256;
901
949
  for ((i=1, j=0); ! isspace(list[i]); (i++,j++)) bdomain[j]=list[i];
902
950
  bdomain[j]='\0'; 
903
951
  for ((i++, j=0); ! isspace(list[i]); (i++,j++)) bsourcefile[j]=list[i];
910
958
  battributes[j]='\0'; 
911
959
  for ((i++, j=0); ! isspace(list[i]); (i++,j++)) bpredicates[j]=list[i];
912
960
  bpredicates[j]='\0'; 
 
961
  return(0);
913
962
}
914
963
 
915
 
/*defun*/ pprintinfo(char *property)
 
964
/*defun*/ int pprintinfo(char *property)
916
965
/* prettyprint the information from the database files      */
917
966
{ int pretty = 1; /* print pretty form for any option   */
918
967
  int all  = 0; /* only print the option specificed */ 
955
1004
  if (all || (strcmp(property,"predicates") == 0))
956
1005
    printpredicates(pretty);
957
1006
  /*printexit("pprintinfo");*/
 
1007
  return(0);
958
1008
}
959
1009
 
960
1010
/*defun*/ char *fullname(char *property, char *progname)
987
1037
 return("short");
988
1038
}
989
1039
 
990
 
/*defun*/ printhelp(char *arg)
 
1040
/*defun*/ int printhelp(char *arg)
991
1041
{printf("%s -property searchkey \n\n",arg);
992
1042
 printf("property is one of the following flags: \n");
993
1043
 printf(" (al)    all (default)         (sh)    short\n");
1004
1054
 printf("\n e.g. %s -so Integer\n",arg);
1005
1055
 printf("   will give the source file name written to stdout\n");
1006
1056
 printf(" (Version %d)\n",VERSION);
 
1057
 return(0);
1007
1058
}
1008
1059
 
1009
 
/*defun*/ main(int argc, char *argv[])
 
1060
/*defun*/ int main(int argc, char *argv[])
1010
1061
{
1011
 
  FILE *test;        /* when testing we leave tombstones     */
1012
 
  char *ssearch;      /* the domain or abbreviation           */
1013
 
  char *property;    /* the property we want (e.g. niladic)  */
 
1062
/*  FILE *test;         when testing we leave tombstones     */
 
1063
  char *ssearch =""; /* the domain or abbreviation           */
 
1064
  char *property=""; /* the property we want (e.g. niladic)  */
1014
1065
  int found=1;       /* did we find the domain? print if yes */
1015
1066
  char c;            /* a temporary                          */
1016
1067
  int i;             /* a temporary                          */
1105
1156
  if ((argv[2] != NULL) && (strcmp(argv[2],"test") == 0))
1106
1157
    {sprintf(erasecmd,"erase %s",argv[1]);
1107
1158
    system(erasecmd);}
 
1159
  return(0);
1108
1160
}
1109
1161
 
1110
1162
@