/shark/trunk/config/hconf/example.h |
---|
0,0 → 1,42 |
/* |
* This file is generated by a script |
* |
* (run 'make config' to change) |
*/ |
#undef EX_TRISTATE |
#define EX_CHOICE_2 1 |
#undef EX_BOOL2 |
#define EX_BOOL4 1 |
#define CONFIG_SYS_MSDOS 1 |
#define CONFIG_CPU_I386 1 |
#define CONFIG_MAXTASK 5 |
#define CONFIG_SCHED_EDF 1 |
#undef CONFIG_CHAR |
#define CONFIG_BLOCK 1 |
#undef CONFIG_BLOCK_IDE |
#undef CONFIG_BLOCK_LOOP |
#undef CONFIG_GRAPHICS |
#undef CONFIG_NET |
#define CONFIG_FSSUPPORT 1 |
#define CONFIG_FS_MSDOS 1 |
#undef CONFIG_FS_ISO9660 |
#undef CONFIG_FS_DEVFS |
/* var EX_CHOICE_1 n */ |
/* var EX_CHOICE_3 n */ |
/* var EX_BOOL3 n */ |
/* var EX_TRI2 n */ |
/* var CONFIG_SYS_LINUX y */ |
/* var CONFIG_CPU_PENTIUM y */ |
/* var CONFIG_CPU_PENTIUMII n */ |
/* var CONFIG_SCHED_RM n */ |
/* var CONFIG_SCHED_EDFSERV y */ |
/* var CONFIG_SCHED_EDFRMSERV n */ |
/* var CONFIG_CHAR_KEYBOARD n */ |
/* var CONFIG_CHAR_MOUSE n */ |
/* var CONFIG_CHAR_RTC n */ |
/* var CONFIG_CHAR_CONSOLE2 n */ |
/* var CONFIG_NET_3COM n */ |
/* var CONFIG_FS_ISO9960_JOLIET n */ |
/* var CONFIG_FS_ISO9960_ROCKRIDGE n */ |
/shark/trunk/config/hconf/hconf.h |
---|
0,0 → 1,161 |
/* |
* |
* |
* |
*/ |
int init_tokenizer(char *filename,int); |
char *gettoken(void); |
void ungettoken(void); |
int done_tokenizer(void); |
/* |
* |
* |
* |
*/ |
int copystring(char **dstptr, char *src); |
#define MAXVARIABLES 64 |
#define NOTYPEVAR 0 |
#define PRINTEDVAR 1 |
#define BOOLVAR 2 |
#define TRISTATEVAR 3 |
#define CHOICEVAR 4 |
#define RANGEVAR 5 |
/* FLAG_M (if this variable change value some menu must be modified) */ |
#define FLAG_M 0x01 |
#define MAXFILETABLE 16 |
extern char *filetable[]; |
extern int maxfileindex; |
#define NOFILEINDEX -1 |
struct variable { |
int fileindex; |
int type; |
char *name; |
char *value; |
int flags; |
}; |
extern struct variable vartable[]; |
struct choice { |
struct choice *next; |
char *text; |
struct variable *var; |
}; |
struct menuentry; |
struct _case { |
struct _case *next; |
char *value; |
struct menuentry *list; |
}; |
#define BOOLENTRY 1 |
#define SUBMENUENTRY 2 |
#define TRISTATEENTRY 3 |
#define CHOICEENTRY 4 |
#define CASEENTRY 5 |
#define RANGEENTRY 6 |
#define SEPARATORENTRY 7 |
struct menuentry { |
int type; |
struct menuentry *next; |
struct menuentry *n; |
struct menuentry *p; |
union tagentry { |
struct boolentry { |
char *text; |
struct variable *var; |
} bool; |
struct rangeentry { |
char *text; |
int minval,maxval; |
struct variable *var; |
} range; |
struct tristateentry { |
char *text; |
struct variable *var; |
} tristate; |
struct choiceentry { |
char *text; |
int numchoices; |
struct choice *act; |
struct choice *list; |
} choice; |
struct submenuentry { |
char *text; |
char *menuname; |
struct menu *menu; |
} submenu; |
struct caseentry { |
struct _case *list; |
struct variable *var; |
} _case; |
} x; |
}; |
#define MAXMENUS 16 |
struct menu { |
char *name; |
char *title; |
struct menuentry *entries; |
}; |
extern struct menu menutable[]; |
extern struct menu *mainmenu; |
extern char *caption; |
int readconfigin(char *filename); |
void dumpvariables(void); |
extern int line; |
extern int nextvariable; |
struct variable *findvar(char *s); |
extern long varhelp[]; |
extern char helpfilename[]; |
int findvarindex(struct variable *var); |
/* |
* |
* |
* |
*/ |
int show(void); |
/* |
* |
* |
* |
*/ |
int writeconfig(char *srcfilename); |
int writeconfigmak(char *srcfilename); |
int readconfig(char *filename); |
/shark/trunk/config/hconf/shower.c |
---|
0,0 → 1,817 |
/* |
* |
* |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
/* per sleep() */ |
#include <unistd.h> |
#if defined(USE_NCURSES) |
#include <curses.h> |
#elif defined(USE_CONIO) |
#include <conio.o> |
#else |
#error USE_NCURSES or USE_CONIO must be defined |
#endif |
#include "hconf.h" |
/* |
* |
* CONIO |
* |
*/ |
#ifdef USE_CONIO |
#define DEFAULT_BG BLUE |
#define NORMAL_FG WHITE |
#define NORMAL_BG BLUE |
#define INVERSE_FG BLACK |
#define INVERSE_BG RED |
/* -- */ |
struct text_info info; |
void _initscreen(void) |
{ |
textbackground(DEFAULT_BG); |
clrscr(); |
gettextinfo(&info); |
} |
void _endscreen(void) |
{ |
clrscr(); |
} |
static __inline__ int _cols(void) |
{ |
return info.screenwidth; |
} |
static __inline__ int _rows(void) |
{ |
return info.screenheight; |
} |
int _gotorc(int r, int c) |
{ |
/* zero based */ |
gotoxy(c,r); |
} |
#define _printw(fmt,args...) cprintf(fmt,##args) |
#define _refresh() |
void _normal(void) |
{ |
textbackground(NORMAL_BG); |
textcolor(NORMAL_FG); |
} |
#endif |
/* |
* |
* NCURSES |
* |
*/ |
#ifdef USE_NCURSES |
// with bold |
#define DEFAULT_FG COLOR_CYAN |
#define DEFAULT_BG COLOR_BLUE |
#define NORMAL_FG COLOR_BLACK |
#define NORMAL_BG COLOR_WHITE |
// with bold |
#define INVERSE_FG COLOR_WHITE |
#define INVERSE_BG COLOR_BLUE |
//with bold |
#define BOX_BORDERFGU COLOR_WHITE |
#define BOX_BORDERBGU COLOR_WHITE |
#define BOX_BORDERFGD COLOR_BLACK |
#define BOX_BORDERBGD COLOR_WHITE |
#define BOX_FG COLOR_BLACK |
#define BOX_BG COLOR_WHITE |
#define SHADOW_FG COLOR_BLACK |
#define SHADOW_BG COLOR_BLACK |
#define TITLE_FG COLOR_YELLOW |
#define TITLE_BG COLOR_WHITE |
#define _KEY_OK 0x1b |
#define _KEY_DOWN KEY_DOWN |
#define _KEY_UP KEY_UP |
#define _KEY_TOGGLE 0x0a |
/* -- */ |
#define _BACKGROUND 1 |
#define _NORMAL 2 |
#define _INVERSE 3 |
#define _BORDERBOXU 4 |
#define _BORDERBOXD 5 |
#define _BOX 6 |
#define _SHADOW 7 |
#define _TITLE 8 |
#define _DEFAULT 9 |
#define STDWIN stdscr |
/* (U-upper,L-lower) (L-left,R-right) */ |
#define _UL ACS_BSSB |
#define _LL ACS_SSBB |
#define _UR ACS_BBSS |
#define _LR ACS_SBBS |
#define _HH ACS_BSBS |
#define _VV ACS_SBSB |
void _defaultcolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_DEFAULT)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_DEFAULT)|A_BOLD); |
} |
void _normal(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_NORMAL)); |
wbkgdset(w,COLOR_PAIR(_NORMAL)); |
} |
void _inverse(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_INVERSE)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_INVERSE)|A_BOLD); |
} |
void _shadow(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_SHADOW)); |
wbkgdset(w,COLOR_PAIR(_SHADOW)); |
} |
void _boxcolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_BOX)); |
wbkgdset(w,COLOR_PAIR(_BOX)); |
} |
void _titlecolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_TITLE)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_TITLE)|A_BOLD); |
} |
void _borderboxucolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_BORDERBOXU)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_BORDERBOXU)|A_BOLD); |
} |
void _borderboxdcolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_BORDERBOXD)); |
wbkgdset(w,COLOR_PAIR(_BORDERBOXD)); |
} |
void _initscreen(void) |
{ |
initscr(); |
start_color(); |
init_pair(_BACKGROUND,DEFAULT_BG,DEFAULT_BG); |
init_pair(_DEFAULT,DEFAULT_FG,DEFAULT_BG); |
init_pair(_NORMAL,NORMAL_FG,NORMAL_BG); |
init_pair(_INVERSE,INVERSE_FG,INVERSE_BG); |
init_pair(_BORDERBOXU,BOX_BORDERFGU,BOX_BORDERBGU); |
init_pair(_BORDERBOXD,BOX_BORDERFGD,BOX_BORDERBGD); |
init_pair(_BOX,BOX_FG,BOX_BG); |
init_pair(_SHADOW,SHADOW_FG,SHADOW_BG); |
init_pair(_TITLE,TITLE_FG,TITLE_BG); |
bkgdset(COLOR_PAIR(_BACKGROUND)); |
clear(); |
cbreak(); /* input one char at time (don't wait for \n) */ |
noecho(); |
keypad(stdscr,TRUE); |
_normal(stdscr); |
refresh(); |
} |
void _endscreen(void) |
{ |
endwin(); |
} |
static __inline__ int _cols(void) |
{ |
return COLS; |
} |
static __inline__ int _rows(void) |
{ |
return LINES; |
} |
static __inline__ void _gotorc(WINDOW *w,int r, int c) |
{ |
/* zero based */ |
wmove(w,r,c); |
} |
#define _printw(w,fmt,args...) wprintw(w,fmt,##args) |
void _refresh(WINDOW *w) |
{ |
wrefresh(w); |
} |
WINDOW *_createwin(int str, int stc, int lines, int cols) |
{ |
WINDOW *wnd; |
wnd=newwin(lines,cols,str,stc); |
if (wnd!=NULL) { |
//wbkgdset(wnd,COLOR_PAIR(_BACKGROUND)); |
//wclear(wnd); |
//_normal(wnd); |
} |
return wnd; |
} |
#define _deletewin(w) delwin(w) |
#define _putch(w,c) waddch(w,c) |
#define _getch() getch() |
#define _clreol(w) wclrtoeol(w) |
#define _clrscr(w) wclear(w) |
#define _bell() addch('\07'); |
#endif |
/* |
* |
* |
* |
*/ |
static void whichcolor(WINDOW *wnd, int up, int inv) |
{ |
if (((inv==1)&&(up==1))||((inv==0)&&(up==0))) _borderboxdcolor(wnd); |
else _borderboxucolor(wnd); |
} |
void _settitle(WINDOW *wnd, |
int sy, int sx, |
int lines, int cols, |
int bordy, int bordx, |
char *title, |
int shad, int inv) |
{ |
int x; |
sx-=bordx+1; |
sy-=bordy+1; |
cols+=2*(bordx+1); |
lines+=2*(bordy+1); |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy,sx+1); |
for (x=0;x<cols-2;x++) _putch(wnd,_HH); |
if (title!=NULL) { |
_titlecolor(wnd); |
_gotorc(wnd,sy,sx+(cols-strlen(title)-2)/2); |
_printw(wnd," %s ",title); |
_normal(wnd); |
_gotorc(wnd,sy+2,sx+2); |
_printw(wnd,"use <ESC> to exit, <ENTER> to enter/toggle,"); |
_gotorc(wnd,sy+3,sx+2); |
_printw(wnd,"arrows keys to move"); |
} |
_refresh(wnd); |
} |
void _box(WINDOW *wnd, |
int sy, int sx, |
int lines, int cols, |
int bordy, int bordx, |
char *title, |
int shad, int inv) |
{ |
int x,y; |
sx-=bordx+1; |
sy-=bordy+1; |
cols+=2*(bordx+1); |
lines+=2*(bordy+1); |
{ |
char blanks[180]; |
memset(blanks,' ',sizeof(blanks)); |
blanks[cols]='\0'; |
_boxcolor(wnd); |
for (y=0;y<lines;y++) { |
_gotorc(wnd,sy+y,sx); |
_printw(wnd,"%s",blanks); |
} |
} |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy,sx); |
_putch(wnd,_UL); |
for (x=0;x<cols-2;x++) _putch(wnd,_HH); |
whichcolor(wnd,0,inv); |
_putch(wnd,_UR); |
for (y=1;y<lines-1;y++) { |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy+y,sx); |
_putch(wnd,_VV); |
whichcolor(wnd,0,inv); |
_gotorc(wnd,sy+y,sx+cols-1); |
_putch(wnd,_VV); |
if (shad) { |
_shadow(wnd); |
_putch(wnd,' '); |
_putch(wnd,' '); |
} |
} |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy+lines-1,sx); |
_putch(wnd,_LL); |
whichcolor(wnd,0,inv); |
for (x=0;x<cols-2;x++) _putch(wnd,_HH); |
_putch(wnd,_LR); |
if (shad) { |
_shadow(wnd); |
_putch(wnd,' '); |
_putch(wnd,' '); |
} |
if (shad) { |
_shadow(wnd); |
_gotorc(wnd,sy+lines,sx+1); |
for (x=0;x<cols+1;x++) _putch(wnd,' '); |
} |
sx+=bordx+1; |
sy+=bordy+1; |
cols-=2*(bordx+1); |
lines-=2*(bordy+1); |
_settitle(wnd,sy,sx,lines,cols,bordy,bordx,title,shad,inv); |
/* refresh made by _settitle() */ |
} |
void showtitle(char *s); |
/* -- */ |
void showbol(WINDOW *wnd, struct menuentry *ptr) |
{ |
struct variable *var; |
char ch; |
var=ptr->x.bool.var; |
if (!strcmp(var->value,"y")) ch='*'; |
else ch=' '; |
_printw(wnd,"[%c] %s",ch,ptr->x.bool.text); |
_normal(wnd); |
_clreol(wnd); |
} |
void showtristate(WINDOW *wnd, struct menuentry *ptr) |
{ |
struct variable *var; |
char ch; |
var=ptr->x.bool.var; |
if (!strcmp(var->value,"y")) ch='*'; |
else if (!strcmp(var->value,"n")) ch=' '; |
else ch='M'; |
_printw(wnd,"<%c> %s",ch,ptr->x.bool.text); |
_normal(wnd); |
_clreol(wnd); |
} |
void showchoice(WINDOW *wnd, struct menuentry *ptr) |
{ |
_printw(wnd," %s (%s)",ptr->x.choice.text,ptr->x.choice.act->text); |
_normal(wnd); |
_clreol(wnd); |
} |
void showsubmenu(WINDOW *wnd, struct menuentry *ptr) |
{ |
_printw(wnd," %s --->",ptr->x.submenu.text); |
_normal(wnd); |
_clreol(wnd); |
} |
/* -- */ |
int nmax; // numero linee massimo |
void showmenuentries(WINDOW *wnd,struct menuentry *ptr, int r, int c, int rcur) |
{ |
int i; |
i=0; |
while (ptr!=NULL) { |
_gotorc(wnd,r,c); |
if (r==rcur) _inverse(wnd); |
else _normal(wnd); |
r++; |
switch(ptr->type) { |
case BOOLENTRY: |
showbol(wnd,ptr); |
break; |
case TRISTATEENTRY: |
showtristate(wnd,ptr); |
break; |
case CHOICEENTRY: |
showchoice(wnd,ptr); |
break; |
case SUBMENUENTRY: |
showsubmenu(wnd,ptr); |
break; |
default: |
_printw(wnd,"@@@"); |
break; |
} |
ptr=ptr->n; |
i++; |
if (i==nmax) return; |
} |
} |
/* --- */ |
struct menuentry *expandcase(struct menuentry *menuent); |
struct menuentry *expandmenu(struct menuentry *menuent); |
struct menuentry *expandcase(struct menuentry *menuent) |
{ |
struct _case *list; |
list=menuent->x._case.list; |
while (list!=NULL) { |
if (!strcmp(list->value,menuent->x._case.var->value)) { |
return expandmenu(list->list); |
} |
list=list->next; |
} |
return NULL; |
} |
int nument; |
struct menuentry *expandmenu(struct menuentry *menuent) |
{ |
struct menuentry *start,*ptr,*ent,*prev,*p; |
int ne; |
ne=0; |
ptr=menuent; |
prev=NULL; |
start=NULL; |
while (ptr!=NULL) { |
switch(ptr->type) { |
case CASEENTRY: |
ent=expandcase(ptr); |
if (ent==NULL) { |
if (prev!=NULL) prev->n=ptr->next; |
ptr=ptr->next; |
break; |
} |
if (start==NULL) start=ent; |
if (prev!=NULL) prev->n=ent; |
ent->p=prev; |
p=ent; |
while (p->n!=NULL) p=p->n; |
p->n=ptr->next; |
prev=p; |
ptr=ptr->next; |
break; |
default: |
if (start==NULL) start=ptr; |
ne++; |
ptr->p=prev; |
ptr->n=ptr->next; |
prev=ptr; |
ptr=ptr->next; |
break; |
} |
} |
nument+=ne; |
return start; |
} |
/* -- */ |
#define MUSTREDISPLAY 0x01 |
#define MUSTREBUILD 0x02 |
int showmenu(WINDOW *wnd, struct menu *menu); |
int showchoicewnd(WINDOW *wnd, struct menuentry *menu); |
int enteron(WINDOW *wnd,struct menuentry *ptr) |
{ |
struct variable *var; |
switch(ptr->type) { |
case BOOLENTRY: |
var=ptr->x.bool.var; |
if (*var->value=='y') *var->value='n'; |
else *var->value='y'; |
if (var->flags&FLAG_M) return MUSTREBUILD; |
break; |
case TRISTATEENTRY: |
var=ptr->x.tristate.var; |
if (*var->value=='y') *var->value='n'; |
else if (*var->value=='n') *var->value='m'; |
else *var->value='y'; |
if (var->flags&FLAG_M) return MUSTREBUILD; |
break; |
case CHOICEENTRY: |
return showchoicewnd(wnd,ptr)|MUSTREDISPLAY; |
case SUBMENUENTRY: |
return showmenu(wnd,ptr->x.submenu.menu)|MUSTREDISPLAY; |
default: |
_bell(); |
break; |
} |
return 0; |
} |
/* --- */ |
int SC=9; |
int SR=9; |
int NL=36; |
int NC=61; |
int BR=0; |
int BC=4; |
/* --- */ |
/* sigh :-( */ |
static struct choice *findprev(struct choice *list, struct choice *cur) |
{ |
struct choice *c,*p; |
c=list; |
p=NULL; |
while (c!=NULL) { |
if (c==cur) return p; |
p=c; |
c=c->next; |
} |
return NULL; |
} |
int showchoicewnd(WINDOW *wnd, struct menuentry *ent) |
{ |
struct choice *first; // first menuentry of the list |
struct choice *cur; // selected menuentry |
struct choice *fline; // menuentry to show on the first line |
struct choice *p; |
int ch; |
int rcur; |
int i,r,c; |
int ret; |
ret=MUSTREDISPLAY; |
first=fline=cur=ent->x.choice.list; |
rcur=0; |
showtitle(ent->x.choice.text); |
_clrscr(wnd); |
for (;;) { |
r=c=0; |
p=fline; |
i=0; |
while (p!=NULL) { |
_gotorc(wnd,r,c); |
if (r==rcur) _inverse(wnd); |
else _normal(wnd); |
r++; |
_printw(wnd,"(%c) %s",p==ent->x.choice.act?'X':' ',p->text); |
_clreol(wnd); |
p=p->next; |
i++; |
if (i==nmax) break; |
} |
_refresh(wnd); |
ch=getch(); |
switch (ch) { |
case _KEY_OK: |
return ret; |
case _KEY_DOWN: |
if (cur->next==NULL) break; |
cur=cur->next; |
if (rcur<NL-1) { |
rcur++; |
break; |
} |
fline=fline->next; |
break; |
case _KEY_UP: |
p=findprev(ent->x.choice.list,cur); |
if (p==NULL) break; |
cur=p; |
if (rcur!=0) { |
rcur=rcur--; |
break; |
} |
fline=findprev(ent->x.choice.list,fline); |
break; |
case _KEY_TOGGLE: |
if ((ent->x.choice.act->var->flags&FLAG_M)||(cur->var->flags&FLAG_M)) |
ret|=MUSTREBUILD; |
*(ent->x.choice.act->var->value)='n'; |
ent->x.choice.act=cur; |
*(ent->x.choice.act->var->value)='y'; |
break; |
} |
} |
} |
int showmenu(WINDOW *wnd, struct menu *menu) |
{ |
struct menuentry *first; // first menuentry of the list |
struct menuentry *cur; // selected menuentry |
struct menuentry *fline; // menuentry to show on the first line |
int redo; |
int ch; |
int rcur; |
int ret; |
first=fline=cur=NULL; |
rcur=0; |
redo=1; |
ret=MUSTREDISPLAY; |
for (;;) { |
if (redo&MUSTREBUILD) redo|=MUSTREDISPLAY; |
ret|=redo; |
if (redo&MUSTREBUILD) { |
fline=NULL; |
} |
if (redo&MUSTREDISPLAY) { |
nument=0; |
first=expandmenu(menu->entries); |
if (fline==NULL) { |
fline=first; |
if (cur==NULL) { |
cur=fline; |
rcur=0; |
} |
} |
nmax=NL; |
showtitle(menu->title); |
_normal(wnd); |
_clrscr(wnd); |
redo=0; |
} |
showmenuentries(wnd,fline,0,0,rcur); |
_refresh(wnd); |
ch=getch(); |
switch (ch) { |
case _KEY_OK: |
return ret; |
case _KEY_DOWN: |
if (cur->n==NULL) break; |
cur=cur->n; |
if (rcur<NL-1) { |
rcur++; |
break; |
} |
fline=fline->n; |
break; |
case _KEY_UP: |
if (cur->p==NULL) break; |
cur=cur->p; |
if (rcur!=0) { |
rcur=rcur--; |
break; |
} |
fline=fline->p; |
break; |
case _KEY_TOGGLE: |
redo=enteron(wnd,cur); |
break; |
default: |
/* |
_normal(STDWIN); |
_gotorc(STDWIN,0,0); |
_printw(STDWIN,"%04x",ch); |
_refresh(STDWIN); |
*/ |
} |
} |
} |
void showtitle(char *s) |
{ |
_settitle(STDWIN,SR-6,SC-2,NL+8,NC+4,BR,BC,s,1,0); |
} |
/* |
* |
*/ |
int show(void) |
{ |
WINDOW *wnd; |
int i; |
_initscreen(); |
SC=9; |
SR=9; |
NL=_rows()-5-SR-BR*2; |
NC=_cols()-2-SC-BC*2; |
BR=0; |
BC=4; |
_defaultcolor(STDWIN); |
_gotorc(STDWIN,0,0); |
_printw(STDWIN," Hartik4 (Lego) version 4.0pre1 - Configuration"); |
_gotorc(STDWIN,1,1); |
for (i=0;i<_cols()-2;i++) _putch(STDWIN,_HH); |
_box(STDWIN,SR-6,SC-2,NL+8,NC+4,BR,BC,NULL,1,0); |
_box(STDWIN,SR,SC,NL,NC,BR,BC,NULL,0,1); |
wnd=_createwin(SR,SC,NL,NC); |
//showmenu(wnd,mainmenu); |
_endscreen(); |
return 0; |
} |
/shark/trunk/config/hconf/parse.c |
---|
0,0 → 1,861 |
/* |
* |
* |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <ctype.h> |
#include "hconf.h" |
struct variable vartable[MAXVARIABLES]; |
struct menu menutable[MAXMENUS]; |
char *filetable[MAXFILETABLE]; |
int maxfileindex=0; |
long varhelp[MAXVARIABLES]; |
char helpfilename[FILENAME_MAX]; |
#if 0 |
#define printd(fmt,args...) fprintf(stderr,fmt,##args) |
#else |
#define printd(fmt,args...) |
#endif |
struct menu *mainmenu=NULL; |
char *caption=NULL; |
/* |
* |
*/ |
int copystring(char **dstptr, char *src) |
{ |
int sz; |
if (*dstptr!=NULL) free(*dstptr); |
sz=strlen(src)+1; |
*dstptr=(char*)malloc(sz); |
if (*dstptr==NULL) return -100; |
strcpy(*dstptr,src); |
return 0; |
} |
/* |
* |
*/ |
int nextvariable=0; |
struct variable *findvar(char *s) |
{ |
int i; |
i=0; |
while (i<nextvariable) { |
if (!strcmp(vartable[i].name,s)) return vartable+i; |
i++; |
} |
return NULL; |
} |
int findvarindex(struct variable *var) |
{ |
return (var-vartable); |
} |
struct variable *newvar(char *s, int type) |
{ |
struct variable *var; |
/* safety test */ |
var=findvar(s); |
if (var!=NULL) { |
if (var->type==NOTYPEVAR) var->type=type; |
else if (var->type!=type) return NULL; |
return var; |
} |
if (nextvariable>=MAXVARIABLES) return NULL; |
vartable[nextvariable].name=NULL; |
copystring(&vartable[nextvariable].name,s); |
vartable[nextvariable].type=type; |
vartable[nextvariable].value=NULL; |
vartable[nextvariable].flags=0; |
vartable[nextvariable].fileindex=NOFILEINDEX; |
return vartable+nextvariable++; |
} |
/* -- */ |
int nextmenu=0; |
struct menu *findmenu(char *s) |
{ |
int i; |
i=0; |
while (i<nextmenu) { |
if (!strcmp(menutable[i].name,s)) return menutable+i; |
i++; |
} |
return NULL; |
} |
struct menu *newmenu(char *s) |
{ |
if (nextmenu>=MAXMENUS) return NULL; |
menutable[nextmenu].name=NULL; |
copystring(&menutable[nextmenu].name,s); |
menutable[nextmenu].title=NULL; |
menutable[nextmenu].entries=NULL; |
return menutable+nextmenu++; |
} |
/* |
* |
* |
* |
*/ |
struct _case *newcase(struct menuentry *menuent) |
{ |
struct _case *c; |
struct _case *n; |
c=malloc(sizeof(struct _case)); |
if (c==NULL) return NULL; |
c->next=NULL; |
c->value=NULL; |
c->list=NULL; |
if (menuent->x._case.list==NULL) { |
menuent->x._case.list=c; |
return c; |
} |
n=menuent->x._case.list; |
for (;;) { |
if (n->next==NULL) { |
n->next=c; |
return c; |
} |
n=n->next; |
} |
} |
struct choice *newchoice(struct menuentry *menuent) |
{ |
struct choice *c; |
struct choice *n; |
c=malloc(sizeof(struct choice)); |
if (c==NULL) return NULL; |
c->next=NULL; |
c->text=NULL; |
c->var=NULL; |
if (menuent->x.choice.list==NULL) { |
menuent->x.choice.list=c; |
return c; |
} |
n=menuent->x.choice.list; |
for (;;) { |
if (n->next==NULL) { |
n->next=c; |
return c; |
} |
n=n->next; |
} |
} |
struct menuentry *newmenuentry(struct menuentry **ptr) |
{ |
struct menuentry *n; |
struct menuentry *p; |
n=malloc(sizeof(struct menuentry)); |
if (n==NULL) return NULL; |
n->next=NULL; |
n->type=0; |
if (*ptr==NULL) { |
*ptr=n; |
return n; |
} |
p=*ptr; |
for (;;) { |
if (p->next==NULL) { |
p->next=n; |
return n; |
} |
p=p->next; |
} |
} |
int newfile(char *s) |
{ |
if (maxfileindex==MAXFILETABLE) return NOFILEINDEX; |
filetable[maxfileindex]=malloc(strlen(s)+1); |
if (filetable[maxfileindex]==NULL) return NOFILEINDEX; |
strcpy(filetable[maxfileindex],s); |
maxfileindex++; |
return maxfileindex-1; |
} |
/* |
* |
* |
* |
*/ |
/* |
* |
* |
* |
*/ |
int parsebool(struct menuentry **ptr); |
int parsetristate(struct menuentry **ptr); |
int parserange(struct menuentry **ptr); |
int parsesubmenu(struct menuentry **ptr); |
int parsecase(struct menuentry **ptr); |
int parsechoice(struct menuentry **ptr); |
int parseseparator(struct menuentry **ptr); |
int parsemenufield(struct menuentry **ptr) |
{ |
char *s; |
s=gettoken(); |
if (s==NULL) return -999; |
if (!strcmp(s,"bool")) return parsebool(ptr); |
if (!strcmp(s,"tristate")) return parsetristate(ptr); |
if (!strcmp(s,"range")) return parserange(ptr); |
if (!strcmp(s,"submenu")) return parsesubmenu(ptr); |
if (!strcmp(s,"switch")) return parsecase(ptr); |
if (!strcmp(s,"choice")) return parsechoice(ptr); |
if (!strcmp(s,"separator")) return parseseparator(ptr); |
return -333; |
} |
/* --- */ |
int parsecase(struct menuentry **ptr) |
{ |
char *s; |
struct menuentry *ent; |
struct _case *cas=NULL; |
struct variable *v; |
int res; |
printd("start parseswitch()\n"); |
ent=newmenuentry(ptr); |
if (ent==NULL) return -31; |
ent->type=CASEENTRY; |
ent->x._case.list=NULL; |
s=gettoken(); |
if (s==NULL) return -32; |
v=findvar(s); |
if (v==NULL) return -36; |
ent->x._case.var=v; |
v->flags|=FLAG_M; |
for (;;) { |
s=gettoken(); |
if (!strcmp(s,"endswitch")) break; |
if (!strcmp(s,"case")) { |
cas=newcase(ent); |
if (cas==NULL) return -34; |
s=gettoken(); |
if (s==NULL) return -35; |
if (*s!='\"') return -35; |
cas->value=NULL; |
copystring(&cas->value,s+1); |
continue; |
} |
if (cas==NULL) return -39; |
ungettoken(); |
res=parsemenufield(&cas->list); |
if (res) return res; |
} |
return 0; |
} |
int parsechoice(struct menuentry **ptr) |
{ |
struct menuentry *ent; |
struct choice *cho; |
struct variable *v; |
char *def; |
int defdone; |
char *s; |
printd("start parsechoice()\n"); |
ent=newmenuentry(ptr); |
if (ent==NULL) return -31; |
ent->type=CHOICEENTRY; |
ent->x.choice.list=NULL; |
ent->x.choice.act=NULL; |
ent->x.choice.numchoices=0; |
s=gettoken(); |
if (s==NULL) return -32; |
if (*s!='\"') return -33; |
ent->x.choice.text=NULL; |
copystring(&ent->x.choice.text,s+1); |
defdone=0; |
def=NULL; |
s=gettoken(); |
if (s==NULL) return -39; |
if (*s!='\"') { |
copystring(&def,s); |
} else |
ungettoken(); |
for (;;) { |
s=gettoken(); |
if (s==NULL) return -34; |
if (!strcmp(s,"endchoice")) { |
if (def==NULL||!defdone) return -37; |
free(def); |
break; |
} |
if (*s!='\"') return -38; |
cho=newchoice(ent); |
ent->x.choice.numchoices++; |
if (cho==NULL) return -33; |
cho->text=NULL; |
copystring(&cho->text,s+1); |
s=gettoken(); |
if (s==NULL) return -34; |
v=newvar(s,CHOICEVAR); |
if (v==NULL) return -37; |
cho->var=v; |
v->value=NULL; |
copystring(&v->value,"n"); |
if (def==NULL) { |
ent->x.choice.act=cho; |
copystring(&def,s); |
defdone=1; |
} else if (!strcmp(def,s)) { |
ent->x.choice.act=cho; |
defdone=1; |
} |
} |
return 0; |
} |
int parsebool(struct menuentry **ptr) |
{ |
struct menuentry *ent; |
struct variable *var; |
char *s; |
printd("start parsebool()\n"); |
ent=newmenuentry(ptr); |
if (ent==NULL) return -50; |
ent->type=BOOLENTRY; |
s=gettoken(); |
if (s==NULL) return -51; |
if (*s!='\"') return -55; |
ent->x.bool.text=NULL; |
copystring(&ent->x.bool.text,s+1); |
s=gettoken(); |
if (s==NULL) return -52; |
var=newvar(s,BOOLVAR); |
if (var==NULL) return -53; |
ent->x.bool.var=var; |
s=gettoken(); |
if (*s!='\"') { |
ungettoken(); |
var->value=(char *)malloc(2); |
var->value[0]='n'; |
var->value[1]='\0'; |
return 0; |
} |
if (*(s+1)=='\0') return -54; |
var->value=NULL; |
copystring(&var->value,s+1); |
return 0; |
} |
int parseseparator(struct menuentry **ptr) |
{ |
struct menuentry *ent; |
printd("start parseseparator()\n"); |
ent=newmenuentry(ptr); |
if (ent==NULL) return -50; |
ent->type=SEPARATORENTRY; |
return 0; |
} |
int parserange(struct menuentry **ptr) |
{ |
struct menuentry *ent; |
struct variable *var; |
char *s; |
int v; |
printd("start parserange()\n"); |
ent=newmenuentry(ptr); |
if (ent==NULL) return -60; |
ent->type=RANGEENTRY; |
s=gettoken(); |
if (s==NULL) return -61; |
if (*s!='\"') return -65; |
ent->x.range.text=NULL; |
copystring(&ent->x.range.text,s+1); |
s=gettoken(); |
if (s==NULL) return -62; |
var=newvar(s,RANGEVAR); |
if (var==NULL) return -63; |
ent->x.range.var=var; |
s=gettoken(); |
if (s==NULL) return -66; |
ent->x.range.minval=atoi(s); |
if (ent->x.range.minval==0&&strcmp(s,"0")) return -67; |
s=gettoken(); |
if (s==NULL) return -66; |
ent->x.range.maxval=atoi(s); |
if (ent->x.range.maxval==0&&strcmp(s,"0")) return -68; |
s=gettoken(); |
if (s==NULL) return -69; |
v=atoi(s); |
if (v==0&&strcmp(s,"0")) { |
ungettoken(); |
v=ent->x.range.minval; |
} |
{ |
char buffer[256]; |
sprintf(buffer,"%i",v); |
var->value=NULL; |
copystring(&var->value,buffer); |
} |
return 0; |
} |
int parsetristate(struct menuentry **ptr) |
{ |
struct menuentry *ent; |
struct variable *var; |
char *s; |
printd("start parsetristate()\n"); |
ent=newmenuentry(ptr); |
if (ent==NULL) return -50; |
ent->type=TRISTATEENTRY; |
s=gettoken(); |
if (s==NULL) return -51; |
if (*s!='\"') return -55; |
ent->x.tristate.text=NULL; |
copystring(&ent->x.tristate.text,s+1); |
s=gettoken(); |
if (s==NULL) return -52; |
var=newvar(s,TRISTATEVAR); |
if (var==NULL) return -53; |
ent->x.tristate.var=var; |
s=gettoken(); |
if (*s!='\"') { |
ungettoken(); |
var->value=(char *)malloc(2); |
var->value[0]='n'; |
var->value[1]='\0'; |
return 0; |
} |
if (*(s+1)=='\0') return -54; |
var->value=NULL; |
copystring(&var->value,s+1); |
return 0; |
} |
int parsesubmenu(struct menuentry **ptr) |
{ |
struct menuentry *ent; |
char *s; |
printd("start parsesubmenu()\n"); |
ent=newmenuentry(ptr); |
if (ent==NULL) return -40; |
ent->type=SUBMENUENTRY; |
s=gettoken(); |
if (s==NULL) return -41; |
if (*s!='\"') return -43; |
ent->x.submenu.text=NULL; |
copystring(&ent->x.submenu.text,s+1); |
s=gettoken(); |
if (s==NULL) return -42; |
ent->x.submenu.menuname=NULL; |
ent->x.submenu.menu=NULL; |
copystring(&ent->x.submenu.menuname,s); |
return 0; |
} |
int parsetitle(struct menu *ptr) |
{ |
char *s; |
printd("start parsetitle()\n"); |
s=gettoken(); |
if (s==NULL) return -71; |
ptr->title=NULL; |
copystring(&ptr->title,s+1); |
return 0; |
} |
int parsecaption(void) |
{ |
char *s; |
printd("start parsecaption()\n"); |
s=gettoken(); |
if (s==NULL) return -91; |
caption=NULL; |
copystring(&caption,s+1); |
return 0; |
} |
int parsemenu(void) |
{ |
struct menu *ptr; |
char *s; |
int ret; |
printd("start parsemenu()\n"); |
ret=0; |
s=gettoken(); |
if (s==NULL) return -12; |
ptr=newmenu(s); |
if (ptr==NULL) return -15; |
for (;;) { |
s=gettoken(); |
if (!strcmp(s,"endmenu")) return 0; |
if (!strcmp(s,"title")) { |
ret=parsetitle(ptr); |
if (ret) return ret; |
continue; |
} |
ungettoken(); |
ret=parsemenufield(&ptr->entries); |
if (ret) break; |
} |
return ret; |
} |
int parsefile(void) |
{ |
struct variable *var; |
char *s; |
int index; |
int ret; |
printd("start parsefile()\n"); |
ret=0; |
s=gettoken(); |
if (s==NULL) return -112; |
index=newfile(s); |
if (index==-1) return -115; |
for (;;) { |
s=gettoken(); |
if (!strcmp(s,"endfile")) return 0; |
var=newvar(s,NOTYPEVAR); |
if (var==NULL) return -117; |
var->fileindex=index; |
} |
return ret; |
} |
/* |
* |
*/ |
int resolvmenuentries(struct menuentry *ptr) |
{ |
struct _case *ca; |
int res,i; |
while (ptr!=NULL) { |
switch(ptr->type) { |
case BOOLENTRY: |
break; |
case TRISTATEENTRY: |
break; |
case SUBMENUENTRY: |
ptr->x.submenu.menu=findmenu(ptr->x.submenu.menuname); |
if (ptr->x.submenu.menu==NULL) return -10; |
break; |
case CHOICEENTRY: |
break; |
case CASEENTRY: |
ca=ptr->x._case.list; |
i=1; |
while (ca!=NULL) { |
res=resolvmenuentries(ca->list); |
if (res) return res; |
ca=ca->next; |
i++; |
} |
break; |
} |
ptr=ptr->next; |
} |
return 0; |
} |
static int resolv(void) |
{ |
int res,i; |
i=0; |
while (i<nextmenu) { |
res=resolvmenuentries(menutable[i].entries); |
if (res) return res; |
i++; |
} |
return 0; |
} |
/* |
* |
*/ |
int parse(void) |
{ |
char *s; |
int ret; |
ret=0; |
while ((s=gettoken())!=NULL) { |
if (!strcmp(s,"menu")) ret=parsemenu(); |
else if (!strcmp(s,"caption")) ret=parsecaption(); |
else if (!strcmp(s,"file")) ret=parsefile(); |
else ret=-1; |
if (ret) break; |
} |
return ret; |
} |
int parsehelp(char *filename) |
{ |
struct variable *var; |
char buffer[256]; |
FILE *fin; |
char *s; |
int i; |
fin=fopen(filename,"rt"); |
if (fin==NULL) return 0; |
while (fgets(buffer,sizeof(buffer),fin)!=NULL) |
if (*buffer=='@') { |
s=strchr(buffer,'\n'); |
if (s!=NULL) *s='\0'; |
var=findvar(buffer+1); |
if (var==NULL) { |
fprintf(stderr,"help var %s not found config file",buffer); |
return -845; |
} |
i=findvarindex(var); |
varhelp[i]=ftell(fin); |
} |
fclose(fin); |
return 0; |
} |
int readconfigin(char *filename) |
{ |
char *ptr; |
int res; |
res=init_tokenizer(filename,0x01); |
if (res) return res; |
res=parse(); |
if (res) return res; |
res=done_tokenizer(); |
if (res) return res; |
res=resolv(); |
if (res) return res; |
mainmenu=findmenu("main"); |
if (mainmenu==NULL) return -97; |
/* -- */ |
ptr=strstr(filename,".in"); |
if (ptr!=NULL) *ptr='\0'; |
else { |
ptr=strchr(filename,'.'); |
if (ptr!=NULL) *ptr='\0'; |
} |
strcpy(helpfilename,filename); |
strcat(helpfilename,".hlp"); |
res=parsehelp(helpfilename); |
if (res) return res; |
return 0; |
} |
/* |
* |
* |
* |
*/ |
void dumpvariables(void) |
{ |
int i; |
fprintf(stderr,"VARIABLES TABLE\n---------------\n\n"); |
i=0; |
while (i<nextvariable) { |
fprintf(stderr,"name: -%s-\n",vartable[i].name); |
if (vartable[i].value!=NULL) |
fprintf(stderr,"value: \"%s\"\n",vartable[i].value); |
else |
fprintf(stderr,"value: NO VALUE\n"); |
fprintf(stderr,"flags: 0x%04x\n",vartable[i].flags); |
fputc('\n',stderr); |
i++; |
} |
} |
#if 0 |
void dumpmenuentrytype(struct menuentry *ptr,char *s) |
{ |
fprintf(stderr,"%s entry type : ",s); |
switch(ptr->type) { |
case BOOLENTRY: fprintf(stderr,"bool\n"); break; |
case SUBMENUENTRY: fprintf(stderr,"submenu\n"); break; |
case TRISTATEENTRY: fprintf(stderr,"tristate\n"); break; |
case CHOICEENTRY: fprintf(stderr,"choice\n"); break; |
case CASEENTRY: fprintf(stderr,"case\n"); break; |
default: fprintf(stderr,"unknown\n"); break; |
} |
} |
void dumpmenuentries(struct menuentry *ptr,int x) |
{ |
struct choice *cho; |
struct _case *ca; |
char blanks[64]; |
int i; |
memset(blanks,' ',sizeof(blanks)); |
blanks[x-1]='\0'; |
while (ptr!=NULL) { |
dumpmenuentrytype(ptr,blanks); |
switch(ptr->type) { |
case BOOLENTRY: |
fprintf(stderr,"%s text : '%s'\n",blanks,ptr->x.bool.text); |
fprintf(stderr,"%s variable : %s\n",blanks,ptr->x.bool.var->name); |
break; |
case TRISTATEENTRY: |
fprintf(stderr,"%s text : '%s'\n",blanks,ptr->x.tristate.text); |
fprintf(stderr,"%s variable : %s\n",blanks,ptr->x.tristate.var->name); |
break; |
case SUBMENUENTRY: |
fprintf(stderr,"%s text : '%s'\n",blanks,ptr->x.submenu.text); |
fprintf(stderr,"%s submenu : %s\n",blanks,ptr->x.submenu.menu->name); |
break; |
case CHOICEENTRY: |
fprintf(stderr,"%s text : '%s'\n",blanks,ptr->x.choice.text); |
fprintf(stderr,"%s def variable: %s\n",blanks,ptr->x.choice.act->var->name); |
i=1; |
cho=ptr->x.choice.list; |
while (cho!=NULL) { |
fprintf(stderr,"%s text %i : '%s'\n",blanks,i,cho->text); |
fprintf(stderr,"%s variable %i : %s\n",blanks,i,cho->var->name); |
i++; |
cho=cho->next; |
} |
break; |
case CASEENTRY: |
fprintf(stderr,"%s variable : %s\n",blanks,ptr->x._case.var->name); |
fputc('\n',stderr); |
ca=ptr->x._case.list; |
i=1; |
while (ca!=NULL) { |
fprintf(stderr,"%s value %i : '%s'\n",blanks,i,ca->value); |
dumpmenuentries(ca->list,x+2); |
ca=ca->next; |
i++; |
} |
break; |
} |
fputc('\n',stderr); |
ptr=ptr->next; |
} |
} |
void dumpmenus(void) |
{ |
int i; |
fprintf(stderr,"MENUS TABLE\n-----------\n\n"); |
i=0; |
while (i<nextmenu) { |
fprintf(stderr,"name: %s\n",menutable[i].name); |
fprintf(stderr,"text: '%s'\n",menutable[i].comment); |
fputc('\n',stderr); |
dumpmenuentries(menutable[i].entries,2); |
//fputc('\n',stderr); |
i++; |
} |
} |
#endif |
/shark/trunk/config/hconf/lego.in |
---|
0,0 → 1,209 |
# |
# |
# |
caption "Hartik4 (Lego) version 4.0pre1 - Configuration" |
#file pippo.h |
#dasf |
#sdf |
#sdf |
#fd |
#endfile |
# |
# Menu principale |
# |
menu main |
title "Configuration Menu" |
submenu "Makefile & Compiler " compiler |
submenu "Low Level Layer " lowlevel |
submenu "Generic Kernel Layer " kernel |
submenu "Module Parameters " modules |
submenu "POSIX constants & limits" posix |
submenu "Drivers " drivers |
submenu "File system " filesystem |
submenu "Examples & tests " tests |
endmenu |
menu compiler |
title "Makefile & Compiler options" |
choice "Processor" |
"i386/i486" CONFIG_CPU_I386 |
"pentium/K5" CONFIG_CPU_PENTIUM |
"pentium II/K6/K6-2" CONFIG_CPU_PENTIUMII |
endchoice |
choice "Compiler" |
"gcc" CONFIG_COMPILER_GCC |
endchoice |
switch CONFIG_COMPILER_GCC |
case "y" |
submenu " GCC compiler options" gcc_options |
case "n" |
endswitch |
choice "Assembler" |
"gcc" CONFIG_ASSEMBLER_GCC |
endchoice |
choice "Linker" |
"ld" CONFIG_LINKER_LD |
endchoice |
switch CONFIG_LINKER_LD |
case "y" |
choice " Base text address" |
"0x140000 no smartdrv, low memory" CONFIG_LD_NOSMARTDRV |
"0x540000 smartdrv up to 4Mb" CONFIG_LD_4SMARTDRV |
"0x940000 smartdrv up to 8Mb" CONFIG_LD_8SMARTDRV |
endchoice |
case "n" |
endswitch |
choice "Library manager" |
"ar" CONFIG_LIBRARY_AR |
endchoice |
separator |
choice "Host OS" |
"MS-DOS" CONFIG_OS_MSDOS |
"Linux" CONFIG_OS_LINUX |
"Winbug 9x" CONFIG_OS_WIN |
endchoice |
# |
# MS-DOS options |
# |
switch CONFIG_OS_MSDOS |
case "y" |
bool " use redir.exe" CONFIG_REDIR |
choice " File management commands" |
"DOS - like (copy, del, ...)" CONFIG_SYS_COPY |
"Unix - like (cp, rm, ...)" CONFIG_SYS_CP |
endchoice |
case "n" |
endswitch |
# |
# Linux options |
# |
# |
# Win options |
# |
switch CONFIG_OS_WIN |
case "y" |
bool " Disinstall Windows before compiling LEGO" CONFIG_JOKE0 |
case "n" |
endswitch |
endmenu |
menu lowlevel |
range "Max number of tasks" TSSMax 1 256 100 |
range "cprintf() buffer size" MAX_CPRINT_BUF 16 1024 512 |
endmenu |
menu kernel |
range "Max number of exit functions" MAX_EXITFUNC 10 100 20 |
range "Default stack size (bytes)" STACK_SIZE 1024 65536 4096 |
range "JET entries per task" JET_TABLE_DIM 1 1024 20 |
range "Max task name characters (+1)" MAX_TASKNAME 2 255 20 |
separator |
range "Max number of cancellation points" MAX_CANCPOINTS 10 1024 20 |
range "Max n. of signal interruptable points" MAX_SIGINTPOINTS 10 1024 20 |
endmenu |
menu modules |
range "Max number of Scheduling levels" MAX_SCHED_LEVEL 1 256 16 |
range "Max number of Resource levels" MAX_RES_LEVEL 1 256 8 |
separator |
range "Max sched. level name characters (+1)" MAX_LEVELNAME 2 255 20 |
range "Max res. level name characters (+1)" MAX_MODULENAME 2 255 20 |
separator |
range "Max number of init functions" MAX_INITFUNC 10 100 20 |
endmenu |
menu posix |
range "DELAYTIMER_MAX" DELAYTIMER_MAX 32 2147483648 32 |
range "MQ_OPEN_MAX" MQ_OPEN_MAX 8 1024 8 |
range "MQ_PRIO_MAX" MQ_PRIO_MAX 32 2147483648 32 |
range "PTHREAD_DESTRUCTOR_ITERATIONS" PTHREAD_DESTRUCTOR_ITERATIONS 4 128 4 |
range "PTHREAD_KEYS_MAX" PTHREAD_KEYS_MAX 128 1024 128 |
range "PTHREAD_STACK_MIN" PTHREAD_STACK_MIN 0 65536 4096 |
range "SEM_NSEMS_MAX" SEM_NSEMS_MAX 256 65536 256 |
range "SIGQUEUE_MAX" SIGQUEUE_MAX 32 1024 32 |
range "TIMER_MAX" TIMER_MAX 32 1024 32 |
#define NGROUPS_MAX _POSIX_NGROUPS_MAX |
#define AIO_LISTIO_MAX _POSIX_AIO_LISTIO_MAX |
#define AIO_MAX _POSIX_AIO_MAX |
#define AIO_PRIO_DELTA_MAX 0 |
#define ARG_MAX _POSIX_ARG_MAX |
#define CHILD_MAX _POSIX_CHILD_MAX |
#define LOGIN_NAME_MAX _POSIX_LOGIN_NAME_MAX |
#define OPEN_MAX _POSIX_OPEN_MAX |
#define PAGESIZE 1 |
#define STREAM_MAX _POSIX_STREAM_MAX |
#define TTY_NAME_MAX _POSIX_TTY_NAME_MAX |
#define TZNAME_MAX _POSIX_TZNAME_MAX |
#define LINK_MAX _POSIX_LINK_MAX |
#define MAX_CANON _POSIX_MAX_CANON |
#define MAX_INPUT _POSIX_MAX_INPUT |
#define NAME_MAX _POSIX_NAME_MAX |
#define PATH_MAX _POSIX_PATH_MAX |
#define PIPE_BUF _POSIX_PIPE_BUF |
#define SSIZE_MAX _POSIX_SSIZE_MAX |
#define _POSIX_CLOCKRES_MIN 20000000L |
endmenu |
menu drivers |
endmenu |
menu filesystem |
endmenu |
menu tests |
choice "Default kernel configuration" |
"EDF+CBS+RR, NOP, NPP, PI, PC, SRP" CONFIG_TESTS_INIT_H3PIPS |
"Posix" CONFIG_TESTS_INIT_POSIX |
"None (built into the application)" CONFIG_TESTS_INIT_NONE |
endchoice |
separator |
choice "RT clock (INT 0) programming" |
"Periodic" CONFIG_TESTS_INIT_RTCLOCK_PERIODIC |
"One shot" CONFIG_TESTS_INIT_RTCLOCK_ONESHOT |
endchoice |
switch CONFIG_TESTS_INIT_RTCLOCK_PERIODIC |
case "y" |
range " Default system tick (x100us)" CONFIG_TESTS_SYSTICK 1 200 3 |
case "n" |
endswitch |
range "RR Default timeslice (x100us)" CONFIG_TESTS_RRSLICE 10 2000 25 |
separator |
bool "check when compiling test[1|2|3|9|B].c (mandatory)" __TEST1__ |
bool "check when compiling testG.c (optional)" TESTG |
endmenu |
menu gcc_options |
title "GCC compiler options" |
bool "-Wimplicit-function-declaration" CONFIG_GCC_W_IMPLICIT |
bool "-Wall" CONFIG_GCC_W_ALL |
endmenu |
/shark/trunk/config/hconf/read.c |
---|
0,0 → 1,79 |
#include <stdio.h> |
#include <string.h> |
#include "hconf.h" |
static char buffer[1024]; |
static char name[64]; |
static char value[64]; |
static int read_h(char *filename) |
{ |
FILE *fin; |
struct variable *var; |
int res; |
fin=fopen(filename,"rt"); |
if (fin==NULL) return -1; |
while (fgets(buffer,sizeof(buffer),fin)!=NULL) { |
res=sscanf(buffer,"#define %s %s",name,value); |
if (res==2) { |
var=findvar(name); |
if (var==NULL) continue; |
switch (var->type) { |
case RANGEVAR: |
copystring(&var->value,value); |
continue; |
case BOOLVAR: |
copystring(&var->value,"y"); |
continue; |
case TRISTATEVAR: |
if (*value=='0') copystring(&var->value,"m"); |
else copystring(&var->value,"y"); |
continue; |
case CHOICEVAR: |
copystring(&var->value,"y"); |
continue; |
} |
} |
res=sscanf(buffer,"#undef %s",name); |
if (res==1) { |
var=findvar(name); |
if (var==NULL) continue; |
copystring(&var->value,"n"); |
continue; |
} |
res=sscanf(buffer,"/* var %s %s */",name,value); |
if (res==2) { |
var=findvar(name); |
if (var==NULL) continue; |
copystring(&var->value,value); |
continue; |
} |
} |
fclose(fin); |
return 0; |
} |
/* -- */ |
int readconfig(char *srcfilename) |
{ |
char buffer[256]; |
char *ptr; |
ptr=strstr(srcfilename,".in"); |
if (ptr!=NULL) *ptr='\0'; |
else { |
ptr=strchr(srcfilename,'.'); |
if (ptr!=NULL) *ptr='\0'; |
} |
strcpy(buffer,srcfilename); |
strcat(buffer,".h"); |
read_h(buffer); |
return 0; |
} |
/shark/trunk/config/hconf/example.in |
---|
0,0 → 1,120 |
# |
# |
# |
caption "Hartik4 (Lego) version 4.0pre1 - Configuration" |
file example2.h |
EX_BOOL |
EX_RANGE |
endfile |
# |
# Menu principale |
# |
menu main |
title "Example menu" |
bool "this is a 'bool' entry" EX_BOOL |
tristate "this is a 'tristate' entry" EX_TRISTATE |
range "this is a 'range' entry" EX_RANGE 1 50 10 |
choice "this is a choice entry" |
"first choice" EX_CHOICE_1 |
"second choice" EX_CHOICE_2 |
"third choice" EX_CHOICE_3 |
endchoice |
separator |
bool "this is a 'bool' entry associated with a 'switch' entry" EX_BOOL2 |
switch EX_BOOL2 |
case "y" |
bool " this bool is visible only when previous bool is 'true'" EX_BOOL3 |
tristate " another 'tristate' to show" EX_TRI2 |
case "n" |
bool " visible when previous bool is 'false'" EX_BOOL4 |
endswitch |
separator |
submenu "example of a 'submenu' entry - hartik submenu" hartik |
endmenu |
# |
# Una menu di prova per HARTIK |
# |
menu hartik |
title "Main menu" |
choice "Batch system" |
"MS-DOS" CONFIG_SYS_MSDOS |
"Linux" CONFIG_SYS_LINUX |
endchoice |
submenu "System" system |
submenu "Scheduler" scheduler |
submenu "Drivers" drivers |
submenu "File system" filesystem |
endmenu |
menu system |
title "System" |
choice "Processor" |
"i386/i486" CONFIG_CPU_I386 |
"pentium/K5" CONFIG_CPU_PENTIUM |
"pentium II/K6/K6-2" CONFIG_CPU_PENTIUMII |
endchoice |
range "Max number of task" CONFIG_MAXTASK 3 10 7 |
endmenu |
menu scheduler |
title "Kernel scheduler" |
choice "Scheduler" |
"EDF" CONFIG_SCHED_EDF |
"RM" CONFIG_SCHED_RM |
"EDF+Server" CONFIG_SCHED_EDFSERV |
"EDF+RM+Server" CONFIG_SCHED_EDFRMSERV |
endchoice |
endmenu |
menu drivers |
title "Low level drivers" |
bool "Character device" CONFIG_CHAR |
switch CONFIG_CHAR |
case "y" |
bool " Keyboard support" CONFIG_CHAR_KEYBOARD "y" |
bool " Mouse support" CONFIG_CHAR_MOUSE |
bool " RealTime clock (RTC) support" CONFIG_CHAR_RTC |
bool " Console support" CONFIG_CHAR_CONSOLE2 "y" |
endswitch |
bool "Block device" CONFIG_BLOCK |
switch CONFIG_BLOCK |
case "y" |
bool " IDE device support" CONFIG_BLOCK_IDE |
bool " Loopback support" CONFIG_BLOCK_LOOP |
endswitch |
bool "Graphics support" CONFIG_GRAPHICS |
bool "Networkig" CONFIG_NET |
switch CONFIG_NET |
case "y" |
bool " 3COM cards" CONFIG_NET_3COM |
endswitch |
endmenu |
menu filesystem |
title "File system" |
bool "Filesystem support" CONFIG_FSSUPPORT |
switch CONFIG_FSSUPPORT |
case "y" |
bool " MS-DOS filesystem" CONFIG_FS_MSDOS |
bool " ISO9660 filesystem" CONFIG_FS_ISO9660 |
switch CONFIG_FS_ISO9660 |
case "y" |
bool " Microsoft Joliet support" CONFIG_FS_ISO9960_JOLIET |
bool " RockRidge extension" CONFIG_FS_ISO9960_ROCKRIDGE |
endswitch |
bool " DEVFS filesystem" CONFIG_FS_DEVFS |
endswitch |
endmenu |
/shark/trunk/config/hconf/show.c |
---|
0,0 → 1,1114 |
/* |
* |
* |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#if defined(USE_NCURSES) |
#include <curses.h> |
#include <term.h> |
#elif defined(USE_CONIO) |
#include <conio.h> |
/* for usleep() */ |
#include <unistd.h> |
/* for sound(), nosound() */ |
#include <pc.h> |
#else |
#error USE_NCURSES or USE_CONIO must be defined |
#endif |
#include "hconf.h" |
/* |
* |
* CONIO |
* |
*/ |
#ifdef USE_CONIO |
// with bold |
#define DEFAULT_FG CYAN |
#define DEFAULT_BG BLUE |
#define NORMAL_FG BLACK |
#define NORMAL_BG WHITE |
// with bold |
#define INVERSE_FG WHITE |
#define INVERSE_BG BLUE |
//with bold |
#define BOX_BORDERFGU WHITE |
#define BOX_BORDERBGU WHITE |
#define BOX_BORDERFGD BLACK |
#define BOX_BORDERBGD WHITE |
#define BOX_FG BLACK |
#define BOX_BG WHITE |
#define SHADOW_FG BLACK |
#define SHADOW_BG BLACK |
#define TITLE_FG YELLOW |
#define TITLE_BG WHITE |
#define _KEY_OK 0x1b |
#define _KEY_OK2 0x4b |
#define _KEY_DOWN 0x50 |
#define _KEY_UP 0x48 |
#define _KEY_TOGGLE 0x0d |
#define _KEY_HELP '?' |
/* (U-upper,L-lower) (L-left,R-right) */ |
#define _UL 'Ú' |
#define _LL 'À' |
#define _UR '¿' |
#define _LR 'Ù' |
#define _HH 'Ä' |
#define _VV '³' |
/* -- */ |
typedef struct tagWINDOW { |
int str,stc,nl,nc; |
} WINDOW; |
void _defaultcolor(WINDOW *w) |
{ |
textbackground(DEFAULT_BG); |
textcolor(DEFAULT_FG); |
} |
void _normal(WINDOW *w) |
{ |
textbackground(NORMAL_BG); |
textcolor(NORMAL_FG); |
} |
void _inverse(WINDOW *w) |
{ |
textbackground(INVERSE_BG); |
textcolor(INVERSE_FG); |
} |
void _shadow(WINDOW *w) |
{ |
textbackground(SHADOW_BG); |
textcolor(SHADOW_FG); |
} |
void _boxcolor(WINDOW *w) |
{ |
textbackground(BOX_BG); |
textcolor(BOX_FG); |
} |
void _titlecolor(WINDOW *w) |
{ |
textbackground(TITLE_BG); |
textcolor(TITLE_FG); |
} |
void _borderboxucolor(WINDOW *w) |
{ |
textbackground(BOX_BORDERBGU); |
textcolor(BOX_BORDERFGU); |
} |
void _borderboxdcolor(WINDOW *w) |
{ |
textbackground(BOX_BORDERBGD); |
textcolor(BOX_BORDERFGD); |
} |
/* -- */ |
struct text_info info; |
#define _cols() info.screenwidth |
#define _rows() info.screenheight |
#define _cursor_invisible() _setcursortype(_NOCURSOR) |
#define _cursor_visible() _setcursortype(_NORMALCURSOR) |
#define _gotorc(w,r,c) gotoxy(w->stc+c+1,w->str+r+1) |
#define _printw(w,fmt,args...) cprintf(fmt,##args) |
#define _refresh(w) |
#define _putch(w,c) putch(c) |
#define _getch() getch() |
void _clrscr(WINDOW *w) |
{ |
static char buffer[256]; |
int r; |
memset(buffer,' ',sizeof(buffer)); |
buffer[w->nc]='\0'; |
for (r=0;r<w->nl;r++) { |
gotoxy(w->stc+1,w->str+r+1); |
cprintf("%s",buffer); |
} |
} |
void _clreol(WINDOW *w) |
{ |
int l; |
l=w->stc+w->nc-wherex(); |
if (l>0) |
while (l-->0) putch(' '); |
} |
void _bell(void) |
{ |
sound(2000); |
usleep(250000l); |
nosound(); |
} |
/* -- */ |
WINDOW *_createwin(int str, int stc, int nlines, int cols) |
{ |
WINDOW *wnd; |
wnd=(WINDOW*)malloc(sizeof(WINDOW)); |
if (wnd!=NULL) { |
wnd->str=str; |
wnd->stc=stc; |
wnd->nl=nlines; |
wnd->nc=cols; |
} |
return wnd; |
} |
#define _deletewin(w) free(w) |
WINDOW *STDWIN; |
void _initscreen(void) |
{ |
gppconio_init(); |
gettextinfo(&info); |
STDWIN=_createwin(0,0,_rows(),_cols()); |
_defaultcolor(STDWIN); |
clrscr(); |
} |
void _endscreen(void) |
{ |
//clrscr(); |
} |
#endif |
/* |
* |
* NCURSES |
* |
*/ |
#ifdef USE_NCURSES |
// with bold |
#define DEFAULT_FG COLOR_CYAN |
#define DEFAULT_BG COLOR_BLUE |
#define NORMAL_FG COLOR_BLACK |
#define NORMAL_BG COLOR_WHITE |
// with bold |
#define INVERSE_FG COLOR_WHITE |
#define INVERSE_BG COLOR_BLUE |
//with bold |
#define BOX_BORDERFGU COLOR_WHITE |
#define BOX_BORDERBGU COLOR_WHITE |
#define BOX_BORDERFGD COLOR_BLACK |
#define BOX_BORDERBGD COLOR_WHITE |
#define BOX_FG COLOR_BLACK |
#define BOX_BG COLOR_WHITE |
#define SHADOW_FG COLOR_BLACK |
#define SHADOW_BG COLOR_BLACK |
#define TITLE_FG COLOR_YELLOW |
#define TITLE_BG COLOR_WHITE |
#define _KEY_OK 0x1b |
#define _KEY_OK2 'q' |
#define _KEY_DOWN KEY_DOWN |
#define _KEY_UP KEY_UP |
#define _KEY_TOGGLE 0x0a |
#define _KEY_HELP '?' |
/* -- */ |
#define _BACKGROUND 1 |
#define _NORMAL 2 |
#define _INVERSE 3 |
#define _BORDERBOXU 4 |
#define _BORDERBOXD 5 |
#define _BOX 6 |
#define _SHADOW 7 |
#define _TITLE 8 |
#define _DEFAULT 9 |
#define STDWIN stdscr |
/* (U-upper,L-lower) (L-left,R-right) */ |
#define _UL ACS_BSSB |
#define _LL ACS_SSBB |
#define _UR ACS_BBSS |
#define _LR ACS_SBBS |
#define _HH ACS_BSBS |
#define _VV ACS_SBSB |
void _defaultcolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_DEFAULT)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_DEFAULT)|A_BOLD); |
} |
void _normal(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_NORMAL)); |
wbkgdset(w,COLOR_PAIR(_NORMAL)); |
} |
void _inverse(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_INVERSE)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_INVERSE)|A_BOLD); |
} |
void _shadow(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_SHADOW)); |
wbkgdset(w,COLOR_PAIR(_SHADOW)); |
} |
void _boxcolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_BOX)); |
wbkgdset(w,COLOR_PAIR(_BOX)); |
} |
void _titlecolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_TITLE)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_TITLE)|A_BOLD); |
} |
void _borderboxucolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_BORDERBOXU)|A_BOLD); |
wbkgdset(w,COLOR_PAIR(_BORDERBOXU)|A_BOLD); |
} |
void _borderboxdcolor(WINDOW *w) |
{ |
wattrset(w,COLOR_PAIR(_BORDERBOXD)); |
wbkgdset(w,COLOR_PAIR(_BORDERBOXD)); |
} |
/* -- */ |
#define _cursor_invisible() putp(cursor_invisible) |
#define _cursor_visible() {putp(cursor_visible);putp(cursor_normal);} |
#define _cols() COLS |
#define _rows() LINES |
#define _gotorc(w,r,c) wmove(w,r,c) |
#define _printw(w,fmt,args...) wprintw(w,fmt,##args) |
#define _refresh(w) wrefresh(w) |
#define _putch(w,c) waddch(w,c) |
#define _getch() getch() |
#define _clreol(w) wclrtoeol(w) |
#define _clrscr(w) wclear(w) |
#define _bell() addch('\07'); |
/* -- */ |
void _initscreen(void) |
{ |
initscr(); |
start_color(); |
init_pair(_BACKGROUND,DEFAULT_BG,DEFAULT_BG); |
init_pair(_DEFAULT,DEFAULT_FG,DEFAULT_BG); |
init_pair(_NORMAL,NORMAL_FG,NORMAL_BG); |
init_pair(_INVERSE,INVERSE_FG,INVERSE_BG); |
init_pair(_BORDERBOXU,BOX_BORDERFGU,BOX_BORDERBGU); |
init_pair(_BORDERBOXD,BOX_BORDERFGD,BOX_BORDERBGD); |
init_pair(_BOX,BOX_FG,BOX_BG); |
init_pair(_SHADOW,SHADOW_FG,SHADOW_BG); |
init_pair(_TITLE,TITLE_FG,TITLE_BG); |
bkgdset(COLOR_PAIR(_BACKGROUND)); |
clear(); |
cbreak(); /* input one char at time (don't wait for \n) */ |
noecho(); |
keypad(stdscr,TRUE); |
_normal(stdscr); |
_cursor_invisible(); |
refresh(); |
} |
void _endscreen(void) |
{ |
_cursor_visible(); |
refresh(); |
endwin(); |
} |
WINDOW *_createwin(int str, int stc, int nlines, int cols) |
{ |
WINDOW *wnd; |
wnd=newwin(nlines,cols,str,stc); |
if (wnd!=NULL) { |
//wbkgdset(wnd,COLOR_PAIR(_BACKGROUND)); |
//wclear(wnd); |
//_normal(wnd); |
} |
return wnd; |
} |
#define _deletewin(w) delwin(w) |
#endif |
/* |
* |
* |
* |
*/ |
static void whichcolor(WINDOW *wnd, int up, int inv) |
{ |
if (((inv==1)&&(up==1))||((inv==0)&&(up==0))) _borderboxdcolor(wnd); |
else _borderboxucolor(wnd); |
} |
void _settitle(WINDOW *wnd, |
int sy, int sx, |
int nlines, int cols, |
int bordy, int bordx, |
char *title, |
int shad, int inv) |
{ |
int x; |
sx-=bordx+1; |
sy-=bordy+1; |
cols+=2*(bordx+1); |
nlines+=2*(bordy+1); |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy,sx+1); |
for (x=0;x<cols-2;x++) _putch(wnd,_HH); |
if (title!=NULL) { |
_titlecolor(wnd); |
_gotorc(wnd,sy,sx+(cols-strlen(title)-2)/2); |
_printw(wnd," %s ",title); |
_normal(wnd); |
_gotorc(wnd,sy+2,sx+2); |
_printw(wnd,"use <ESC> to exit, <ENTER> to enter/toggle,"); |
_gotorc(wnd,sy+3,sx+2); |
_printw(wnd,"arrows keys to move"); |
} |
_refresh(wnd); |
} |
void _box(WINDOW *wnd, |
int sy, int sx, |
int nlines, int cols, |
int bordy, int bordx, |
char *title, |
int shad, int inv) |
{ |
int x,y; |
sx-=bordx+1; |
sy-=bordy+1; |
cols+=2*(bordx+1); |
nlines+=2*(bordy+1); |
{ |
static char blanks[180]; |
memset(blanks,' ',sizeof(blanks)); |
blanks[cols]='\0'; |
_boxcolor(wnd); |
for (y=0;y<nlines;y++) { |
_gotorc(wnd,sy+y,sx); |
_printw(wnd,"%s",blanks); |
} |
} |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy,sx); |
_putch(wnd,_UL); |
for (x=0;x<cols-2;x++) _putch(wnd,_HH); |
whichcolor(wnd,0,inv); |
_putch(wnd,_UR); |
for (y=1;y<nlines-1;y++) { |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy+y,sx); |
_putch(wnd,_VV); |
whichcolor(wnd,0,inv); |
_gotorc(wnd,sy+y,sx+cols-1); |
_putch(wnd,_VV); |
if (shad) { |
_shadow(wnd); |
_putch(wnd,' '); |
_putch(wnd,' '); |
} |
} |
whichcolor(wnd,1,inv); |
_gotorc(wnd,sy+nlines-1,sx); |
_putch(wnd,_LL); |
whichcolor(wnd,0,inv); |
for (x=0;x<cols-2;x++) _putch(wnd,_HH); |
_putch(wnd,_LR); |
if (shad) { |
_shadow(wnd); |
_putch(wnd,' '); |
_putch(wnd,' '); |
} |
if (shad) { |
_shadow(wnd); |
_gotorc(wnd,sy+nlines,sx+1); |
for (x=0;x<cols+1;x++) _putch(wnd,' '); |
} |
sx+=bordx+1; |
sy+=bordy+1; |
cols-=2*(bordx+1); |
nlines-=2*(bordy+1); |
_settitle(wnd,sy,sx,nlines,cols,bordy,bordx,title,shad,inv); |
/* refresh made by _settitle() */ |
} |
void showtitle(char *s); |
/* -- */ |
void showbool(WINDOW *wnd, struct menuentry *ptr) |
{ |
struct variable *var; |
char ch; |
var=ptr->x.bool.var; |
if (!strcmp(var->value,"y")) ch='*'; |
else ch=' '; |
_printw(wnd,"[%c] %s",ch,ptr->x.bool.text); |
_normal(wnd); |
_clreol(wnd); |
} |
void showtristate(WINDOW *wnd, struct menuentry *ptr) |
{ |
struct variable *var; |
char ch; |
var=ptr->x.bool.var; |
if (!strcmp(var->value,"y")) ch='*'; |
else if (!strcmp(var->value,"n")) ch=' '; |
else ch='M'; |
_printw(wnd,"<%c> %s",ch,ptr->x.bool.text); |
_normal(wnd); |
_clreol(wnd); |
} |
void showchoice(WINDOW *wnd, struct menuentry *ptr) |
{ |
if (strcmp(ptr->x.choice.act->var->value,"y")) { |
/* well.. sometimes reading an old config.h can cause act pointer */ |
/* to be bad :-( */ |
struct choice *p; |
p=ptr->x.choice.list; |
while (p!=NULL) { |
if (!strcmp(p->var->value,"y")) { |
ptr->x.choice.act=p; |
break; |
} |
p=p->next; |
} |
} |
_printw(wnd," %s (%s)",ptr->x.choice.text,ptr->x.choice.act->text); |
_normal(wnd); |
_clreol(wnd); |
} |
void showrange(WINDOW *wnd, struct menuentry *ptr) |
{ |
_printw(wnd," %s (%s)",ptr->x.range.text,ptr->x.range.var->value); |
_normal(wnd); |
_clreol(wnd); |
} |
void showsubmenu(WINDOW *wnd, struct menuentry *ptr) |
{ |
_printw(wnd," %s --->",ptr->x.submenu.text); |
_normal(wnd); |
_clreol(wnd); |
} |
void showseparator(WINDOW *wnd, struct menuentry *ptr) |
{ |
_printw(wnd," *********************** "); |
_normal(wnd); |
_clreol(wnd); |
} |
/* -- */ |
int nmax; // numero linee massimo |
void showmenuentries(WINDOW *wnd,struct menuentry *ptr, int r, int c, int rcur) |
{ |
int i; |
i=0; |
while (ptr!=NULL) { |
_gotorc(wnd,r,c); |
if (r==rcur) _inverse(wnd); |
else _normal(wnd); |
r++; |
switch(ptr->type) { |
case RANGEENTRY: |
showrange(wnd,ptr); |
break; |
case BOOLENTRY: |
showbool(wnd,ptr); |
break; |
case TRISTATEENTRY: |
showtristate(wnd,ptr); |
break; |
case CHOICEENTRY: |
showchoice(wnd,ptr); |
break; |
case SUBMENUENTRY: |
showsubmenu(wnd,ptr); |
break; |
case SEPARATORENTRY: |
showseparator(wnd,ptr); |
break; |
default: |
_printw(wnd,"@@@"); |
break; |
} |
ptr=ptr->n; |
i++; |
if (i==nmax) return; |
} |
} |
/* --- */ |
struct menuentry *expandcase(struct menuentry *menuent); |
struct menuentry *expandmenu(struct menuentry *menuent); |
struct menuentry *expandcase(struct menuentry *menuent) |
{ |
struct _case *list; |
list=menuent->x._case.list; |
while (list!=NULL) { |
if (!strcmp(list->value,menuent->x._case.var->value)) { |
return expandmenu(list->list); |
} |
list=list->next; |
} |
return NULL; |
} |
int nument; |
struct menuentry *expandmenu(struct menuentry *menuent) |
{ |
struct menuentry *start,*ptr,*ent,*prev,*p; |
int ne; |
ne=0; |
ptr=menuent; |
prev=NULL; |
start=NULL; |
while (ptr!=NULL) { |
switch(ptr->type) { |
case CASEENTRY: |
ent=expandcase(ptr); |
if (ent==NULL) { |
if (prev!=NULL) prev->n=ptr->next; |
ptr=ptr->next; |
break; |
} |
if (start==NULL) start=ent; |
if (prev!=NULL) prev->n=ent; |
ent->p=prev; |
p=ent; |
while (p->n!=NULL) p=p->n; |
p->n=ptr->next; |
prev=p; |
ptr=ptr->next; |
break; |
default: |
if (start==NULL) start=ptr; |
ne++; |
ptr->p=prev; |
ptr->n=ptr->next; |
prev=ptr; |
ptr=ptr->next; |
break; |
} |
} |
nument+=ne; |
return start; |
} |
/* -- */ |
#define MUSTREDISPLAY 0x01 |
#define MUSTREBUILD 0x02 |
int showmenu(WINDOW *wnd, struct menu *menu); |
int showchoicewnd(WINDOW *wnd, struct menuentry *menu); |
int showrangewnd(WINDOW *wnd, struct menuentry *menu); |
int enteron(WINDOW *wnd,struct menuentry *ptr) |
{ |
struct variable *var; |
switch(ptr->type) { |
case BOOLENTRY: |
var=ptr->x.bool.var; |
if (*var->value=='y') *var->value='n'; |
else *var->value='y'; |
if (var->flags&FLAG_M) return MUSTREBUILD; |
break; |
case TRISTATEENTRY: |
var=ptr->x.tristate.var; |
if (*var->value=='y') *var->value='n'; |
else if (*var->value=='n') *var->value='m'; |
else *var->value='y'; |
if (var->flags&FLAG_M) return MUSTREBUILD; |
break; |
case RANGEENTRY: |
return showrangewnd(wnd,ptr)|MUSTREDISPLAY; |
case CHOICEENTRY: |
return showchoicewnd(wnd,ptr)|MUSTREDISPLAY; |
case SUBMENUENTRY: |
return showmenu(wnd,ptr->x.submenu.menu)|MUSTREDISPLAY; |
default: |
_bell(); |
break; |
} |
return 0; |
} |
/* --- */ |
int SC=9; |
int SR=9; |
int NL=36; |
int NC=61; |
int BR=0; |
int BC=4; |
/* --- */ |
/* sigh :-( */ |
static struct choice *findprev(struct choice *list, struct choice *cur) |
{ |
struct choice *c,*p; |
c=list; |
p=NULL; |
while (c!=NULL) { |
if (c==cur) return p; |
p=c; |
c=c->next; |
} |
return NULL; |
} |
int showchoicewnd(WINDOW *oldwnd, struct menuentry *ent) |
{ |
WINDOW *wnd; |
struct choice *first; // first menuentry of the list |
struct choice *cur; // selected menuentry |
struct choice *fline; // menuentry to show on the first line |
struct choice *p; |
int ch; |
int rcur; |
int i,r,c; |
int ret; |
int numcho; |
ret=MUSTREDISPLAY; |
numcho=ent->x.choice.numchoices; |
_box(oldwnd,(NL-2-numcho)/2,5,numcho,NC-10,1,1,NULL,0,0); |
wnd=_createwin(SR+(NL-2-numcho)/2,SC+5,numcho,NC-10); |
_normal(wnd); |
_clrscr(wnd); |
first=fline=cur=ent->x.choice.list; |
rcur=0; |
//showtitle(ent->x.choice.text); |
_clrscr(wnd); |
for (;;) { |
r=c=0; |
p=fline; |
i=0; |
while (p!=NULL) { |
_gotorc(wnd,r,c); |
if (r==rcur) _inverse(wnd); |
else _normal(wnd); |
r++; |
_printw(wnd,"(%c) %s",p==ent->x.choice.act?'X':' ',p->text); |
_clreol(wnd); |
p=p->next; |
i++; |
if (i==nmax) break; |
} |
_refresh(wnd); |
ch=getch(); |
switch (ch) { |
case _KEY_OK: |
case _KEY_OK2: |
return ret; |
case _KEY_DOWN: |
if (cur->next==NULL) break; |
cur=cur->next; |
if (rcur<NL-1) { |
rcur++; |
break; |
} |
fline=fline->next; |
break; |
case _KEY_UP: |
p=findprev(ent->x.choice.list,cur); |
if (p==NULL) break; |
cur=p; |
if (rcur!=0) { |
rcur=rcur--; |
break; |
} |
fline=findprev(ent->x.choice.list,fline); |
break; |
case _KEY_TOGGLE: |
if ((ent->x.choice.act->var->flags&FLAG_M)||(cur->var->flags&FLAG_M)) |
ret|=MUSTREBUILD; |
*(ent->x.choice.act->var->value)='n'; |
ent->x.choice.act=cur; |
*(ent->x.choice.act->var->value)='y'; |
break; |
} |
} |
} |
int showrangewnd(WINDOW *wnd, struct menuentry *ent) |
{ |
WINDOW *nw; |
int ret; |
int ch; |
int val; |
ret=MUSTREDISPLAY; |
_box(wnd,(NL-3)/2,5,1,NC-10,1,1,NULL,0,0); |
nw=_createwin(SR+(NL-3)/2,SC+5,1,NC-10); |
_normal(nw); |
_clrscr(nw); |
val=atoi(ent->x.range.var->value); |
for (;;) { |
_normal(nw); |
_gotorc(nw,0,0); |
_printw(nw," %s : %8i",ent->x.range.text,val); |
_clreol(nw); |
_refresh(nw); |
ch=getch(); |
switch (ch) { |
case _KEY_OK: |
case _KEY_OK2: |
case _KEY_TOGGLE: |
{ |
char buffer[256]; |
sprintf(buffer,"%i",val); |
copystring(&ent->x.range.var->value,buffer); |
} |
_deletewin(nw); |
return ret; |
case _KEY_DOWN: |
if (val>ent->x.range.minval) val--; |
break; |
case _KEY_UP: |
if (val<ent->x.range.maxval) val++; |
break; |
} |
} |
} |
int showhelpwin(WINDOW *wnd, struct menuentry *ent) |
{ |
struct variable *var; |
FILE *fin; |
char buffer[256]; |
WINDOW *nw; |
int ret; |
int ch; |
int flag; |
ret=MUSTREDISPLAY; |
_box(wnd,(NL-3)/2,5,1,NC-10,1,1,NULL,0,0); |
nw=_createwin(SR+(NL-3)/2,SC+5,1,NC-10); |
_normal(nw); |
_clrscr(nw); |
_normal(nw); |
_gotorc(nw,0,0); |
switch(ent->type) { |
case BOOLENTRY: var=ent->x.bool.var; break; |
case SUBMENUENTRY: var=NULL; break; |
case TRISTATEENTRY: var=ent->x.tristate.var; break; |
case CHOICEENTRY: var=ent->x.choice.act->var; break; |
case CASEENTRY: var=NULL; break; |
case RANGEENTRY: var=ent->x.range.var; break; |
case SEPARATORENTRY: var=NULL; break; |
default: var=NULL; |
} |
if (var==NULL) goto END; |
fin=fopen(helpfilename,"rt"); |
if (fin!=NULL) { |
if (varhelp[findvarindex(var)]==0) goto END; |
fseek(fin,varhelp[findvarindex(var)],SEEK_SET); |
flag=0; |
while (fgets(buffer,sizeof(buffer),fin)!=NULL) { |
if (*buffer=='#') continue; |
if (*buffer=='@') { |
if (flag) break; |
continue; |
} |
_gotorc(nw,flag,0); |
_printw(nw,"%s",buffer); |
flag++; |
} |
fclose(fin); |
} |
_clreol(nw); |
_refresh(nw); |
ch=getch(); |
END: |
_deletewin(nw); |
return ret; |
} |
int showmenu(WINDOW *wnd, struct menu *menu) |
{ |
struct menuentry *first; /* first menuentry of the list */ |
struct menuentry *cur; /* selected menuentry */ |
struct menuentry *fline; /* menuentry to show on the first line */ |
int redo; |
int ch; |
int rcur; |
int ret; |
first=fline=cur=NULL; |
rcur=0; |
redo=1; |
ret=MUSTREDISPLAY; |
for (;;) { |
if (redo&MUSTREBUILD) redo|=MUSTREDISPLAY; |
ret|=redo; |
if (redo&MUSTREBUILD) { |
fline=NULL; |
} |
if (redo&MUSTREDISPLAY) { |
nument=0; |
first=expandmenu(menu->entries); |
if (fline==NULL) { |
fline=first; |
if (cur==NULL) { |
cur=fline; |
rcur=0; |
} |
} |
nmax=NL; |
showtitle(menu->title); |
_normal(wnd); |
_clrscr(wnd); |
redo=0; |
} |
showmenuentries(wnd,fline,0,0,rcur); |
_refresh(wnd); |
ch=getch(); |
switch (ch) { |
case _KEY_OK: |
case _KEY_OK2: |
return ret; |
case _KEY_DOWN: |
if (cur->n==NULL) break; |
cur=cur->n; |
if (rcur<NL-1) { |
rcur++; |
break; |
} |
fline=fline->n; |
break; |
case _KEY_UP: |
if (cur->p==NULL) break; |
cur=cur->p; |
if (rcur!=0) { |
rcur=rcur--; |
break; |
} |
fline=fline->p; |
break; |
case _KEY_TOGGLE: |
redo=enteron(wnd,cur); |
break; |
case _KEY_HELP: |
redo=showhelpwin(wnd,cur); |
break; |
default: |
/* |
_normal(STDWIN); |
_gotorc(STDWIN,0,0); |
_printw(STDWIN,"%04x",ch); |
_refresh(STDWIN); |
*/ |
} |
} |
} |
void showtitle(char *s) |
{ |
_settitle(STDWIN,SR-6,SC-2,NL+8,NC+4,BR,BC,s,1,0); |
} |
/* |
* |
*/ |
int show(void) |
{ |
WINDOW *wnd; |
int i; |
_initscreen(); |
_cursor_invisible(); |
SC=9; |
SR=9; |
NL=_rows()-5-SR-BR*2; |
NC=_cols()-2-SC-BC*2; |
BR=0; |
BC=4; |
_defaultcolor(STDWIN); |
_gotorc(STDWIN,0,0); |
if (caption!=NULL) _printw(STDWIN," %s",caption); |
_gotorc(STDWIN,1,1); |
for (i=0;i<_cols()-2;i++) _putch(STDWIN,_HH); |
_box(STDWIN,SR-6,SC-2,NL+8,NC+4,BR,BC,NULL,1,0); |
_box(STDWIN,SR,SC,NL,NC,BR,BC,NULL,0,1); |
wnd=_createwin(SR,SC,NL,NC); |
showmenu(wnd,mainmenu); |
_cursor_visible(); |
_refresh(STDWIN); |
_endscreen(); |
return 0; |
} |
/shark/trunk/config/hconf/token.c |
---|
0,0 → 1,116 |
/* |
* |
* |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <ctype.h> |
#define MAXTOKENSIZE 128 |
static char string[MAXTOKENSIZE]; |
static char buffer[MAXTOKENSIZE*8]; |
static FILE *fin; |
int line; |
static int flags; |
static char *lasttoken,*token; |
int init_tokenizer(char *filename,int fl) |
{ |
fin=fopen(filename,"rt"); |
if (fin==NULL) return -1; |
line=0; |
buffer[0]='\0'; |
strtok(buffer," \n"); |
flags=fl; |
lasttoken=NULL; |
token=NULL; |
return 0; |
} |
void ungettoken(void) |
{ |
if (flags&0x02) {fprintf(stderr,"<<UNGET>>"); fflush(stderr); } |
if (lasttoken!=NULL) abort(); |
lasttoken=token; |
} |
char *gettoken(void) |
{ |
char *s; |
if (lasttoken!=NULL) { |
token=lasttoken; |
lasttoken=NULL; |
if (flags&0x02) {fprintf(stderr,"<%s>",token); fflush(stderr); } |
return token; |
} |
s=strtok(NULL," \n"); |
if (s==NULL) { |
for (;;) { |
s=fgets(buffer,sizeof(buffer),fin); |
line++; |
if (flags&0x1) {fprintf(stderr,"[%i]",line); fflush(stderr); } |
if (s==NULL) { |
if (flags&0x03) {fprintf(stderr,"\n"); fflush(stderr); } |
return NULL; |
} |
s=strtok(buffer," \n"); |
if (s!=NULL) { |
if (*s=='#') continue; |
break; |
} |
} |
} |
if (*s=='\"') { |
/* Well, the strings are returned with a \" on first character */ |
char *p; |
strcpy(string,s); |
p=strchr(string+1,'\"'); |
if (p!=NULL) { |
*p='\0'; |
if (flags&0x02) {fprintf(stderr,"<%s>",string); fflush(stderr); } |
return token=string; |
} |
s=strtok(NULL,"\""); |
if (s==NULL) { |
if (flags&0x03) {fprintf(stderr,"\n"); fflush(stderr); } |
return NULL; |
} |
strcat(string," "); |
strcat(string,s); |
p=strchr(string+1,'\"'); |
if (p!=NULL) *p='\0'; |
if (flags&0x02) {fprintf(stderr,"<%s>",string); fflush(stderr); } |
return token=string; |
} |
if (flags&0x02) {fprintf(stderr,"<%s>",s); fflush(stderr); } |
return token=s; |
} |
int done_tokenizer(void) |
{ |
return fclose(fin); |
} |
#if 0 |
int main(int argc, char *argv[]) |
{ |
char *s; |
init_tokenizer(argv[1]); |
while ((s=gettoken())!=NULL) { |
printf("<%s>\n",s); |
} |
done_tokenizer(); |
} |
#endif |
/shark/trunk/config/hconf/example.mak |
---|
0,0 → 1,50 |
# |
# the following lines are preserved |
# new lines are appended at end of file! |
# |
CC=gcc |
CFLAGS=-Wall -s -O2 |
# |
# the following lines are generated |
# by a script (do not edit by hand) |
# |
EX_BOOL=y |
EX_TRISTATE=m |
EX_RANGE=20 |
EX_CHOICE_1=n |
EX_CHOICE_2=n |
EX_CHOICE_3=y |
EX_BOOL2=n |
EX_BOOL3=n |
EX_TRI2=n |
EX_BOOL4=n |
CONFIG_SYS_MSDOS=y |
CONFIG_SYS_LINUX=n |
CONFIG_CPU_I386=y |
CONFIG_CPU_PENTIUM=y |
CONFIG_CPU_PENTIUMII=n |
CONFIG_MAXTASK=6 |
CONFIG_SCHED_EDF=y |
CONFIG_SCHED_RM=n |
CONFIG_SCHED_EDFSERV=y |
CONFIG_SCHED_EDFRMSERV=n |
CONFIG_CHAR=y |
CONFIG_CHAR_KEYBOARD=y |
CONFIG_CHAR_MOUSE=n |
CONFIG_CHAR_RTC=n |
CONFIG_CHAR_CONSOLE2=y |
CONFIG_BLOCK=n |
CONFIG_BLOCK_IDE=n |
CONFIG_BLOCK_LOOP=n |
CONFIG_GRAPHICS=n |
CONFIG_NET=n |
CONFIG_NET_3COM=n |
CONFIG_FSSUPPORT=n |
CONFIG_FS_MSDOS=n |
CONFIG_FS_ISO9660=n |
CONFIG_FS_ISO9960_JOLIET=n |
CONFIG_FS_ISO9960_ROCKRIDGE=n |
CONFIG_FS_DEVFS=n |
/shark/trunk/config/hconf/example2.h |
---|
0,0 → 1,9 |
/* |
* This file is generated by a script |
* |
* (run 'make config' to change) |
*/ |
#undef EX_BOOL |
#define EX_RANGE 10 |
/shark/trunk/config/hconf/examples.h |
---|
0,0 → 1,42 |
/* |
* This file is generated by a script |
* |
* (run 'make config' to change) |
*/ |
#undef EX_TRISTATE |
#define EX_CHOICE_2 1 |
#undef EX_BOOL2 |
#define EX_BOOL4 1 |
#define CONFIG_SYS_MSDOS 1 |
#define CONFIG_CPU_I386 1 |
#define CONFIG_MAXTASK 5 |
#define CONFIG_SCHED_EDF 1 |
#undef CONFIG_CHAR |
#define CONFIG_BLOCK 1 |
#undef CONFIG_BLOCK_IDE |
#undef CONFIG_BLOCK_LOOP |
#undef CONFIG_GRAPHICS |
#undef CONFIG_NET |
#define CONFIG_FSSUPPORT 1 |
#define CONFIG_FS_MSDOS 1 |
#undef CONFIG_FS_ISO9660 |
#undef CONFIG_FS_DEVFS |
/* var EX_CHOICE_1 n */ |
/* var EX_CHOICE_3 n */ |
/* var EX_BOOL3 n */ |
/* var EX_TRI2 n */ |
/* var CONFIG_SYS_LINUX y */ |
/* var CONFIG_CPU_PENTIUM y */ |
/* var CONFIG_CPU_PENTIUMII n */ |
/* var CONFIG_SCHED_RM n */ |
/* var CONFIG_SCHED_EDFSERV y */ |
/* var CONFIG_SCHED_EDFRMSERV n */ |
/* var CONFIG_CHAR_KEYBOARD n */ |
/* var CONFIG_CHAR_MOUSE n */ |
/* var CONFIG_CHAR_RTC n */ |
/* var CONFIG_CHAR_CONSOLE2 n */ |
/* var CONFIG_NET_3COM n */ |
/* var CONFIG_FS_ISO9960_JOLIET n */ |
/* var CONFIG_FS_ISO9960_ROCKRIDGE n */ |
/shark/trunk/config/hconf/write.c |
---|
0,0 → 1,210 |
#include <stdio.h> |
#include <string.h> |
#include <unistd.h> |
#include "hconf.h" |
static void visitcase(struct menuentry *menuent); |
static void visitmenu(struct menuentry *menuent); |
static void (*writevar)(struct variable *); |
static void visitcase(struct menuentry *menuent) |
{ |
struct _case *list; |
list=menuent->x._case.list; |
while (list!=NULL) { |
if (!strcmp(list->value,menuent->x._case.var->value)) { |
visitmenu(list->list); |
break; |
} |
list=list->next; |
} |
return; |
} |
static void visitmenu(struct menuentry *menuent) |
{ |
struct menuentry *ptr; |
ptr=menuent; |
while (ptr!=NULL) { |
switch(ptr->type) { |
case CASEENTRY: visitcase(ptr);break; |
case SUBMENUENTRY: visitmenu(ptr->x.submenu.menu->entries); break; |
case BOOLENTRY: writevar(ptr->x.bool.var); break; |
case TRISTATEENTRY: writevar(ptr->x.tristate.var); break; |
case RANGEENTRY: writevar(ptr->x.range.var); break; |
case CHOICEENTRY: writevar(ptr->x.choice.act->var); break; |
} |
ptr=ptr->next; |
} |
return; |
} |
/* |
* |
* |
* |
*/ |
static FILE *fout; |
static FILE *ftable[MAXFILETABLE]; |
static void write_hvar(struct variable *var) |
{ |
FILE *myfout; |
int t; |
if (var->fileindex!=NOFILEINDEX) myfout=ftable[var->fileindex]; |
else myfout=fout; |
t=var->type; |
var->type=PRINTEDVAR; |
switch (t) { |
case TRISTATEVAR: |
if (*var->value=='m') |
{ fprintf(myfout,"#define %s 0\n",var->name); return; } |
case BOOLVAR: |
if (*var->value=='y') |
{ fprintf(myfout,"#define %s 1\n",var->name); return; } |
fprintf(myfout,"#undef %s\n",var->name); |
return; |
case CHOICEVAR: |
fprintf(myfout,"#define %s 1\n",var->name); |
return; |
case RANGEVAR: |
fprintf(myfout,"#define %s %s\n",var->name,var->value); |
return; |
} |
return; |
} |
#if 0 |
static void write_makvar(struct variable *var) |
{ |
return; |
} |
#endif |
/* -- */ |
char hmessage[]= |
"/*\n" |
" * This file is generated by a script\n" |
" *\n" |
" * (run 'make config' to change)\n" |
" */\n" |
"\n"; |
static int write_h(char *filename) |
{ |
int i; |
fout=fopen(filename,"wt"); |
if (fout==NULL) return -1; |
fprintf(fout,"%s",hmessage); |
for (i=0;i<maxfileindex;i++) { |
ftable[i]=fopen(filetable[i],"wt"); |
if (ftable[i]==NULL) return -3; |
fprintf(ftable[i],"%s",hmessage); |
} |
writevar=write_hvar; |
visitmenu(mainmenu->entries); |
fprintf(fout,"\n"); |
for (i=0;i<maxfileindex;i++) fprintf(ftable[i],"\n"); |
for (i=0;i<nextvariable;i++) |
if (vartable[i].type!=PRINTEDVAR) |
fprintf(fout,"/* var %s %s */\n",vartable[i].name,vartable[i].value); |
fclose(fout); |
for (i=0;i<maxfileindex;i++) fclose(ftable[i]); |
return 0; |
} |
static int write_mak(char *filename) |
{ |
char buffer[256]; |
int i; |
off_t pos; |
/* truncate file if necessary... */ |
pos=0; |
fout=fopen(filename,"rt"); |
if (fout!=NULL) { |
while (fgets(buffer,sizeof(buffer),fout)!=NULL) |
if (!strcmp(buffer,"# by a script (do not edit by hand)\n")) { |
pos=ftell(fout); |
break; |
} |
fclose(fout); |
if (pos) truncate(filename,pos); |
} |
/* open file */ |
fout=fopen(filename,"at"); |
if (fout==NULL) return -1; |
/* write all vars */ |
if (!pos) { |
fprintf(fout,"\n#\n# the following lines are generated\n"); |
fprintf(fout,"# by a script (do not edit by hand)\n#\n\n"); |
} |
else fprintf(fout,"#\n\n"); |
for (i=0;i<nextvariable;i++) |
fprintf(fout,"%s=%s\n",vartable[i].name,vartable[i].value); |
/* close file */ |
fclose(fout); |
return 0; |
} |
/* -- */ |
int writeconfig(char *srcfilename) |
{ |
char buffer[256]; |
char *ptr; |
ptr=strstr(srcfilename,".in"); |
if (ptr!=NULL) *ptr='\0'; |
else { |
ptr=strchr(srcfilename,'.'); |
if (ptr!=NULL) *ptr='\0'; |
} |
strcpy(buffer,srcfilename); |
strcat(buffer,".h"); |
write_h(buffer); |
return 0; |
} |
int writeconfigmak(char *srcfilename) |
{ |
char buffer[256]; |
char *ptr; |
ptr=strstr(srcfilename,".in"); |
if (ptr!=NULL) *ptr='\0'; |
else { |
ptr=strchr(srcfilename,'.'); |
if (ptr!=NULL) *ptr='\0'; |
} |
strcpy(buffer,srcfilename); |
strcat(buffer,".mak"); |
write_mak(buffer); |
return 0; |
} |
/shark/trunk/config/hconf/hconf.txt |
---|
0,0 → 1,7 |
- se ho un menu con dentro nulla e premo un tasto diverso da ESC esce!!! |
- se ho una voce di menu troppo lunga va fuori e fa male il refresh |
- farebbe comodo avere una immissione da tastiera (non indispensabile) |
- farebbe comodo che quando uso le choices Enter le facesse sparire |
/shark/trunk/config/hconf/makefile |
---|
0,0 → 1,61 |
.PHONY: all clean |
# |
# HOSTNAME must be "Linux" or "MS-DOS" |
# |
HOSTNAME=$(shell uname) |
# |
# |
# |
ifeq ($(HOSTNAME),Linux) |
LDFLAGS=-lncurses |
CFLAGS=-DUSE_NCURSES |
OBJ_EXT=.o |
EXE_EXT= |
else |
ifeq ($(HOSTNAME),MS-DOS) |
CFLAGS=-DUSE_CONIO |
OBJ_EXT=.o |
EXE_EXT=.exe |
%.exe: %.o |
gcc -O2 -s -o $@ $? |
else |
all:: |
@echo System "$(HOSTNAME)" unknow |
@echo Try to modify the first line of makefile |
@false |
endif |
endif |
# |
# |
# |
CC=gcc |
CFLAGS+=-Wall -O2 -s |
all:: clean hconf$(EXE_EXT) |
@echo ... |
@echo ... |
@echo esempio di uso del programma: |
@echo hconf -m config.in |
clean: |
rm -f *$(OBJ_EXT) |
rm -f hconf$(EXE_EXT) |
hconf$(EXE_EXT): hconf$(OBJ_EXT) parse$(OBJ_EXT) \ |
show$(OBJ_EXT) write$(OBJ_EXT) read$(OBJ_EXT) token$(OBJ_EXT) |
hconf$(OBJ_EXT): hconf.c |
parse$(OBJ_EXT): parse.c |
show$(OBJ_EXT): show.c |
write$(OBJ_EXT): write.c |
read$(OBJ_EXT): write.c |
token(OBJ_EXT): token.c |
/shark/trunk/config/hconf/example.hlp |
---|
0,0 → 1,22 |
# |
# Hartik 4.0.0 help file |
# |
@EX_BOOL |
@EX_RANGE |
Questa e' una prova di help file da visualizzare |
#questa riga e' un commento |
sullo schermo |
@EX_CHOICE_1 |
@EX_CHOICE_2 |
@EX_CHOICE_3 |
Un'altro help da visualizzare |
@EX_TRISTATE |
Questo e' l'help del tristate |
ultima linea |
/shark/trunk/config/hconf/hconf.c |
---|
0,0 → 1,63 |
/* |
* |
* |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include "hconf.h" |
int main(int argc, char *argv[]) |
{ |
char *filename; |
int res,ind,mk; |
/* command line parsing... to do better */ |
if (argc<2) { |
fprintf(stderr,"a filename must be supplied!\n"); |
exit(-1); |
} |
ind=1; |
mk=0; |
if (!strcmp(argv[1],"-m")) { |
mk=1; |
ind++; |
} |
if (ind!=argc-1) { |
fprintf(stderr,"command line error!\n"); |
exit(-1); |
} |
filename=argv[ind]; |
/* read config.in */ |
res=readconfigin(filename); |
if (res) { |
fprintf(stderr,"\nerror %i on line %i reading %s!\n",res,line,filename); |
exit(-2); |
} |
if (mainmenu==NULL) { |
fprintf(stderr,"\nno main menu found on %s file!\n",filename); |
exit(-3); |
} |
/* dump config.in */ |
//dumpvariables(); |
//dumpmenus(); |
//return 0; |
/* read/show/write config.h */ |
res=readconfig(filename); |
show(); |
writeconfig(filename); |
if (mk) writeconfigmak(filename); |
return 0; |
} |