00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #include <string.h>
00043 #include "memvirtu.h"
00044 #include "lowparam.h"
00045 #include "lowsolid.h"
00046 #include "mancommd.h"
00047
00048 void help(void)
00049 {
00050 COMTYPE *p;
00051 int ip, pn, cont;
00052 char com[30];
00053
00054 for (ip = 0; ip == 0;)
00055 {
00056 pn = sscanf(restbuf, "%s", com);
00057 if ((pn == 0) || (pn == EOF))
00058 {
00059 p = (COMTYPE *)NIL;
00060 ip = 1;
00061 }
00062 if (ip == 0)
00063 {
00064 strupper((unsigned char *)com);
00065 for (p = comtable; *p->comname; ++p)
00066 {
00067 if (!strncmp(p->comname, com, strlen(com)))
00068 {
00069 break;
00070 }
00071 }
00072 if (*p->comname)
00073 {
00074 ip = 1;
00075 }
00076 else
00077 {
00078 printf("Comando %s nao existe!\n", com);
00079 return;
00080 }
00081 }
00082 }
00083 if (p)
00084 {
00085 helpman(p);
00086 }
00087 else
00088 {
00089 for (p = comtable, cont = 0; *p->comname; p++, cont++)
00090 {
00091 if (cont == 6)
00092 {
00093 printf("\n");
00094 cont = 0;
00095 }
00096 printf("%-13s", p->comname);
00097 }
00098 printf("\n");
00099 }
00100 }
00101
00102 void helpman(COMTYPE *p)
00103 {
00104 FILE *helpfptr;
00105 char filename[16], c;
00106
00107 strcpy(filename, p->comname);
00108 filename[8] = '\0';
00109 strcat(filename, ".HLP");
00110 if ((helpfptr = fopen(filename, "r")) == NIL)
00111 {
00112 printf("Nao conseguiu abrir o arquivo HELP \"%s\"\n", filename);
00113 return;
00114 }
00115 while ((c = getc(helpfptr)) != EOF)
00116 {
00117 putchar(c);
00118 }
00119 fclose(helpfptr);
00120 }