aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 9758a2f..5bed343 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,3 @@
1/* blabla */
2#include <stdio.h> 1#include <stdio.h>
3#include <stdlib.h> 2#include <stdlib.h>
4#include <time.h> 3#include <time.h>
@@ -8,6 +7,7 @@
8#include "moves.h" 7#include "moves.h"
9#include "solver.h" 8#include "solver.h"
10#include "string.h" 9#include "string.h"
10#include "helppages.h"
11 11
12char *commands[][10] = { 12char *commands[][10] = {
13 {"help", "[COMMAND]", 13 {"help", "[COMMAND]",
@@ -130,17 +130,15 @@ void help_cmd(int n, char cmdtok[][100]) {
130 printf("\n"); 130 printf("\n");
131 printf("Type \'help\' followed by a command for a detailed help page.\n"); 131 printf("Type \'help\' followed by a command for a detailed help page.\n");
132 printf("Type \'help nissy\' for a general user guide.\n"); 132 printf("Type \'help nissy\' for a general user guide.\n");
133 } else if (n == 2) { 133 } else if (n == 2) {
134 char fname[255], line[255] = ""; 134 for (int i = 0; i < Npages; i++) {
135 FILE *file; 135 if (!strcmp(helppages[i][0], cmdtok[1])) {
136 sprintf(fname, "docs/%s.txt", cmdtok[1]); 136 printf("%s", helppages[i][1]);
137 file = fopen(fname, "r"); 137 return;
138 if (file == NULL) { 138 }
139 printf("No help file for %s.\n", cmdtok[1]);
140 return;
141 } 139 }
142 while (fgets(line, 255, file) != NULL) 140 printf("No help page for %s.\n", cmdtok[1]);
143 printf("%s", line); 141 return;
144 } else { 142 } else {
145 printf("help: wrong syntax.\n"); 143 printf("help: wrong syntax.\n");
146 } 144 }

Generated with cgit - Back to sebastiano.tronto.net