char new_file[LINE_LEN]; /* Buffer to hold new file name */
if (modified == TRUE && ask_save() == ERRORS)
- return;
+ return;
/* Get new file name */
if (get_file("Visit file:", new_file) == ERRORS)
- return;
+ return;
/* Free old linked list, initialize global variables and load new file */
initialize();
/* Check if file_name is valid and if file can be written */
if (file_name[0] == '\0' || writable == FALSE) {
- if (get_file("Enter file name:", file) != FINE)
- return ERRORS;
- copy_string(file_name, file); /* Save file name */
+ if (get_file("Enter file name:", file) != FINE)
+ return ERRORS;
+ copy_string(file_name, file); /* Save file name */
}
if ((fd = creat(file_name, 0644)) < 0) { /* Empty file */
- error("Cannot create ", file_name);
- writable = FALSE;
- return ERRORS;
+ error("Cannot create ", file_name);
+ writable = FALSE;
+ return ERRORS;
}
else
- writable = TRUE;
+ writable = TRUE;
clear_buffer();
if (line->next == tail && line->text[0] == '\n')
continue;
}
- if (writeline(fd, line->text) == ERRORS) {
- count = -1L;
- break;
- }
- count += (long) length_of(line->text);
+ if (writeline(fd, line->text) == ERRORS) {
+ count = -1L;
+ break;
+ }
+ count += (long) length_of(line->text);
}
if (count > 0L && flush_buffer(fd) == ERRORS)
- count = -1L;
+ count = -1L;
close(fd);
if (count == -1L)
- return ERRORS;
+ return ERRORS;
modified = FALSE;
rpipe = FALSE; /* File name is now assigned */
if ((shell = getenv("SHELL")) == NIL_PTR) shell = "/bin/sh";
switch (pid = fork()) {
- case -1: /* Error */
- error("Cannot fork.", NIL_PTR);
- return;
- case 0: /* This is the child */
- set_cursor(0, ymax);
- putchar('\n');
- flush();
- raw_mode(OFF);
+ case -1: /* Error */
+ error("Cannot fork.", NIL_PTR);
+ return;
+ case 0: /* This is the child */
+ set_cursor(0, ymax);
+ putchar('\n');
+ flush();
+ raw_mode(OFF);
if (rpipe) { /* Fix stdin */
close (0);
if (open("/dev/tty", 0) < 0)
exit (126);
}
- execl(shell, shell, (char *) 0);
- exit(127); /* Exit with 127 */
- default : /* This is the parent */
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- do {
- w = wait(&status);
- } while (w != -1 && w != pid);
+ execl(shell, shell, NULL);
+ exit(127); /* Exit with 127 */
+ default : /* This is the parent */
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ do {
+ w = wait(&status);
+ } while (w != -1 && w != pid);
}
raw_mode(ON);
RD(0);
if ((status >> 8) == 127) /* Child died with 127 */
- error("Cannot exec ", shell);
+ error("Cannot exec ", shell);
else if ((status >> 8) == 126)
- error("Cannot open /dev/tty as fd #0", NIL_PTR);
+ error("Cannot open /dev/tty as fd #0", NIL_PTR);
}
/*
proceed(LINE *line, int count)
{
if (count < 0)
- while (count++ < 0 && line != header)
- line = line->prev;
+ while (count++ < 0 && line != header)
+ line = line->prev;
else
- while (count-- > 0 && line != tail)
- line = line->next;
+ while (count-- > 0 && line != tail)
+ line = line->next;
return line;
}
set_cursor(0, ymax);
if (revfl == ON) { /* Print rev. start sequence */
#ifdef UNIX
- tputs(SO, 0, _putchar);
+ tputs(SO, 0, _putchar);
#else
- string_print(rev_video);
+ string_print(rev_video);
#endif /* UNIX */
- stat_visible = TRUE;
+ stat_visible = TRUE;
}
else /* Used as clear_status() */
- stat_visible = FALSE;
+ stat_visible = FALSE;
string_print(buf);
-
+
if (inbuf != NIL_PTR)
- ret = input(inbuf, statfl);
+ ret = input(inbuf, statfl);
/* Print normal video */
#ifdef UNIX
string_print(blank_line); /* Clear the rest of the line */
#endif /* UNIX */
if (inbuf != NIL_PTR)
- set_cursor(0, ymax);
+ set_cursor(0, ymax);
else
- set_cursor(x, y); /* Set cursor back to old position */
+ set_cursor(x, y); /* Set cursor back to old position */
flush(); /* Perform the actual write */
if (ret != FINE)
- clear_status();
+ clear_status();
return ret;
}
/* Find begin of line on screen */
while (cnt < 0) {
- if (is_tab(*textp++))
- cnt = tab(cnt);
- else
- cnt++;
+ if (is_tab(*textp++))
+ cnt = tab(cnt);
+ else
+ cnt++;
}
/* Count number of chars left */
cnt = 0;
while (*textp != '\n') {
- if (is_tab(*textp++))
- cnt = tab(cnt);
- else
- cnt++;
+ if (is_tab(*textp++))
+ cnt = tab(cnt);
+ else
+ cnt++;
}
return cnt;
}
/* Check for illegal values */
if (new_y < 0 || new_y > last_y)
- return;
+ return;
/* Adjust y-coordinate and cur_line */
if (new_y < y)
- while (y != new_y) {
+ while (y != new_y) {
if(line->shift_count>0) {
line->shift_count=0;
move_to(0,y);
string_print(blank_line);
line_print(line);
}
- y--;
- line = line->prev;
- }
+ y--;
+ line = line->prev;
+ }
else
- while (y != new_y) {
+ while (y != new_y) {
if(line->shift_count>0) {
line->shift_count=0;
move_to(0,y);
string_print(blank_line);
line_print(line);
}
- y++;
- line = line->next;
- }
+ y++;
+ line = line->next;
+ }
/* Set or unset relative x-coordinate */
if (new_address == NIL_PTR) {
- new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx);
+ new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx);
if (new_x != x)
rel_x = tx;
- new_x = tx;
+ new_x = tx;
}
else {
- rel_x = new_x = find_x(line, new_address);
+ rel_x = new_x = find_x(line, new_address);
}
/* Adjust shift_count if new_x lower than 0 or higher than XBREAK */
if (new_x < 0 || new_x >= XBREAK) {
- if (new_x > XBREAK || (new_x == XBREAK && *new_address != '\n'))
- shift = (new_x - XBREAK) / SHIFT_SIZE + 1;
- else {
- shift = new_x / SHIFT_SIZE;
+ if (new_x > XBREAK || (new_x == XBREAK && *new_address != '\n'))
+ shift = (new_x - XBREAK) / SHIFT_SIZE + 1;
+ else {
+ shift = new_x / SHIFT_SIZE;
if (new_x % SHIFT_SIZE)
shift--;
- }
-
- if (shift != 0) {
- line->shift_count += shift;
- new_x = find_x(line, new_address);
- set_cursor(0, y);
- line_print(line);
- rel_x = new_x;
- }
+ }
+
+ if (shift != 0) {
+ line->shift_count += shift;
+ new_x = find_x(line, new_address);
+ set_cursor(0, y);
+ line_print(line);
+ rel_x = new_x;
+ }
}
/* Assign and position cursor */
int nx = get_shift(line->shift_count) * -SHIFT_SIZE;
while (textp != address && *textp != '\0') {
- if (is_tab(*textp++)) /* Expand tabs */
- nx = tab(nx);
- else
- nx++;
+ if (is_tab(*textp++)) /* Expand tabs */
+ nx = tab(nx);
+ else
+ nx++;
}
return nx;
}
int tx = get_shift(line->shift_count) * -SHIFT_SIZE;
while (tx < x_coord && *textp != '\n') {
- if (is_tab(*textp)) {
- if (*old_x - x_coord == 1 && tab(tx) > x_coord)
- break; /* Moving left over tab */
- else
- tx = tab(tx);
- }
- else
- tx++;
- textp++;
+ if (is_tab(*textp)) {
+ if (*old_x - x_coord == 1 && tab(tx) > x_coord)
+ break; /* Moving left over tab */
+ else
+ tx = tab(tx);
+ }
+ else
+ tx++;
+ textp++;
}
-
+
*old_x = tx;
return textp;
}
int count = 0;
if (string != NIL_PTR) {
- while (*string++ != '\0')
- count++;
+ while (*string++ != '\0')
+ count++;
}
return count;
}
copy_string(char *to, const char *from)
{
while ((*to++ = *from++) != 0)
- ;
+ ;
}
/*
/* Search for bot_line (might be last line in file) */
for (last_y = 0; last_y < nlines - 1 && last_y < screenmax
&& line->next != tail; last_y++)
- line = line->next;
+ line = line->next;
bot_line = line;
y = (screen_y > last_y) ? last_y : screen_y;
char c;
if (read(input_fd, &c, 1) != 1 && quit == FALSE)
- panic("Can't read one char from fd #0");
+ panic("Can't read one char from fd #0");
return c & 0377;
#endif /* UNIX */
/* Find new startline if count is negative */
if (count < 0) {
- line = proceed(line, count);
- count = -count;
+ line = proceed(line, count);
+ count = -count;
}
/* Print the lines */
while (line != tail && count-- >= 0) {
line->shift_count=0;
- line_print(line);
- line = line->next;
+ line_print(line);
+ line = line->next;
}
/* Print the blank lines (if any) */
}
/*
- * Write_char does a buffered output.
+ * Write_char does a buffered output.
*/
int
write_char(int fd, char c)
{
screen [out_count++] = c;
if (out_count == SCREEN_SIZE) /* Flush on SCREEN_SIZE chars */
- return flush_buffer(fd);
+ return flush_buffer(fd);
return FINE;
}
writeline(int fd, const char *text)
{
while(*text)
- if (write_char(fd, *text++) == ERRORS)
- return ERRORS;
+ if (write_char(fd, *text++) == ERRORS)
+ return ERRORS;
return FINE;
}
/* Skip all chars as indicated by the offset and the shift_count field */
while (count < offset) {
- if (is_tab(*textp++))
- count = tab(count);
- else
- count++;
+ if (is_tab(*textp++))
+ count = tab(count);
+ else
+ count++;
}
while (*textp != '\n' && count < XBREAK) {
- if (is_tab(*textp)) { /* Expand tabs to spaces */
- tab_count = tab(count);
- while (count < XBREAK && count < tab_count) {
- count++;
- putchar(' ');
- }
- textp++;
- }
- else {
+ if (is_tab(*textp)) { /* Expand tabs to spaces */
+ tab_count = tab(count);
+ while (count < XBREAK && count < tab_count) {
+ count++;
+ putchar(' ');
+ }
+ textp++;
+ }
+ else {
if (*textp >= '\01' && *textp <= '\037') {
#ifdef UNIX
tputs(SO, 0, _putchar);
#else
string_print (rev_video);
#endif /* UNIX */
- putchar(*textp++ + '\100');
+ putchar(*textp++ + '\100');
#ifdef UNIX
tputs(SE, 0, _putchar);
#else
#endif /* UNIX */
}
else
- putchar(*textp++);
- count++;
- }
+ putchar(*textp++);
+ count++;
+ }
}
/* If line is longer than XBREAK chars, print the shift_mark */
if (count == XBREAK && *textp != '\n')
- putchar(textp[1]=='\n' ? *textp : SHIFT_MARK);
+ putchar(textp[1]=='\n' ? *textp : SHIFT_MARK);
/* Clear the rest of the line is clear_line is TRUE */
if (clear_line == TRUE) {
#ifdef UNIX
- tputs(CE, 0, _putchar);
+ tputs(CE, 0, _putchar);
#else
string_print(blank_line);
#endif /* UNIX */
- putchar('\n');
+ putchar('\n');
}
}
flush_buffer(int fd)
{
if (out_count <= 0) /* There is nothing to flush */
- return FINE;
+ return FINE;
#ifdef UNIX
if (fd == STD_OUT) {
- printf("%.*s", out_count, screen);
- _flush();
+ printf("%.*s", out_count, screen);
+ _flush();
}
else
#endif /* UNIX */
if (write(fd, screen, out_count) != out_count) {
- bad_write(fd);
- return ERRORS;
+ bad_write(fd);
+ return ERRORS;
}
clear_buffer(); /* Empty buffer */
return FINE;
bad_write(int fd)
{
if (fd == STD_OUT) /* Cannot write to terminal? */
- exit(1);
-
+ exit(1);
+
clear_buffer();
build_string(text_buffer, "Command aborted: %s (File incomplete)",
- (errno == ENOSPC || errno == -ENOSPC) ?
- "No space on device" : "Write error");
+ (errno == ENOSPC || errno == -ENOSPC) ?
+ "No space on device" : "Write error");
error(text_buffer, NIL_PTR);
}
/* Ask for confirmation */
status_line("Really abort? ", NIL_PTR);
if (getchar() != 'y') {
- clear_status();
- return;
+ clear_status();
+ return;
}
/* Reset terminal */
static struct termios new_tty;
if (state == OFF) {
- tcsetattr(input_fd, TCSANOW, &old_tty);
- return;
+ tcsetattr(input_fd, TCSANOW, &old_tty);
+ return;
}
/* Save old tty settings */
write(STD_OUT, text_buffer, length_of(text_buffer));
if (loading == FALSE)
- XT(0); /* Check if file can be saved */
+ XT(0); /* Check if file can be saved */
else
- unlink(yank_file);
+ unlink(yank_file);
raw_mode(OFF);
#ifdef UNIX
const char *blank_line = "\033[K"; /* Clear line to end */
#endif /* UNIX */
-/*
+/*
* Yank variables.
*/
FLAG yank_status = NOT_VALID; /* Status of yank_file */
/* Delete the whole list */
for (line = header->next; line != tail; line = next_line) {
- next_line = line->next;
- free_space(line->text);
- free_space((char*)line);
+ next_line = line->next;
+ free_space(line->text);
+ free_space((char*)line);
}
/* header and tail should point to itself */
char *last = NIL_PTR;
while (*ptr != '\0') {
- if (*ptr == '/')
- last = ptr;
- ptr++;
+ if (*ptr == '/')
+ last = ptr;
+ ptr++;
}
if (last == NIL_PTR)
- return path;
+ return path;
if (*(last + 1) == '\0') { /* E.g. /usr/tmp/pipo/ */
- *last = '\0';
- return basename(path);/* Try again */
+ *last = '\0';
+ return basename(path);/* Try again */
}
return last + 1;
}
writable = TRUE; /* Benefit of the doubt */
if (file == NIL_PTR) {
if (rpipe == FALSE)
- status_line("No file.", NIL_PTR);
+ status_line("No file.", NIL_PTR);
else {
fd = 0;
file = "standard input";
file_name[0] = '\0';
}
else {
- copy_string(file_name, file); /* Save file name */
- if (access(file, 0) < 0) /* Cannot access file. */
- status_line("New file ", file);
- else if ((fd = open(file, 0)) < 0)
- status_line("Cannot open ", file);
- else if (access(file, 2) != 0) /* Set write flag */
- writable = FALSE;
+ copy_string(file_name, file); /* Save file name */
+ if (access(file, 0) < 0) /* Cannot access file. */
+ status_line("New file ", file);
+ else if ((fd = open(file, 0)) < 0)
+ status_line("Cannot open ", file);
+ else if (access(file, 2) != 0) /* Set write flag */
+ writable = FALSE;
}
/* Read file */
loading = TRUE; /* Loading file, so set flag */
if (fd >= 0) {
- status_line("Reading ", file);
- while ((len = get_line(fd, text_buffer)) != ERRORS) {
- line = line_insert(line, text_buffer, len);
- nr_of_chars += (long) len;
- }
- if (nlines == 0) /* The file was empty! */
- line = line_insert(line, "\n", 1);
- clear_buffer(); /* Clear output buffer */
- cur_line = header->next;
- fstatus("Read", nr_of_chars);
- close(fd); /* Close file */
+ status_line("Reading ", file);
+ while ((len = get_line(fd, text_buffer)) != ERRORS) {
+ line = line_insert(line, text_buffer, len);
+ nr_of_chars += (long) len;
+ }
+ if (nlines == 0) /* The file was empty! */
+ line = line_insert(line, "\n", 1);
+ clear_buffer(); /* Clear output buffer */
+ cur_line = header->next;
+ fstatus("Read", nr_of_chars);
+ close(fd); /* Close file */
}
else /* Just install a "\n" */
- line_insert(line, "\n", 1);
+ line_insert(line, "\n", 1);
reset(header->next, 0); /* Initialize pointers */
char *begin = buffer;
do {
- if (cur_pos == last) {
- if ((read_chars = read(fd, screen, SCREEN_SIZE)) <= 0)
- break;
- last = &screen[read_chars];
- cur_pos = screen;
- }
+ if (cur_pos == last) {
+ if ((read_chars = read(fd, screen, SCREEN_SIZE)) <= 0)
+ break;
+ last = &screen[read_chars];
+ cur_pos = screen;
+ }
if (*cur_pos == '\0')
*cur_pos = ' ';
} while ((*buffer++ = *cur_pos++) != '\n');
current = cur_pos;
if (read_chars <= 0) {
- if (buffer == begin)
- return ERRORS;
- if (*(buffer - 1) != '\n') {
- if (loading == TRUE) /* Add '\n' to last line of file */
- *buffer++ = '\n';
- else {
- *buffer = '\0';
- return NO_LINE;
- }
+ if (buffer == begin)
+ return ERRORS;
+ if (*(buffer - 1) != '\n') {
+ if (loading == TRUE) /* Add '\n' to last line of file */
+ *buffer++ = '\n';
+ else {
+ *buffer = '\0';
+ return NO_LINE;
+ }
}
}
return new_line;
}
-int
+int
main(int argc, char *argv[])
{
/* mined is the Minix editor. */
/* Load the file (if any) */
if (argc < 2)
- load_file(NIL_PTR);
+ load_file(NIL_PTR);
else {
- get_file(NIL_PTR, argv[1]); /* Truncate filename */
- load_file(argv[1]);
+ get_file(NIL_PTR, argv[1]); /* Truncate filename */
+ load_file(argv[1]);
}
/* Main loop of the editor. */
for (;;) {
- index = getchar();
- if (stat_visible == TRUE)
- clear_status();
- if (quit == TRUE)
- abort_mined();
- else { /* Call the function for this key */
- (*key_map[index])(index);
- flush(); /* Flush output (if any) */
- if (quit == TRUE)
- quit = FALSE;
- }
+ index = getchar();
+ if (stat_visible == TRUE)
+ clear_status();
+ if (quit == TRUE)
+ abort_mined();
+ else { /* Call the function for this key */
+ (*key_map[index])(index);
+ flush(); /* Flush output (if any) */
+ if (quit == TRUE)
+ quit = FALSE;
+ }
}
/* NOTREACHED */
}
XT(int u __unused)
{
if (modified == TRUE && ask_save() == ERRORS)
- return;
+ return;
raw_mode(OFF);
set_cursor(0, ymax);
/* F6 = ESC [ 6 ~ */
/* F7 = ESC [ 17 ~ */
/* F8 = ESC [ 18 ~ */
- case '1':
- switch (ch) {
+ case '1':
+ switch (ch) {
case '~': return(SF);
case '7': getchar(); return(MA);
case '8': getchar(); return(CTL);
}
/*
- * ESC() wants a count and a command after that. It repeats the
+ * ESC() wants a count and a command after that. It repeats the
* command count times. If a ^\ is given during repeating, stop looping and
* return to main loop.
*/
index = getchar();
while (index >= '0' && index <= '9' && quit == FALSE) {
- count *= 10;
- count += index - '0';
- index = getchar();
+ count *= 10;
+ count += index - '0';
+ index = getchar();
}
if (count == 0) {
count = 1;
}
if (func == I) { /* Function assigned? */
- clear_status();
- return;
+ clear_status();
+ return;
}
while (count-- > 0 && quit == FALSE) {
- if (stat_visible == TRUE)
- clear_status();
- (*func)(index);
- flush();
+ if (stat_visible == TRUE)
+ clear_status();
+ (*func)(index);
+ flush();
}
if (quit == TRUE) /* Abort has been given */
- error("Aborted", NIL_PTR);
+ error("Aborted", NIL_PTR);
}
/*
" has been modified. Save? (y/n)");
while((c = getchar()) != 'y' && c != 'n' && quit == FALSE) {
- ring_bell();
- flush();
+ ring_bell();
+ flush();
}
clear_status();
if (c == 'y')
- return WT();
+ return WT();
if (c == 'n')
- return FINE;
+ return FINE;
quit = FALSE; /* Abort character has been given */
return ERRORS;
int count = 1;
while (line != cur_line) {
- count++;
- line = line->next;
+ count++;
+ line = line->next;
}
-
+
return count;
}
-
+
/*
* Display a line telling how many chars and lines the file contains. Also tell
* whether the file is readonly and/or modified.
char yank_msg[LINE_LEN];/* Buffer for msg of yank_file */
if (count < 0) /* Not valid. Count chars in file */
- for (line = header->next; line != tail; line = line->next)
- count += length_of(line->text);
+ for (line = header->next; line != tail; line = line->next)
+ count += length_of(line->text);
if (yank_status != NOT_VALID) /* Append buffer info */
- build_string(yank_msg, " Buffer: %D char%s.", chars_saved,
+ build_string(yank_msg, " Buffer: %D char%s.", chars_saved,
(chars_saved == 1L) ? "" : "s");
else
- yank_msg[0] = '\0';
+ yank_msg[0] = '\0';
build_string(msg, "%s %s%s%s %d line%s %D char%s.%s Line %d", message,
- (rpipe == TRUE && *message != '[') ? "standard input" : basename(file),
- (changed == TRUE) ? "*" : "",
- (writefl == FALSE) ? " (Readonly)" : "",
- lines, (lines == 1) ? "" : "s",
+ (rpipe == TRUE && *message != '[') ? "standard input" : basename(file),
+ (changed == TRUE) ? "*" : "",
+ (writefl == FALSE) ? " (Readonly)" : "",
+ lines, (lines == 1) ? "" : "s",
count, (count == 1L) ? "" : "s",
yank_msg, line_number());
if (length_of(msg) + 1 > LINE_LEN - 4) {
- msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */
- msg[LINE_LEN - 3] = '\0';
+ msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */
+ msg[LINE_LEN - 3] = '\0';
}
status_line(msg, NIL_PTR); /* Print the information */
}
va_start(argptr, fmt);
while (*fmt) {
- if (*fmt == '%') {
- fmt++;
- switch (*fmt++) {
- case 's' :
- scanp = va_arg(argptr, char *);
- break;
- case 'd' :
- scanp = num_out((long) va_arg(argptr, int));
- break;
- case 'D' :
- scanp = num_out((long) va_arg(argptr, long));
- break;
- default :
- scanp = "";
- }
- while ((*buf++ = *scanp++) != 0)
- ;
- buf--;
- }
- else
- *buf++ = *fmt++;
+ if (*fmt == '%') {
+ fmt++;
+ switch (*fmt++) {
+ case 's' :
+ scanp = va_arg(argptr, char *);
+ break;
+ case 'd' :
+ scanp = num_out((long) va_arg(argptr, int));
+ break;
+ case 'D' :
+ scanp = num_out((long) va_arg(argptr, long));
+ break;
+ default :
+ scanp = "";
+ }
+ while ((*buf++ = *scanp++) != 0)
+ ;
+ buf--;
+ }
+ else
+ *buf++ = *fmt++;
}
va_end(argptr);
*buf = '\0';
int i;
for (i = 0; i < 10; i++) {
- digit = number / pow; /* Get next digit */
- if (digit == 0L && digit_seen == FALSE && i != 9)
- num_buf[i] = ' ';
- else {
- num_buf[i] = '0' + (char) digit;
- number -= digit * pow; /* Erase digit */
- digit_seen = TRUE;
- }
- pow /= 10L; /* Get next digit */
+ digit = number / pow; /* Get next digit */
+ if (digit == 0L && digit_seen == FALSE && i != 9)
+ num_buf[i] = ' ';
+ else {
+ num_buf[i] = '0' + (char) digit;
+ number -= digit * pow; /* Erase digit */
+ digit_seen = TRUE;
+ }
+ pow /= 10L; /* Get next digit */
}
for (i = 0; num_buf[i] == ' '; i++) /* Skip leading spaces */
- ;
+ ;
return (&num_buf[i]);
}
index = getchar();
if (quit == FALSE && (index < '0' || index > '9')) {
- error("Bad count", NIL_PTR);
- return ERRORS;
+ error("Bad count", NIL_PTR);
+ return ERRORS;
}
/* Convert input to a decimal number */
while (index >= '0' && index <= '9' && quit == FALSE) {
- count *= 10;
- count += index - '0';
- index = getchar();
+ count *= 10;
+ count += index - '0';
+ index = getchar();
}
if (quit == TRUE) {
- clear_status();
- return ERRORS;
+ clear_status();
+ return ERRORS;
}
*result = count;
*ptr = '\0';
while (quit == FALSE) {
- flush();
- switch (c = getchar()) {
- case '\b' : /* Erase previous char */
- if (ptr > inbuf) {
- ptr--;
+ flush();
+ switch (c = getchar()) {
+ case '\b' : /* Erase previous char */
+ if (ptr > inbuf) {
+ ptr--;
#ifdef UNIX
- tputs(SE, 0, _putchar);
+ tputs(SE, 0, _putchar);
#else
- string_print(normal_video);
+ string_print(normal_video);
#endif /* UNIX */
- if (is_tab(*ptr))
- string_print(" \b\b\b \b\b");
- else
- string_print(" \b\b \b");
+ if (is_tab(*ptr))
+ string_print(" \b\b\b \b\b");
+ else
+ string_print(" \b\b \b");
#ifdef UNIX
- tputs(SO, 0, _putchar);
+ tputs(SO, 0, _putchar);
#else
- string_print(rev_video);
+ string_print(rev_video);
#endif /* UNIX */
- string_print(" \b");
- *ptr = '\0';
- }
- else
- ring_bell();
- break;
- case '\n' : /* End of input */
- /* If inbuf is empty clear status_line */
- return (ptr == inbuf && clearfl == TRUE) ? NO_INPUT :FINE;
- default : /* Only read ASCII chars */
- if ((c >= ' ' && c <= '~') || c == '\t') {
- *ptr++ = c;
- *ptr = '\0';
- if (c == '\t')
- string_print("^I");
- else
- putchar(c);
- string_print(" \b");
- }
- else
- ring_bell();
- }
+ string_print(" \b");
+ *ptr = '\0';
+ }
+ else
+ ring_bell();
+ break;
+ case '\n' : /* End of input */
+ /* If inbuf is empty clear status_line */
+ return (ptr == inbuf && clearfl == TRUE) ? NO_INPUT :FINE;
+ default : /* Only read ASCII chars */
+ if ((c >= ' ' && c <= '~') || c == '\t') {
+ *ptr++ = c;
+ *ptr = '\0';
+ if (c == '\t')
+ string_print("^I");
+ else
+ putchar(c);
+ string_print(" \b");
+ }
+ else
+ ring_bell();
+ }
}
quit = FALSE;
return ERRORS;
}
/*
- * Get_file() reads a filename from the terminal. Filenames longer than
+ * Get_file() reads a filename from the terminal. Filenames longer than
* FILE_LENGHT chars are truncated.
*/
int
int ret = FINE;
if (message == NIL_PTR || (ret = get_string(message, file, TRUE)) == FINE) {
- if (length_of((ptr = basename(file))) > NAME_MAX)
- ptr[NAME_MAX] = '\0';
+ if (length_of((ptr = basename(file))) > NAME_MAX)
+ ptr[NAME_MAX] = '\0';
}
return ret;
}
char entry[1024];
if (tgetent(entry, getenv("TERM")) <= 0) {
- printf("Unknown terminal.\n");
- exit(1);
+ printf("Unknown terminal.\n");
+ exit(1);
}
AL = tgetstr("al", &loc);
screenmax = ymax - 1;
if (!CE || !SO || !SE || !CL || !AL || !CM) {
- printf("Sorry, no mined on this type of terminal\n");
- exit(1);
+ printf("Sorry, no mined on this type of terminal\n");
+ exit(1);
}
}
#endif /* UNIX */
pline("Your weapon is welded to your hand!");
return(0);
}
- setuwep((struct obj *) 0);
+ setuwep(NULL);
}
current_ice_box->owt += obj->owt;
freeinv(obj);
else {
pline("Do you want to take something out of the ice-box? [yn] ");
if(readchar() == 'y')
- if(askchain(fcobj, (char *) 0, 0, out_ice_box, ck_ice_box, 0))
+ if(askchain(fcobj, NULL, 0, out_ice_box, ck_ice_box, 0))
return;
pline("That was all. Do you wish to put something in? [yn] ");
if(readchar() != 'y') return;
static struct monst *
bchit(int ddx, int ddy, int range, char sym)
{
- struct monst *mtmp = (struct monst *) 0;
+ struct monst *mtmp = NULL;
int bchx = u.ux, bchy = u.uy;
if(sym) Tmp_at(-1, sym); /* open call */
&& !sobj_at(ENORMOUS_ROCK, rx, ry)) {
/* ACCESSIBLE or POOL */
pline("You swing your %s through thin air.",
- aobjnam(obj, (char *) 0));
+ aobjnam(obj, NULL));
} else {
if(dig_pos.x != rx || dig_pos.y != ry
|| dig_level != dlevel || dig_down) {
struct ext_func_tab extcmdlist[] = {
{ "dip", dodip },
{ "pray", dopray },
- { (char *) 0, donull }
+ { NULL, donull }
};
extern char quitchars[];
pline("Your weapon is welded to your hand!");
return(0);
}
- setuwep((struct obj *) 0);
+ setuwep(NULL);
}
pline("You dropped %s.", doname(obj));
dropx(obj);
if(obj->quan > 1)
setuwep(splitobj(obj, 1));
else
- setuwep((struct obj *) 0);
+ setuwep(NULL);
}
else if(obj->quan > 1)
splitobj(obj, 1);
pline("%s hits the floor.", Doname(obj));
if(obj->otyp == EXPENSIVE_CAMERA) {
pline("It is shattered in a thousand pieces!");
- obfree(obj, Null(obj));
+ obfree(obj, NULL);
} else if(obj->otyp == EGG) {
pline("\"Splash!\"");
- obfree(obj, Null(obj));
+ obfree(obj, NULL);
} else if(obj->olet == POTION_SYM) {
pline("The flask breaks, and you smell a peculiar odor ...");
potionbreathe(obj);
- obfree(obj, Null(obj));
+ obfree(obj, NULL);
} else {
dropy(obj);
}
/* weapons thrown disappear sometimes */
if(obj->otyp < BOOMERANG && rn2(3)) {
/* check bill; free */
- obfree(obj, (struct obj *) 0);
+ obfree(obj, NULL);
return(1);
}
} else miss(objects[obj->otyp].oc_name, mon);
otmp2->onamelth = lth;
strcpy(ONAME(otmp2), buf);
- setworn((struct obj *) 0, obj->owornmask);
+ setworn(NULL, obj->owornmask);
setworn(otmp2, otmp2->owornmask);
/* do freeinv(obj); etc. by hand in order to preserve
{
int delay = -objects[otmp->otyp].oc_delay;
if(cursed(otmp)) return(0);
- setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
+ setworn(NULL, otmp->owornmask & W_ARMOR);
if(delay) {
nomul(delay);
switch(otmp->otyp) {
if(err) return(0);
setworn(otmp, mask);
if(otmp == uwep)
- setuwep((struct obj *) 0);
+ setuwep(NULL);
delay = -objects[otmp->otyp].oc_delay;
if(delay){
nomul(delay);
} while(!mask);
setworn(otmp, mask);
if(otmp == uwep)
- setuwep((struct obj *) 0);
+ setuwep(NULL);
oldprop = u.uprops[PROP(otmp->otyp)].p_flgs;
u.uprops[PROP(otmp->otyp)].p_flgs |= mask;
switch(otmp->otyp){
{
long mask;
mask = obj->owornmask & W_RING;
- setworn((struct obj *) 0, obj->owornmask);
+ setworn(NULL, obj->owornmask);
if(!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
impossible("Strange... I didn't know you had that ring.");
u.uprops[PROP(obj->otyp)].p_flgs &= ~mask;
pline("Your %s off your fingers.",
(uleft && uright) ? "rings slip" : "ring slips");
xfl++;
- if((otmp = uleft) != Null(obj)){
+ if((otmp = uleft) != NULL){
ringoff(uleft);
dropx(otmp);
}
- if((otmp = uright) != Null(obj)){
+ if((otmp = uright) != NULL){
ringoff(uright);
dropx(otmp);
}
}
- if((otmp = uwep) != Null(obj)){
+ if((otmp = uwep) != NULL){
/* Note: at present also cursed weapons fall */
- setuwep((struct obj *) 0);
+ setuwep(NULL);
dropx(otmp);
pline("Your weapon %sslips from your hands.",
xfl ? "also " : "");
pline("%s devours the %s.", Monnam(mtmp),
objects[obj->otyp].oc_name);
}
- obfree(obj, (struct obj *) 0);
+ obfree(obj, NULL);
}
mtmp2 = newmonst(sizeof(struct edog) + mtmp->mnamelth);
*mtmp2 = *mtmp;
goto no_opener;
}
pline("Using your %s you try to open the tin.",
- aobjnam(uwep, (char *) 0));
+ aobjnam(uwep, NULL));
} else {
no_opener:
pline("It is not so easy to open this tin.");
outrip();
}
if(*st1 == 'c') killer = st1; /* after outrip() */
- settty((char *) 0); /* does a clear_screen() */
+ settty(NULL); /* does a clear_screen() */
if(!done_stopprint)
printf("Goodbye %s %s...\n\n", pl_character, plname);
{ long int tmp;
return(ep);
ep = ep->nxt_engr;
}
- return((struct engr *) 0);
+ return(NULL);
}
bool
if(uwep && uwep->cursed) {
/* Andreas Bormann */
pline("Since your weapon is welded to your hand,");
- pline("you use the %s.", aobjnam(uwep, (char *) 0));
+ pline("you use the %s.", aobjnam(uwep, NULL));
otmp = uwep;
} else {
if(!otmp)
pline("As you hit %s, the boomerang breaks into splinters.",
monnam(mon));
freeinv(obj);
- setworn((struct obj *) 0, obj->owornmask);
- obfree(obj, (struct obj *) 0);
+ setworn(NULL, obj->owornmask);
+ obfree(obj, NULL);
tmp++;
}
}
pline("You succeed in destroying your camera. Congratulations!");
freeinv(obj);
if(obj->owornmask)
- setworn((struct obj *) 0, obj->owornmask);
- obfree(obj, (struct obj *) 0);
+ setworn(NULL, obj->owornmask);
+ obfree(obj, NULL);
return(TRUE);
case DEAD_COCKATRICE:
pline("You hit %s with the cockatrice corpse.",
#define rindex strrchr
#endif /* BSD */
-#define Null(type) ((struct type *) 0)
-
#include "def.objclass.h"
typedef struct {
} else {
setnotworn(obj);
freeinv(obj);
- obfree(obj, (struct obj *) 0);
+ obfree(obj, NULL);
}
}
{
freeobj(obj);
unpobj(obj);
- obfree(obj, (struct obj *) 0);
+ obfree(obj, NULL);
}
/* unlink obj from chain starting with fobj */
if(objchn->o_id == id) return(objchn);
objchn = objchn->nobj;
}
- return((struct obj *) 0);
+ return(NULL);
}
struct trap *
/*
* getobj returns:
* struct obj *xxx: object to do something with.
- * (struct obj *) 0 error return: no object.
+ * NULL error return: no object.
* &zeroobj explicitly no object (as in w-).
*/
struct obj *
if(index(quitchars,ilet))
return(NULL);
if(ilet == '-') {
- return(allownone ? &zeroobj : (struct obj *) 0);
+ return(allownone ? &zeroobj : NULL);
}
if(ilet == '$') {
if(!allowgold){
if(!(ilet = morc)) continue;
/* he typed a letter (not a space) to more() */
} else if(ilet == '*') {
- doinv((char *) 0);
+ doinv(NULL);
if(!(ilet = morc)) continue;
/* ... */
}
int
ddoinv(void)
{
- doinv((char *) 0);
+ doinv(NULL);
return(0);
}
return;
}
- cornline(0, (char *) 0);
+ cornline(0, NULL);
ilet = 'a';
for(otmp = invent; otmp; otmp = otmp->nobj) {
if(flags.invlet_constant) ilet = otmp->invlet;
if(ct == 1 && !gold) {
pline("You %s here %s.", verb, doname(otmp0));
- cornline(3, (char *) 0);
+ cornline(3, NULL);
}
if(ct > 1)
- cornline(2, (char *) 0);
+ cornline(2, NULL);
return(!!Blind);
}
{
#ifdef SIGTSTP
if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
- settty((char *) 0);
+ settty(NULL);
signal(SIGTSTP, SIG_DFL);
kill(0, SIGTSTP);
gettty();
#ifdef MAIL
ckmailstatus();
#endif
- rhack((char *) 0);
+ rhack(NULL);
}
if(multi && multi%7 == 0)
fflush(stdout);
int tmp, ct;
boolean anything = (!ptr);
- if(x != 0 || y != 0) if(m_at(x,y)) return((struct monst *) 0);
+ if(x != 0 || y != 0) if(m_at(x,y)) return(NULL);
if(ptr){
- if(index(fut_geno, ptr->mlet)) return((struct monst *) 0);
+ if(index(fut_geno, ptr->mlet)) return(NULL);
} else {
ct = CMNUM - strlen(fut_geno);
if(index(fut_geno, 'm')) ct++; /* make only 1 minotaur */
while a monster was on the stairs. Conclusion:
we have to check for monsters on the stairs anyway. */
if(!rn2(3))
- makemon((struct permonst *) 0, somex(), somey());
+ makemon(NULL, somex(), somey());
/* put traps and mimics inside */
goldseen = FALSE;
makemon(PM_MINOTAUR, mm.x, mm.y);
for(x = rn1(5,7); x; x--) {
mm = mazexy();
- makemon((struct permonst *) 0, mm.x, mm.y);
+ makemon(NULL, mm.x, mm.y);
}
for(x = rn1(6,7); x; x--) {
mm = mazexy();
mkgold(0L,mm.x,mm.y);
}
for(x = rn1(6,7); x; x--)
- mktrap(0,1,(struct mkroom *) 0);
+ mktrap(0,1,NULL);
mm = mazexy();
levl[(xupstair = mm.x)][(yupstair = mm.y)].scrsym = '<';
levl[xupstair][yupstair].typ = STAIRS;
(sy == sroom->hy && doors[sh].y == sy+1)) continue;
mon = makemon(
(type == MORGUE) ? morguemon() :
- (type == BEEHIVE) ? PM_KILLER_BEE : (struct permonst *) 0,
+ (type == BEEHIVE) ? PM_KILLER_BEE : NULL,
sx, sy);
if(mon) mon->msleep = 1;
switch(type) {
}
if (ct == 0) {
pline ("You haven't discovered anything yet...");
- cornline(3, (char *) 0);
+ cornline(3, NULL);
} else
- cornline(2, (char *) 0);
+ cornline(2, NULL);
return(0);
}
if(dup(fd)) {
if(!silent) printf("Cannot open %s as stdin.\n", fnam);
} else {
- execl(catmore, "page", (char *) 0);
+ execl(catmore, "page", NULL);
if(!silent) printf("Cannot exec %s.\n", catmore);
}
exit(1);
{
FILE *f; /* free after Robert Viduya */
- if ((f = fopen (fnam, "r")) == (FILE *) 0) {
+ if ((f = fopen (fnam, "r")) == NULL) {
if(!silent) {
home(); perror (fnam); flags.toplin = 1;
pline ("Cannot open %s.", fnam);
char *str;
if(child(0)) {
if((str = getenv("SHELL")))
- execl(str, str, (char *) 0);
+ execl(str, str, NULL);
else
- execl("/bin/sh", "sh", (char *) 0);
+ execl("/bin/sh", "sh", NULL);
pline("sh: cannot execute.");
exit(1);
}
f = fork();
if(f == 0){ /* child */
- settty((char *) 0); /* also calls end_screen() */
+ settty(NULL); /* also calls end_screen() */
/* revoke */
setgid(getgid());
#ifdef CHDIR
}
if(uclose && rn2(5))
potionbreathe(obj);
- obfree(obj, Null(obj));
+ obfree(obj, NULL);
}
void
free((char *) uchain);
uball->spe = 0;
uball->owornmask &= ~W_BALL;
- uchain = uball = (struct obj *) 0;
+ uchain = uball = NULL;
}
break;
}
if(confused) cnt += 12;
while(cnt--)
makemon(confused ? PM_ACID_BLOB :
- (struct permonst *) 0, u.ux, u.uy);
+ NULL, u.ux, u.uy);
break;
}
case SCR_ENCHANT_WEAPON:
for(i = -bd; i <= bd; i++) for(j = -bd; j <= bd; j++)
if((mtmp = m_at(u.ux+i, u.uy+j)))
- tamedog(mtmp, (struct obj *) 0);
+ tamedog(mtmp, NULL);
break;
}
case SCR_GENOCIDE:
int rn,i;
FILE *rumf;
if(n_rumors <= n_used_rumors ||
- (rumf = fopen(RUMORFILE, "r")) == (FILE *) 0) return;
+ (rumf = fopen(RUMORFILE, "r")) == NULL) return;
if(n_used_rumors < 0) init_rumors(rumf);
if(!n_rumors) goto none;
rn = rn2(n_rumors - n_used_rumors);
break;
case ARMOR_SYM:
if(multi < 0 || otmp == uarms){
- setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
+ setworn(NULL, otmp->owornmask & W_ARMOR);
break;
}
{ int curssv = otmp->cursed;
}
}
else if(otmp == uwep)
- setuwep((struct obj *) 0);
+ setuwep(NULL);
if(otmp->olet == CHAIN_SYM) {
impossible("How come you are carrying that chain?");
}
Punished = 0;
freeobj(uchain);
free((char *) uchain);
- uchain = (struct obj *) 0;
+ uchain = NULL;
uball->spe = 0;
- uball = (struct obj *) 0; /* superfluous */
+ uball = NULL; /* superfluous */
}
freeinv(otmp);
pline("%s stole %s.", named ? "She" : Monnam(mtmp), doname(otmp));
for(otmp = invent; otmp; otmp = otmp->nobj) {
if(otmp->olet == AMULET_SYM) {
/* might be an imitation one */
- if(otmp == uwep) setuwep((struct obj *) 0);
+ if(otmp == uwep) setuwep(NULL);
freeinv(otmp);
mpickobj(mtmp,otmp);
pline("%s stole %s!", Monnam(mtmp), doname(otmp));
if(show & cansee(mtmp->mx,mtmp->my))
atl(otmp->ox,otmp->oy,otmp->olet);
}
- mtmp->minvent = (struct obj *) 0;
+ mtmp->minvent = NULL;
if(mtmp->mgold || mtmp->data->mlet == 'L') {
long tmp;
{
va_list ap;
if(settty_needed)
- settty((char *) 0);
+ settty(NULL);
va_start(ap, s);
vprintf(s, ap);
va_end(ap);
if(!(mr = getenv("MAILREADER")))
mr = DEF_MAILREADER;
if(child(1)){
- execl(mr, mr, (char *) 0);
+ execl(mr, mr, NULL);
exit(1);
}
#else /* DEF_MAILREADER */
if(uwep == 0){
pline("You are already empty handed.");
} else {
- setuwep((struct obj *) 0);
+ setuwep(NULL);
res++;
pline("You are empty handed.");
}
{ int cnt = 1;
if(!rn2(23)) cnt += rn2(7) + 1;
while(cnt--)
- makemon((struct permonst *) 0, u.ux, u.uy);
+ makemon(NULL, u.ux, u.uy);
}
break;
case WAN_WISHING:
#include "rogue.h"
char login_name[MAX_OPT_LEN];
-char *nick_name = (char *) 0;
+char *nick_name = NULL;
char *rest_file = 0;
boolean cant_int = 0;
boolean did_int = 0;
md_heed_signals();
if (score_only) {
- put_scores((object *) 0, 0);
+ put_scores(NULL, 0);
}
seed = md_gseed();
srrandom(seed);
get_wand_and_ring_materials();
make_scroll_titles();
- level_objects.next_object = (object *) 0;
- level_monsters.next_monster = (object *) 0;
+ level_objects.next_object = NULL;
+ level_monsters.next_monster = NULL;
player_init();
ring_stats(0);
return(0);
{
object *obj;
- rogue.pack.next_object = (object *) 0;
+ rogue.pack.next_object = NULL;
obj = alloc_object();
get_food(obj, 1);
case ARMOR:
return(id_armors);
}
- return((struct id *) 0);
+ return(NULL);
}
void
n = get_rand(4, 6);
for (i = 0; i < n; i++) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster(NULL, 0);
if ((monster->m_flags & WANDERS) && coin_toss()) {
wake_up(monster);
}
}
}
if (found) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster(NULL, 0);
if (!(monster->m_flags & IMITATES)) {
monster->m_flags |= WAKENS;
}
boolean found = 0;
for (i = 0; ((i < 15) && (!found)); i++) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster(NULL, 0);
if (!(monster->m_flags & (WAKENS | WANDERS))) {
free_object(monster);
} else {
}
}
if (found) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster(NULL, 0);
put_m_at(row, col, monster);
mvaddch(row, col, gmc(monster));
if (monster->m_flags & (WANDERS | WAKENS)) {
return(fainted);
}
if (rogue.moves_left <= STARVE) {
- killed_by((object *) 0, STARVATION);
+ killed_by(NULL, STARVATION);
}
switch(e_rings) {
object level_objects;
unsigned short dungeon[DROWS][DCOLS];
short foods = 0;
-object *free_list = (object *) 0;
-char *fruit = (char *) 0;
+object *free_list = NULL;
+char *fruit = NULL;
fighter rogue = {
INIT_AW, /* armor, weapon */
object *
object_at(object *pack, short row, short col)
{
- object *obj = (object *) 0;
+ object *obj = NULL;
if (dungeon[row][col] & (MONSTER | OBJECT)) {
obj = pack->next_object;
object *obj;
char buf[80];
- if (pack_count((object *) 0) >= MAX_PACK_COUNT) {
+ if (pack_count(NULL) >= MAX_PACK_COUNT) {
message("pack full", 0);
return;
}
if (levitate) {
message("you're floating in the air!", 0);
- return((object *) 0);
+ return(NULL);
}
obj = object_at(&level_objects, row, col);
if (!obj) {
if (id_scrolls[SCARE_MONSTER].id_status == UNIDENTIFIED) {
id_scrolls[SCARE_MONSTER].id_status = IDENTIFIED;
}
- return((object *) 0);
+ return(NULL);
}
if (obj->what_is == GOLD) {
rogue.gold += obj->quantity;
}
if (pack_count(obj) >= MAX_PACK_COUNT) {
message("pack too full", 1);
- return((object *) 0);
+ return(NULL);
}
dungeon[row][col] &= ~(OBJECT);
take_from_pack(obj, &level_objects);
if (obj) {
obj->in_use_flags &= (~BEING_WORN);
}
- rogue.armor = (object *) 0;
+ rogue.armor = NULL;
}
void
if (obj) {
obj->in_use_flags &= (~BEING_WIELDED);
}
- rogue.weapon = (object *) 0;
+ rogue.weapon = NULL;
}
void
} options[NOPTS] = {
{
"Flush typeahead during battle (\"flush\"): ",
- 1, (char **) 0, &flush
+ 1, NULL, &flush
},
{
"Show position only at end of run (\"jump\"): ",
- 1, (char **) 0, &jump
+ 1, NULL, &jump
},
{
"Follow turnings in passageways (\"passgo\"): ",
- 1, (char **) 0, &passgo
+ 1, NULL, &passgo
},
{
"Don't print skull when killed (\"noskull\" or \"notombstone\"): ",
- 1, (char **) 0, &no_skull
+ 1, NULL, &no_skull
},
{
"Ask player before saying 'Okay, bye-bye!' (\"askquit\"): ",
- 1, (char **) 0, &ask_quit
+ 1, NULL, &ask_quit
},
{
"Name (\"name\"): ",
#include "rogue.h"
short write_failed = 0;
-char *save_file = (char *) 0;
+char *save_file = NULL;
static char save_name[80];
extern short cur_level, max_level;
for (;;) {
r_read(fp, (char *) &read_obj, sizeof(object));
if (read_obj.ichar == 0) {
- pack->next_object = (object *) 0;
+ pack->next_object = NULL;
break;
}
new_obj = alloc_object();
message("", 0);
id_all();
sell_pack();
- put_scores((object *) 0, WIN);
+ put_scores(NULL, WIN);
}
void
clean_up(byebye_string);
}
check_message();
- killed_by((object *) 0, QUIT);
+ killed_by(NULL, QUIT);
}
void
}
print_stats(STAT_HP | STAT_STRENGTH);
if (rogue.hp_current <= 0) {
- killed_by((object *) 0, POISON_DART);
+ killed_by(NULL, POISON_DART);
}
break;
case SLEEPING_GAS_TRAP:
break;
case RUST_TRAP:
message(trap_strings[(t*2)+1], 1);
- rust((object *) 0);
+ rust(NULL);
break;
}
}
damage -= get_armor_class(rogue.armor);
}
sprintf(buf, "the %s hits", s);
- rogue_damage(damage, (object *) 0,
+ rogue_damage(damage, NULL,
((ball == FIRE) ? KFIRE : HYPOTHERMIA));
message(buf, 0);
}
int i;
for (i = 0; i < dtbsize; i++)
- cond_init(&dg_cv[i], 0, (void *) 0);
+ cond_init(&dg_cv[i], 0, NULL);
}
}
char *out, /* recv/send data */
const char *nettype) /* nettype */
{
- struct rpc_call_private *rcp = (struct rpc_call_private *) 0;
+ struct rpc_call_private *rcp = NULL;
enum clnt_stat clnt_stat;
struct timeval timeout, tottimeout;
static thread_key_t rpc_call_key;
int i;
for (i = 0; i < dtbsize; i++)
- cond_init(&vc_cv[i], 0, (void *) 0);
+ cond_init(&vc_cv[i], 0, NULL);
}
} else
assert(vc_cv != (cond_t *) NULL);
if (line[0] == 0) /* skip blank lines */
continue;
if (!(perm = strtok(line, fs))
- || !(users = strtok((char *) 0, fs))
- || !(froms = strtok((char *) 0, fs))
- || strtok((char *) 0, fs)) {
+ || !(users = strtok(NULL, fs))
+ || !(froms = strtok(NULL, fs))
+ || strtok(NULL, fs)) {
syslog(LOG_ERR, "%s: line %d: bad field count", _PATH_LOGACCESS,
lineno);
continue;
* the match is affected by any exceptions.
*/
- for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) {
+ for (tok = strtok(list, sep); tok != 0; tok = strtok(NULL, sep)) {
if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */
break;
if ((match = (*match_fn)(tok, item)) != 0) /* YES */
/* Process exceptions to matches. */
if (match != NO) {
- while ((tok = strtok((char *) 0, sep)) && strcasecmp(tok, "EXCEPT"))
+ while ((tok = strtok(NULL, sep)) && strcasecmp(tok, "EXCEPT"))
/* VOID */ ;
- if (tok == 0 || list_match((char *) 0, item, match_fn) == NO)
+ if (tok == 0 || list_match(NULL, item, match_fn) == NO)
return (match);
}
return (NO);
*/
if (tok[0] == '@') { /* netgroup */
- return (netgroup_match(tok + 1, (char *) 0, string));
+ return (netgroup_match(tok + 1, NULL, string));
} else if (string_match(tok, string)) { /* ALL or exact match */
return (YES);
} else if ((group = getgrnam(tok)) != NULL) {/* try group membership */
*/
if (tok[0] == '@') { /* netgroup */
- return (netgroup_match(tok + 1, string, (char *) 0));
+ return (netgroup_match(tok + 1, string, NULL));
} else if (string_match(tok, string)) { /* ALL or exact match */
return (YES);
} else if (tok[0] == '.') { /* domain: match last fields */
#ifdef TIOCNOTTY
n = open(_PATH_TTY, O_RDWR);
if (n >= 0) {
- ioctl(n, TIOCNOTTY, (char *) 0);
+ ioctl(n, TIOCNOTTY, NULL);
(void) close(n);
}
#endif /* TIOCNOTTY */
#ifdef TIOCNOTTY
n = open(_PATH_TTY, O_RDWR);
if (n >= 0) {
- ioctl(n, TIOCNOTTY, (char *) 0);
+ ioctl(n, TIOCNOTTY, NULL);
(void) close(n);
}
#endif /* TIOCNOTTY */
/* If no address was supplied, just return NULL. */
if (!addrp)
- return (struct ifreq *) 0;
+ return NULL;
/* Get the interface config if not done already. */
if (ifconf.ifc_len == 0) {
#endif /* SVR4 */
if ((m < 0) || (ifconf.ifc_len <= 0)) {
report(LOG_ERR, "ioctl SIOCGIFCONF");
- return (struct ifreq *) 0;
+ return NULL;
}
}
maxmatch = 7; /* this many bits or less... */
- ifrmax = (struct ifreq *) 0;/* ... is not a valid match */
+ ifrmax = NULL; /* ... is not a valid match */
p = (char *) ifreq;
len = ifconf.ifc_len;
while (len > 0) {
if (ether_hostton(hostname, &ea)) {
report(LOG_ERR, "no HW addr for host \"%s\"",
hostname);
- return (u_char *) 0;
+ return NULL;
}
return (u_char *) & ea;
}
} /* switch */
/* If the system can't do it, just return an error. */
- return (u_char *) 0;
+ return NULL;
}
limit.rlim_max = RLIM_INFINITY;
limit.rlim_cur = RLIM_INFINITY;
(void)setrlimit(RLIMIT_CPU, &limit);
- execle(PP, "ppplogin", ttyn, (char *) 0, env);
+ execle(PP, "ppplogin", ttyn, NULL, env);
syslog(LOG_ERR, "%s: %m", PP);
exit(1);
} else if (rval || AL) {
limit.rlim_cur = RLIM_INFINITY;
(void)setrlimit(RLIMIT_CPU, &limit);
execle(LO, "login", AL ? "-fp" : "-p", name,
- (char *) 0, env);
+ NULL, env);
syslog(LOG_ERR, "%s: %m", LO);
exit(1);
}
case 't':
slash = strrchr(ttyn, '/');
- if (slash == (char *) 0)
+ if (slash == NULL)
puts(ttyn);
else
puts(&slash[1]);
stats_all.s1.v_pswpin = vmm.v_swappgsin;
stats_all.s1.v_pswpout = vmm.v_swappgsout;
stats_all.s1.v_intr = vmm.v_intr;
- gettimeofday(&tm, (struct timezone *) 0);
+ gettimeofday(&tm, NULL);
stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) +
hz*(tm.tv_usec - btm.tv_usec)/1000000;
stats_all.s2.v_swtch = vmm.v_swtch;
stats_all.s1.if_oerrors += ifmd.ifmd_data.ifi_oerrors;
stats_all.s1.if_collisions += ifmd.ifmd_data.ifi_collisions;
}
- gettimeofday((struct timeval *)&stats_all.s3.curtime,
- (struct timezone *) 0);
+ gettimeofday((struct timeval *)&stats_all.s3.curtime, NULL);
alarm(1);
}
if (doencrypt) {
wready = writeto;
if (select(nfd, &ready,
- &wready, (fd_set *) 0,
- (struct timeval *) 0) < 0)
+ &wready, NULL,
+ NULL) < 0)
break;
} else
#endif
return;
}
ptr = find_request(mp);
- if (ptr == (CTL_MSG *) 0) {
+ if (ptr == NULL) {
insert_table(mp, rp);
rp->answer = announce(mp, hp->h_name);
return;
#else
slash = strrchr(line, '/');
#endif
- if (slash == (char *) 0)
+ if (slash == NULL)
putstr(line);
else
putstr(&slash[1]);
delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS,
SIGXCPU, SIGXFSZ, SIGHUP, SIGINT, SIGTERM, SIGTSTP, SIGALRM,
SIGUSR1, SIGUSR2, 0);
- sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
sa.sa_mask = mask_everything;
/* XXX SA_RESTART? */
sa.sa_flags = sig == SIGCHLD ? SA_NOCLDSTOP : 0;
- sigaction(sig, &sa, (struct sigaction *) 0);
+ sigaction(sig, &sa, NULL);
}
va_end(ap);
}
* and those are reset to SIG_DFL on exec.
*/
sigemptyset(&mask);
- sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
/*
* Fire off a shell.
* We are seriously hosed. Do our best.
*/
emergency("can't fork single-user shell, trying again");
- while (waitpid(-1, (int *) 0, WNOHANG) > 0)
+ while (waitpid(-1, NULL, WNOHANG) > 0)
continue;
return (state_func_t) single_user;
}
argv[2] = runcom_mode == AUTOBOOT ? "autoboot" : 0;
argv[3] = 0;
- sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL);
#ifdef LOGIN_CAP
setprocresources(RESOURCE_RC);
if (pid == -1) {
emergency("can't fork for %s on %s: %m",
_PATH_BSHELL, _PATH_RUNCOM);
- while (waitpid(-1, (int *) 0, WNOHANG) > 0)
+ while (waitpid(-1, NULL, WNOHANG) > 0)
continue;
sleep(STALL_TIMEOUT);
return (state_func_t) single_user;
free(argv);
return (NULL);
}
- while ((argv[argc++] = strk((char *) 0)) != NULL)
+ while ((argv[argc++] = strk(NULL)) != NULL)
continue;
return argv;
}
return;
sigemptyset(&mask);
- sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
if (setsid() < 0)
emergency("setsid failed (window) %m");
{
pid_t pid;
sigset_t mask;
- time_t current_time = time((time_t *) 0);
+ time_t current_time = time(NULL);
int too_quick = 0;
char term[64], *env[2];
}
sigemptyset(&mask);
- sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
#ifdef LOGIN_CAP
setprocresources(RESOURCE_GETTY);
}
sp->se_process = pid;
- sp->se_started = time((time_t *) 0);
+ sp->se_started = time(NULL);
add_session(sp);
}
break;
}
sp->se_process = pid;
- sp->se_started = time((time_t *) 0);
+ sp->se_started = time(NULL);
add_session(sp);
}
while (!requested_transition)
- if ((pid = waitpid(-1, (int *) 0, 0)) != -1)
+ if ((pid = waitpid(-1, NULL, 0)) != -1)
collect_child(pid);
return (state_func_t) requested_transition;
argv[2] = "single";
argv[3] = 0;
- sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL);
#ifdef LOGIN_CAP
setprocresources(RESOURCE_RC);
if (pid == -1) {
emergency("can't fork for %s on %s: %m",
_PATH_BSHELL, _PATH_RUNDOWN);
- while (waitpid(-1, (int *) 0, WNOHANG) > 0)
+ while (waitpid(-1, NULL, WNOHANG) > 0)
continue;
sleep(STALL_TIMEOUT);
return -1;
{
pid_t pid;
- while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0)
+ while ((pid = waitpid((pid_t) -1, NULL, WNOHANG)) > 0)
;
/* wrtp - waitpid _doesn't_ return 0 when no children! */
#ifdef notdef
*/
FD_ZERO(&fdset);
FD_SET(so, &fdset);
- rc = select(so+1, &fdset, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0);
+ rc = select(so+1, &fdset, NULL, NULL, NULL);
if (rc < 0) {
if (errno == EINTR)
continue;
int so;
if (priv)
- so = rresvport((int *) 0);
+ so = rresvport(NULL);
else
so = socket(AF_INET, SOCK_STREAM, 0);
if (so < 0) {
olen = tblp[0];
oadr = tblp[1];
} else {
- tblp = (u_int32_t *) 0;
+ tblp = NULL;
olen = READSCRIPT_OFF(vdsp_base, vdsp_off) & 0xffffff;
};
olen = scr_to_cpu(tblp[0]);
oadr = scr_to_cpu(tblp[1]);
} else {
- tblp = (u32 *) 0;
+ tblp = NULL;
olen = scr_to_cpu(vdsp[0]) & 0xffffff;
};
/* XXX - this is broken... */
if (ie->mcast_count >= MAXMCAST) {
ie->arpcom.ac_if.if_flags |= IFF_ALLMULTI;
- ieioctl(&ie->arpcom.ac_if, SIOCSIFFLAGS, (void *) 0,
+ ieioctl(&ie->arpcom.ac_if, SIOCSIFFLAGS, NULL,
(struct ucred *)NULL);
goto setflag;
}
}
return 0;
}
- m->m_next = (struct mbuf *) 0;
+ m->m_next = NULL;
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = 0; /* don't know this yet */
m->m_len = MHLEN;
continue;
}
/* next mbuf short -> coallesce as needed */
- if ( (tm_p->m_next == (struct mbuf *) 0) ||
+ if ( (tm_p->m_next == NULL) ||
#define HDW_THRESHOLD 55
tm_p->m_len > HDW_THRESHOLD)
/* ok */;
ra->ipopt_list[3] = 0x00;
router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1];
- Head = (struct router_info *) 0;
+ Head = NULL;
}
static struct router_info *
* If we failed to find an existing at_ifaddr entry, then we
* allocate a fresh one.
*/
- if ( aa == (struct at_ifaddr *) 0 ) {
+ if ( aa == NULL ) {
aa0 = ifa_create(sizeof(struct at_ifaddr), M_WAITOK);
callout_init(&aa0->aa_ch);
if (( aa = at_ifaddr ) != NULL ) {
}
}
- if ( aa == (struct at_ifaddr *) 0 )
+ if ( aa == NULL )
return( EADDRNOTAVAIL );
break;
}
{ SPANS_VCIR_IND, "SPANS_VCIR_IND" },
{ SPANS_QUERY_REQ, "SPANS_QUERY_REQ" },
{ SPANS_QUERY_RSP, "SPANS_QUERY_RSP" },
- { 0, (char *) 0 }
+ { 0, NULL }
};
/*
* Disallowed IE present
*/
ie = msg->msg_ie_vec[i];
- msg->msg_ie_vec[i] =
- (struct ie_generic *) 0;
+ msg->msg_ie_vec[i] = NULL;
MSG_IE_ADD(msg, ie, UNI_MSG_IE_ERR);
while (ie) {
ie->ie_err_cause =
/*
* Pass the acceptance to the VC state machine
*/
- *errp = unisig_vc_state(usp, uvp, UNI_VC_ACCEPT_CALL,
- (struct unisig_msg *) 0);
+ *errp = unisig_vc_state(usp, uvp, UNI_VC_ACCEPT_CALL, NULL);
if (*errp)
goto failed;
/*
* Call the VC state machine
*/
- *errp = unisig_vc_state(usp, uvp, UNI_VC_REJECT_CALL,
- (struct unisig_msg *) 0);
+ *errp = unisig_vc_state(usp, uvp, UNI_VC_REJECT_CALL, NULL);
if (*errp)
goto failed;
/*
* Convert message to network order
*/
- err = usf_init(&usf, usp, (KBuffer *) 0, USF_ENCODE,
+ err = usf_init(&usf, usp, NULL, USF_ENCODE,
usp->us_headout);
if (err)
return(err);
/*
* Send STATUS message indicating the error
*/
- err = unisig_send_status(usp, (struct unisig_vccb *) 0,
+ err = unisig_send_status(usp, NULL,
msg, UNI_IE_CAUS_CREF);
goto done;
}
*/
unisig_sigmgr_state(usp,
UNISIG_SIGMGR_TIMEOUT,
- (KBuffer *) 0);
+ NULL);
}
* If we're aborting, this is an ABORT call
*/
unisig_vc_state(usp, uvp, UNI_VC_ABORT_CALL,
- (struct unisig_msg *) 0);
+ NULL);
} else {
/*
* If we're not aborting, it's a timeout
*/
unisig_vc_state(usp, uvp, UNI_VC_TIMEOUT,
- (struct unisig_msg *) 0);
+ NULL);
}
}
case SSCF_UNI_ESTABLISH_IND:
unisig_sigmgr_state(usp,
UNISIG_SIGMGR_SSCF_EST_IND,
- (KBuffer *) 0);
+ NULL);
break;
case SSCF_UNI_ESTABLISH_CNF:
unisig_sigmgr_state(usp,
UNISIG_SIGMGR_SSCF_EST_CNF,
- (KBuffer *) 0);
+ NULL);
break;
case SSCF_UNI_RELEASE_IND:
unisig_sigmgr_state(usp,
UNISIG_SIGMGR_SSCF_RLS_IND,
- (KBuffer *) 0);
+ NULL);
break;
case SSCF_UNI_RELEASE_CNF:
unisig_sigmgr_state(usp,
UNISIG_SIGMGR_SSCF_RLS_CNF,
- (KBuffer *) 0);
+ NULL);
break;
default:
*/
unisig_sigmgr_state(usp,
UNISIG_SIGMGR_CALL_CLEARED,
- (KBuffer *) 0);
+ NULL);
}
uvp; uvp = vnext) {
vnext = Q_NEXT(uvp, struct unisig_vccb, uv_sigelem);
unisig_vc_state(usp, uvp, UNI_VC_SAAL_ESTAB,
- (struct unisig_msg *) 0);
+ NULL);
}
return(0);
uvp; uvp = vnext) {
vnext = Q_NEXT(uvp, struct unisig_vccb, uv_sigelem);
unisig_vc_state(usp, uvp, UNI_VC_SAAL_ESTAB,
- (struct unisig_msg *) 0);
+ NULL);
}
return(0);
uvp; uvp = vnext) {
vnext = Q_NEXT(uvp, struct unisig_vccb, uv_sigelem);
unisig_vc_state(usp, uvp, UNI_VC_SAAL_FAIL,
- (struct unisig_msg *) 0);
+ NULL);
}
/*
* Try to restart the SSCF session
*/
- unisig_sigmgr_act04(usp, (KBuffer *) 0);
+ unisig_sigmgr_act04(usp, NULL);
/*
* Go to INIT state
* Call the VC state machine if this is an SVC
*/
if (!pvc) {
- err = unisig_vc_state(usp, uvp, UNI_VC_SETUP_CALL,
- (struct unisig_msg *) 0);
+ err = unisig_vc_state(usp, uvp, UNI_VC_SETUP_CALL, NULL);
if (err) {
/*
* On error, delete the VCCB
* Call the VC state machine
*/
uvp->uv_ustate = VCCU_CLOSED;
- err = unisig_vc_state(usp, uvp, UNI_VC_RELEASE_CALL,
- (struct unisig_msg *) 0);
+ err = unisig_vc_state(usp, uvp, UNI_VC_RELEASE_CALL, NULL);
}
/*
if (nsp) {
cb = nstosppcb(nsp);
cb->s_flags |= SF_RVD;
- spp_output(cb, (struct mbuf *) 0);
+ spp_output(cb, NULL);
cb->s_flags &= ~SF_RVD;
error = 0;
} else {
cb->s_flags &= ~SF_DELACK;
cb->s_flags |= SF_ACKNOW;
sppstat.spps_delack++;
- spp_output(cb, (struct mbuf *) 0);
+ spp_output(cb, NULL);
}
}
}
win = 2;
cb->s_cwnd = CUNIT;
cb->s_ssthresh = win * CUNIT;
- spp_output(cb, (struct mbuf *) 0);
+ spp_output(cb, NULL);
break;
/*
case SPPT_PERSIST:
sppstat.spps_persisttimeo++;
spp_setpersist(cb);
- spp_output(cb, (struct mbuf *) 0);
+ spp_output(cb, NULL);
break;
/*
if (cb->s_idle >= SPPTV_MAXIDLE)
goto dropit;
sppstat.spps_keepprobe++;
- spp_output(cb, (struct mbuf *) 0);
+ spp_output(cb, NULL);
} else
cb->s_idle = 0;
cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
static void
null_final(u_int8_t *buf, void *ctx)
{
- if (buf != (u_int8_t *) 0)
+ if (buf != NULL)
bzero(buf, 12);
}
* Discard reference to underlying file. Must call closef because
* this may be the last reference.
*/
- closef(VFSTOPORTAL(mp)->pm_server, (struct thread *) 0);
+ closef(VFSTOPORTAL(mp)->pm_server, NULL);
/*
* Finally, throw away the portalmount structure
*/
auio.uio_offset = 0;
auio.uio_resid = aiov[0].iov_len + aiov[1].iov_len;
- error = sosend(so, (struct sockaddr *) 0, &auio,
- (struct mbuf *) 0, (struct mbuf *) 0, 0, td);
+ error = sosend(so, NULL, &auio, NULL, NULL, 0, td);
if (error)
goto bad;
{
int ret = -1;
- *e = (char *) 0;
+ *e = NULL;
ret = strtol(s, e, 0);
if (*e)
switch (**e) {
{
int ret = -1;
- *e = (char *) 0;
+ *e = NULL;
ret = strtol(s, e, 0);
if (*e)
switch (**e) {
int Verbose = 0;
int quiet = 0;
int exit_code = 0;
-FILE* report_fp = (FILE *) 0;
-char *report_file = (char *) 0;
-char *chat_file = (char *) 0;
-char *phone_num = (char *) 0;
-char *phone_num2 = (char *) 0;
+FILE* report_fp = NULL;
+char *report_file = NULL;
+char *chat_file = NULL;
+char *phone_num = NULL;
+char *phone_num2 = NULL;
int timeout = DEFAULT_CHAT_TIMEOUT;
static char blank[] = "";
void terminate(int status)
{
echo_stderr(-1);
- if (report_file != (char *) 0 && report_fp != (FILE *) NULL) {
+ if (report_file != NULL && report_fp != (FILE *) NULL) {
/*
* Allow the last of the report string to be gathered before we terminate.
*/
if (*str)
result = str;
else
- result = (char *) 0;
+ result = NULL;
while (*str) {
if (escape_flag) {
/*
* If this is not in the termination string, continue.
*/
- if (strchr (term, *str) == (char *) 0) {
+ if (strchr (term, *str) == NULL) {
++str;
continue;
}
*/
for (;;) {
expect = expect_strtok (s, "-");
- s = (char *) 0;
+ s = NULL;
- if (expect == (char *) 0)
+ if (expect == NULL)
return;
reply = expect_strtok (s, "-");
* If there is a sub-reply string then send it. Otherwise any condition
* is terminal.
*/
- if (reply == (char *) 0 || exit_code != 3)
+ if (reply == NULL || exit_code != 3)
break;
chat_send (reply);
}
do
{
- return_val = wait((int *) 0);
+ return_val = wait(NULL);
}
while ((return_val != parent) && (return_val != -1));
/*
new = palloc(option);
/* compare against what */
if (option->flags & F_TIME2_T) {
- new->t_data = get_date(fn_or_tspec, (struct timeb *) 0);
+ new->t_data = get_date(fn_or_tspec, NULL);
if (new->t_data == (time_t) -1)
errx(1, "Can't parse date/time: %s", fn_or_tspec);
} else {
* Sort the symbol table in reverse topological order
*/
topsortnlp = (nltype **) calloc( nname , sizeof(nltype *) );
- if ( topsortnlp == (nltype **) 0 ) {
+ if ( topsortnlp == NULL ) {
fprintf( stderr , "[doarcs] ran out of memory for topo sorting\n" );
}
for ( index = 0 ; index < nname ; index += 1 ) {
* and cycle headers.
*/
timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
- if ( timesortnlp == (nltype **) 0 ) {
+ if ( timesortnlp == NULL ) {
warnx("ran out of memory for sorting");
}
for ( index = 0 ; index < nname ; index++ ) {
* Sort the symbol table in by time
*/
sortednlp = (nltype **) calloc( nname , sizeof(nltype *) );
- if ( sortednlp == (nltype **) 0 ) {
+ if ( sortednlp == NULL ) {
fprintf( stderr , "[printprof] ran out of memory for time sorting\n" );
}
for ( index = 0 ; index < nname ; index += 1 ) {
* to create an index.
*/
namesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
- if ( namesortnlp == (nltype **) 0 ) {
+ if ( namesortnlp == NULL ) {
warnx("ran out of memory for sorting");
}
for ( index = 0 , nnames = 0 ; index < nname ; index++ ) {
struct stringlist *slp;
slp = (struct stringlist *) malloc( sizeof(struct stringlist));
- if ( slp == (struct stringlist *) 0 ) {
+ if ( slp == NULL ) {
warnx("ran out room for printlist");
done();
}
(int) 0 , /* internal number of cycle on */
(int) 0 , /* number of live parent arcs */
(struct nl *) &indirectchild , /* pointer to head of cycle */
- (struct nl *) 0 , /* pointer to next member of cycle */
- (arctype *) 0 , /* list of caller arcs */
- (arctype *) 0 /* list of callee arcs */
+ NULL , /* pointer to next member of cycle */
+ NULL , /* list of caller arcs */
+ NULL /* list of callee arcs */
};
findcall(nltype *parentp, unsigned long p_lowpc, unsigned long p_highpc)
if ( nacc == 0 )
{
if ( reject )
- dfaacc[newds].dfaacc_set = (int *) 0;
+ dfaacc[newds].dfaacc_set = NULL;
else
dfaacc[newds].dfaacc_state = 0;
int yyleng;
/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
+static char *yy_c_buf_p = NULL;
static int yy_init = 1; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
int yyleng;
/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
+static char *yy_c_buf_p = NULL;
static int yy_init = 1; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
extern char *yytext;
#define yytext_ptr yytext
#line 110 "scan.l"
{
++linenum;
- line_directive_out( (FILE *) 0, 1 );
+ line_directive_out( NULL, 1 );
indented_code = false;
BEGIN(CODEBLOCK);
}
sectnum = 2;
bracelevel = 0;
mark_defs1();
- line_directive_out( (FILE *) 0, 1 );
+ line_directive_out( NULL, 1 );
BEGIN(SECT2PROLOG);
return SECTEND;
}
{
static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
static char yy_nostdinit[] =
- "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;";
+ "FILE *yyin = NULL, *yyout = NULL;";
- line_directive_out( (FILE *) 0, 1 );
+ line_directive_out( NULL, 1 );
if ( yyparse() )
{
dss = allocate_int_ptr_array( current_max_dfas );
dfaacc = allocate_dfaacc_union( current_max_dfas );
- nultrans = (int *) 0;
+ nultrans = NULL;
}
if ( ! continued_action )
add_action( "YY_RULE_SETUP\n" );
- line_directive_out( (FILE *) 0, 1 );
+ line_directive_out( NULL, 1 );
}
}
}
- line_directive_out( (FILE *) 0, 1 );
+ line_directive_out( NULL, 1 );
/* This isn't a normal rule after all - don't count it as
* such, so we don't have any holes in the rule numbering
^"%x"{NAME}? return XSCDECL;
^"%{".*{NL} {
++linenum;
- line_directive_out( (FILE *) 0, 1 );
+ line_directive_out( NULL, 1 );
indented_code = false;
BEGIN(CODEBLOCK);
}
sectnum = 2;
bracelevel = 0;
mark_defs1();
- line_directive_out( (FILE *) 0, 1 );
+ line_directive_out( NULL, 1 );
BEGIN(SECT2PROLOG);
return SECTEND;
}
Char *copy_unsigned_string();
(void) addsym( (char *) copy_unsigned_string( ccltxt ),
- (char *) 0, cclnum,
+ NULL, cclnum,
ccltab, CCL_HASH_SIZE );
}
{
static struct hash_entry empty_entry =
{
- (struct hash_entry *) 0, (struct hash_entry *) 0,
- (char *) 0, (char *) 0, 0,
+ NULL, NULL,
+ NULL, NULL, 0,
} ;
struct hash_entry *sym_entry =
table[hashfunct( sym, table_size )];
scname[lastsc] = copy_string( str );
- if ( addsym( scname[lastsc], (char *) 0, lastsc,
+ if ( addsym( scname[lastsc], NULL, lastsc,
sctbl, START_COND_HASH_SIZE ) )
format_pinpoint_message(
_( "start condition %s declared twice" ),
if ((cp = devname = strtok(buf, WSPACE)) == 0)
continue; /* empty or comment */
if (strncmp(devname, _PATH_DEV, sizeof _PATH_DEV - 1) != 0
- || (cp = strtok((char *) 0, WSPACE)) == 0
+ || (cp = strtok(NULL, WSPACE)) == 0
|| *cp != '0'
|| sscanf(cp, "%o", &prot) == 0
|| prot == 0
|| (prot & 0777) != prot
- || (cp = strtok((char *) 0, WSPACE)) == 0) {
+ || (cp = strtok(NULL, WSPACE)) == 0) {
syslog(LOG_ERR, "%s: bad entry: %s", table, cp ? cp : "(null)");
continue;
}
if (strcmp(devname + 5, tty) == 0) {
- for (cp = strtok(cp, ":"); cp; cp = strtok((char *) 0, ":")) {
+ for (cp = strtok(cp, ":"); cp; cp = strtok(NULL, ":")) {
login_protect(table, cp, prot, uid, gid);
}
}
longest = 0;
nmatches = 0;
- found = (struct cmdtab *) 0;
+ found = NULL;
for (ct = cmdtab; (p = ct->c_name); ct++) {
for (q = name; *q == *p++; q++)
if (*q == 0) /* exact match? */
TerminalFlushOutput(void)
{
#ifdef TIOCFLUSH
- (void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0);
+ (void) ioctl(fileno(stdout), TIOCFLUSH, NULL);
#else
- (void) ioctl(fileno(stdout), TCFLSH, (char *) 0);
+ (void) ioctl(fileno(stdout), TCFLSH, NULL);
#endif
}
if (TTYBYTES() == 0) {
FD_SET(tout, &o);
- (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0); /* wait for TTLOWAT */
+ (void) select(tout+1, NULL, &o, NULL, NULL); /* wait for TTLOWAT */
} else {
while (TTYBYTES()) {
(void) ttyflush(0);
FD_SET(tout, &o);
- (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0); /* wait for TTLOWAT */
+ (void) select(tout+1, NULL, &o, NULL, NULL); /* wait for TTLOWAT */
}
}
}
wwputc('\n', cmdwin);
wwcurtowin(cmdwin);
(void) openwin(id, row, col, xrow-row+1, xcol-col+1, default_nline,
- (char *) 0, 1, 1, default_shellfile, default_shell);
+ NULL, 1, 1, default_shellfile, default_shell);
}
getpos(row, col, minrow, mincol, maxrow, maxcol)
register r = wwnrow / 2 - 1;
if (openwin(1, r + 2, 0, wwnrow - r - 2, wwncol, default_nline,
- (char *) 0, 1, 1, default_shellfile, default_shell) == 0)
+ NULL, 1, 1, default_shellfile, default_shell) == 0)
return;
if ((w = openwin(0, 1, 0, r, wwncol, default_nline,
- (char *) 0, 1, 1, default_shellfile, default_shell)) == 0)
+ NULL, 1, 1, default_shellfile, default_shell)) == 0)
return;
wwprintf(w, "Escape character is %s.\r\n", unctrl(escapec));
}
struct sockaddr_storage ss;
socklen_t size;
- now = time((time_t *) 0);
+ now = time(NULL);
size = sizeof(ss);
if (recvfrom(s, buffer, sizeof(buffer), 0,
char buffer[256];
time_t now;
- now = time((time_t *) 0);
+ now = time(NULL);
sprintf(buffer, "%.24s\r\n", ctime(&now));
send(s, buffer, strlen(buffer), MSG_EOF);
void
callout_init(void)
{
- Q = (struct timeout_q *) 0;
+ Q = NULL;
}
void
p++;
do {
char c = *p++;
- char *arg = (char *) 0;
+ char *arg = NULL;
if (isdigit(*p)) {
arg = p;
p = "";
rend = rstart = strtol(reg, &end, 0);
if (end && *end == ':') {
end++;
- rend = strtol(end, (char **) 0, 0);
+ rend = strtol(end, NULL, 0);
}
sel = getsel(name);
for (i = 1, r = rstart; r <= rend; i++, r += width) {
len = MIN(userlen, sizeof(user) - 1);
BCOPY(auser, user, len);
user[len] = '\0';
- *msg = (char *) 0;
+ *msg = NULL;
/*
* Open the file of pap secrets and scan for a suitable secret
}
if (ret == UPAP_AUTHNAK) {
- if (*msg == (char *) 0)
+ if (*msg == NULL)
*msg = "Login incorrect";
*msglen = strlen(*msg);
/*
} else {
attempts = 0; /* Reset count */
- if (*msg == (char *) 0)
+ if (*msg == NULL)
*msg = "Login ok";
*msglen = strlen(*msg);
set_allowed_addrs(unit, addrs);
if (ptr_mask != NULL) {
int bit_count;
- bit_count = (int) strtol (ptr_mask+1, (char **) 0, 10);
+ bit_count = (int) strtol (ptr_mask+1, NULL, 10);
if (bit_count <= 0 || bit_count > 32) {
syslog (LOG_WARNING,
"invalid address length %s in auth. address list",
nconf->nc_device, errno);
return (-1);
}
- xprt = svc_tli_create(fd, 0, (struct t_bind *) 0, 0, 0);
+ xprt = svc_tli_create(fd, 0, NULL, 0, 0);
if (xprt == NULL) {
if (debugging)
fprintf(stderr,