summaryrefslogtreecommitdiff
path: root/dbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'dbox.c')
-rw-r--r--dbox.c188
1 files changed, 94 insertions, 94 deletions
diff --git a/dbox.c b/dbox.c
index 173c9f2..955d8b1 100644
--- a/dbox.c
+++ b/dbox.c
@@ -163,100 +163,6 @@ static void SigHandler(int i)
}
-/* ---------------------------------------- MAIN
-*/
-int main(int argc, char *argv[])
-{
- int interact = FALSE;
- int play = FALSE;
- int check = TRUE;
- int base;
- int f;
- int verbose = FALSE;
-
- g_name = argv[0];
-
- base = 1;
-
- while(argv[base] && argv[base][0] == '-')
- {
- switch(argv[base++][1])
- {
- case 'i':
- interact = TRUE;
- break;
-
- case 'p':
- interact = TRUE;
- play = TRUE;
- break;
-
- case 'P':
- interact = TRUE;
- play = TRUE;
- check = FALSE;
- break;
-
- case 'v':
- verbose = TRUE;
- break;
-
- default:
- base = argc;
- break;
- }
- }
-
- if (!argv[base])
- {
- fprintf(stderr,"%s: usage %s [-v|-i|-p|-P] file [file2 ...]\n",
- g_name, g_name);
- return EXIT_FAILURE;
- }
-
- signal(SIGUSR1, SigHandler);
-
- for(f = base; f < argc; f++)
- {
- route_t route;
- level_t *level;
-
- if (!(level=Load(argv[f])))
- {
- fprintf(stderr,"%s: %s could not be read\n", g_name, argv[f]);
- }
- else
- {
- if (interact)
- {
- Interactive(level, play, check);
- }
- else
- {
- printf("Solving %s\n\n", level->name);
-
- Display(level, level->state);
-
- Solve(level, route, MAX_ROUTE, verbose);
-
- if (route[0])
- {
- printf("\nRoute = '%s'\n",route);
- }
- else
- {
- printf("\nNo solution found!\n");
- }
- }
-
- FreeLevel(level);
- }
- }
-
- return EXIT_SUCCESS;
-}
-
-
/* ---------------------------------------- UTIL
*/
static void *Grab(size_t p_size)
@@ -1425,4 +1331,98 @@ static void Interactive(const level_t *p_level, int p_play, int p_check)
}
+/* ---------------------------------------- MAIN
+*/
+int main(int argc, char *argv[])
+{
+ int interact = FALSE;
+ int play = FALSE;
+ int check = TRUE;
+ int base;
+ int f;
+ int verbose = FALSE;
+
+ g_name = argv[0];
+
+ base = 1;
+
+ while(argv[base] && argv[base][0] == '-')
+ {
+ switch(argv[base++][1])
+ {
+ case 'i':
+ interact = TRUE;
+ break;
+
+ case 'p':
+ interact = TRUE;
+ play = TRUE;
+ break;
+
+ case 'P':
+ interact = TRUE;
+ play = TRUE;
+ check = FALSE;
+ break;
+
+ case 'v':
+ verbose = TRUE;
+ break;
+
+ default:
+ base = argc;
+ break;
+ }
+ }
+
+ if (!argv[base])
+ {
+ fprintf(stderr,"%s: usage %s [-v|-i|-p|-P] file [file2 ...]\n",
+ g_name, g_name);
+ return EXIT_FAILURE;
+ }
+
+ signal(SIGUSR1, SigHandler);
+
+ for(f = base; f < argc; f++)
+ {
+ route_t route;
+ level_t *level;
+
+ if (!(level=Load(argv[f])))
+ {
+ fprintf(stderr,"%s: %s could not be read\n", g_name, argv[f]);
+ }
+ else
+ {
+ if (interact)
+ {
+ Interactive(level, play, check);
+ }
+ else
+ {
+ printf("Solving %s\n\n", level->name);
+
+ Display(level, level->state);
+
+ Solve(level, route, MAX_ROUTE, verbose);
+
+ if (route[0])
+ {
+ printf("\nRoute = '%s'\n",route);
+ }
+ else
+ {
+ printf("\nNo solution found!\n");
+ }
+ }
+
+ FreeLevel(level);
+ }
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
/* END OF FILE */