home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
msq31004.zip
/
MISC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-13
|
4KB
|
222 lines
/* misc.c
**
** released into the PUBLIC DOMAIN 30 jul 1990 by jim nutt
** Changes released into the PUBLIC DOMAIN 10 jul 1994 by John Dennis
**
** Miscilaneous extra functions & stuff tacked on :-)
*/
#define TEXTLEN 80
#include "msged.h"
#include "menu.h"
#include "date.h"
#include "main.h"
#include "dialogs.h"
#include "help.h"
#include "nshow.h"
void change_curr_addr()
{
int ch = 0;
int num = 0;
int x1, y1, x2, y2;
char line[TEXTLEN];
char **addrch = NULL;
if (SW->aliascount < 2)
{
return;
}
if ((addrch = calloc(SW->aliascount + 2, sizeof(char *))) == NULL)
{
return;
}
for (; num < SW->aliascount; num++)
{
sprintf(line, "%-20.20s", show_address(&alias[num]));
if ((addrch[num] = strdup(line)) == NULL) {
break;
}
}
addrch[num] = NULL;
x1 = (maxx/2)-11;
x2 = (maxx/2)+11;
y1 = 8;
y2 = (num > maxy - 1) ? maxy - 1 : y1 + num + 1;
ch = DoMenu(x1+1, y1+1, x2-1, y2-1, addrch, 0);
switch (ch)
{
case -1 : break;
default :
CurArea.addr = alias[ch];
ShowNewArea();
ShowMsgHeader(message);
break;
}
for (num = 0; num < SW->aliascount; num++)
{
free(addrch[num]);
}
free(addrch);
return;
}
void change_nodelist(void)
{
int ch = 0;
int num = 0;
int x1, y1, x2, y2;
char line[TEXTLEN];
char **nodls = NULL;
if (SW->nodelists < 2)
{
return;
}
if ((nodls = calloc(SW->nodelists + 2, sizeof(char *))) == NULL)
{
return;
}
for (; num < SW->nodelists; num++)
{
sprintf(line, "%-20.20s", node_lists[num].name);
if ((nodls[num] = strdup(line)) == NULL) {
break;
}
}
nodls[num] = NULL;
x1 = (maxx/2)-11;
x2 = (maxx/2)+11;
y1 = 8;
y2 = (num > maxy - 1) ? maxy - 1 : y1 + num + 1;
ch = DoMenu(x1+1, y1+1, x2-1, y2-1, nodls, 0);
switch (ch)
{
case -1 :
break;
default :
ST->nodebase = node_lists[ch].base_name;
ST->sysop = node_lists[ch].sysop;
break;
}
for (num = 0; num < SW->nodelists; num++)
{
free(nodls[num]);
}
free(nodls);
return;
}
void change_username(void)
{
int x1, y1, x2, y2, len = 0;
int i, j, ch;
char *list[11];
if (user_list[1].name == NULL)
return;
for (i = 0; i < 11; i++)
{
if (user_list[i].name == NULL)
break;
list[i] = strdup(user_list[i].name);
if ((j = strlen(list[i])) >= len)
{
len = j;
}
if (j >= maxx - 2)
*(list[i] + maxx - 4) = '\0';
}
list[i] = NULL;
if (len >= maxx - 2)
len = maxx - 4;
x1 = (maxx/2) - (len/2) - 1;
x2 = (maxx/2) + (len/2) + 1;
y1 = 7;
y2 = y1 + i + 1;
ch = DoMenu(x1+1, y1+1, x2-1, y2-1, list, 0);
switch (ch)
{
case -1 : break;
default :
release(ST->username);
ST->username = strdup(user_list[ch].name);
release(ST->lastread);
if (user_list[ch].lastread != NULL)
{
ST->lastread = strdup(user_list[ch].lastread);
}
else
ST->lastread = strdup(user_list[0].lastread);
SW->useroffset = user_list[ch].offset;
break;
}
i = 0;
while (list[i])
{
free(list[i++]);
}
}
void set_switch(void)
{
WND *hCurr, *hWnd;
int ret;
ReadSettings();
hCurr = Wtop();
// hWnd = WPopUp(52, 16, INSBDR|SHADOW, cm[DL_BTXT], cm[DL_WTXT]);
hWnd = WPopUp(52, 17, INSBDR|SHADOW, cm[DL_BTXT], cm[DL_WTXT]);
if (!hWnd)
return;
ret = DoDialog(&settings, 1);
WClose(hWnd);
WCurr(hCurr);
if (ret == ID_OK)
{
WriteSettings();
ShowNewArea();
ShowMsgHeader(message);
message = KillMsg(message);
}
}
void show_help(void)
{
if (ST->helpfile != NULL)
DoHelp(0);
}
/*--- end ---*/