/* System-dependent prototypes
   Copyright (C) 1985, 1993, 1994 Free Software Foundation, Inc.

This file is part of XEmacs.

XEmacs is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.

XEmacs is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with XEmacs; see the file COPYING.  If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* Synched up with: FSF 19.28.  Split out of sysdep.c/emacs.c. */

#ifndef _XEMACS_SYSDEP_H_
#define _XEMACS_SYSDEP_H_

#if !defined(VMS) || !defined(LINK_CRTL_SHARE) || !defined(SHAREABLE_LIB_BUG)
extern char **environ;
#else
extern noshare char **environ;
#endif /* VMS sharable environ bug */

struct emacs_tty;
extern int emacs_get_tty (int fd, struct emacs_tty *settings);
extern int emacs_set_tty (int fd, struct emacs_tty *settings, int waitp);

extern void stuff_char (struct device *d, int c);

extern void init_baud_rate (struct device *d);

extern void set_exclusive_use (int fd);

extern void set_descriptor_non_blocking (int fd);

extern void wait_without_blocking (void);

/* Wait for subprocess with process id `pid' to terminate and
   make sure it will get eliminated (not remain forever as a zombie) */
extern void wait_for_termination (int pid);

/* flush any pending output
 * (may flush input as well; it does not matter the way we use it)
 */
extern void flush_pending_output (int channel);

extern void child_setup_tty (int out);

extern void setpgrp_of_tty (int fid, int pid);

extern int interrupt_input;

/* Suspend the Emacs process; give terminal to its superior.  */
extern void sys_suspend (void);

extern void request_sigio (void);
extern void unrequest_sigio (void);

extern void stop_interrupts (void);
extern void start_interrupts (void);

extern void sys_init_device (struct device *d);
/* Prepare the terminal for exiting Emacs; move the cursor to the
   bottom of the frame, turn off interrupt-driven I/O, etc.  */
extern void sys_reset_device (struct device *d);

extern void reset_sys_modes (void);

/* Return nonzero if safe to use tabs in output.
   At the time this is called, init_sys_modes has not been done yet.  */
extern int tabs_safe_p (struct device *d);

/* Get terminal size from system.
   If zero or a negative number is stored, the value is not valid.  */
extern void get_tty_device_size (struct device *d, int *widthp, int *heightp);
/* Set the logical window size associated with descriptor FD */
extern int set_window_size (int fd, int height, int width);

/* Set up the proper status flags for use of a pty.  */
extern void setup_pty (int fd);

/* Return the address of the start of the text segment prior to unexec. */
extern char *start_of_text (void);
/* Return the address of the start of the data segment prior to unexec. */
extern void *start_of_data (void);
/* Return the address of the end of the text segment prior to unexec. */
extern char *end_of_text (void);
/* Return the address of the end of the data segment prior to unexec. */
extern char *end_of_data (void);


/* Get_system_name returns as its value a string for system-name to return. */
extern void init_system_name (void);


#ifndef HAVE_SELECT
extern int select_alarmed;
extern int select (int nfds, int *rfds, int *wfds, int *efds, int *timeout);
extern void read_input_waiting (void);
#endif /* HAVE_SELECT */

#ifndef HAVE_GETWD
extern char *getwd (char *pathname);
#endif

#ifndef HAVE_RENAME
extern int rename (CONST char *from, CONST char *to);
#endif

extern int setpriority (int which, int who, int prio);

#ifndef HAVE_VFORK
extern pid_t vfork (void);
#endif

#if defined(MISSING_UTIMES) || defined(IRIS_UTIME)
struct timeval;
extern int utimes (CONST char *file, CONST struct timeval *tvp);
#endif


#ifndef HAVE_DUP2
extern int dup2 (int oldd, int newd);
#endif

#ifdef VMS
extern void init_vms_input (void);
extern void stop_vms_input (void);

extern int vms_truncate (char *fn);
extern int vlimit (void);       /* BTW, name conflicts with unix syscall */
extern int define_logical_name (char *varname, char *string)
extern int delete_logical_name (char *varname);
extern int rename_sans_version (char *from, char *to);
extern char *vmserrstr (int status);
extern char *sys_translate_vms (char *vfile);
extern char *sys_translate_unix (char *ufile);
extern int creat_copy_attrs (char *old, char *new);
extern int link (char *file, char *new);
#endif /* VMS */

#ifdef BSD_PGRPS
extern int inherited_pgroup;
#endif /* BSD */

#ifndef HAVE_STRERROR
/* X11R6 defines strerror as a macro */
# ifdef strerror
# undef strerror
# endif
extern char *strerror (int);
#endif

#ifndef HAVE_H_ERRNO
extern int h_errno;
#endif

#endif /* _XEMACS_SYSDEP_H_ */
