Mercurial > emacs
comparison src/w32.c @ 49600:23a1cea22d13
Trailing whitespace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 14:56:31 +0000 |
parents | f0df5f687c15 |
children | 373b8dc17c8b d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49599:5ade352e8d1c | 49600:23a1cea22d13 |
---|---|
341 #ifndef HAVE_SOCKETS | 341 #ifndef HAVE_SOCKETS |
342 /* Emulate gethostname. */ | 342 /* Emulate gethostname. */ |
343 int | 343 int |
344 gethostname (char *buffer, int size) | 344 gethostname (char *buffer, int size) |
345 { | 345 { |
346 /* NT only allows small host names, so the buffer is | 346 /* NT only allows small host names, so the buffer is |
347 certainly large enough. */ | 347 certainly large enough. */ |
348 return !GetComputerName (buffer, &size); | 348 return !GetComputerName (buffer, &size); |
349 } | 349 } |
350 #endif /* HAVE_SOCKETS */ | 350 #endif /* HAVE_SOCKETS */ |
351 | 351 |
354 getloadavg (double loadavg[], int nelem) | 354 getloadavg (double loadavg[], int nelem) |
355 { | 355 { |
356 int i; | 356 int i; |
357 | 357 |
358 /* A faithful emulation is going to have to be saved for a rainy day. */ | 358 /* A faithful emulation is going to have to be saved for a rainy day. */ |
359 for (i = 0; i < nelem; i++) | 359 for (i = 0; i < nelem; i++) |
360 { | 360 { |
361 loadavg[i] = 0.0; | 361 loadavg[i] = 0.0; |
362 } | 362 } |
363 return i; | 363 return i; |
364 } | 364 } |
371 static char the_passwd_passwd[PASSWD_FIELD_SIZE]; | 371 static char the_passwd_passwd[PASSWD_FIELD_SIZE]; |
372 static char the_passwd_gecos[PASSWD_FIELD_SIZE]; | 372 static char the_passwd_gecos[PASSWD_FIELD_SIZE]; |
373 static char the_passwd_dir[PASSWD_FIELD_SIZE]; | 373 static char the_passwd_dir[PASSWD_FIELD_SIZE]; |
374 static char the_passwd_shell[PASSWD_FIELD_SIZE]; | 374 static char the_passwd_shell[PASSWD_FIELD_SIZE]; |
375 | 375 |
376 static struct passwd the_passwd = | 376 static struct passwd the_passwd = |
377 { | 377 { |
378 the_passwd_name, | 378 the_passwd_name, |
379 the_passwd_passwd, | 379 the_passwd_passwd, |
380 0, | 380 0, |
381 0, | 381 0, |
383 the_passwd_gecos, | 383 the_passwd_gecos, |
384 the_passwd_dir, | 384 the_passwd_dir, |
385 the_passwd_shell, | 385 the_passwd_shell, |
386 }; | 386 }; |
387 | 387 |
388 int | 388 int |
389 getuid () | 389 getuid () |
390 { | 390 { |
391 return the_passwd.pw_uid; | 391 return the_passwd.pw_uid; |
392 } | 392 } |
393 | 393 |
394 int | 394 int |
395 geteuid () | 395 geteuid () |
396 { | 396 { |
397 /* I could imagine arguing for checking to see whether the user is | 397 /* I could imagine arguing for checking to see whether the user is |
398 in the Administrators group and returning a UID of 0 for that | 398 in the Administrators group and returning a UID of 0 for that |
399 case, but I don't know how wise that would be in the long run. */ | 399 case, but I don't know how wise that would be in the long run. */ |
400 return getuid (); | 400 return getuid (); |
401 } | 401 } |
402 | 402 |
403 int | 403 int |
404 getgid () | 404 getgid () |
405 { | 405 { |
406 return the_passwd.pw_gid; | 406 return the_passwd.pw_gid; |
407 } | 407 } |
408 | 408 |
409 int | 409 int |
410 getegid () | 410 getegid () |
411 { | 411 { |
412 return getgid (); | 412 return getgid (); |
413 } | 413 } |
414 | 414 |
415 struct passwd * | 415 struct passwd * |
416 getpwuid (int uid) | 416 getpwuid (int uid) |
422 | 422 |
423 struct passwd * | 423 struct passwd * |
424 getpwnam (char *name) | 424 getpwnam (char *name) |
425 { | 425 { |
426 struct passwd *pw; | 426 struct passwd *pw; |
427 | 427 |
428 pw = getpwuid (getuid ()); | 428 pw = getpwuid (getuid ()); |
429 if (!pw) | 429 if (!pw) |
430 return pw; | 430 return pw; |
431 | 431 |
432 if (stricmp (name, pw->pw_name)) | 432 if (stricmp (name, pw->pw_name)) |
780 return 1; | 780 return 1; |
781 } | 781 } |
782 | 782 |
783 /* Routines that are no-ops on NT but are defined to get Emacs to compile. */ | 783 /* Routines that are no-ops on NT but are defined to get Emacs to compile. */ |
784 | 784 |
785 int | 785 int |
786 sigsetmask (int signal_mask) | 786 sigsetmask (int signal_mask) |
787 { | 787 { |
788 return 0; | 788 return 0; |
789 } | 789 } |
790 | 790 |
791 int | 791 int |
792 sigmask (int sig) | 792 sigmask (int sig) |
793 { | 793 { |
794 return 0; | 794 return 0; |
795 } | 795 } |
796 | 796 |
797 int | 797 int |
798 sigblock (int sig) | 798 sigblock (int sig) |
799 { | 799 { |
800 return 0; | 800 return 0; |
801 } | 801 } |
802 | 802 |
803 int | 803 int |
804 sigunblock (int sig) | 804 sigunblock (int sig) |
805 { | 805 { |
806 return 0; | 806 return 0; |
807 } | 807 } |
808 | 808 |
809 int | 809 int |
810 setpgrp (int pid, int gid) | 810 setpgrp (int pid, int gid) |
811 { | 811 { |
812 return 0; | 812 return 0; |
813 } | 813 } |
814 | 814 |
815 int | 815 int |
816 alarm (int seconds) | 816 alarm (int seconds) |
817 { | 817 { |
818 return 0; | 818 return 0; |
819 } | 819 } |
820 | 820 |
821 void | 821 void |
822 unrequest_sigio (void) | 822 unrequest_sigio (void) |
823 { | 823 { |
824 return; | 824 return; |
825 } | 825 } |
826 | 826 |
827 void | 827 void |
828 request_sigio (void) | 828 request_sigio (void) |
829 { | 829 { |
830 return; | 830 return; |
831 } | 831 } |
832 | 832 |
833 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" | 833 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
834 | 834 |
835 LPBYTE | 835 LPBYTE |
836 w32_get_resource (key, lpdwtype) | 836 w32_get_resource (key, lpdwtype) |
837 char *key; | 837 char *key; |
838 LPDWORD lpdwtype; | 838 LPDWORD lpdwtype; |
839 { | 839 { |
840 LPBYTE lpvalue; | 840 LPBYTE lpvalue; |
841 HKEY hrootkey = NULL; | 841 HKEY hrootkey = NULL; |
842 DWORD cbData; | 842 DWORD cbData; |
843 BOOL ok = FALSE; | 843 BOOL ok = FALSE; |
844 | 844 |
845 /* Check both the current user and the local machine to see if | 845 /* Check both the current user and the local machine to see if |
846 we have any resources. */ | 846 we have any resources. */ |
847 | 847 |
848 if (RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) | 848 if (RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
849 { | 849 { |
850 lpvalue = NULL; | 850 lpvalue = NULL; |
851 | 851 |
852 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS | |
853 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | |
854 && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) | |
855 { | |
856 return (lpvalue); | |
857 } | |
858 | |
859 if (lpvalue) xfree (lpvalue); | |
860 | |
861 RegCloseKey (hrootkey); | |
862 } | |
863 | |
864 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) | |
865 { | |
866 lpvalue = NULL; | |
867 | |
868 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS | 852 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS |
869 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | 853 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL |
870 && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) | 854 && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) |
871 { | 855 { |
872 return (lpvalue); | 856 return (lpvalue); |
873 } | 857 } |
874 | 858 |
875 if (lpvalue) xfree (lpvalue); | 859 if (lpvalue) xfree (lpvalue); |
876 | 860 |
877 RegCloseKey (hrootkey); | 861 RegCloseKey (hrootkey); |
878 } | 862 } |
879 | 863 |
864 if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) | |
865 { | |
866 lpvalue = NULL; | |
867 | |
868 if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS | |
869 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | |
870 && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) == ERROR_SUCCESS) | |
871 { | |
872 return (lpvalue); | |
873 } | |
874 | |
875 if (lpvalue) xfree (lpvalue); | |
876 | |
877 RegCloseKey (hrootkey); | |
878 } | |
879 | |
880 return (NULL); | 880 return (NULL); |
881 } | 881 } |
882 | 882 |
883 char *get_emacs_configuration (void); | 883 char *get_emacs_configuration (void); |
884 extern Lisp_Object Vsystem_configuration; | 884 extern Lisp_Object Vsystem_configuration; |
931 | 931 |
932 static struct env_entry | 932 static struct env_entry |
933 { | 933 { |
934 char * name; | 934 char * name; |
935 char * def_value; | 935 char * def_value; |
936 } env_vars[] = | 936 } env_vars[] = |
937 { | 937 { |
938 {"HOME", "C:/"}, | 938 {"HOME", "C:/"}, |
939 {"PRELOAD_WINSOCK", NULL}, | 939 {"PRELOAD_WINSOCK", NULL}, |
940 {"emacs_dir", "C:/emacs"}, | 940 {"emacs_dir", "C:/emacs"}, |
941 {"EMACSLOADPATH", "%emacs_dir%/site-lisp;%emacs_dir%/../site-lisp;%emacs_dir%/lisp;%emacs_dir%/leim"}, | 941 {"EMACSLOADPATH", "%emacs_dir%/site-lisp;%emacs_dir%/../site-lisp;%emacs_dir%/lisp;%emacs_dir%/leim"}, |
985 char buf[SET_ENV_BUF_SIZE]; | 985 char buf[SET_ENV_BUF_SIZE]; |
986 | 986 |
987 *p = 0; | 987 *p = 0; |
988 for (p = modname; *p; p++) | 988 for (p = modname; *p; p++) |
989 if (*p == '\\') *p = '/'; | 989 if (*p == '\\') *p = '/'; |
990 | 990 |
991 _snprintf (buf, sizeof(buf)-1, "emacs_dir=%s", modname); | 991 _snprintf (buf, sizeof(buf)-1, "emacs_dir=%s", modname); |
992 _putenv (strdup (buf)); | 992 _putenv (strdup (buf)); |
993 } | 993 } |
994 } | 994 } |
995 | 995 |
1017 _putenv (strdup (buf2)); | 1017 _putenv (strdup (buf2)); |
1018 } | 1018 } |
1019 else if (dwType == REG_SZ) | 1019 else if (dwType == REG_SZ) |
1020 { | 1020 { |
1021 char buf[SET_ENV_BUF_SIZE]; | 1021 char buf[SET_ENV_BUF_SIZE]; |
1022 | 1022 |
1023 _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval); | 1023 _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval); |
1024 _putenv (strdup (buf)); | 1024 _putenv (strdup (buf)); |
1025 } | 1025 } |
1026 | 1026 |
1027 if (!dont_free) | 1027 if (!dont_free) |
1111 char *arch, *oem, *os; | 1111 char *arch, *oem, *os; |
1112 int build_num; | 1112 int build_num; |
1113 static char configuration_buffer[32]; | 1113 static char configuration_buffer[32]; |
1114 | 1114 |
1115 /* Determine the processor type. */ | 1115 /* Determine the processor type. */ |
1116 switch (get_processor_type ()) | 1116 switch (get_processor_type ()) |
1117 { | 1117 { |
1118 | 1118 |
1119 #ifdef PROCESSOR_INTEL_386 | 1119 #ifdef PROCESSOR_INTEL_386 |
1120 case PROCESSOR_INTEL_386: | 1120 case PROCESSOR_INTEL_386: |
1121 case PROCESSOR_INTEL_486: | 1121 case PROCESSOR_INTEL_486: |
1228 | 1228 |
1229 | 1229 |
1230 #include <sys/timeb.h> | 1230 #include <sys/timeb.h> |
1231 | 1231 |
1232 /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ | 1232 /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ |
1233 void | 1233 void |
1234 gettimeofday (struct timeval *tv, struct timezone *tz) | 1234 gettimeofday (struct timeval *tv, struct timezone *tz) |
1235 { | 1235 { |
1236 struct timeb tb; | 1236 struct timeb tb; |
1237 _ftime (&tb); | 1237 _ftime (&tb); |
1238 | 1238 |
1239 tv->tv_sec = tb.time; | 1239 tv->tv_sec = tb.time; |
1240 tv->tv_usec = tb.millitm * 1000L; | 1240 tv->tv_usec = tb.millitm * 1000L; |
1241 if (tz) | 1241 if (tz) |
1242 { | 1242 { |
1243 tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */ | 1243 tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */ |
1244 tz->tz_dsttime = tb.dstflag; /* type of dst correction */ | 1244 tz->tz_dsttime = tb.dstflag; /* type of dst correction */ |
1245 } | 1245 } |
1246 } | 1246 } |
1248 /* ------------------------------------------------------------------------- */ | 1248 /* ------------------------------------------------------------------------- */ |
1249 /* IO support and wrapper functions for W32 API. */ | 1249 /* IO support and wrapper functions for W32 API. */ |
1250 /* ------------------------------------------------------------------------- */ | 1250 /* ------------------------------------------------------------------------- */ |
1251 | 1251 |
1252 /* Place a wrapper around the MSVC version of ctime. It returns NULL | 1252 /* Place a wrapper around the MSVC version of ctime. It returns NULL |
1253 on network directories, so we handle that case here. | 1253 on network directories, so we handle that case here. |
1254 (Ulrich Leodolter, 1/11/95). */ | 1254 (Ulrich Leodolter, 1/11/95). */ |
1255 char * | 1255 char * |
1256 sys_ctime (const time_t *t) | 1256 sys_ctime (const time_t *t) |
1257 { | 1257 { |
1258 char *str = (char *) ctime (t); | 1258 char *str = (char *) ctime (t); |
1354 number (if nothing else) can change. Remote drives should be | 1354 number (if nothing else) can change. Remote drives should be |
1355 treated as if they are removable, since there is no sure way to | 1355 treated as if they are removable, since there is no sure way to |
1356 tell whether they are or not. Also, the UNC association of drive | 1356 tell whether they are or not. Also, the UNC association of drive |
1357 letters mapped to remote volumes can be changed at any time (even | 1357 letters mapped to remote volumes can be changed at any time (even |
1358 by other processes) without notice. | 1358 by other processes) without notice. |
1359 | 1359 |
1360 As a compromise, so we can benefit from caching info for remote | 1360 As a compromise, so we can benefit from caching info for remote |
1361 volumes, we use a simple expiry mechanism to invalidate cache | 1361 volumes, we use a simple expiry mechanism to invalidate cache |
1362 entries that are more than ten seconds old. */ | 1362 entries that are more than ten seconds old. */ |
1363 | 1363 |
1364 #if 0 | 1364 #if 0 |
1460 *str = 0; | 1460 *str = 0; |
1461 } | 1461 } |
1462 | 1462 |
1463 if (pPath) | 1463 if (pPath) |
1464 *pPath = name; | 1464 *pPath = name; |
1465 | 1465 |
1466 info = GetCachedVolumeInformation (rootname); | 1466 info = GetCachedVolumeInformation (rootname); |
1467 if (info != NULL) | 1467 if (info != NULL) |
1468 { | 1468 { |
1469 /* Set global referenced by other functions. */ | 1469 /* Set global referenced by other functions. */ |
1470 volume_info = *info; | 1470 volume_info = *info; |
1598 stricmp (p, ".com") == 0 || | 1598 stricmp (p, ".com") == 0 || |
1599 stricmp (p, ".bat") == 0 || | 1599 stricmp (p, ".bat") == 0 || |
1600 stricmp (p, ".cmd") == 0)); | 1600 stricmp (p, ".cmd") == 0)); |
1601 } | 1601 } |
1602 | 1602 |
1603 /* Emulate the Unix directory procedures opendir, closedir, | 1603 /* Emulate the Unix directory procedures opendir, closedir, |
1604 and readdir. We can't use the procedures supplied in sysdep.c, | 1604 and readdir. We can't use the procedures supplied in sysdep.c, |
1605 so we provide them here. */ | 1605 so we provide them here. */ |
1606 | 1606 |
1607 struct direct dir_static; /* simulated directory contents */ | 1607 struct direct dir_static; /* simulated directory contents */ |
1608 static HANDLE dir_find_handle = INVALID_HANDLE_VALUE; | 1608 static HANDLE dir_find_handle = INVALID_HANDLE_VALUE; |
1671 struct direct * | 1671 struct direct * |
1672 readdir (DIR *dirp) | 1672 readdir (DIR *dirp) |
1673 { | 1673 { |
1674 if (wnet_enum_handle != INVALID_HANDLE_VALUE) | 1674 if (wnet_enum_handle != INVALID_HANDLE_VALUE) |
1675 { | 1675 { |
1676 if (!read_unc_volume (wnet_enum_handle, | 1676 if (!read_unc_volume (wnet_enum_handle, |
1677 dir_find_data.cFileName, | 1677 dir_find_data.cFileName, |
1678 MAX_PATH)) | 1678 MAX_PATH)) |
1679 return NULL; | 1679 return NULL; |
1680 } | 1680 } |
1681 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */ | 1681 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */ |
1682 else if (dir_find_handle == INVALID_HANDLE_VALUE) | 1682 else if (dir_find_handle == INVALID_HANDLE_VALUE) |
1698 else | 1698 else |
1699 { | 1699 { |
1700 if (!FindNextFile (dir_find_handle, &dir_find_data)) | 1700 if (!FindNextFile (dir_find_handle, &dir_find_data)) |
1701 return NULL; | 1701 return NULL; |
1702 } | 1702 } |
1703 | 1703 |
1704 /* Emacs never uses this value, so don't bother making it match | 1704 /* Emacs never uses this value, so don't bother making it match |
1705 value returned by stat(). */ | 1705 value returned by stat(). */ |
1706 dir_static.d_ino = 1; | 1706 dir_static.d_ino = 1; |
1707 | 1707 |
1708 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 + | 1708 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 + |
1709 dir_static.d_namlen - dir_static.d_namlen % 4; | 1709 dir_static.d_namlen - dir_static.d_namlen % 4; |
1710 | 1710 |
1711 dir_static.d_namlen = strlen (dir_find_data.cFileName); | 1711 dir_static.d_namlen = strlen (dir_find_data.cFileName); |
1712 strcpy (dir_static.d_name, dir_find_data.cFileName); | 1712 strcpy (dir_static.d_name, dir_find_data.cFileName); |
1713 if (dir_is_fat) | 1713 if (dir_is_fat) |
1714 _strlwr (dir_static.d_name); | 1714 _strlwr (dir_static.d_name); |
1715 else if (!NILP (Vw32_downcase_file_names)) | 1715 else if (!NILP (Vw32_downcase_file_names)) |
1719 if (*p >= 'a' && *p <= 'z') | 1719 if (*p >= 'a' && *p <= 'z') |
1720 break; | 1720 break; |
1721 if (!*p) | 1721 if (!*p) |
1722 _strlwr (dir_static.d_name); | 1722 _strlwr (dir_static.d_name); |
1723 } | 1723 } |
1724 | 1724 |
1725 return &dir_static; | 1725 return &dir_static; |
1726 } | 1726 } |
1727 | 1727 |
1728 HANDLE | 1728 HANDLE |
1729 open_unc_volume (char *path) | 1729 open_unc_volume (char *path) |
1730 { | 1730 { |
1731 NETRESOURCE nr; | 1731 NETRESOURCE nr; |
1732 HANDLE henum; | 1732 HANDLE henum; |
1733 int result; | 1733 int result; |
1734 | 1734 |
1735 nr.dwScope = RESOURCE_GLOBALNET; | 1735 nr.dwScope = RESOURCE_GLOBALNET; |
1736 nr.dwType = RESOURCETYPE_DISK; | 1736 nr.dwType = RESOURCETYPE_DISK; |
1737 nr.dwDisplayType = RESOURCEDISPLAYTYPE_SERVER; | 1737 nr.dwDisplayType = RESOURCEDISPLAYTYPE_SERVER; |
1738 nr.dwUsage = RESOURCEUSAGE_CONTAINER; | 1738 nr.dwUsage = RESOURCEUSAGE_CONTAINER; |
1739 nr.lpLocalName = NULL; | 1739 nr.lpLocalName = NULL; |
1740 nr.lpRemoteName = map_w32_filename (path, NULL); | 1740 nr.lpRemoteName = map_w32_filename (path, NULL); |
1741 nr.lpComment = NULL; | 1741 nr.lpComment = NULL; |
1742 nr.lpProvider = NULL; | 1742 nr.lpProvider = NULL; |
1743 | 1743 |
1744 result = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, | 1744 result = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, |
1745 RESOURCEUSAGE_CONNECTABLE, &nr, &henum); | 1745 RESOURCEUSAGE_CONNECTABLE, &nr, &henum); |
1746 | 1746 |
1747 if (result == NO_ERROR) | 1747 if (result == NO_ERROR) |
1748 return henum; | 1748 return henum; |
1749 else | 1749 else |
1800 } | 1800 } |
1801 | 1801 |
1802 | 1802 |
1803 /* Shadow some MSVC runtime functions to map requests for long filenames | 1803 /* Shadow some MSVC runtime functions to map requests for long filenames |
1804 to reasonable short names if necessary. This was originally added to | 1804 to reasonable short names if necessary. This was originally added to |
1805 permit running Emacs on NT 3.1 on a FAT partition, which doesn't support | 1805 permit running Emacs on NT 3.1 on a FAT partition, which doesn't support |
1806 long file names. */ | 1806 long file names. */ |
1807 | 1807 |
1808 int | 1808 int |
1809 sys_access (const char * path, int mode) | 1809 sys_access (const char * path, int mode) |
1810 { | 1810 { |
2450 /* determine rwx permissions */ | 2450 /* determine rwx permissions */ |
2451 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) | 2451 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) |
2452 permission = _S_IREAD; | 2452 permission = _S_IREAD; |
2453 else | 2453 else |
2454 permission = _S_IREAD | _S_IWRITE; | 2454 permission = _S_IREAD | _S_IWRITE; |
2455 | 2455 |
2456 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) | 2456 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
2457 permission |= _S_IEXEC; | 2457 permission |= _S_IEXEC; |
2458 else if (is_exec (name)) | 2458 else if (is_exec (name)) |
2459 permission |= _S_IEXEC; | 2459 permission |= _S_IEXEC; |
2460 | 2460 |
2534 /* determine rwx permissions */ | 2534 /* determine rwx permissions */ |
2535 if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) | 2535 if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) |
2536 permission = _S_IREAD; | 2536 permission = _S_IREAD; |
2537 else | 2537 else |
2538 permission = _S_IREAD | _S_IWRITE; | 2538 permission = _S_IREAD | _S_IWRITE; |
2539 | 2539 |
2540 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) | 2540 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
2541 permission |= _S_IEXEC; | 2541 permission |= _S_IEXEC; |
2542 else | 2542 else |
2543 { | 2543 { |
2544 #if 0 /* no way of knowing the filename */ | 2544 #if 0 /* no way of knowing the filename */ |
2786 WSAEBADF , "Bad file descriptor", | 2786 WSAEBADF , "Bad file descriptor", |
2787 WSAEACCES , "Permission denied", | 2787 WSAEACCES , "Permission denied", |
2788 WSAEFAULT , "Bad address", | 2788 WSAEFAULT , "Bad address", |
2789 WSAEINVAL , "Invalid argument", | 2789 WSAEINVAL , "Invalid argument", |
2790 WSAEMFILE , "Too many open files", | 2790 WSAEMFILE , "Too many open files", |
2791 | 2791 |
2792 WSAEWOULDBLOCK , "Resource temporarily unavailable", | 2792 WSAEWOULDBLOCK , "Resource temporarily unavailable", |
2793 WSAEINPROGRESS , "Operation now in progress", | 2793 WSAEINPROGRESS , "Operation now in progress", |
2794 WSAEALREADY , "Operation already in progress", | 2794 WSAEALREADY , "Operation already in progress", |
2795 WSAENOTSOCK , "Socket operation on non-socket", | 2795 WSAENOTSOCK , "Socket operation on non-socket", |
2796 WSAEDESTADDRREQ , "Destination address required", | 2796 WSAEDESTADDRREQ , "Destination address required", |
2824 WSAEPROCLIM , "Too many processes", | 2824 WSAEPROCLIM , "Too many processes", |
2825 WSAEUSERS , "Too many users", /* not sure */ | 2825 WSAEUSERS , "Too many users", /* not sure */ |
2826 WSAEDQUOT , "Double quote in host name", /* really not sure */ | 2826 WSAEDQUOT , "Double quote in host name", /* really not sure */ |
2827 WSAESTALE , "Data is stale", /* not sure */ | 2827 WSAESTALE , "Data is stale", /* not sure */ |
2828 WSAEREMOTE , "Remote error", /* not sure */ | 2828 WSAEREMOTE , "Remote error", /* not sure */ |
2829 | 2829 |
2830 WSASYSNOTREADY , "Network subsystem is unavailable", | 2830 WSASYSNOTREADY , "Network subsystem is unavailable", |
2831 WSAVERNOTSUPPORTED , "WINSOCK.DLL version out of range", | 2831 WSAVERNOTSUPPORTED , "WINSOCK.DLL version out of range", |
2832 WSANOTINITIALISED , "Winsock not initialized successfully", | 2832 WSANOTINITIALISED , "Winsock not initialized successfully", |
2833 WSAEDISCON , "Graceful shutdown in progress", | 2833 WSAEDISCON , "Graceful shutdown in progress", |
2834 #ifdef WSAENOMORE | 2834 #ifdef WSAENOMORE |
2842 WSATYPE_NOT_FOUND , "Class type not found", | 2842 WSATYPE_NOT_FOUND , "Class type not found", |
2843 WSA_E_NO_MORE , "No more resources available", /* really not sure */ | 2843 WSA_E_NO_MORE , "No more resources available", /* really not sure */ |
2844 WSA_E_CANCELLED , "Operation already cancelled", /* really not sure */ | 2844 WSA_E_CANCELLED , "Operation already cancelled", /* really not sure */ |
2845 WSAEREFUSED , "Operation refused", /* not sure */ | 2845 WSAEREFUSED , "Operation refused", /* not sure */ |
2846 #endif | 2846 #endif |
2847 | 2847 |
2848 WSAHOST_NOT_FOUND , "Host not found", | 2848 WSAHOST_NOT_FOUND , "Host not found", |
2849 WSATRY_AGAIN , "Authoritative host not found during name lookup", | 2849 WSATRY_AGAIN , "Authoritative host not found during name lookup", |
2850 WSANO_RECOVERY , "Non-recoverable error during name lookup", | 2850 WSANO_RECOVERY , "Non-recoverable error during name lookup", |
2851 WSANO_DATA , "Valid name, no data record of requested type", | 2851 WSANO_DATA , "Valid name, no data record of requested type", |
2852 | 2852 |
2897 | 2897 |
2898 check_errno (); | 2898 check_errno (); |
2899 | 2899 |
2900 /* call the real socket function */ | 2900 /* call the real socket function */ |
2901 s = pfn_socket (af, type, protocol); | 2901 s = pfn_socket (af, type, protocol); |
2902 | 2902 |
2903 if (s != INVALID_SOCKET) | 2903 if (s != INVALID_SOCKET) |
2904 return socket_to_fd (s); | 2904 return socket_to_fd (s); |
2905 | 2905 |
2906 set_errno (); | 2906 set_errno (); |
2907 return -1; | 2907 return -1; |
2970 } | 2970 } |
2971 else | 2971 else |
2972 { | 2972 { |
2973 CloseHandle (new_s); | 2973 CloseHandle (new_s); |
2974 } | 2974 } |
2975 } | 2975 } |
2976 } | 2976 } |
2977 } | 2977 } |
2978 fd_info[fd].hnd = (HANDLE) s; | 2978 fd_info[fd].hnd = (HANDLE) s; |
2979 #endif | 2979 #endif |
2980 | 2980 |
3183 if (rc == SOCKET_ERROR) | 3183 if (rc == SOCKET_ERROR) |
3184 set_errno (); | 3184 set_errno (); |
3185 return rc; | 3185 return rc; |
3186 } | 3186 } |
3187 h_errno = ENOTSOCK; | 3187 h_errno = ENOTSOCK; |
3188 return SOCKET_ERROR; | 3188 return SOCKET_ERROR; |
3189 } | 3189 } |
3190 | 3190 |
3191 int | 3191 int |
3192 sys_listen (int s, int backlog) | 3192 sys_listen (int s, int backlog) |
3193 { | 3193 { |
3204 if (rc == SOCKET_ERROR) | 3204 if (rc == SOCKET_ERROR) |
3205 set_errno (); | 3205 set_errno (); |
3206 return rc; | 3206 return rc; |
3207 } | 3207 } |
3208 h_errno = ENOTSOCK; | 3208 h_errno = ENOTSOCK; |
3209 return SOCKET_ERROR; | 3209 return SOCKET_ERROR; |
3210 } | 3210 } |
3211 | 3211 |
3212 int | 3212 int |
3213 sys_getsockname (int s, struct sockaddr * name, int * namelen) | 3213 sys_getsockname (int s, struct sockaddr * name, int * namelen) |
3214 { | 3214 { |
3225 if (rc == SOCKET_ERROR) | 3225 if (rc == SOCKET_ERROR) |
3226 set_errno (); | 3226 set_errno (); |
3227 return rc; | 3227 return rc; |
3228 } | 3228 } |
3229 h_errno = ENOTSOCK; | 3229 h_errno = ENOTSOCK; |
3230 return SOCKET_ERROR; | 3230 return SOCKET_ERROR; |
3231 } | 3231 } |
3232 | 3232 |
3233 int | 3233 int |
3234 sys_accept (int s, struct sockaddr * addr, int * addrlen) | 3234 sys_accept (int s, struct sockaddr * addr, int * addrlen) |
3235 { | 3235 { |
3423 } | 3423 } |
3424 | 3424 |
3425 /* make sure we close the destination first if it's a pipe or socket */ | 3425 /* make sure we close the destination first if it's a pipe or socket */ |
3426 if (src != dst && fd_info[dst].flags != 0) | 3426 if (src != dst && fd_info[dst].flags != 0) |
3427 sys_close (dst); | 3427 sys_close (dst); |
3428 | 3428 |
3429 rc = _dup2 (src, dst); | 3429 rc = _dup2 (src, dst); |
3430 if (rc == 0) | 3430 if (rc == 0) |
3431 { | 3431 { |
3432 /* duplicate our internal info as well */ | 3432 /* duplicate our internal info as well */ |
3433 fd_info[dst] = fd_info[src]; | 3433 fd_info[dst] = fd_info[src]; |
3483 || (fd_info[fd].flags & FILE_READ) == 0) | 3483 || (fd_info[fd].flags & FILE_READ) == 0) |
3484 { | 3484 { |
3485 DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe or socket!\n", fd)); | 3485 DebPrint (("_sys_read_ahead: internal error: fd %d is not a pipe or socket!\n", fd)); |
3486 abort (); | 3486 abort (); |
3487 } | 3487 } |
3488 | 3488 |
3489 cp->status = STATUS_READ_IN_PROGRESS; | 3489 cp->status = STATUS_READ_IN_PROGRESS; |
3490 | 3490 |
3491 if (fd_info[fd].flags & FILE_PIPE) | 3491 if (fd_info[fd].flags & FILE_PIPE) |
3492 { | 3492 { |
3493 rc = _read (fd, &cp->chr, sizeof (char)); | 3493 rc = _read (fd, &cp->chr, sizeof (char)); |
3494 | 3494 |
3495 /* Give subprocess time to buffer some more output for us before | 3495 /* Give subprocess time to buffer some more output for us before |
3527 nblock = 1; | 3527 nblock = 1; |
3528 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); | 3528 pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); |
3529 } | 3529 } |
3530 } | 3530 } |
3531 #endif | 3531 #endif |
3532 | 3532 |
3533 if (rc == sizeof (char)) | 3533 if (rc == sizeof (char)) |
3534 cp->status = STATUS_READ_SUCCEEDED; | 3534 cp->status = STATUS_READ_SUCCEEDED; |
3535 else | 3535 else |
3536 cp->status = STATUS_READ_FAILED; | 3536 cp->status = STATUS_READ_FAILED; |
3537 | 3537 |
3726 /* insert '\r' before '\n' */ | 3726 /* insert '\r' before '\n' */ |
3727 next[-1] = '\r'; | 3727 next[-1] = '\r'; |
3728 next[0] = '\n'; | 3728 next[0] = '\n'; |
3729 dst = next + 1; | 3729 dst = next + 1; |
3730 count++; | 3730 count++; |
3731 } | 3731 } |
3732 else | 3732 else |
3733 /* copied remaining partial line -> now finished */ | 3733 /* copied remaining partial line -> now finished */ |
3734 break; | 3734 break; |
3735 } | 3735 } |
3736 buffer = tmpbuf; | 3736 buffer = tmpbuf; |
3779 | 3779 |
3780 /* A common indication that Emacs is not installed properly is when | 3780 /* A common indication that Emacs is not installed properly is when |
3781 it cannot find the Windows installation file. If this file does | 3781 it cannot find the Windows installation file. If this file does |
3782 not exist in the expected place, tell the user. */ | 3782 not exist in the expected place, tell the user. */ |
3783 | 3783 |
3784 if (!noninteractive && !inhibit_window_system) | 3784 if (!noninteractive && !inhibit_window_system) |
3785 { | 3785 { |
3786 extern Lisp_Object Vwindow_system, Vload_path, Qfile_exists_p; | 3786 extern Lisp_Object Vwindow_system, Vload_path, Qfile_exists_p; |
3787 Lisp_Object objs[2]; | 3787 Lisp_Object objs[2]; |
3788 Lisp_Object full_load_path; | 3788 Lisp_Object full_load_path; |
3789 Lisp_Object init_file; | 3789 Lisp_Object init_file; |
3792 objs[0] = Vload_path; | 3792 objs[0] = Vload_path; |
3793 objs[1] = decode_env_path (0, (getenv ("EMACSLOADPATH"))); | 3793 objs[1] = decode_env_path (0, (getenv ("EMACSLOADPATH"))); |
3794 full_load_path = Fappend (2, objs); | 3794 full_load_path = Fappend (2, objs); |
3795 init_file = build_string ("term/w32-win"); | 3795 init_file = build_string ("term/w32-win"); |
3796 fd = openp (full_load_path, init_file, Vload_suffixes, NULL, Qnil); | 3796 fd = openp (full_load_path, init_file, Vload_suffixes, NULL, Qnil); |
3797 if (fd < 0) | 3797 if (fd < 0) |
3798 { | 3798 { |
3799 Lisp_Object load_path_print = Fprin1_to_string (full_load_path, Qnil); | 3799 Lisp_Object load_path_print = Fprin1_to_string (full_load_path, Qnil); |
3800 char *init_file_name = SDATA (init_file); | 3800 char *init_file_name = SDATA (init_file); |
3801 char *load_path = SDATA (load_path_print); | 3801 char *load_path = SDATA (load_path_print); |
3802 char *buffer = alloca (1024); | 3802 char *buffer = alloca (1024); |
3803 | 3803 |
3804 sprintf (buffer, | 3804 sprintf (buffer, |
3805 "The Emacs Windows initialization file \"%s.el\" " | 3805 "The Emacs Windows initialization file \"%s.el\" " |
3806 "could not be found in your Emacs installation. " | 3806 "could not be found in your Emacs installation. " |
3807 "Emacs checked the following directories for this file:\n" | 3807 "Emacs checked the following directories for this file:\n" |
3808 "\n%s\n\n" | 3808 "\n%s\n\n" |
3809 "When Emacs cannot find this file, it usually means that it " | 3809 "When Emacs cannot find this file, it usually means that it " |
3864 | 3864 |
3865 parent = GetCurrentProcess (); | 3865 parent = GetCurrentProcess (); |
3866 | 3866 |
3867 /* ignore errors when duplicating and closing; typically the | 3867 /* ignore errors when duplicating and closing; typically the |
3868 handles will be invalid when running as a gui program. */ | 3868 handles will be invalid when running as a gui program. */ |
3869 DuplicateHandle (parent, | 3869 DuplicateHandle (parent, |
3870 GetStdHandle (STD_INPUT_HANDLE), | 3870 GetStdHandle (STD_INPUT_HANDLE), |
3871 parent, | 3871 parent, |
3872 &stdin_save, | 3872 &stdin_save, |
3873 0, | 3873 0, |
3874 FALSE, | 3874 FALSE, |
3875 DUPLICATE_SAME_ACCESS); | 3875 DUPLICATE_SAME_ACCESS); |
3876 | 3876 |
3877 DuplicateHandle (parent, | 3877 DuplicateHandle (parent, |
3878 GetStdHandle (STD_OUTPUT_HANDLE), | 3878 GetStdHandle (STD_OUTPUT_HANDLE), |
3879 parent, | 3879 parent, |
3880 &stdout_save, | 3880 &stdout_save, |
3881 0, | 3881 0, |
3882 FALSE, | 3882 FALSE, |
3883 DUPLICATE_SAME_ACCESS); | 3883 DUPLICATE_SAME_ACCESS); |
3884 | 3884 |
3885 DuplicateHandle (parent, | 3885 DuplicateHandle (parent, |
3886 GetStdHandle (STD_ERROR_HANDLE), | 3886 GetStdHandle (STD_ERROR_HANDLE), |
3887 parent, | 3887 parent, |
3888 &stderr_save, | 3888 &stderr_save, |
3889 0, | 3889 0, |
3890 FALSE, | 3890 FALSE, |
3891 DUPLICATE_SAME_ACCESS); | 3891 DUPLICATE_SAME_ACCESS); |
3892 | 3892 |
3893 fclose (stdin); | 3893 fclose (stdin); |
3894 fclose (stdout); | 3894 fclose (stdout); |
3895 fclose (stderr); | 3895 fclose (stderr); |
3896 | 3896 |
3897 if (stdin_save != INVALID_HANDLE_VALUE) | 3897 if (stdin_save != INVALID_HANDLE_VALUE) |
3924 | 3924 |
3925 /* Loop over all possible drive letters */ | 3925 /* Loop over all possible drive letters */ |
3926 while (*drive <= 'Z') | 3926 while (*drive <= 'Z') |
3927 { | 3927 { |
3928 /* Record if this drive letter refers to a fixed drive. */ | 3928 /* Record if this drive letter refers to a fixed drive. */ |
3929 fixed_drives[DRIVE_INDEX (*drive)] = | 3929 fixed_drives[DRIVE_INDEX (*drive)] = |
3930 (GetDriveType (drive) == DRIVE_FIXED); | 3930 (GetDriveType (drive) == DRIVE_FIXED); |
3931 | 3931 |
3932 (*drive)++; | 3932 (*drive)++; |
3933 } | 3933 } |
3934 | 3934 |
3935 /* Reset the volume info cache. */ | 3935 /* Reset the volume info cache. */ |
3936 volume_cache = NULL; | 3936 volume_cache = NULL; |
3937 } | 3937 } |
3938 | 3938 |
3939 /* Check to see if Emacs has been installed correctly. */ | 3939 /* Check to see if Emacs has been installed correctly. */ |
3940 check_windows_init_file (); | 3940 check_windows_init_file (); |
3941 } | 3941 } |
3942 | 3942 |
3943 /* | 3943 /* |