Merge of Fredrik Hultin command_line
[people/xl0/gpxe.git] / src / commandline / cmdline.c
1 #include <console.h>
2 #include "etherboot.h"
3 #include "cmdline.h"
4 #include "cmdlinelib.h"
5 #include "cmdlist.h"
6
7
8 #define CMDL_DELAY (2000 * TICKS_PER_SEC) / 1000;
9
10 void cmdl_exec_cmdline();
11 char cmdl_spin();
12
13 void cmdl_start()
14 {
15         unsigned int stop;
16         //int spin;
17
18         //printf("gPXE %s (GPL) etherboot.org ...  ", VERSION);
19         printf("gPXE %s (GPL) etherboot.org\n", VERSION);
20
21         stop = currticks() + CMDL_DELAY;
22         
23         while(currticks() < stop){
24         
25                 /*if(spin++ % 250 == 0){
26                         putchar(8);
27                         putchar(cmdl_spin());
28                 }*/
29                 
30                 if(iskey()){
31                         if(getchar() == 2){
32                                 putchar('\n');
33                                 cmdl_exec_cmdline();
34                                 break;
35                         }else{
36                                 putchar('\n');
37                                 printf("Skipping command line.\n");
38                                 break;
39                         }
40                 }
41         }
42         putchar('\n');
43
44         // empty the input buffer
45         while(iskey()) {
46                 getchar();
47         }
48 }
49
50 /*char cmdl_spin()
51 {
52         static int state;*/
53         //int spinner[4] = {'-', '\\', '|', '/'}; <- undefined reference to memcpy!
54 /*      int spinner[4];
55         
56         spinner[0] = '-';
57         spinner[1] = '\\';
58         spinner[2] = '|';
59         spinner[3] = '/';
60
61         return spinner[state++ % 4];
62 }*/
63
64 void cmdl_exec_cmdline(){
65         cmd_line* cmd;
66         cmd = cmdl_create();
67         
68         cmdl_setputchar(cmd, putchar);
69         cmdl_setgetchar(cmd, getchar);
70         cmdl_setprintf(cmd, printf);
71
72         cmdl_setpropmt(cmd, "gPXE>");
73
74         printf("Welcome to Etherboot\n\n");
75
76
77         cmdl_enterloop(cmd);
78
79         cmdl_free(cmd);
80 }
81