Commit 919fae88 authored by deuce's avatar deuce
Browse files

Added helptitle to the UIFC api to set the title for help windows.

umonitor now uses showhelp() to display error log.
parent 6c297c8b
CFLAGS += -I../ -I../../xpdev -I../../uifc -DUSE_CURSES -DUSE_SIGNALS
CFLAGS += -I../ -I../../xpdev -I../../uifc -DUSE_CURSES -DUSE_SIGNALS -g
LFLAGS += -lcurses
CC ?= gcc
LD ?= gcc
vpath %.c ../../xpdev ../../uifc
OBJS := filewrap.o uifcc.o uifcx.o umonitor.o sockwrap.o
OBJS := filewrap.o uifcc.o uifcx.o umonitor.o sockwrap.o dirwrap.o genwrap.o
umonitor: $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o umonitor
......
......@@ -8,8 +8,10 @@
#include "uifc.h"
#include "sbbsdefs.h"
#include "genwrap.h" /* stricmp */
#include "dirwrap.h" /* lock/unlock/sopen */
#include "filewrap.h" /* lock/unlock/sopen */
#include "sockwrap.h"
#include "genwrap.h"
enum {
MODE_LIST
......@@ -531,12 +533,15 @@ int main(int argc, char** argv) {
int server=0;
char revision[16];
char str[256],ctrl_dir[41],*p,debug=0;
char title[256];
int sys_nodes,node_num=0,onoff=0;
int i,j,mode=0,misc;
int modify=0;
int loop=0;
long value=0;
node_t node;
char *buf;
int buffile;
sscanf("$Revision$", "%*s %s", revision);
......@@ -619,8 +624,8 @@ int main(int argc, char** argv) {
if((mopt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
allocfail(MAX_OPLN);
sprintf(str,"Synchronet UNIX Monitor %s-%s",revision,PLATFORM_DESC);
if(uifc.scrn(str)) {
sprintf(title,"Synchronet UNIX Monitor %s-%s",revision,PLATFORM_DESC);
if(uifc.scrn(title)) {
printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1);
bail(1);
}
......@@ -636,8 +641,37 @@ int main(int argc, char** argv) {
"\nToDo: Add help.";
j=uifc.list(WIN_ORG|WIN_MID|WIN_ESC|WIN_ACT|WIN_DYN,0,0,70,&main_dflt,&main_bar
,str,mopt);
if(j==-2)
,title,mopt);
if(j==-7) { /* CTRL-E */
/* ToDo must get the logs dir from the config */
sprintf(str,"%s../data/error.log",ctrl_dir);
if(fexist(str)) {
if((buffile=sopen(str,O_RDONLY,SH_DENYRW))>=0) {
j=filelength(buffile);
if((buf=(char *)MALLOC(j+1))!=NULL) {
read(buffile,buf,j);
close(buffile);
*(buf+j)=0;
uifc.helpbuf=buf;
uifc.helptitle="Error Log";
uifc.showhelp();
uifc.helptitle=NULL;
free(buf);
continue;
}
close(buffile);
continue;
}
uifc.msg("Error reading error log");
}
else {
uifc.msg("Error log does not exist");
}
continue;
}
if(j <= -2)
continue;
if(j==-1) {
......
......@@ -351,6 +351,11 @@ typedef struct {
/* Shows the current help text */
/****************************************************************************/
void (*showhelp)(void);
/****************************************************************************/
/* Shows help title text */
/****************************************************************************/
char *helptitle;
#endif
} uifcapi_t;
......
......@@ -135,11 +135,18 @@ static void upop(char *str);
static void sethelp(int line, char* file);
/* Dynamic menu support */
static int *last_menu_cur;
static int *last_menu_bar;
static int *last_menu_cur=NULL;
static int *last_menu_bar=NULL;
static int save_menu_cur=-1;
static int save_menu_bar=-1;
void reset_dynamic(void) {
*last_menu_cur=NULL;
*last_menu_bar=NULL;
save_menu_cur=-1;
save_menu_bar=-1;
}
int inkey(int mode)
{
if(mode)
......@@ -175,6 +182,7 @@ int uifcinic(uifcapi_t* uifcapi)
api->sethelp=sethelp;
#ifdef __unix__
api->showhelp=help;
api->helptitle=NULL;
#endif
#if defined(LOCALE)
......@@ -341,6 +349,7 @@ int uscrn(char *str)
gotoxy(1,api->scrn_len+1);
clrtoeol();
refresh();
reset_dynamic();
return(0);
}
......@@ -1631,6 +1640,7 @@ void upop(char *str)
char buf[26*3*2];
int i,j,k;
reset_dynamic();
hidemouse();
if(!str) {
puttext(28,12,53,14,sav);
......@@ -1707,22 +1717,40 @@ void help()
for(i=1;i<76*21*2;i+=2)
buf[i]=(hclr|(bclr<<4));
buf[0]='';
for(i=2;i<30*2;i+=2)
buf[i]='';
buf[i]=''; i+=4;
buf[i]='O'; i+=2;
buf[i]='n'; i+=2;
buf[i]='l'; i+=2;
buf[i]='i'; i+=2;
buf[i]='n'; i+=2;
buf[i]='e'; i+=4;
buf[i]='H'; i+=2;
buf[i]='e'; i+=2;
buf[i]='l'; i+=2;
buf[i]='p'; i+=4;
buf[i]=''; i+=2;
for(j=i;j<i+(30*2);j+=2)
buf[j]='';
if(api->helptitle==NULL) {
for(i=2;i<30*2;i+=2)
buf[i]='';
buf[i]=''; i+=4;
buf[i]='O'; i+=2;
buf[i]='n'; i+=2;
buf[i]='l'; i+=2;
buf[i]='i'; i+=2;
buf[i]='n'; i+=2;
buf[i]='e'; i+=4;
buf[i]='H'; i+=2;
buf[i]='e'; i+=2;
buf[i]='l'; i+=2;
buf[i]='p'; i+=4;
buf[i]=''; i+=2;
for(j=i;j<i+(30*2);j+=2)
buf[j]='';
}
else {
j=strlen(api->helptitle);
if(j>70)
*(api->helptitle+70)=0;
for(i=2;i<(35-(j/2))*2;i+=2)
buf[i]='';
buf[i]=''; i+=4;
for(p=api->helptitle;*p;p++) {
buf[i]=*p;
i+=2;
}
i+=2;
buf[i]=''; i+=2;
for(j=i;j<(75*2);j+=2)
buf[j]='';
}
i=j;
buf[i]=''; i+=2;
j=i; /* leave i alone */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment