void command_disable_command (NICK * nick, CHANNEL * channel, const char *cmd, const char **args, int argc) { struct command_s *handler; // show usage if (argc < 1) { puttext ("NOTICE %s :Usage: %s command\n", nick->nick, cmd); return; } // find out handler if (!(handler = array_find (commands, args[0]))) { puttext ("NOTICE %s :Command '%s' not known\r\n", nick->nick, args[0]); // ENSURE THAT IT IS NOT DISABLE OR ENABLE AS THESE ARE CRITICAL COMMANDS } else if ((handler->handler == command_disable_command) || (handler->handler == command_enable_command)) { puttext ("NOTICE %s :Command '%s' cannot be disabled\r\n", nick->nick, handler->command); } else { // disable command handler->disabled = 1; puttext ("NOTICE %s :Command '%s' has been disabled\r\n", nick->nick, handler->command); } }
void chanmod_command_chaninfo (NICK * nick, CHANNEL * channel, const char *cmd, const char **args, int argc) { char services[300]; char *keep, *drop; keep = drop = NULL; if (channel->modes_keep) keep = mode2modestr (channel->modes_keep); if (channel->modes_drop) drop = mode2modestr (channel->modes_drop); puttext ("NOTICE %s :Information on %s\r\n", nick->nick, channel->channel); puttext ("NOTICE %s : Modes: %c%s%c%s\r\n", nick->nick, (keep ? '+' : ' '), (keep ? keep : ""), (drop ? '-' : ' '), (drop ? drop : "")); if (keep) free (keep); if (drop) free (drop); services[0] = '\0'; strcat (services, " Services: bitchmode "); if (channel_has_service (channel, CHANNEL_SERV_BITCHMODE)) strcat (services, "on"); else strcat (services, "off"); strcat (services, ", autovoice "); if (channel_has_service (channel, CHANNEL_SERV_AUTOVOICE)) strcat (services, "on"); else strcat (services, "off"); strcat (services, ", lamercontrol "); if (channel_has_service (channel, CHANNEL_SERV_LAMER)) strcat (services, "on"); else strcat (services, "off"); strcat (services, ", enforcebans "); if (channel_has_service (channel, CHANNEL_SERV_ENFORCEBANS)) strcat (services, "on"); else strcat (services, "off"); strcat (services, ", topic forcing "); if (channel_has_service (channel, CHANNEL_SERV_TOPIC)) strcat (services, "on"); else strcat (services, "off"); puttext ("NOTICE %s :%s\r\n", nick->nick, services); services[0] = '\0'; strcat (services, " join flood protect "); if (channel_has_service (channel, CHANNEL_SERV_JOIN_FLOOD_PROTECT)) strcat (services, "on"); else strcat (services, "off"); strcat (services, ", disallow IP hosts "); if (channel_has_service (channel, CHANNEL_SERV_NO_IP)) strcat (services, "on"); else strcat (services, "off"); puttext ("NOTICE %s :%s\r\n", nick->nick, services); }
static void _http_modusererror(int s, char *message) { _http_header_ok(s, 0); puttext(s, "<html><head><title>Error: "); puttext(s, message); puttext(s, "</title></head><body bgcolor=\"fFfFfF\"><h2>Error:</h2>"); puttext(s, message); }
static void test_unicode_acs(const FONT *f, int c, int c0, int x) { char s[4] = ""; s[0] = c; x += 8*(c-c0); puttext(f, s, x, 10); if (usetc(s, acs_to_unicode(c)) > 0) puttext(f, s, x, 12+text_height(f)); }
static void test_8bit_acs(const FONT *f, int c, int c0, int x) { char s[2] = ""; s[0] = c; x += 8*(c-c0); puttext(f, s, x, 10); convert_chars(s, s, 2); puttext(f, s, x, 12+text_height(f)); }
static void test_ascii() { int c; puttext(font, "ACS to ASCII:", 0, 0); set_char_table(acs_vt100, acs_ascii); for (c=0x60; c < 0x7f; c++) test_8bit_acs(font, c, 0x60, 0); for (c='+'; c <= '0'; c++) test_8bit_acs(font, c, '+', 254); puttext(font, "Latin-1 to ASCII:", 0, 50); set_latin1_table(latin1_ascii); test_8bit_latin1(font); }
void misc_command_google (NICK * nick, CHANNEL * channel, const char *cmd, const char **args, int argc) { char *google; if ((argc < 1) || (args[0] == NULL)) { puttext ("NOTICE %s :Usage: %s keyword(s)\r\n", nick->nick, cmd); return; } google = misc_urlencode (args[0]); puttext ("PRIVMSG %s :http://www.google.com/search?q=%s\r\n", (channel ? channel->channel : nick->nick), google); free (google); }
/* If yesToAll and/or noToAll are NULL, then those prompts not displayed */ int select_yn (char *prompt, char *yes, char *no, char *yesToAll, char *noToAll) { int len; int ret; int xPrompt; int listSize; char *yesno[4]; char screenbuf[512]; /* fill in yes/no/yestoall/notoall struct & get its size */ listSize = 2; yesno[0] = yes; yesno[1] = no; if (yesToAll != NULL) { yesno[listSize] = yesToAll; listSize++; } if (noToAll != NULL) { yesno[listSize] = noToAll; listSize++; } /* Draw a box */ len = strlen (prompt); xord = 40 - (len / 2) - 1; if (xord < 1) { xord = 1; } xord1 = xord + len + 1; if (xord1 > 80) { xord1 = 80; } gettext(xord, 22-listSize, xord1 + 1, 25, screenbuf); /* at 20 for yes/no, 19 for yes/no/yestoall or yes/no/notoall, 18 for all 4 */ box (xord, 22-listSize, xord1, 25); /* Display the prompt, and do the y/n selection */ gotoxy (xord + 1, 23-listSize); cputs (prompt); gotoxy (35, 24-listSize); ret = select_list (listSize, yesno); puttext(xord, 22-listSize, xord1 + 1, 25, screenbuf); return (ret); }
/*---------------------------------------------------------------------- ToggleWindow ----------------------------------------------------------------------*/ void ToggleWindow(void) { struct text_info TextInfo; char *Clip; int Grootte; if (hWnd>=0) { gettextinfo(&TextInfo); Grootte=((TextInfo.winbottom-TextInfo.wintop+2)* (TextInfo.winright-TextInfo.winleft+3))*2; Clip=(char *) malloc(Grootte); gettext(TextInfo.winleft,TextInfo.wintop,TextInfo.winright+2, TextInfo.winbottom+1,Clip); puttext(TextInfo.winleft,TextInfo.wintop,TextInfo.winright+2, TextInfo.winbottom+1,WindowStruc[hWnd]->Clip); memcpy(WindowStruc[hWnd]->Clip,Clip,Grootte); free(Clip); } }
int selectwindow(void) { int row,col; char scrn[61-19+1][2]; struct text_info t; window(19,1,61,24); textbackground(CYAN); textcolor(BLACK); clrscr(); memset(scrn,0x20,sizeof(scrn)); for (col=0; col<43; col++) scrn[col][1]=CYAN*16+BLACK; scrn[0][0]=scrn[42][0]='º'; scrn[0][1]=scrn[42][1]=CYAN*16+BLUE; gettextinfo(&t); for (row=t.wintop; row<=t.winbottom; row++) puttext(t.winleft,row,t.winright,row,scrn); window(20,1,60,24); return 1; }
void putprmpt(FILE *fp, char *prompt, char *choices[], char *defstr) { char buffer[1024] = ""; /* NB: code should prevent overflow... */ int i, n; (void) fputc('\n', fp); if (prompt == NULL) { (void) strlcpy(buffer, defstr ? defstr : "No default prompt.", sizeof (buffer)); } else if (n = (int)strlen(prompt)) { if (defstr == NULL) defstr = ""; if (prompt[0] == '~') (void) snprintf(buffer, sizeof (buffer), "%s%s", defstr, prompt + 1); else if (prompt[n-1] == '~') (void) snprintf(buffer, sizeof (buffer), "%.*s%s", n - 1, prompt, defstr); else (void) strlcpy(buffer, prompt, sizeof (buffer)); } else (void) strlcpy(buffer, "", sizeof (buffer)); (void) strlcat(buffer, "\\ [", sizeof (buffer)); for (i = 0; choices && choices[i]; ++i) { (void) strlcat(buffer, choices[i], sizeof (buffer)); (void) strlcat(buffer, ",", sizeof (buffer)); } (void) strlcat(buffer, ckquit ? "?,q] " : "?] ", sizeof (buffer)); (void) puttext(fp, buffer, 0, ckwidth); }
void puthelp(FILE *fp, char *defmesg, char *help) { char *tmp; size_t n; tmp = NULL; if (help == NULL) { /* use default message since no help was provided */ help = defmesg ? defmesg : "No help available."; } else if (defmesg != NULL) { n = strlen(help); if (help[0] == '~') { /* prepend default message */ tmp = calloc(n+strlen(defmesg)+1, sizeof (char)); (void) strcpy(tmp, defmesg); (void) strcat(tmp, "\n"); ++help; (void) strcat(tmp, help); help = tmp; } else if (n && (help[n-1] == '~')) { /* append default message */ tmp = calloc(n+strlen(defmesg)+2, sizeof (char)); (void) strcpy(tmp, help); tmp[n-1] = '\0'; (void) strcat(tmp, "\n"); (void) strcat(tmp, defmesg); help = tmp; } } (void) puttext(fp, help, ckindent, ckwidth); (void) fputc('\n', fp); if (tmp) free(tmp); }
/* Pausa a função que chamou, salva um pedaço da tela, e printa nele a tela de confimação. Caso o usuário confirme a saida, retorna 1; senão, retorna 0. Se for retornar 0, restaura o pedaço retirado. Se printFromFile não achou o arquivo "tela de confirmação", limpa a tela, printa erro e confirma saida*/ int confirmaSaida() { TCores cores = {15, 15, 15, 'T', 0, 15, 'T', 0, 15, ' ', 15, 15, 'W', 15, 15, 15, 15, 15, 15, 15, 'T'}; struct char_info holdscreen[239]; char escolha; // Salva o pedaço da tela a ser utilizado gettext(23, 10, 56, 16, holdscreen); //Impressão da caixa de mensagem if(!printFromFile(23, 10, cores, "resources/reallyquit.txt")) { // Se não achou o arquivo, limpa a tela, printa um erro e confirma saída textcolor(15); clrscr(); printf("Erro 404: arquivo \"resources/reallyquit.txt\" n%co encontrado.\nConfira se o jogo est%c instalado corretamente.", 198, 160); getch(); return -1; } // Pega a resposta do usuário do { escolha = tolower(getch()); } while(escolha != 'n' && escolha != 's' && escolha != 27); if(escolha == 'n') { // Se ele escolheu não sair, restaura a tela puttext(23, 10, 56, 16, holdscreen); return 0; } // Se confirmou a saída, limpa a tela e retorna 1 textcolor(15); clrscr(); return 1; }
char *snpp_login(int s, char *what) { char *u, *p; struct user usr; u=strdup(what); for(p=u; *p&&*p!=' '; p++); if(*p) { *p=NULL; p++; } _ndebug(3, ("Login: ``%s''\nPasswd: ``%s''\n", u, p)); if(conf.udb.u_exists(u)) { usr=conf.udb.getuser(u); } else { free(u); puttext(s, INVALIDLOGIN); return(NULL); } if(strlen(usr.passwd)<(size_t)13) { free(u); puttext(s, INVALIDLOGIN); return(NULL); } if(checkpass(usr.passwd, p)) { _ndebug(2, ("SNPP login for user ``%s''\n", usr.name)); puttext(s, LOGINOK); } else { _ndebug(2, ("SNPP invalid login for user ``%s''\n", usr.name)); free(u); u=NULL; puttext(s, INVALIDLOGIN); } return(u); }
void user_command_chanlev (NICK * nick, CHANNEL * channel, const char *cmd, const char **args, int argc) { struct user_walker_s user; memset (&user, 0, sizeof user); if (argc > 0) { if (!(user.channel = channel_find (args[0]))) { puttext ("NOTICE %s :No such channel %s\r\n", nick->nick, args[0]); return; } } else { user.channel = channel; } user_walk (user_walker, &user); if (user.owner) { user_print_chanlev (nick, user.owner, user.nowner, "owner(s)"); free (user.owner); } if (user.master) { user_print_chanlev (nick, user.master, user.nmaster, "master(s)"); free (user.master); } if (user.op) { user_print_chanlev (nick, user.op, user.nop, "op(s)"); free (user.op); } if (user.voice) { user_print_chanlev (nick, user.voice, user.nvoice, "voice(s)"); free (user.voice); } if (user.banned) { user_print_chanlev (nick, user.banned, user.nbanned, "banned"); free (user.banned); } puttext ("NOTICE %s :Total " FSO " owners, " FSO " masters, " FSO " ops, " FSO " voices, " FSO " banned\r\n", nick->nick, user.nowner, user.nmaster, user.nop, user.nvoice, user.nbanned); }
void chanmod_command_delchan (NICK * nick, CHANNEL * channel, const char *cmd, const char **args, int argc) { char *c; if ((channel->permanent != 0) || ((nick->user->admin == 0) && !(user_get_channel_modes (nick->user, channel) & USER_OWNER))) { puttext ("NOTICE %s :You cannot remove channel %s\r\n", nick->nick, channel->channel); return; } c = strdup (channel->channel); channel_delete (c); puttext ("NOTICE %s :Deleted channel %s\r\n", nick->nick, c); free (c); }
void BOX::put_background() { if(buffer!=NULL) { puttext(left, top, left+width-1, top+height-1, buffer); delete [] buffer; } }
EXTERNC int movetext(int left, int top, int right, int bottom, int destleft, int desttop) { char *buf; buf = (char *)alloca((right - left + 1) * (bottom - top + 1) * 2); gettext(left, top, right, bottom, buf); puttext(destleft, desttop, destleft + right - left, desttop + bottom - top, buf); // TODO: check return values return 1; };
static void snpp_displayq(int s, struct queuent q) { char buf[BUFLEN]; sprintf(buf, "214 %s: Pri: %d, size: %d, sent: %s%s", q.qid, q.priority, strlen(q.message), (q.soonest>q.submitted?"*":""), ctime(&q.submitted)); puttext(s, buf); }
void movetext (int left, int top, int right, int bottom, int destleft, int desttop) { struct char_info * buffer; buffer = malloc ((right - left + 1) * (bottom - top + 1) * sizeof(struct char_info)); gettext (left, top, right, bottom, buffer); puttext (destleft, desttop, destleft + right - left, desttop + bottom - top, buffer); free(buffer); }
static void CopyText(int x1, int y1, int width, int height, int x2, int y2) { static void *mem = NULL; mem = realloc(mem, width * height * 2); gettext(x1 - 1, y1 - 1, x1 + width, y1 + height, mem); puttext(x2 - 1, y2 - 1, x2 + width, y2 + height, mem); }
void user_print_chanlev (NICK * nick, char **list, size_t lsize, const char *prefix) { size_t i; char buf[300]; sprintf (buf, "\002%s\002: ", prefix); i = 0; while (i < lsize) { if (300 - strlen (buf) < strlen (list[i])) { puttext ("NOTICE %s :%s\r\n", nick->nick, buf); sprintf (buf, "\002%s\002: ", prefix); } strcat (buf, list[i]); strcat (buf, " "); i++; } puttext ("NOTICE %s :%s\r\n", nick->nick, buf); }
static void test_8bit_latin1(const FONT *f) { char s1[33] = ""; char s2[33] = ""; int y = 60; int i; for (i=0; i<32; i++) s1[i] = 0xa0+i; convert_chars(s1, s2, sizeof(s2)); puttext(font, s1, 0, y); puttext(f, s2, 0, y+10); for (i=0; i<2; i++) { str_map(add32, s1, s1); convert_chars(s1, s2, sizeof(s2)); y += 16+text_height(f); puttext(font, s1, 0, y); puttext(f, s2, 0, y+10); } }
int movetext(int left, int top, int right, int bottom, int dleft, int dtop) { char *buf = malloc((right - left + 1) * (bottom - top + 1) * 2); if (!buf) return 0; gettext(left, top, right, bottom, buf); puttext(dleft, dtop, dleft + right - left, dtop + bottom - top, buf); free(buf); return 1; }
static void test_unicode() { FONT *f = font; DATAFILE *dat = load_datafile(DATA_PREFIX "font.dat"); if (dat && dat->type == DAT_FONT) f = (FONT *) dat->dat; int c; puttext(font, "ACS to unicode:", 0, 0); set_acs_unicode_table(acs_vt100, acs_unicode); for (c=0x60; c < 0x7f; c++) test_unicode_acs(f, c, 0x60, 0); for (c='+'; c <= '0'; c++) test_unicode_acs(f, c, '+', 254); puttext(font, "testing UTF-8 encoder...", 0, 70); puttext(font, test_utf8_enc() ? "ok" : "failed!", 204, 70); if (dat) unload_datafile(dat); }
void pause() { TCores cores = {15, 15, 15, 'T', 0, 15, 'T', 0, 15, ' ', 15, 15, 'T', 15, 15, 15, 15, 15, 15, 15, 'T'}; struct char_info holdscreen[211]; // Salva o pedaço da tela a ser utilizado gettext(22, 10, 56, 15, holdscreen); //Impressão da caixa de mensagem printFromFile(22, 10, cores, "resources/pause.txt"); // Espera despausar getch(); // Restaura a tela puttext(22, 10, 56, 15, holdscreen); }
void user_command_password (NICK * nick, CHANNEL * channel, const char *cmd, const char **args, int argc) { char *newpw; if (channel) { puttext ("NOTICE %s :Do not use this command in a channel - logging this so you will get spanked with a wide SCSI cable\r\n", nick->nick); print ("SECURITY ALERT: %s[%s] tried to change password on a channel", nick->nick, nick->user->user); return; } if (argc < 2) { puttext ("NOTICE %s :Usage: %s [old password] [new password] [new password]\r\n", nick->nick, cmd); puttext ("NOTICE %s :Usage: %s [new password] [new password] (if you do not have a password)\r\n", nick->nick, cmd); return; } if (strlen (nick->user->pass) > 0) { if (!user_check_pass (nick->user, args[0])) { puttext ("NOTICE %s :Old password did not match - event logged\r\n", nick->nick); print ("SECURITY ALERT: %s[%s] tried to change password - wrong old password", nick->nick, nick->user->user); return; } if ((argc < 3) || strcmp (args[1], args[2])) { puttext ("NOTICE %s :New passwords did not match\r\n", nick->nick); return; } } else { if (strcmp (args[0], args[1])) { puttext ("NOTICE %s :New passwords did not match\r\n", nick->nick); return; } } newpw = sha1sum (args[1]); memcpy (nick->user->pass, newpw, SHA_DIGEST_LENGTH); puttext ("NOTICE %s :Password changed\r\n", nick->nick); print ("%s!%s@%s[%s] changed password", nick->nick, nick->ident, nick->host, nick->user->user); free (newpw); }
void ekran_cikis(char *bellek) { puttext(15, 2, 79, 24, bellek); git_xy(*(bellek + 3294), *(bellek + 3296)); ekran_x = (int) *(bellek + 3294); ekran_y = (int) *(bellek + 3296); baslik.referans -=DUZEY; pencere.derecesi -= DUZEY; pencere.turu -= DUZEY; if (pencere.derecesi == UST_DUZEY) memcpy(&baslik, 0, sizeof(baslik)); free(bellek); }
void misc_command_params (NICK * nick, CHANNEL * channel, const char *cmd, const char **args, int argc) { SERVER *server; if (argc < 2) { puttext ("NOTICE %s :Usage %s param value\r\n", nick->nick, cmd); return; } server = server_get_current (); if (!strcasecmp (args[0], "oblines")) { int nlines; nlines = s_atoi (args[1]); if (nlines > 0) { server->ob.mlines = nlines; puttext ("NOTICE %s :Max lines now %d\r\n", nick->nick, nlines); } else { puttext ("NOTICE %s :Need positive number\r\n", nick->nick); } } else if (!strcasecmp (args[0], "obmsec")) { int nmsec; nmsec = s_atoi (args[1]); if (nmsec > 0) { server->ob.msec = nmsec; puttext ("NOTICE %s :Max msecs now %d\r\n", nick->nick, nmsec); } else { puttext ("NOTICE %s :Need positive number\r\n", nick->nick); } } }
static void test_cp437() { FONT *f = load_font(DATA_PREFIX CP437_FONT, NULL, NULL); if (!f) { puttext(font, "couldn't load " DATA_PREFIX CP437_FONT, 16, 16); return; } int c; puttext(font, "ACS to codepage 437:", 0, 0); set_char_table(acs_vt100, acs_cp437); for (c=0x60; c < 0x7f; c++) test_8bit_acs(f, c, 0x60, 0); for (c='+'; c <= '0'; c++) test_8bit_acs(f, c, '+', 254); puttext(font, "Latin-1 to CP437:", 0, 50); set_latin1_table(latin1_cp437); test_8bit_latin1(f); destroy_font(f); }