kill warnings, c99 up in this
This commit is contained in:
parent
8cf326558c
commit
7ad46735c1
@ -1,7 +1,7 @@
|
|||||||
OBJECTS = nyancat.o
|
OBJECTS = nyancat.o
|
||||||
|
|
||||||
CC ?=
|
CC ?=
|
||||||
CFLAGS ?= -g
|
CFLAGS ?= -g -Wall -Wextra -std=c99
|
||||||
CPPFLAGS ?=
|
CPPFLAGS ?=
|
||||||
LDFLAGS ?=
|
LDFLAGS ?=
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
* WITH THE SOFTWARE.
|
* WITH THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _XOPEN_SOURCE 500
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -111,7 +112,7 @@ int show_counter = 1;
|
|||||||
* Number of frames to show before quitting
|
* Number of frames to show before quitting
|
||||||
* or 0 to repeat forever (default)
|
* or 0 to repeat forever (default)
|
||||||
*/
|
*/
|
||||||
int frame_count = 0;
|
unsigned int frame_count = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear the screen between frames (as opposed to reseting
|
* Clear the screen between frames (as opposed to reseting
|
||||||
@ -184,6 +185,7 @@ void finish() {
|
|||||||
* (^C) so that we can restore the cursor and clear the terminal.
|
* (^C) so that we can restore the cursor and clear the terminal.
|
||||||
*/
|
*/
|
||||||
void SIGINT_handler(int sig){
|
void SIGINT_handler(int sig){
|
||||||
|
(void)sig;
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +194,7 @@ void SIGINT_handler(int sig){
|
|||||||
* handling if we didn't receive a terminal
|
* handling if we didn't receive a terminal
|
||||||
*/
|
*/
|
||||||
void SIGALRM_handler(int sig) {
|
void SIGALRM_handler(int sig) {
|
||||||
|
(void)sig;
|
||||||
alarm(0);
|
alarm(0);
|
||||||
longjmp(environment, 1);
|
longjmp(environment, 1);
|
||||||
/* Unreachable */
|
/* Unreachable */
|
||||||
@ -202,10 +205,12 @@ void SIGALRM_handler(int sig) {
|
|||||||
* in telnet mode and the client disconnects
|
* in telnet mode and the client disconnects
|
||||||
*/
|
*/
|
||||||
void SIGPIPE_handler(int sig) {
|
void SIGPIPE_handler(int sig) {
|
||||||
|
(void)sig;
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIGWINCH_handler(int sig) {
|
void SIGWINCH_handler(int sig) {
|
||||||
|
(void)sig;
|
||||||
struct winsize w;
|
struct winsize w;
|
||||||
ioctl(0, TIOCGWINSZ, &w);
|
ioctl(0, TIOCGWINSZ, &w);
|
||||||
terminal_width = w.ws_col;
|
terminal_width = w.ws_col;
|
||||||
@ -339,11 +344,12 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
/* The default terminal is ANSI */
|
/* The default terminal is ANSI */
|
||||||
char term[1024] = {'a','n','s','i', 0};
|
char term[1024] = {'a','n','s','i', 0};
|
||||||
int k, ttype;
|
unsigned int k;
|
||||||
uint32_t option = 0, done = 0, sb_mode = 0, do_echo = 0;
|
int ttype;
|
||||||
|
uint32_t option = 0, done = 0, sb_mode = 0;
|
||||||
/* Various pieces for the telnet communication */
|
/* Various pieces for the telnet communication */
|
||||||
unsigned char sb[1024] = {0};
|
char sb[1024] = {0};
|
||||||
short sb_len = 0;
|
unsigned short sb_len = 0;
|
||||||
|
|
||||||
/* Whether or not to show the MOTD intro */
|
/* Whether or not to show the MOTD intro */
|
||||||
char show_intro = 0;
|
char show_intro = 0;
|
||||||
@ -516,11 +522,6 @@ int main(int argc, char ** argv) {
|
|||||||
telnet_options[opt] = DONT;
|
telnet_options[opt] = DONT;
|
||||||
}
|
}
|
||||||
send_command(telnet_options[opt], opt);
|
send_command(telnet_options[opt], opt);
|
||||||
if (opt == ECHO) {
|
|
||||||
/* We don't really need this, as we don't accept input, but,
|
|
||||||
* in case we do in the future, set our echo mode */
|
|
||||||
do_echo = (i == DO);
|
|
||||||
}
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
break;
|
break;
|
||||||
case SB:
|
case SB:
|
||||||
@ -761,7 +762,7 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
if (show_intro) {
|
if (show_intro) {
|
||||||
/* Display the MOTD */
|
/* Display the MOTD */
|
||||||
int countdown_clock = 5;
|
unsigned int countdown_clock = 5;
|
||||||
for (k = 0; k < countdown_clock; ++k) {
|
for (k = 0; k < countdown_clock; ++k) {
|
||||||
newline(3);
|
newline(3);
|
||||||
printf(" \033[1mNyancat Telnet Server\033[0m");
|
printf(" \033[1mNyancat Telnet Server\033[0m");
|
||||||
@ -845,12 +846,12 @@ int main(int argc, char ** argv) {
|
|||||||
}
|
}
|
||||||
if (always_escape) {
|
if (always_escape) {
|
||||||
/* Text mode (or "Always Send Color Escapes") */
|
/* Text mode (or "Always Send Color Escapes") */
|
||||||
printf("%s", colors[color]);
|
printf("%s", colors[(int)color]);
|
||||||
} else {
|
} else {
|
||||||
if (color != last && colors[color]) {
|
if (color != last && colors[(int)color]) {
|
||||||
/* Normal Mode, send escape (because the color changed) */
|
/* Normal Mode, send escape (because the color changed) */
|
||||||
last = color;
|
last = color;
|
||||||
printf("%s%s", colors[color], output);
|
printf("%s%s", colors[(int)color], output);
|
||||||
} else {
|
} else {
|
||||||
/* Same color, just send the output characters */
|
/* Same color, just send the output characters */
|
||||||
printf("%s", output);
|
printf("%s", output);
|
||||||
|
Loading…
Reference in New Issue
Block a user