comparison src/sysdep.c @ 4990:8f0cf4fd3d2c

Automatic merge
author Ben Wing <ben@xemacs.org>
date Sat, 06 Feb 2010 04:01:46 -0600
parents 3c3c1d139863
children d4f666cda5e6 861f2601a38b
comparison
equal deleted inserted replaced
4989:d2ec55325515 4990:8f0cf4fd3d2c
1 /* Interfaces to system-dependent kernel and library entries. 1 /* Interfaces to system-dependent kernel and library entries.
2 Copyright (C) 1985-1988, 1992-1995 Free Software Foundation, Inc. 2 Copyright (C) 1985-1988, 1992-1995 Free Software Foundation, Inc.
3 Copyright (C) 1995 Tinker Systems. 3 Copyright (C) 1995 Tinker Systems.
4 Copyright (C) 2000, 2001, 2002, 2003, 2004 Ben Wing. 4 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2010 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 XEmacs is free software; you can redistribute it and/or modify it 8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
2035 qxeGetComputerName (hostname, &size); 2035 qxeGetComputerName (hostname, &size);
2036 Vsystem_name = build_tstr_string (hostname); 2036 Vsystem_name = build_tstr_string (hostname);
2037 #elif !defined (HAVE_GETHOSTNAME) 2037 #elif !defined (HAVE_GETHOSTNAME)
2038 struct utsname uts; 2038 struct utsname uts;
2039 uname (&uts); 2039 uname (&uts);
2040 Vsystem_name = build_string (uts.nodename); 2040 Vsystem_name = build_extstring (uts.nodename, Qunix_host_name_encoding);
2041 #else /* HAVE_GETHOSTNAME */ 2041 #else /* HAVE_GETHOSTNAME */
2042 int hostname_size = 256; 2042 int hostname_size = 256;
2043 /* !!#### Needs review */ 2043 Extbyte *hostname = alloca_extbytes (hostname_size);
2044 char *hostname = (char *) ALLOCA (hostname_size);
2045 2044
2046 /* Try to get the host name; if the buffer is too short, try 2045 /* Try to get the host name; if the buffer is too short, try
2047 again. Apparently, the only indication gethostname gives of 2046 again. Apparently, the only indication gethostname gives of
2048 whether the buffer was large enough is the presence or absence 2047 whether the buffer was large enough is the presence or absence
2049 of a '\0' in the string. Eech. */ 2048 of a '\0' in the string. Eech. */
2055 /* Was the buffer large enough for the '\0'? */ 2054 /* Was the buffer large enough for the '\0'? */
2056 if ((int) strlen (hostname) < (hostname_size - 1)) 2055 if ((int) strlen (hostname) < (hostname_size - 1))
2057 break; 2056 break;
2058 2057
2059 hostname_size <<= 1; 2058 hostname_size <<= 1;
2060 /* !!#### Needs review */ 2059 hostname = alloca_extbytes (hostname_size);
2061 hostname = (char *) ALLOCA (hostname_size); 2060 }
2062 } 2061 # if defined (HAVE_SOCKETS)
2063 # if defined( HAVE_SOCKETS)
2064 /* Turn the hostname into the official, fully-qualified hostname. 2062 /* Turn the hostname into the official, fully-qualified hostname.
2065 Don't do this if we're going to dump; this can confuse system 2063 Don't do this if we're going to dump; this can confuse system
2066 libraries on some machines and make the dumped emacs core dump. */ 2064 libraries on some machines and make the dumped emacs core dump. */
2067 if (initialized) 2065 if (initialized)
2066 /* !!#### Could fail if we have a 7-bit external encoding */
2068 if (!strchr (hostname, '.')) 2067 if (!strchr (hostname, '.'))
2069 { 2068 {
2070 # if !(defined(HAVE_GETADDRINFO) && defined(HAVE_GETNAMEINFO)) 2069 # if !(defined (HAVE_GETADDRINFO) && defined (HAVE_GETNAMEINFO))
2071 struct hostent *hp = NULL; 2070 struct hostent *hp = NULL;
2072 int count; 2071 int count;
2073 # ifdef TRY_AGAIN 2072 # ifdef TRY_AGAIN
2074 for (count = 0; count < 10; count++) 2073 for (count = 0; count < 10; count++)
2075 { 2074 {
2085 Fsleep_for (make_int (1)); 2084 Fsleep_for (make_int (1));
2086 } 2085 }
2087 # endif 2086 # endif
2088 if (hp) 2087 if (hp)
2089 { 2088 {
2090 const char *fqdn = (const char *) hp->h_name; 2089 const Extbyte *fqdn = (const Extbyte *) hp->h_name;
2091 2090
2091 /* !!#### Could fail if we have a 7-bit external encoding */
2092 if (!strchr (fqdn, '.')) 2092 if (!strchr (fqdn, '.'))
2093 { 2093 {
2094 /* We still don't have a fully qualified domain name. 2094 /* We still don't have a fully qualified domain name.
2095 Try to find one in the list of alternate names */ 2095 Try to find one in the list of alternate names */
2096 char **alias = hp->h_aliases; 2096 Extbyte **alias = hp->h_aliases;
2097 while (*alias && !strchr (*alias, '.')) 2097 while (*alias && !strchr (*alias, '.'))
2098 alias++; 2098 alias++;
2099 if (*alias) 2099 if (*alias)
2100 fqdn = *alias; 2100 fqdn = *alias;
2101 } 2101 }
2102 /* !!#### Needs review */ 2102 hostname = alloca_extbytes (strlen (fqdn) + 1);
2103 hostname = (char *) ALLOCA (strlen (fqdn) + 1);
2104 strcpy (hostname, fqdn); 2103 strcpy (hostname, fqdn);
2105 } 2104 }
2106 # else /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */ 2105 # else /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */
2107 struct addrinfo hints, *res; 2106 struct addrinfo hints, *res;
2108 2107
2115 #endif 2114 #endif
2116 hints.ai_socktype = SOCK_STREAM; 2115 hints.ai_socktype = SOCK_STREAM;
2117 hints.ai_protocol = 0; 2116 hints.ai_protocol = 0;
2118 if (!getaddrinfo (hostname, NULL, &hints, &res)) 2117 if (!getaddrinfo (hostname, NULL, &hints, &res))
2119 { 2118 {
2120 /* !!#### Needs review */ 2119 hostname = alloca_extbytes (strlen (res->ai_canonname) + 1);
2121 hostname = (char *) ALLOCA (strlen (res->ai_canonname) + 1);
2122 strcpy (hostname, res->ai_canonname); 2120 strcpy (hostname, res->ai_canonname);
2123 2121
2124 freeaddrinfo (res); 2122 freeaddrinfo (res);
2125 } 2123 }
2126 # endif /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */ 2124 # endif /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */
2127 } 2125 }
2128 # endif /* HAVE_SOCKETS */ 2126 # endif /* HAVE_SOCKETS */
2129 Vsystem_name = build_string (hostname); 2127 Vsystem_name = build_extstring (hostname, Qunix_host_name_encoding);
2130 #endif /* HAVE_GETHOSTNAME */ 2128 #endif /* HAVE_GETHOSTNAME */
2131 { 2129 {
2132 Ibyte *p; 2130 Ibyte *p;
2133 Bytecount i; 2131 Bytecount i;
2134 2132
2773 offsetof (DIRENTRY, d_name)); 2771 offsetof (DIRENTRY, d_name));
2774 2772
2775 2773
2776 Dynarr_add_many (internal_DIRENTRY, internal_name, internal_len); 2774 Dynarr_add_many (internal_DIRENTRY, internal_name, internal_len);
2777 Dynarr_add (internal_DIRENTRY, '\0'); /* NUL-terminate */ 2775 Dynarr_add (internal_DIRENTRY, '\0'); /* NUL-terminate */
2778 return (DIRENTRY *) Dynarr_atp (internal_DIRENTRY, 0); 2776 return (DIRENTRY *) Dynarr_begin (internal_DIRENTRY);
2779 } 2777 }
2780 } 2778 }
2781 #endif /* MULE */ 2779 #endif /* MULE */
2782 #endif /* WIN32_NATIVE */ 2780 #endif /* WIN32_NATIVE */
2783 } 2781 }
2833 ret = _getcwd (cwd, cwdsize); 2831 ret = _getcwd (cwd, cwdsize);
2834 2832
2835 if (ret) 2833 if (ret)
2836 { 2834 {
2837 Ibyte *retin; 2835 Ibyte *retin;
2838 TSTR_TO_C_STRING_MALLOC (ret, retin); 2836 retin = TSTR_TO_ITEXT_MALLOC (ret);
2839 xfree (cwd, Extbyte *); 2837 xfree (cwd);
2840 return retin; 2838 return retin;
2841 } 2839 }
2842 #else 2840 #else
2843 Extbyte *ret = getcwd (cwd, cwdsize); 2841 Extbyte *ret = getcwd (cwd, cwdsize);
2844 if (ret) 2842 if (ret)
2845 { 2843 {
2846 Ibyte *retin; 2844 Ibyte *retin;
2847 EXTERNAL_TO_C_STRING_MALLOC (ret, retin, Qfile_name); 2845 retin = EXTERNAL_TO_ITEXT_MALLOC (ret, Qfile_name);
2848 xfree (cwd, Extbyte *); 2846 xfree (cwd);
2849 return retin; 2847 return retin;
2850 } 2848 }
2851 #endif /* WIN32_NATIVE */ 2849 #endif /* WIN32_NATIVE */
2852 2850
2853 if (errno == ERANGE) 2851 if (errno == ERANGE)
2855 cwdsize *= 2; 2853 cwdsize *= 2;
2856 XREALLOC_ARRAY (cwd, Extbyte, cwdsize); 2854 XREALLOC_ARRAY (cwd, Extbyte, cwdsize);
2857 } 2855 }
2858 else 2856 else
2859 { 2857 {
2860 xfree (cwd, Extbyte *); 2858 xfree (cwd);
2861 return NULL; 2859 return NULL;
2862 } 2860 }
2863 } 2861 }
2864 #else 2862 #else
2865 Extbyte chingame_limitos_arbitrarios[PATH_MAX_TCHAR]; 2863 Extbyte chingame_limitos_arbitrarios[PATH_MAX_TCHAR];
2866 Ibyte *ret2; 2864 Ibyte *ret2;
2867 2865
2868 if (!getwd (chingame_limitos_arbitrarios)) 2866 if (!getwd (chingame_limitos_arbitrarios))
2869 return 0; 2867 return 0;
2870 EXTERNAL_TO_C_STRING_MALLOC (chingame_limitos_arbitrarios, ret2, Qfile_name); 2868 ret2 = EXTERNAL_TO_ITEXT_MALLOC (chingame_limitos_arbitrarios, Qfile_name);
2871 return ret2; 2869 return ret2;
2872 #endif /* HAVE_GETCWD */ 2870 #endif /* HAVE_GETCWD */
2873 } 2871 }
2874 2872
2875 /***************** file-information calls ******************/ 2873 /***************** file-information calls ******************/
2939 eicpy_rawz (name2, path); 2937 eicpy_rawz (name2, path);
2940 eicat_ascii (name2, ".LNK"); 2938 eicat_ascii (name2, ".LNK");
2941 resolved = mswindows_read_link (eidata (name2)); 2939 resolved = mswindows_read_link (eidata (name2));
2942 if (resolved) 2940 if (resolved)
2943 { 2941 {
2944 xfree (resolved, Ibyte *); 2942 xfree (resolved);
2945 return mswindows_stat (eidata (name2), buf); 2943 return mswindows_stat (eidata (name2), buf);
2946 } 2944 }
2947 } 2945 }
2948 } 2946 }
2949 2947
3090 3088
3091 for (argc = 0; argv[argc]; argc++) 3089 for (argc = 0; argv[argc]; argc++)
3092 ; 3090 ;
3093 new_argv = alloca_array (Extbyte *, argc + 1); 3091 new_argv = alloca_array (Extbyte *, argc + 1);
3094 for (i = 0; i < argc; i++) 3092 for (i = 0; i < argc; i++)
3095 C_STRING_TO_EXTERNAL (argv[i], new_argv[i], Qcommand_argument_encoding); 3093 new_argv[i] = ITEXT_TO_EXTERNAL (argv[i], Qcommand_argument_encoding);
3096 new_argv[argc] = NULL; 3094 new_argv[argc] = NULL;
3097 3095
3098 for (envc = 0; envp[envc]; envc++) 3096 for (envc = 0; envp[envc]; envc++)
3099 ; 3097 ;
3100 new_envp = alloca_array (Extbyte *, envc + 1); 3098 new_envp = alloca_array (Extbyte *, envc + 1);
3101 for (i = 0; i < envc; i++) 3099 for (i = 0; i < envc; i++)
3102 C_STRING_TO_EXTERNAL (envp[i], new_envp[i], 3100 new_envp[i] = ITEXT_TO_EXTERNAL (envp[i], Qenvironment_variable_encoding);
3103 Qenvironment_variable_encoding);
3104 new_envp[envc] = NULL; 3101 new_envp[envc] = NULL;
3105 3102
3106 #if defined (WIN32_NATIVE) 3103 #if defined (WIN32_NATIVE)
3107 if (XEUNICODE_P) 3104 if (XEUNICODE_P)
3108 return _wexecve ((const wchar_t *) pathext, 3105 return _wexecve ((const wchar_t *) pathext,
3132 { 3129 {
3133 if (!pwd) 3130 if (!pwd)
3134 return NULL; 3131 return NULL;
3135 3132
3136 if (cached_pwd.pw_name) 3133 if (cached_pwd.pw_name)
3137 xfree (cached_pwd.pw_name, char *); 3134 xfree (cached_pwd.pw_name);
3138 if (cached_pwd.pw_passwd) 3135 if (cached_pwd.pw_passwd)
3139 xfree (cached_pwd.pw_passwd, char *); 3136 xfree (cached_pwd.pw_passwd);
3140 if (cached_pwd.pw_gecos) 3137 if (cached_pwd.pw_gecos)
3141 xfree (cached_pwd.pw_gecos, char *); 3138 xfree (cached_pwd.pw_gecos);
3142 if (cached_pwd.pw_dir) 3139 if (cached_pwd.pw_dir)
3143 xfree (cached_pwd.pw_dir, char *); 3140 xfree (cached_pwd.pw_dir);
3144 if (cached_pwd.pw_shell) 3141 if (cached_pwd.pw_shell)
3145 xfree (cached_pwd.pw_shell, char *); 3142 xfree (cached_pwd.pw_shell);
3146 3143
3147 cached_pwd = *pwd; 3144 cached_pwd = *pwd;
3148 if (cached_pwd.pw_name) 3145
3149 TO_INTERNAL_FORMAT (C_STRING, cached_pwd.pw_name, 3146 #define FROB(field, encoding) \
3150 C_STRING_MALLOC, cached_pwd.pw_name, 3147 do \
3151 Quser_name_encoding); 3148 { \
3152 if (cached_pwd.pw_passwd) 3149 if (cached_pwd.field) \
3153 TO_INTERNAL_FORMAT (C_STRING, cached_pwd.pw_passwd, 3150 cached_pwd.field = (CIbyte *) \
3154 C_STRING_MALLOC, cached_pwd.pw_passwd, 3151 EXTERNAL_TO_ITEXT_MALLOC (cached_pwd.field, encoding); \
3155 Quser_name_encoding); 3152 } while (0)
3156 if (cached_pwd.pw_gecos) 3153
3157 TO_INTERNAL_FORMAT (C_STRING, cached_pwd.pw_gecos, 3154 FROB (pw_name, Quser_name_encoding);
3158 C_STRING_MALLOC, cached_pwd.pw_gecos, 3155 FROB (pw_passwd, Quser_name_encoding);
3159 Quser_name_encoding); 3156 FROB (pw_gecos, Quser_name_encoding);
3160 if (cached_pwd.pw_dir) 3157 FROB (pw_dir, Qfile_name);
3161 TO_INTERNAL_FORMAT (C_STRING, cached_pwd.pw_dir, 3158 FROB (pw_shell, Qfile_name);
3162 C_STRING_MALLOC, cached_pwd.pw_dir, Qfile_name); 3159 #undef FROB
3163 if (cached_pwd.pw_shell)
3164 TO_INTERNAL_FORMAT (C_STRING, cached_pwd.pw_shell,
3165 C_STRING_MALLOC, cached_pwd.pw_shell, Qfile_name);
3166 return &cached_pwd; 3160 return &cached_pwd;
3167 } 3161 }
3168 3162
3169 struct passwd * 3163 struct passwd *
3170 qxe_getpwnam (const Ibyte *name) 3164 qxe_getpwnam (const Ibyte *name)
3171 { 3165 {
3172 #ifdef WIN32_NATIVE 3166 #ifdef WIN32_NATIVE
3173 /* Synthetic versions are defined in nt.c and already do conversion. */ 3167 /* Synthetic versions are defined in nt.c and already do conversion. */
3174 return getpwnam (name); 3168 return getpwnam (name);
3175 #else 3169 #else
3176 Extbyte *nameext; 3170 Extbyte *nameext = ITEXT_TO_EXTERNAL (name, Quser_name_encoding);
3177 C_STRING_TO_EXTERNAL (name, nameext, Quser_name_encoding);
3178 3171
3179 return copy_in_passwd (getpwnam (nameext)); 3172 return copy_in_passwd (getpwnam (nameext));
3180 #endif /* WIN32_NATIVE */ 3173 #endif /* WIN32_NATIVE */
3181 } 3174 }
3182 3175
3211 { 3204 {
3212 Extbyte *str = (Extbyte *) ctime (t); 3205 Extbyte *str = (Extbyte *) ctime (t);
3213 if (!str) /* can happen on MS Windows */ 3206 if (!str) /* can happen on MS Windows */
3214 return (Ibyte *) "Sun Jan 01 00:00:00 1970"; 3207 return (Ibyte *) "Sun Jan 01 00:00:00 1970";
3215 if (ctime_static) 3208 if (ctime_static)
3216 xfree (ctime_static, Ibyte *); 3209 xfree (ctime_static);
3217 EXTERNAL_TO_C_STRING_MALLOC (str, ctime_static, Qtime_function_encoding); 3210 ctime_static = EXTERNAL_TO_ITEXT_MALLOC (str, Qtime_function_encoding);
3218 return ctime_static; 3211 return ctime_static;
3219 } 3212 }
3220 3213
3221 3214
3222 /************************************************************************/ 3215 /************************************************************************/
3387 #elif defined (HAVE_UTIME) 3380 #elif defined (HAVE_UTIME)
3388 struct utimbuf utb; 3381 struct utimbuf utb;
3389 Extbyte *filename; 3382 Extbyte *filename;
3390 utb.actime = EMACS_SECS (atime); 3383 utb.actime = EMACS_SECS (atime);
3391 utb.modtime = EMACS_SECS (mtime); 3384 utb.modtime = EMACS_SECS (mtime);
3392 LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name); 3385 LISP_PATHNAME_CONVERT_OUT (path, filename);
3393 return utime (filename, &utb); 3386 return utime (filename, &utb);
3394 #elif defined (HAVE_UTIMES) 3387 #elif defined (HAVE_UTIMES)
3395 struct timeval tv[2]; 3388 struct timeval tv[2];
3396 Extbyte *filename; 3389 Extbyte *filename;
3397 tv[0] = atime; 3390 tv[0] = atime;
3398 tv[1] = mtime; 3391 tv[1] = mtime;
3399 LISP_STRING_TO_EXTERNAL (path, filename, Qfile_name); 3392 LISP_PATHNAME_CONVERT_OUT (path, filename);
3400 return utimes (filename, tv); 3393 return utimes (filename, tv);
3401 #else 3394 #else
3402 /* No file times setting function available. */ 3395 /* No file times setting function available. */
3403 return -1; 3396 return -1;
3404 #endif 3397 #endif
3570 #if (!defined(HAVE_DECL_SYS_SIGLIST) || !HAVE_DECL_SYS_SIGLIST ) && !defined (HAVE_SYS_SIGLIST) 3563 #if (!defined(HAVE_DECL_SYS_SIGLIST) || !HAVE_DECL_SYS_SIGLIST ) && !defined (HAVE_SYS_SIGLIST)
3571 3564
3572 #if defined(WIN32_NATIVE) || defined(CYGWIN) 3565 #if defined(WIN32_NATIVE) || defined(CYGWIN)
3573 const char *sys_siglist[] = 3566 const char *sys_siglist[] =
3574 { 3567 {
3575 /* $$####begin-snarf */ 3568 /* @@@begin-snarf@@@ */
3576 "bum signal!!", 3569 "bum signal!!",
3577 "hangup", 3570 "hangup",
3578 "interrupt", 3571 "interrupt",
3579 "quit", 3572 "quit",
3580 "illegal instruction", 3573 "illegal instruction",
3596 "child status has changed", 3589 "child status has changed",
3597 "background read attempted from control tty", 3590 "background read attempted from control tty",
3598 "background write attempted from control tty", 3591 "background write attempted from control tty",
3599 "input record available at control tty", 3592 "input record available at control tty",
3600 "exceeded CPU time limit", 3593 "exceeded CPU time limit",
3601 "exceeded file size limit" 3594 "exceeded file size limit",
3602 /* $$####end-snarf */ 3595 /* @@@end-snarf@@@ */
3603 }; 3596 };
3604 #endif 3597 #endif
3605 3598
3606 #ifdef USG 3599 #ifdef USG
3607 #ifdef AIX 3600 #ifdef AIX
3608 const char *sys_siglist[NSIG + 1] = 3601 const char *sys_siglist[NSIG + 1] =
3609 { 3602 {
3610 /* AIX has changed the signals a bit */ 3603 /* AIX has changed the signals a bit */
3611 DEFER_GETTEXT ("bogus signal"), /* 0 */ 3604 /* @@@begin-snarf@@@ */
3612 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ 3605 "bogus signal", /* 0 */
3613 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ 3606 "hangup", /* 1 SIGHUP */
3614 DEFER_GETTEXT ("quit"), /* 3 SIGQUIT */ 3607 "interrupt", /* 2 SIGINT */
3615 DEFER_GETTEXT ("illegal instruction"), /* 4 SIGILL */ 3608 "quit", /* 3 SIGQUIT */
3616 DEFER_GETTEXT ("trace trap"), /* 5 SIGTRAP */ 3609 "illegal instruction", /* 4 SIGILL */
3617 DEFER_GETTEXT ("IOT instruction"), /* 6 SIGIOT */ 3610 "trace trap", /* 5 SIGTRAP */
3618 DEFER_GETTEXT ("crash likely"), /* 7 SIGDANGER */ 3611 "IOT instruction", /* 6 SIGIOT */
3619 DEFER_GETTEXT ("floating point exception"), /* 8 SIGFPE */ 3612 "crash likely", /* 7 SIGDANGER */
3620 DEFER_GETTEXT ("kill"), /* 9 SIGKILL */ 3613 "floating point exception", /* 8 SIGFPE */
3621 DEFER_GETTEXT ("bus error"), /* 10 SIGBUS */ 3614 "kill", /* 9 SIGKILL */
3622 DEFER_GETTEXT ("segmentation violation"), /* 11 SIGSEGV */ 3615 "bus error", /* 10 SIGBUS */
3623 DEFER_GETTEXT ("bad argument to system call"), /* 12 SIGSYS */ 3616 "segmentation violation", /* 11 SIGSEGV */
3624 DEFER_GETTEXT ("write on a pipe with no one to read it"), /* 13 SIGPIPE */ 3617 "bad argument to system call", /* 12 SIGSYS */
3625 DEFER_GETTEXT ("alarm clock"), /* 14 SIGALRM */ 3618 "write on a pipe with no one to read it", /* 13 SIGPIPE */
3626 DEFER_GETTEXT ("software termination signal"), /* 15 SIGTERM */ 3619 "alarm clock", /* 14 SIGALRM */
3627 DEFER_GETTEXT ("user defined signal 1"), /* 16 SIGUSR1 */ 3620 "software termination signal", /* 15 SIGTERM */
3628 DEFER_GETTEXT ("user defined signal 2"), /* 17 SIGUSR2 */ 3621 "user defined signal 1", /* 16 SIGUSR1 */
3629 DEFER_GETTEXT ("death of a child"), /* 18 SIGCLD */ 3622 "user defined signal 2", /* 17 SIGUSR2 */
3630 DEFER_GETTEXT ("power-fail restart"), /* 19 SIGPWR */ 3623 "death of a child", /* 18 SIGCLD */
3631 DEFER_GETTEXT ("bogus signal"), /* 20 */ 3624 "power-fail restart", /* 19 SIGPWR */
3632 DEFER_GETTEXT ("bogus signal"), /* 21 */ 3625 "bogus signal", /* 20 */
3633 DEFER_GETTEXT ("bogus signal"), /* 22 */ 3626 "bogus signal", /* 21 */
3634 DEFER_GETTEXT ("bogus signal"), /* 23 */ 3627 "bogus signal", /* 22 */
3635 DEFER_GETTEXT ("bogus signal"), /* 24 */ 3628 "bogus signal", /* 23 */
3636 DEFER_GETTEXT ("LAN I/O interrupt"), /* 25 SIGAIO */ 3629 "bogus signal", /* 24 */
3637 DEFER_GETTEXT ("PTY I/O interrupt"), /* 26 SIGPTY */ 3630 "LAN I/O interrupt", /* 25 SIGAIO */
3638 DEFER_GETTEXT ("I/O intervention required"), /* 27 SIGIOINT */ 3631 "PTY I/O interrupt", /* 26 SIGPTY */
3639 /* $$####end-snarf */ 3632 "I/O intervention required", /* 27 SIGIOINT */
3633 /* @@@end-snarf@@@ */
3640 0 3634 0
3641 }; 3635 };
3642 #else /* USG, not AIX */ 3636 #else /* USG, not AIX */
3643 const char *sys_siglist[NSIG + 1] = 3637 const char *sys_siglist[NSIG + 1] =
3644 { 3638 {
3645 DEFER_GETTEXT ("bogus signal"), /* 0 */ 3639 /* @@@begin-snarf@@@ */
3646 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ 3640 "bogus signal", /* 0 */
3647 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ 3641 "hangup", /* 1 SIGHUP */
3648 DEFER_GETTEXT ("quit"), /* 3 SIGQUIT */ 3642 "interrupt", /* 2 SIGINT */
3649 DEFER_GETTEXT ("illegal instruction"), /* 4 SIGILL */ 3643 "quit", /* 3 SIGQUIT */
3650 DEFER_GETTEXT ("trace trap"), /* 5 SIGTRAP */ 3644 "illegal instruction", /* 4 SIGILL */
3651 DEFER_GETTEXT ("IOT instruction"), /* 6 SIGIOT */ 3645 "trace trap", /* 5 SIGTRAP */
3652 DEFER_GETTEXT ("EMT instruction"), /* 7 SIGEMT */ 3646 "IOT instruction", /* 6 SIGIOT */
3653 DEFER_GETTEXT ("floating point exception"), /* 8 SIGFPE */ 3647 "EMT instruction", /* 7 SIGEMT */
3654 DEFER_GETTEXT ("kill"), /* 9 SIGKILL */ 3648 "floating point exception", /* 8 SIGFPE */
3655 DEFER_GETTEXT ("bus error"), /* 10 SIGBUS */ 3649 "kill", /* 9 SIGKILL */
3656 DEFER_GETTEXT ("segmentation violation"), /* 11 SIGSEGV */ 3650 "bus error", /* 10 SIGBUS */
3657 DEFER_GETTEXT ("bad argument to system call"), /* 12 SIGSYS */ 3651 "segmentation violation", /* 11 SIGSEGV */
3658 DEFER_GETTEXT ("write on a pipe with no one to read it"), /* 13 SIGPIPE */ 3652 "bad argument to system call", /* 12 SIGSYS */
3659 DEFER_GETTEXT ("alarm clock"), /* 14 SIGALRM */ 3653 "write on a pipe with no one to read it", /* 13 SIGPIPE */
3660 DEFER_GETTEXT ("software termination signal"), /* 15 SIGTERM */ 3654 "alarm clock", /* 14 SIGALRM */
3661 DEFER_GETTEXT ("user defined signal 1"), /* 16 SIGUSR1 */ 3655 "software termination signal", /* 15 SIGTERM */
3662 DEFER_GETTEXT ("user defined signal 2"), /* 17 SIGUSR2 */ 3656 "user defined signal 1", /* 16 SIGUSR1 */
3663 DEFER_GETTEXT ("death of a child"), /* 18 SIGCLD */ 3657 "user defined signal 2", /* 17 SIGUSR2 */
3664 DEFER_GETTEXT ("power-fail restart"), /* 19 SIGPWR */ 3658 "death of a child", /* 18 SIGCLD */
3665 #ifdef sun 3659 "power-fail restart", /* 19 SIGPWR */
3666 "window size changed", /* 20 SIGWINCH */ 3660 #ifdef sun
3667 "urgent socket condition", /* 21 SIGURG */ 3661 "window size changed", /* 20 SIGWINCH */
3668 "pollable event occurred", /* 22 SIGPOLL */ 3662 "urgent socket condition", /* 21 SIGURG */
3669 "stop (cannot be caught or ignored)", /* 23 SIGSTOP */ 3663 "pollable event occurred", /* 22 SIGPOLL */
3670 "user stop requested from tty", /* 24 SIGTSTP */ 3664 "stop (cannot be caught or ignored)", /* 23 SIGSTOP */
3671 "stopped process has been continued", /* 25 SIGCONT */ 3665 "user stop requested from tty", /* 24 SIGTSTP */
3672 "background tty read attempted", /* 26 SIGTTIN */ 3666 "stopped process has been continued", /* 25 SIGCONT */
3673 "background tty write attempted", /* 27 SIGTTOU */ 3667 "background tty read attempted", /* 26 SIGTTIN */
3674 "virtual timer expired", /* 28 SIGVTALRM */ 3668 "background tty write attempted", /* 27 SIGTTOU */
3675 "profiling timer expired", /* 29 SIGPROF */ 3669 "virtual timer expired", /* 28 SIGVTALRM */
3676 "exceeded cpu limit", /* 30 SIGXCPU */ 3670 "profiling timer expired", /* 29 SIGPROF */
3677 "exceeded file size limit", /* 31 SIGXFSZ */ 3671 "exceeded cpu limit", /* 30 SIGXCPU */
3678 "process's lwps are blocked", /* 32 SIGWAITING */ 3672 "exceeded file size limit", /* 31 SIGXFSZ */
3679 "special signal used by thread library", /* 33 SIGLWP */ 3673 "process's lwps are blocked", /* 32 SIGWAITING */
3674 "special signal used by thread library", /* 33 SIGLWP */
3680 #ifdef SIGFREEZE 3675 #ifdef SIGFREEZE
3681 "special signal used by CPR", /* 34 SIGFREEZE */ 3676 "special signal used by CPR", /* 34 SIGFREEZE */
3682 #endif 3677 #endif
3683 #ifdef SIGTHAW 3678 #ifdef SIGTHAW
3684 "special signal used by CPR", /* 35 SIGTHAW */ 3679 "special signal used by CPR", /* 35 SIGTHAW */
3685 #endif 3680 #endif
3686 #endif /* sun */ 3681 #endif /* sun */
3687 /* $$####end-snarf */ 3682 /* @@@end-snarf@@@ */
3688 0 3683 0
3689 }; 3684 };
3690 #endif /* not AIX */ 3685 #endif /* not AIX */
3691 #endif /* USG */ 3686 #endif /* USG */
3692 3687
3711 3706
3712 /* Some systems (like Solaris) allocate the buffer and the DIR all 3707 /* Some systems (like Solaris) allocate the buffer and the DIR all
3713 in one block. Why in the world are we freeing this ourselves 3708 in one block. Why in the world are we freeing this ourselves
3714 anyway? */ 3709 anyway? */
3715 #if ! (defined (sun) && defined (USG5_4)) 3710 #if ! (defined (sun) && defined (USG5_4))
3716 xfree (dirp->dd_buf, char *); /* directory block defined in <dirent.h> */ 3711 xfree (dirp->dd_buf); /* directory block defined in <dirent.h> */
3717 #endif 3712 #endif
3718 xfree (dirp, DIR *); 3713 xfree (dirp);
3719 return (rtnval); 3714 return (rtnval);
3720 } 3715 }
3721 #endif /* not HAVE_CLOSEDIR */ 3716 #endif /* not HAVE_CLOSEDIR */
3722 #endif /* SYSV_SYSTEM_DIR */ 3717 #endif /* SYSV_SYSTEM_DIR */
3723 3718
3750 3745
3751 void 3746 void
3752 closedir (DIR *dirp) /* stream from opendir */ 3747 closedir (DIR *dirp) /* stream from opendir */
3753 { 3748 {
3754 retry_close (dirp->dd_fd); 3749 retry_close (dirp->dd_fd);
3755 xfree (dirp, DIR *); 3750 xfree (dirp);
3756 } 3751 }
3757 3752
3758 3753
3759 #define DIRSIZ 14 3754 #define DIRSIZ 14
3760 struct olddir 3755 struct olddir