/***************************************************************************** * * $Id$ * Purpose ...............: Menu Utils * ***************************************************************************** * Copyright (C) 1997-2005 * * 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. * * MB 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 MB BBS; see the file COPYING. If not, write to the Free * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *****************************************************************************/ #include "../config.h" #include "../lib/mbselib.h" #include "../lib/diesel.h" #include "screen.h" #include "ledit.h" #include "mutil.h" unsigned char readkey(int y, int x, int fg, int bg) { int rc = -1, i; unsigned char ch = 0; working(0, 0, 0); if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) { perror("open 9"); exit(MBERR_TTYIO_ERROR); } mbse_Setraw(); i = 0; while (rc == -1) { if ((i % 10) == 0) show_date(fg, bg, 0, 0); mbse_locate(y, x); fflush(stdout); rc = mbse_Waitchar(&ch, 5); if ((rc == 1) && (ch != KEY_ESCAPE)) break; if ((rc == 1) && (ch == KEY_ESCAPE)) rc = mbse_Escapechar(&ch); if (rc == 1) break; i++; Nopper(); } mbse_Unsetraw(); close(ttyfd); return ch; } unsigned char testkey(int y, int x) { int rc; unsigned char ch = 0; mbse_locate(y, x); fflush(stdout); if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) { perror("open 9"); exit(MBERR_TTYIO_ERROR); } mbse_Setraw(); rc = mbse_Waitchar(&ch, 100); if (rc == 1) { if (ch == KEY_ESCAPE) rc = mbse_Escapechar(&ch); } mbse_Unsetraw(); close(ttyfd); if (rc == 1) return ch; else return '\0'; } int newpage(FILE *fp, int page) { page++; fprintf(fp, "\f MBSE BBS v%-53s page %d\n", VERSION, page); return page; } void addtoc(FILE *fp, FILE *toc, int chapt, int par, int page, char *title) { char temp[81]; char *tit; snprintf(temp, 81, "%s ", title); tit = xstrcpy(title); tu(tit); if (par) { fprintf(toc, " %2d.%-3d %s %d\n", chapt, par, padleft(temp, 50, '.'), page); fprintf(fp, "\n\n %d.%d. %s\n\n", chapt, par, tit); } else { fprintf(toc, " %2d %s %d\n", chapt, padleft(temp, 52, '.'), page); fprintf(fp, "\n\n %d. %s\n", chapt, tit); } free(tit); } void disk_reset(void) { SockS("DRES:0;"); } FILE *open_webdoc(char *filename, char *title, char *title2) { char *p, *temp; FILE *fp; time_t now; temp = calloc(PATH_MAX, sizeof(char)); snprintf(temp, PATH_MAX, "%s/share/doc/html/%s", getenv("MBSE_ROOT"), filename); mkdirs(temp, 0755); if ((fp = fopen(temp, "w+")) == NULL) { WriteError("$Can't create %s", temp); } else { fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); if (title2) fprintf(fp, "%s: %s\n", title, title2); else fprintf(fp, "%s\n", title); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "
\n"); if (title2) fprintf(fp, "

%s: %s

\n", title, title2); else fprintf(fp, "

%s

\n", title); now = time(NULL); p = ctime(&now); Striplf(p); fprintf(fp, "
Created %s
\n", p); } free(temp); return fp; } void close_webdoc(FILE *fp) { fprintf(fp, "
\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fclose(fp); } void add_webtable(FILE *fp, char *hstr, char *dstr) { char left[1024], right[1024]; html_massage(hstr, left, 1023); if (strlen(dstr)) html_massage(dstr, right, 1023); else snprintf(right, 1024, " "); fprintf(fp, "%s%s\n", left, right); } void add_webdigit(FILE *fp, char *hstr, int digit) { char left[1024]; html_massage(hstr, left, 1023); fprintf(fp, "%s%d\n", left, digit); } void add_colors(FILE *fp, char *hstr, int fg, int bg) { fprintf(fp, "%s%s on %s\n", hstr, get_color(fg), get_color(bg)); } void add_statcnt(FILE *fp, char * hstr, statcnt st) { fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n", hstr); fprintf(fp, "\n"); fprintf(fp, "\n", st.tdow[0], st.tdow[1], st.tdow[2], st.tdow[3], st.tdow[4], st.tdow[5], st.tdow[6], st.tweek); fprintf(fp, "\n", st.ldow[0], st.ldow[1], st.ldow[2], st.ldow[3], st.ldow[4], st.ldow[5], st.ldow[6], st.lweek); fprintf(fp, "\n"); fprintf(fp, "
Weekdays overview of %s
 SunMonTueWedThuFriSatTotal
This week%d%d%d%d%d%d%d%d
Last week%d%d%d%d%d%d%d%d
\n"); fprintf(fp, "

\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n", hstr); fprintf(fp, "\n"); fprintf(fp, "\n", st.month[0], st.month[1], st.month[2], st.month[3], st.month[4], st.month[5], st.month[6], st.month[7], st.month[8], st.month[0], st.month[10], st.month[11], st.total); fprintf(fp, "\n"); fprintf(fp, "
Monthly overview of %sTotal ever
JanFebMarAprMayJunJulAugSepOctNovDec
%d%d%d%d%d%d%d%d%d%d%d%d%d
\n"); fprintf(fp, "

\n"); } int horiz; void dotter(void) { Nopper(); mbse_mvprintw(8, horiz++, (char *)"."); fflush(stdout); }