]> code.delx.au - gnu-emacs/blobdiff - src/w32proc.c
Merge from emacs-23
[gnu-emacs] / src / w32proc.c
index 5ac0a1b57eca2bb1328315334b8ce8264fa28b2e..d209a216ed98d999438a91bc07f6a0ca9bef864c 100644 (file)
@@ -32,10 +32,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <setjmp.h>
 
 /* must include CRT headers *before* config.h */
-
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #undef signal
 #undef wait
@@ -117,7 +114,8 @@ extern Lisp_Object Qlocal;
 Lisp_Object Qhigh, Qlow;
 
 #ifdef EMACSDEBUG
-void _DebPrint (const char *fmt, ...)
+void
+_DebPrint (const char *fmt, ...)
 {
   char buf[1024];
   va_list args;
@@ -129,7 +127,7 @@ void _DebPrint (const char *fmt, ...)
 }
 #endif
 
-typedef void (_CALLBACK_ *signal_handler)(int);
+typedef void (_CALLBACK_ *signal_handler) (int);
 
 /* Signal handlers...SIG_DFL == 0 so this is initialized correctly.  */
 static signal_handler sig_handlers[NSIG];
@@ -158,7 +156,7 @@ int child_proc_count = 0;
 child_process child_procs[ MAX_CHILDREN ];
 child_process *dead_child = NULL;
 
-DWORD WINAPI reader_thread (void *arg);
+static DWORD WINAPI reader_thread (void *arg);
 
 /* Find an unused process slot.  */
 child_process *
@@ -278,7 +276,7 @@ find_child_pid (DWORD pid)
    is normally blocked until woken by select() to check for input by
    reading one char.  When the read completes, char_avail is signaled
    to wake up the select emulator and the thread blocks itself again. */
-DWORD WINAPI
+static DWORD WINAPI
 reader_thread (void *arg)
 {
   child_process *cp;
@@ -607,8 +605,11 @@ get_result:
 # define IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
 #endif
 
-void
-w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int * is_gui_app)
+static void
+w32_executable_type (char * filename,
+                    int * is_dos_app,
+                    int * is_cygnus_app,
+                    int * is_gui_app)
 {
   file_data executable;
   char * p;
@@ -722,7 +723,7 @@ unwind:
   close_file_data (&executable);
 }
 
-int
+static int
 compare_env (const void *strp1, const void *strp2)
 {
   const char *str1 = *(const char **)strp1, *str2 = *(const char **)strp2;
@@ -746,7 +747,7 @@ compare_env (const void *strp1, const void *strp2)
     return 1;
 }
 
-void
+static void
 merge_and_sort_env (char **envp1, char **envp2, char **new_envp)
 {
   char **optr, **nptr;
@@ -1690,8 +1691,6 @@ set_process_dir (char * dir)
   process_dir = dir;
 }
 
-#ifdef HAVE_SOCKETS
-
 /* To avoid problems with winsock implementations that work over dial-up
    connections causing or requiring a connection to exist while Emacs is
    running, Emacs no longer automatically loads winsock on startup if it
@@ -1719,8 +1718,7 @@ also loaded immediately if not already loaded.  If winsock is loaded,
 the winsock local hostname is returned (since this may be different from
 the value of `system-name' and should supplant it), otherwise t is
 returned to indicate winsock support is present.  */)
-     (load_now)
-     Lisp_Object load_now;
+  (Lisp_Object load_now)
 {
   int have_winsock;
 
@@ -1751,29 +1749,20 @@ DEFUN ("w32-unload-winsock", Fw32_unload_winsock, Sw32_unload_winsock,
 This is provided to allow dial-up socket connections to be disconnected
 when no longer needed.  Returns nil without unloading winsock if any
 socket connections still exist.  */)
-  ()
+  (void)
 {
   return term_winsock () ? Qt : Qnil;
 }
 
-#endif /* HAVE_SOCKETS */
-
 \f
 /* Some miscellaneous functions that are Windows specific, but not GUI
    specific (ie. are applicable in terminal or batch mode as well).  */
 
-/* lifted from fileio.c  */
-#define CORRECT_DIR_SEPS(s) \
-  do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
-       else unixtodos_filename (s); \
-  } while (0)
-
 DEFUN ("w32-short-file-name", Fw32_short_file_name, Sw32_short_file_name, 1, 1, 0,
        doc: /* Return the short file name version (8.3) of the full path of FILENAME.
 If FILENAME does not exist, return nil.
 All path elements in FILENAME are converted to their short names.  */)
-     (filename)
-     Lisp_Object filename;
+  (Lisp_Object filename)
 {
   char shortname[MAX_PATH];
 
@@ -1786,7 +1775,7 @@ All path elements in FILENAME are converted to their short names.  */)
   if (GetShortPathName (SDATA (ENCODE_FILE (filename)), shortname, MAX_PATH) == 0)
     return Qnil;
 
-  CORRECT_DIR_SEPS (shortname);
+  dostounix_filename (shortname);
 
   return build_string (shortname);
 }
@@ -1797,8 +1786,7 @@ DEFUN ("w32-long-file-name", Fw32_long_file_name, Sw32_long_file_name,
        doc: /* Return the long file name version of the full path of FILENAME.
 If FILENAME does not exist, return nil.
 All path elements in FILENAME are converted to their long names.  */)
-     (filename)
-     Lisp_Object filename;
+  (Lisp_Object filename)
 {
   char longname[ MAX_PATH ];
   int drive_only = 0;
@@ -1815,7 +1803,7 @@ All path elements in FILENAME are converted to their long names.  */)
   if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)), longname, MAX_PATH))
     return Qnil;
 
-  CORRECT_DIR_SEPS (longname);
+  dostounix_filename (longname);
 
   /* If we were passed only a drive, make sure that a slash is not appended
      for consistency with directories.  Allow for drive mapping via SUBST
@@ -1835,8 +1823,7 @@ PRIORITY should be one of the symbols high, normal, or low;
 any other symbol will be interpreted as normal.
 
 If successful, the return value is t, otherwise nil.  */)
-     (process, priority)
-     Lisp_Object process, priority;
+  (Lisp_Object process, Lisp_Object priority)
 {
   HANDLE proc_handle = GetCurrentProcess ();
   DWORD  priority_class = NORMAL_PRIORITY_CLASS;
@@ -1958,8 +1945,7 @@ is a number, it is interpreted as an LCTYPE constant and the corresponding
 locale information is returned.
 
 If LCID (a 16-bit number) is not a valid locale, the result is nil.  */)
-     (lcid, longform)
-     Lisp_Object lcid, longform;
+  (Lisp_Object lcid, Lisp_Object longform)
 {
   int got_abbrev;
   int got_full;
@@ -2005,12 +1991,12 @@ DEFUN ("w32-get-current-locale-id", Fw32_get_current_locale_id,
        doc: /* Return Windows locale id for current locale setting.
 This is a numerical value; use `w32-get-locale-info' to convert to a
 human-readable form.  */)
-     ()
+  (void)
 {
   return make_number (GetThreadLocale ());
 }
 
-DWORD
+static DWORD
 int_from_hex (char * s)
 {
   DWORD val = 0;
@@ -2032,7 +2018,7 @@ int_from_hex (char * s)
    function isn't given a context pointer.  */
 Lisp_Object Vw32_valid_locale_ids;
 
-BOOL CALLBACK
+static BOOL CALLBACK
 enum_locale_fn (LPTSTR localeNum)
 {
   DWORD id = int_from_hex (localeNum);
@@ -2045,7 +2031,7 @@ DEFUN ("w32-get-valid-locale-ids", Fw32_get_valid_locale_ids,
        doc: /* Return list of all valid Windows locale ids.
 Each id is a numerical value; use `w32-get-locale-info' to convert to a
 human-readable form.  */)
-     ()
+  (void)
 {
   Vw32_valid_locale_ids = Qnil;
 
@@ -2062,8 +2048,7 @@ By default, the system default locale setting is returned; if the optional
 parameter USERP is non-nil, the user default locale setting is returned.
 This is a numerical value; use `w32-get-locale-info' to convert to a
 human-readable form.  */)
-     (userp)
-     Lisp_Object userp;
+  (Lisp_Object userp)
 {
   if (NILP (userp))
     return make_number (GetSystemDefaultLCID ());
@@ -2074,8 +2059,7 @@ human-readable form.  */)
 DEFUN ("w32-set-current-locale", Fw32_set_current_locale, Sw32_set_current_locale, 1, 1, 0,
        doc: /* Make Windows locale LCID be the current locale setting for Emacs.
 If successful, the new locale id is returned, otherwise nil.  */)
-     (lcid)
-     Lisp_Object lcid;
+  (Lisp_Object lcid)
 {
   CHECK_NUMBER (lcid);
 
@@ -2098,7 +2082,7 @@ If successful, the new locale id is returned, otherwise nil.  */)
    function isn't given a context pointer.  */
 Lisp_Object Vw32_valid_codepages;
 
-BOOL CALLBACK
+static BOOL CALLBACK
 enum_codepage_fn (LPTSTR codepageNum)
 {
   DWORD id = atoi (codepageNum);
@@ -2109,7 +2093,7 @@ enum_codepage_fn (LPTSTR codepageNum)
 DEFUN ("w32-get-valid-codepages", Fw32_get_valid_codepages,
        Sw32_get_valid_codepages, 0, 0, 0,
        doc: /* Return list of all valid Windows codepages.  */)
-     ()
+  (void)
 {
   Vw32_valid_codepages = Qnil;
 
@@ -2123,7 +2107,7 @@ DEFUN ("w32-get-valid-codepages", Fw32_get_valid_codepages,
 DEFUN ("w32-get-console-codepage", Fw32_get_console_codepage,
        Sw32_get_console_codepage, 0, 0, 0,
        doc: /* Return current Windows codepage for console input.  */)
-     ()
+  (void)
 {
   return make_number (GetConsoleCP ());
 }
@@ -2134,8 +2118,7 @@ DEFUN ("w32-set-console-codepage", Fw32_set_console_codepage,
        doc: /* Make Windows codepage CP be the current codepage setting for Emacs.
 The codepage setting affects keyboard input and display in tty mode.
 If successful, the new CP is returned, otherwise nil.  */)
-     (cp)
-     Lisp_Object cp;
+  (Lisp_Object cp)
 {
   CHECK_NUMBER (cp);
 
@@ -2152,7 +2135,7 @@ If successful, the new CP is returned, otherwise nil.  */)
 DEFUN ("w32-get-console-output-codepage", Fw32_get_console_output_codepage,
        Sw32_get_console_output_codepage, 0, 0, 0,
        doc: /* Return current Windows codepage for console output.  */)
-     ()
+  (void)
 {
   return make_number (GetConsoleOutputCP ());
 }
@@ -2163,8 +2146,7 @@ DEFUN ("w32-set-console-output-codepage", Fw32_set_console_output_codepage,
        doc: /* Make Windows codepage CP be the current codepage setting for Emacs.
 The codepage setting affects keyboard input and display in tty mode.
 If successful, the new CP is returned, otherwise nil.  */)
-     (cp)
-     Lisp_Object cp;
+  (Lisp_Object cp)
 {
   CHECK_NUMBER (cp);
 
@@ -2182,8 +2164,7 @@ DEFUN ("w32-get-codepage-charset", Fw32_get_codepage_charset,
        Sw32_get_codepage_charset, 1, 1, 0,
        doc: /* Return charset of codepage CP.
 Returns nil if the codepage is not valid.  */)
-     (cp)
-     Lisp_Object cp;
+  (Lisp_Object cp)
 {
   CHARSETINFO info;
 
@@ -2203,7 +2184,7 @@ DEFUN ("w32-get-valid-keyboard-layouts", Fw32_get_valid_keyboard_layouts,
        Sw32_get_valid_keyboard_layouts, 0, 0, 0,
        doc: /* Return list of Windows keyboard languages and layouts.
 The return value is a list of pairs of language id and layout id.  */)
-     ()
+  (void)
 {
   int num_layouts = GetKeyboardLayoutList (0, NULL);
   HKL * layouts = (HKL *) alloca (num_layouts * sizeof (HKL));
@@ -2229,7 +2210,7 @@ DEFUN ("w32-get-keyboard-layout", Fw32_get_keyboard_layout,
        Sw32_get_keyboard_layout, 0, 0, 0,
        doc: /* Return current Windows keyboard language and layout.
 The return value is the cons of the language id and the layout id.  */)
-     ()
+  (void)
 {
   DWORD kl = (DWORD) GetKeyboardLayout (dwWindowsThreadId);
 
@@ -2243,8 +2224,7 @@ DEFUN ("w32-set-keyboard-layout", Fw32_set_keyboard_layout,
        doc: /* Make LAYOUT be the current keyboard layout for Emacs.
 The keyboard layout setting affects interpretation of keyboard input.
 If successful, the new layout id is returned, otherwise nil.  */)
-     (layout)
-     Lisp_Object layout;
+  (Lisp_Object layout)
 {
   DWORD kl;
 
@@ -2276,15 +2256,14 @@ If successful, the new layout id is returned, otherwise nil.  */)
 
 \f
 void
-syms_of_ntproc ()
+syms_of_ntproc (void)
 {
   DEFSYM (Qhigh, "high");
   DEFSYM (Qlow, "low");
 
-#ifdef HAVE_SOCKETS
   defsubr (&Sw32_has_winsock);
   defsubr (&Sw32_unload_winsock);
-#endif
+
   defsubr (&Sw32_short_file_name);
   defsubr (&Sw32_long_file_name);
   defsubr (&Sw32_set_process_priority);
@@ -2388,7 +2367,5 @@ where the performance impact may be noticeable even on modern hardware.  */);
   staticpro (&Vw32_valid_locale_ids);
   staticpro (&Vw32_valid_codepages);
 }
-/* end of ntproc.c */
+/* end of w32proc.c */
 
-/* arch-tag: 23d3a34c-06d2-48a1-833b-ac7609aa5250
-   (do not change this comment) */