Commit graph

39 commits

Author SHA1 Message Date
aef5b18c1e (doexecute): Fix to set input_fd on failure, so that play() terminates
the execute correctly.  Closes #723756.
2007-11-17 18:57:06 +00:00
0e506556c2 (doredir): Open the file with mode 0666 instead of 0600, for
consistency with redirections in pipes.  Users should use umask to
restrict permissions.
2007-11-17 14:36:03 +00:00
8b7d0b915d Rewrite much of client's playing phase code:
(EOF_COOKIE, INTR_COOKIE, input_fd, send_intr, recv_output)
(recv_input, intr, play): New playing phase code.  No native Windows
support yet.  Sends just one EOF cookie on EOF on standard input
instead of up to three.  Old servers (before recvclient.c rev. 1.16)
fail to terminate the session when they receive an EOF cookie at an
argument prompt.  The session then hangs; use SIGINT to get out.  No
longer blocks on sending input, which could deadlock the session.
Closes #827090.  Fixes error handling for select().  Fixes race
condition that could cause server output to be discarded on EOF on
standard input.
(main): Replace old playing phase code by a call to play().
(intr, sock, interrupt, handleintr): Replaced by play(), remove.
[_WIN32] (hStdIn): Ditto.
(auxfp): New.
(servercmd, prompt, doexecute): Remove parameter auxfi, use auxfp.
(eight_bit_clean): Move to servcmd.c.
(servercmd): Work on a single non-C_DATA line instead of getting lines
from an ioqueue.
(servercmd, output, screen, outch): Deal with all ids in servercmd()
rather than some there and some in output().  Don't treat C_NOECHO,
C_ABORT, C_CMDERR, C_BADCMD specially.  Fix C_FLASH and C_EXIT to
ignore redirections; they used to ignore them only for some parts.
Replace output() by outch(), fold screen into outch().
(servercmd): Truncate long prompts and telegram infos to prevent
buffer overflow.
(prompt): Use new parameters code, prompt, teles instead of global
variables mode, the_prompt, num_teles.
(num_teles, the_prompt, mode, nbtu, nmin): Remove.
(prompt): Don't write an empty line before argument prompts to auxfp.
(servercmd): Don't strip newline from redirections and execute,
doredir(), dopipe() and doexecute() need it now.
(doredir, dopipe, doexecute): Use new seen_input() instead of gettag().
(doexecute): Set input_fd and leave reading the script file to play().
(serverio, termio, sendeof): Replaced by play(), remove.
(LBUF_LEN_MAX, lbuf, lbuf_init, lbuf_len, lbuf_full, lbuf_line)
(lbuf_putc): New.
(RING_SIZE, ring, ring_init, ring_len, ring_space, ring_peek)
(ring_getc, ring_putc, ring_putm, ring_discard, ring_search)
(ring_from_file, ring_to_file): New.
(clear_recent_input, save_input, seen_input): New.
(MAX): New.
(ioqueue, io, ioq_init, ioq_dequeue, ioq_read, ioq_write, ioq_qsize)
(ioq_drain, ioq_gets, ioqtobuf, enqueuecc, dequeuecc): Unused, remove.
(QEMPTY, qelem, insque, remque, initque): Unused, remove.
(tagstruct, taglist, io_init, gettag): Unused, remove.
2007-11-17 14:17:38 +00:00
43d66c7d87 (doexecute): Use fname(). Simplify convoluted logic. Fix check for
empty argument.  Improve error messages.
2007-11-17 09:41:16 +00:00
2456a71acf (dopipe): Check whether argument starts with '|'. Simplify convoluted
logic.  Improve error messages.
2007-11-17 09:10:29 +00:00
17d6997d4e (fname): New.
(doredir): Use it.  Check whether argument starts with '>'.  Simplify
convoluted logic.  Improve error messages.  Check value of fdopen().
2007-11-17 09:08:57 +00:00
09e7abbd0d (output): Remove unused parameter eol. Caller changed. 2007-08-24 17:05:18 +00:00
198b7760d8 (exec_fd): Useless junk inherited all the way from BSD Empire 1.1.
Remove.
2007-08-18 09:24:05 +00:00
63bdc89835 Update copyright notice. 2007-01-09 19:09:31 +00:00
e42053d928 Break inclusion cycle: prototypes.h and commands.h included each
other.  Ensure headers in include/ can be included in any order
(except for econfig-spec.h, which is special).  New header types.h to
help avoid inclusion cycles.  Sort include directives.  Remove some
superflous includes.
2006-07-10 06:37:23 +00:00
4c4fdca42b Line breaks and other formatting issues. No functional changes. 2006-05-21 13:05:24 +00:00
2ae6be9af6 (num_teles, redir_fp, pipe_fp, exec_fd, sendeof, prompt, command)
(ac_intercept, all_missiles, ac_planedamage, ac_doflak, ac_landflak)
(ac_shipflak, ac_fireflak, can_fly, do_evade, att_calcodds)
(emp_setbitmap, lnd_hit_mine, conditions, get_wp, daemonize): Internal
linkage.
2006-05-20 13:54:45 +00:00
f5a9284867 Update known contributors comment. 2006-02-24 21:35:27 +00:00
4515b84c59 COPYING duplicates information from README. Remove. Move GPL from
LICENSE to COPYING, because that's where it usually is.  Update all
the references to these files.
2006-01-21 19:48:41 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
3aebb68ee7 Include config.h. 2005-12-27 18:04:19 +00:00
Ron Koenderink
733f747a36 (output): Remove C_FLUSH from output() as C_FLUSH is dealt with
by servercmd() and output() is not called from servercmd() with a
code of C_FLUSH.
2005-11-13 12:23:17 +00:00
Ron Koenderink
b7be1fe113 (servercmd): Remove newline for C_INFORM, C_FLUSH,
C_REDIR, C_PIPE and C_EXECUTE.
Fixes the problem created when the newline was left in io_gets().
2005-11-12 20:16:07 +00:00
Ron Koenderink
0918d3c3fc (io_gets, output): Remove the removal of \n in io_gets() and the
readdition of it in output().
2005-11-12 16:40:38 +00:00
Ron Koenderink
89e2b3b481 (servercmd, io_gets, output): Fix client to read lines longer than
1024 bytes from the server.  Closes #1223255.
2005-11-12 14:20:46 +00:00
Ron Koenderink
6304f3b482 (doexecute) [_WIN32]: Open the exec file in text mode.
The exec file contains the user commands created by text editor.
2005-09-24 13:34:39 +00:00
Ron Koenderink
02693bb59b (prompt,dopipe) [_WIN32]: Enable the pipe capability. 2005-07-23 21:44:00 +00:00
fbf9f15bbb (getsose): Port from obsolete termcap to terminfo. The old code
manually stripped off padding, which is evil.  The new code does
nothing when the stdout is not connected to a terminal.
(SO, smso, SE, rmso): Rename, static linkage.
(putso, putse): New.
(screen): Use it.
2005-06-04 13:03:16 +00:00
Ron Koenderink
05a4eae605 (output,screen): In ASCII mode, remove standout bit if the client
does not support standout mode.
In UTF8 mode, remove SO/SI characters if the client does not support
standout mode.
2005-05-29 16:22:14 +00:00
e2fe05be18 Clean up the previous revision. No functional changes. 2005-05-28 08:25:28 +00:00
7ef7aa83b8 Client UTF-8 support.
(login): New parameter utf8.  If set, request option utf-8 from
server.
(expect, recvline): Split recvline() out of expect().  Replace or
remove some unhelpful diagnostics.
(eight_bit_clean): New.
(screen): If eight_bit_clean is set, highlighting is switched with
SO/SI.  Else characters with MSB set are highlighted.
(main): New option -u to request UTF-8 and set eight_bit_clean.
2005-05-27 17:00:25 +00:00
647783f652 (servercmd): Parsed BTUs into nmin and minutes into nbtu. Fix. No
functional change.
2005-05-07 08:47:32 +00:00
345ad3dfe0 Update copyright notice. 2005-03-16 22:03:16 +00:00
Marc Olzheim
6a99690e4e Get rid of "s_char", "register" and 0 used instead of NULL in the
client source.  No functional changes.
2005-03-15 21:47:41 +00:00
fac342ed49 Update copyright notice. 2004-09-07 15:07:16 +00:00
e7811102a3 Declare tags.c variables in tags.h. Declare stuff with external
linkage that is not in any other header in misc.h.  Remove some
redundant declarations elsewhere.
(prompt, doredir, dopipe, doexecute, output, screen, parsedelay):
Static linkage.
2004-02-20 08:22:28 +00:00
d59bc20516 Properly declare functions in headers; remove redundant declarations. 2004-02-19 12:39:17 +00:00
e9eb6b8e2a (_noecho, _echo): Broken, portability headache, remove.
(output): Ignore C_NOECHO.  Server doesn't send it anyway.
2004-02-19 12:00:11 +00:00
237baffca9 Supply prototypes where possible. This uncovered type errors with
thread entrypoints:
(lwpSelect, shutdown_sequence): Parameters didn't match thread entry
point prototype.
(lwpEntryPoint): Arguments didn't match thread entry point prototype.

Change linkage of functions without prototype declaration to static
where possible.

Remove some superflous declarations, replace others by suitable
includes.
2004-02-17 17:59:30 +00:00
7dbb87b0e0 Windows cleanup: include proper headers, remove unused variables, fix
type of signal handler.  Mostly from Ron Koenderink.
2004-02-16 17:44:38 +00:00
51c3215cf8 Fix previous rev. 2004-02-10 18:11:44 +00:00
4ce5f988d0 Portability fixes: don't declare library functions, include
appropriate headers.  Also remove some unused declarations.
2004-01-15 13:43:50 +00:00
9b7adfbecc Indented with src/scripts/indent-emp. 2003-09-02 20:48:48 +00:00
d8b7fdfae1 Import of Empire 4.2.12 2003-08-23 12:23:04 +00:00