This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-mbse/mbsebbs/userlist.c

176 lines
4.9 KiB
C
Raw Normal View History

2001-11-12 21:42:17 +00:00
/*****************************************************************************
*
* $Id$
* Purpose ...............: Display Userlist
*
*****************************************************************************
2007-02-25 20:28:00 +00:00
* Copyright (C) 1997-2007
2001-11-12 21:42:17 +00:00
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
* 1971 BV IJmuiden
* the Netherlands
*
* This file is part of MBSE BBS.
*
* This BBS is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* MBSE BBS is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MBSE BBS; see the file COPYING. If not, write to the Free
2003-08-15 20:05:34 +00:00
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
2001-11-12 21:42:17 +00:00
*****************************************************************************/
2002-06-30 12:48:44 +00:00
#include "../config.h"
2004-02-21 17:22:00 +00:00
#include "../lib/mbselib.h"
2001-11-12 21:42:17 +00:00
#include "../lib/mbse.h"
2002-01-07 19:16:03 +00:00
#include "../lib/users.h"
2001-11-12 21:42:17 +00:00
#include "userlist.h"
#include "language.h"
#include "input.h"
#include "timeout.h"
#include "term.h"
2004-11-03 20:48:45 +00:00
#include "ttyio.h"
2001-11-12 21:42:17 +00:00
2005-10-07 20:42:35 +00:00
extern int rows;
2007-02-25 20:28:00 +00:00
extern int cols;
2005-10-07 20:42:35 +00:00
2001-11-12 21:42:17 +00:00
void UserList(char *OpData)
{
FILE *pUsrConfig;
int LineCount = 2, iFoundName = FALSE, iNameCount = 0;
2007-02-25 20:28:00 +00:00
char ustr[128], *Name, *sTemp, *User, *temp, msg[81];
struct userhdr uhdr;
struct userrec u;
temp = calloc(PATH_MAX, sizeof(char));
Name = calloc(37, sizeof(char));
sTemp = calloc(81, sizeof(char));
User = calloc(81, sizeof(char));
2007-02-25 20:28:00 +00:00
if (utf8)
chartran_init((char *)"CP437", (char *)"UTF-8", 'B');
strcpy(ustr, clear_str());
/* User List */
2007-02-25 20:28:00 +00:00
strncat(ustr, poutCR_str(WHITE, BLACK, (char *) Language(126)), 127);
PUTSTR(chartran(ustr));
LineCount = 1;
2005-08-28 17:27:35 +00:00
snprintf(temp, PATH_MAX, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((pUsrConfig = fopen(temp, "rb")) == NULL) {
WriteError("UserList: Can't open file: %s", temp);
return;
}
fread(&uhdr, sizeof(uhdr), 1, pUsrConfig);
/* Enter Username search string or (Enter) for all users: */
language(WHITE, BLACK, 127);
colour(CFG.InputColourF, CFG.InputColourB);
alarm_on();
GetstrC(Name, 35);
2007-02-25 20:28:00 +00:00
strcpy(ustr, clear_str());
/* Name Location Last On Calls */
2007-02-25 20:28:00 +00:00
strncat(ustr, poutCR_str(WHITE, BLACK, (char *) Language(128)), 127);
PUTSTR(chartran(ustr));
2007-02-25 20:28:00 +00:00
strcpy(ustr, colour_str(GREEN, BLACK));
strncat(ustr, fLine_str(cols -1), 127);
PUTSTR(chartran(ustr));
strcpy(ustr, colour_str(CYAN, BLACK));
PUTSTR(chartran(ustr));
while (fread(&u, uhdr.recsize, 1, pUsrConfig) == 1) {
if ((strcmp(Name,"")) != 0) {
if (((strcasecmp(OpData, "/H")) == 0) && strlen(u.sHandle))
2005-08-28 17:27:35 +00:00
snprintf(User, 36, "%s", u.sHandle);
else if ((strcasecmp(OpData, "/U")) == 0)
2005-08-28 17:27:35 +00:00
snprintf(User, 36, "%s", u.Name);
else
2005-08-28 17:27:35 +00:00
snprintf(User, 36, "%s", u.sUserName);
if ((strstr(tl(User), tl(Name)) != NULL)) {
if ((!u.Hidden) && (!u.Deleted)) {
if ((strcasecmp(OpData, "/H")) == 0) {
if ((strcmp(u.sHandle, "") != 0 && *(u.sHandle) != ' '))
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.sHandle);
2001-11-12 21:42:17 +00:00
else
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.sUserName);
} else if (strcasecmp(OpData, "/U") == 0) {
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.Name);
} else {
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.sUserName);
}
2004-11-03 20:48:45 +00:00
PUTSTR(msg);
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-30s%-14s%-10d", u.sLocation, StrDateDMY(u.tLastLoginDate), u.iTotalCalls);
2004-11-03 20:48:45 +00:00
PUTSTR(msg);
iFoundName = TRUE;
LineCount++;
iNameCount++;
Enter(1);
2001-11-12 21:42:17 +00:00
}
}
} else if ((!u.Hidden) && (!u.Deleted) && (strlen(u.sUserName) > 0)) {
if ((strcmp(OpData, "/H")) == 0) {
if ((strcasecmp(u.sHandle, "") != 0 && *(u.sHandle) != ' '))
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.sHandle);
else
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.sUserName);
} else if (strcasecmp(OpData, "/U") == 0) {
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.Name);
} else {
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-25s", u.sUserName);
}
2004-11-03 20:48:45 +00:00
PUTSTR(msg);
2005-08-28 17:27:35 +00:00
snprintf(msg, 81, "%-30s%-14s%-10d", u.sLocation, StrDateDMY(u.tLastLoginDate), u.iTotalCalls);
2004-11-03 20:48:45 +00:00
PUTSTR(msg);
iFoundName = TRUE;
LineCount++;
iNameCount++;
Enter(1);
2001-11-12 21:42:17 +00:00
}
2005-10-07 20:42:35 +00:00
if (LineCount >= rows - 2) {
LineCount = 0;
Pause();
colour(CYAN, BLACK);
2001-11-12 21:42:17 +00:00
}
}
if (!iFoundName) {
language(CYAN, BLACK, 129);
Enter(1);
}
2001-11-12 21:42:17 +00:00
fclose(pUsrConfig);
2001-11-12 21:42:17 +00:00
2007-02-25 20:28:00 +00:00
strcpy(ustr, colour_str(GREEN, BLACK));
strncat(ustr, fLine_str(cols -1), 127);
PUTSTR(chartran(ustr));
2001-11-12 21:42:17 +00:00
free(temp);
free(Name);
free(sTemp);
free(User);
2001-11-12 21:42:17 +00:00
2007-02-25 20:28:00 +00:00
chartran_close();
Pause();
2001-11-12 21:42:17 +00:00
}