1994-11-01 10:27:02 +00:00
|
|
|
/* Utility and Unix shadow routines for GNU Emacs support programs on NT.
|
2012-08-09 23:59:38 +00:00
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
Copyright (C) 1994, 2001-2024 Free Software Foundation, Inc.
|
2012-08-09 23:59:38 +00:00
|
|
|
|
|
|
|
Author: Geoff Voelker (voelker@cs.washington.edu)
|
|
|
|
Created: 10-8-94
|
1994-11-01 10:27:02 +00:00
|
|
|
|
1996-01-15 09:18:04 +00:00
|
|
|
This file is part of GNU Emacs.
|
|
|
|
|
2008-05-09 23:19:13 +00:00
|
|
|
GNU Emacs is free software: you can redistribute it and/or modify
|
1996-01-15 09:18:04 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2016-03-10 15:34:52 +00:00
|
|
|
the Free Software Foundation, either version 3 of the License, or (at
|
|
|
|
your option) any later version.
|
1996-01-15 09:18:04 +00:00
|
|
|
|
|
|
|
GNU Emacs 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
|
2017-09-30 00:44:23 +00:00
|
|
|
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
1994-11-01 10:27:02 +00:00
|
|
|
|
2021-10-24 17:45:56 +00:00
|
|
|
#define DEFER_MS_W32_H
|
2021-10-24 03:35:18 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
1994-11-01 10:27:02 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
1996-05-03 18:28:37 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <direct.h>
|
2008-05-09 20:37:32 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <errno.h>
|
2011-03-23 16:25:38 +00:00
|
|
|
#include <ctype.h>
|
Support x64 build on MS-Windows with MSVC.
src/w32term.h (SCROLL_BAR_PACK, SCROLL_BAR_UNPACK): Define for x64.
(SET_SCROLL_BAR_W32_WINDOW): Cast ID to intptr_t, for
compatibility with x64.
src/w32term.c (w32_draw_underwave): Don't use GCC extensions for
defining an XRectangle structure.
src/w32proc.c (RVA_TO_PTR, w32_executable_type): Fix pointer
arithmetics for compatibility with x64.
src/w32menu.c (add_menu_item): Use UINT_PTR instead of UINT, for
compatibility with x64.
src/w32heap.h: Adjust prototypes and declarations.
src/w32heap.c (RVA_TO_PTR, allocate_heap, sbrk, init_heap)
(round_heap): Use DWORD_PTR, ptrdiff_t and size_t instead of
DWORD, long, and unsigned long, for compatibility with x64.
(allocate_heap) [_WIN64]: Reserve 32GB of memory.
(sbrk): Argument is now of type ptrdiff_t.
src/w32fns.c (HMONITOR): Condition declaration on _WIN32_WINNT being
less than 0x0500.
(w32_msg_pump): Use WPARAM type for 'result'.
src/w32.c (init_environment, get_emacs_configuration): Support AMD64
architecture.
(init_ntproc): Cast arguments of _open_osfhandle to intptr_t, for
compatibility with x64.
src/vm-limit.c (lim_data): Now size_t.
(check_memory_limits): Adjust prototypes of real_morecore and
__morecore to receive argument of type ptrdiff_t. Use size_t for
five_percent and data_size.
src/unexw32.c: Use DWORD_PTR instead of DWORD for file-scope
variables, for compatibility with x64.
(rva_to_section, offset_to_section, relocate_offset)
(OFFSET_TO_RVA, RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET)
(PTR_TO_RVA, RVA_TO_PTR, OFFSET_TO_PTR, get_section_info)
(copy_executable_and_dump_data): Use DWORD_PTR instead of DWORD
for compatibility with x64.
src/sysdep.c (STDERR_FILENO): Define if not already defined.
src/ralloc.c (real_morecore): Argument type is now ptrdiff_t.
(__morecore): Argument type is now ptrdiff_t.
(ROUNDUP, MEM_ROUNDUP): Use size_t instead of 'unsigned long'.
(relinquish): Use ptrdiff_t type for 'excess'.
(r_alloc_sbrk): Argument type is now ptrdiff_t.
src/makefile.w32-in (HEAPSIZE): Get value from EMACS_HEAPSIZE.
(bootstrap-temacs-CMD, bootstrap-temacs-SH): Use $(EMACS_PURESIZE)
instead of a literal number.
src/gmalloc.c [WINDOWSNT]: Include w32heap.h.
(min): Define only if not already defined.
src/frame.c (x_report_frame_params): Use EMACS_UINT for the return
value of FRAME_X_WINDOW, to fit a 64-bit pointer on 64-bit Windows
hosts.
src/image.c (x_bitmap_pixmap): Return ptrdiff_t, not int, since
'bitmaps' is a pointer.
src/dispextern.h (x_bitmap_pixmap): Adjust prototype.
src/alloc.c (gdb_make_enums_visible): Now conditional on __GNUC__.
nt/makefile.w32-in ($(TRES)): Use $(EMACS_MANIFEST).
nt/inc/sys/socket.h: Don't map Winsock error codes to standard ones
that are already defined.
nt/inc/ms-w32.h (EMACS_INT, EMACS_UINT, EMACS_INT_MAX, PRIuMAX)
(pI, _INTPTR) [_MSC_VER]: Fix definitions for MSVC.
[_MSC_VER]: Add pragmas to suppress some MSVC warnings.
nt/preprep.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_move_sections, ADJUST_IMPORT_RVA, main): Use
DWORD_PTR instead of DWORD for compatibility with x64.
nt/nmake.defs: Support AMD64.
(EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST): New macros.
nt/gmake.defs: (EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST):
New macros.
nt/addsection.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_add_section, main): Use DWORD_PTR instead of
DWORD, for compatibility with x64.
nt/emacs-x64.manifest: New file.
nt/emacs-x86.manifest: Renamed from emacs.manifest.
lib-src/ntlib.c (gettimeofday): Copy from src/w32.c. lib/gettime.
needs this function.
2012-09-30 21:36:42 +00:00
|
|
|
#include <sys/timeb.h>
|
2012-10-17 21:13:20 +00:00
|
|
|
#include <mbstring.h>
|
2018-08-06 14:50:55 +00:00
|
|
|
#include <locale.h>
|
|
|
|
|
|
|
|
#include <nl_types.h>
|
|
|
|
#include <langinfo.h>
|
1996-05-03 18:28:37 +00:00
|
|
|
|
|
|
|
#include "ntlib.h"
|
1994-11-01 10:27:02 +00:00
|
|
|
|
Fix compiler warnings in the MinGW build
* configure.ac [mingw32]: Don't add -Wpointer-sign, and add
-Wno-pointer-sign, to keep the noise level down.
* nt/mingw-cfg.site (gl_cv_warn_c__Wredundant_decls): Disable
-Wredundant-decls, as that produces a lot of noise due to
redeclaration of time-related functions by gnulib.
* nt/runemacs.c (set_user_model_id): Fix argument type of
'SetCurrentProcessExplicitAppUserModelID'.
* src/image.c (x_create_bitmap_from_file) [HAVE_NTGUI]: Don't
declare 'dpyinfo', as it is unused.
(xpm_load): Fix warnings about pointer signedness.
* src/w32proc.c (IsValidLocale, init_winsock): Remove redundant
prototypes.
(sys_spawnve): Avoid warnings about discarding 'const' qualifier.
(sys_select): Provide prototype.
(g_b_init_compare_string_w): Move declaration to file scope.
* src/w32heap.c (dumped_data_commit): Now static.
(FREEABLE_P): Avoid warnings about pointer comparison with integer.
(mmap_realloc): Cast to 'char *' for arithmetics on void pointers.
* src/w32console.c (ctrl_c_handler, sys_tputs, sys_tgetstr)
(evalcost, cmputc, cmcheckmagic, cmcostinit, cmgoto, Wcm_clear):
Provide prototypes.
* src/w32.c (globals_of_w32, conv_sockaddr_to_lisp): Remove
redundant prototypes.
(w32_get_internal_run_time, map_w32_filename): Provide prototype.
(init_environment, sys_ctime): Avoid warnings about discarding
'const' qualifier.
Include utimens.h.
(sys_ctime, sys_chdir, sys_creat, sys_fopen, sys_mkdir)
(sys_open, sys_rename, sys_rmdir, is_slow_fs, term_winsock)
(sys_close, sys_dup2, sys_read, sys_write, sys_localtime): Provide
prototypes.
(sys_rename_replace): Use %d to avoid compiler warnings.
(_wsa_errlist): Make the message text 'const char *', to avoid
compilation warnings.
(dynlib_reset_last_error): Move prototype to file scope.
(w32_get_resource): First argument is now 'const char *'.
* src/w32uniscribe.c (syms_of_w32uniscribe): Provide prototype.
(otf_features): Second argument is no 'const char *'.
* src/w32term.c (free_frame_menubar, x_wm_set_size_hint)
(x_set_window_size): Remove redundant prototypes.
(XChangeGC, XGetGCValues, w32_draw_underwave)
(w32_draw_rectangle, w32_shift_glyphs_for_insert, x_mouse_leave)
(x_calc_absolute_position, x_destroy_window): Now static.
(menubar_selection_callback): Move prototype to file scope.
* src/w32font.c (g_b_init_get_glyph_outline_w): Remove redundant
declaration.
(w32_to_x_charset): Fix warnings about discarding 'const' qualifier.
(w32font_full_name): Fix warnings about implicit conversion of
'float' to 'double'.
* src/w32reg.c (w32_get_rdb_resource): Fix warnings about
discarding 'const' qualifier.
* src/w32menu.c (syms_of_w32menu, globals_of_w32menu)
(set_frame_menubar): Remove redundant prototypes.
(menubar_selection_callback, w32_menu_display_help): Provide
prototypes.
(simple_dialog_show): Avoid warnings about discarding 'const'
qualifier.
* src/w32fns.c (syms_of_w32fns, globals_of_w32fns)
(free_frame_menubar, w32_strerror, x_set_menu_bar_lines)
(x_set_tool_bar_lines, x_set_internal_border_width): Remove
redundant prototypes.
(current_popup_menu): Remove redundant declaration.
(colormap_t): Member 'name' is now 'const char *'.
(add_system_logical_colors_to_map): Fix signed/unsigned warnings.
(x_decode_color, x_set_border_pixel)
(x_clear_under_internal_border, x_set_name, hook_w32_key)
(reset_w32_kbdhook_state, deliver_wm_chars, w32_backtrace): Now
static.
(w32_load_cursor, w32_key_to_modifier, map_keypad_keys)
(w32_msg_worker, w32_last_error): Provide prototypes.
(funhook, lookup_vk_code): Avoid warnings about missing
parentheses.
(x_default_font_parameter, Fw32_notification_notify): Avoid
warnings about discarding 'const' qualifier.
(Fx_create_frame): Avoid warnings about empty body of 'else'.
(x_screen_planes): Ifdef away unused function.
(Fx_show_tip): Remove unused variables.
(Fw32_battery_status): Avoid warnings about implicit promotion
from float to double.
(Fw32_notification_notify): Initialize 'timeout'.
* src/profiler.c (profiler_cpu_running) [HAVE_ITIMERSPEC]: Only
define the TIMER_SETTIME_RUNNING value if it will be used.
* src/w32notify.c (send_notifications): Ifdef away an empty if
clause. Remove unused variable.
(watch_end, watch_completion): Provide prototypes.
* src/sound.c (sound_warning) [WINDOWSNT]: Don't define: unused.
* src/callproc.c (child_setup, getenv_internal_1) [WINDOWSNT]: Fix
warning with pointer signedness.
* src/gnutls.c (gnutls_x509_crt_get_signature)
(gnutls_alert_send_appropriate) [WINDOWSNT]: Don't define, and
don't load them from the GnuTLS library, as they are no longer
used.
* src/process.c (DATAGRAM_CHAN_P) [!DATAGRAM_SOCKETS]: Don't
define, as it's unused.
* src/unexw32.c (open_input_file, open_output_file)
(close_file_data): Remove redundant prototypes.
(_start): provide prototype.
(mainCRTStartup): Move prototype to file level.
(find_section): Use type-cast to shut up compiler warnings.
(offset_to_section, relocate_offset): Now static.
(find_section): First argument is now a 'const char *'.
(offset_to_section): Ifdef away, as it's unused.
* src/w32heap.h (find_section): Adjust prototype.
* src/dynlib.c (dynlib_reset_last_error): Provide prototype.
* src/dired.c (directory_files_internal_w32_unwind): Avoid
warnings about missing prototypes.
(is_slow_fs) [WINDOWSNT]: Provide prototype at file level.
(directory_files_internal) [WINDOWSNT]: Fix warnings about pointer
signedness.
* src/fileio.c (Ffile_writable_p, Ffile_regular_p) [WINDOWSNT]:
Fix warnings about pointer signedness.
* src/filelock.c (WTMP_FILE) [WINDOWSNT]: Don't define, it's
unused.
* src/sysdep.c (_getpid): Remove redundant prototype.
(sys_subshell) [DOS_NT]: Don't define 'status', it's unused.
[!MSDOS]: Don't define 'st', it's unused.
(init_sys_modes) [DOS_NT]: Don't define 'terminal', it's unused.
(str_collate) [WINDOWSNT]: Avoid warnings about pointer signedness.
* src/keyboard.c (tty_read_avail_input) [WINDOWSNT]: Don't define
n_to_read, as it is not used.
(MAX_ENCODED_BYTES) [WINDOWSNT]: Don't define, as it's unused.
* src/w32font.h (syms_of_w32font): Remove redundant prototype.
* src/xfaces.c (x_display_info) [HAVE_NTGUI]: Remove unused macro.
* src/term.c (init_tty) [DOS_NT]: Ifdef away variables that are
not used by DOS_NT builds, to avoid compiler warnings.
* src/menu.c (current_popup_menu) [HAVE_NTGUI]: Remove redundant
declaration.
* src/dispnew.c (init_display) [WINDOWSNT]: Use type-cast to shut
up compiler warnings.
* src/w32term.h (x_set_window_size, x_get_focus_frame)
(x_make_frame_visible, x_make_frame_invisible, x_iconify_frame)
(x_set_frame_alpha, x_activate_menubar, x_bitmap_icon)
(x_free_frame_resources, x_real_positions)
(display_x_get_resource): Remove redundant prototypes.
* lib-src/ntlib.c (sys_ctime, sys_fopen, sys_chdir, mkostemp)
(sys_rename, gettimeofday): Provide prototypes.
* lib-src/ntlib.h (getuid, geteuid, mkostemp): Remove redundant
declarations.
* lib-src/emacsclient.c (w32_getenv): Argument is now 'const char *'.
(xstrdup, w32_get_resource, w32_window_app, w32_execvp, ttyname)
(close_winsock, initialize_sockets, w32_set_user_model_id)
(w32_find_emacs_process, w32_give_focus) [WINDOWSNT]: Add
prototypes.
(w32_get_resource) [WINDOWSNT]: Fix a warning about signedness
difference.
(w32_set_user_model_id): Update prototype of
SetCurrentProcessExplicitAppUserModelID to avoid compiler
warnings.
(start_daemon_and_retry_set_socket) [WINDOWSNT]: Use type-cast to
shut up compiler warnings.
* lib-src/etags.c (MAXPATHLEN) [WINDOWSNT]: Remove unused macro.
2016-05-21 17:06:33 +00:00
|
|
|
char *sys_ctime (const time_t *);
|
|
|
|
FILE *sys_fopen (const char *, const char *);
|
2017-08-12 08:29:37 +00:00
|
|
|
int sys_mkdir (const char *, mode_t);
|
Fix compiler warnings in the MinGW build
* configure.ac [mingw32]: Don't add -Wpointer-sign, and add
-Wno-pointer-sign, to keep the noise level down.
* nt/mingw-cfg.site (gl_cv_warn_c__Wredundant_decls): Disable
-Wredundant-decls, as that produces a lot of noise due to
redeclaration of time-related functions by gnulib.
* nt/runemacs.c (set_user_model_id): Fix argument type of
'SetCurrentProcessExplicitAppUserModelID'.
* src/image.c (x_create_bitmap_from_file) [HAVE_NTGUI]: Don't
declare 'dpyinfo', as it is unused.
(xpm_load): Fix warnings about pointer signedness.
* src/w32proc.c (IsValidLocale, init_winsock): Remove redundant
prototypes.
(sys_spawnve): Avoid warnings about discarding 'const' qualifier.
(sys_select): Provide prototype.
(g_b_init_compare_string_w): Move declaration to file scope.
* src/w32heap.c (dumped_data_commit): Now static.
(FREEABLE_P): Avoid warnings about pointer comparison with integer.
(mmap_realloc): Cast to 'char *' for arithmetics on void pointers.
* src/w32console.c (ctrl_c_handler, sys_tputs, sys_tgetstr)
(evalcost, cmputc, cmcheckmagic, cmcostinit, cmgoto, Wcm_clear):
Provide prototypes.
* src/w32.c (globals_of_w32, conv_sockaddr_to_lisp): Remove
redundant prototypes.
(w32_get_internal_run_time, map_w32_filename): Provide prototype.
(init_environment, sys_ctime): Avoid warnings about discarding
'const' qualifier.
Include utimens.h.
(sys_ctime, sys_chdir, sys_creat, sys_fopen, sys_mkdir)
(sys_open, sys_rename, sys_rmdir, is_slow_fs, term_winsock)
(sys_close, sys_dup2, sys_read, sys_write, sys_localtime): Provide
prototypes.
(sys_rename_replace): Use %d to avoid compiler warnings.
(_wsa_errlist): Make the message text 'const char *', to avoid
compilation warnings.
(dynlib_reset_last_error): Move prototype to file scope.
(w32_get_resource): First argument is now 'const char *'.
* src/w32uniscribe.c (syms_of_w32uniscribe): Provide prototype.
(otf_features): Second argument is no 'const char *'.
* src/w32term.c (free_frame_menubar, x_wm_set_size_hint)
(x_set_window_size): Remove redundant prototypes.
(XChangeGC, XGetGCValues, w32_draw_underwave)
(w32_draw_rectangle, w32_shift_glyphs_for_insert, x_mouse_leave)
(x_calc_absolute_position, x_destroy_window): Now static.
(menubar_selection_callback): Move prototype to file scope.
* src/w32font.c (g_b_init_get_glyph_outline_w): Remove redundant
declaration.
(w32_to_x_charset): Fix warnings about discarding 'const' qualifier.
(w32font_full_name): Fix warnings about implicit conversion of
'float' to 'double'.
* src/w32reg.c (w32_get_rdb_resource): Fix warnings about
discarding 'const' qualifier.
* src/w32menu.c (syms_of_w32menu, globals_of_w32menu)
(set_frame_menubar): Remove redundant prototypes.
(menubar_selection_callback, w32_menu_display_help): Provide
prototypes.
(simple_dialog_show): Avoid warnings about discarding 'const'
qualifier.
* src/w32fns.c (syms_of_w32fns, globals_of_w32fns)
(free_frame_menubar, w32_strerror, x_set_menu_bar_lines)
(x_set_tool_bar_lines, x_set_internal_border_width): Remove
redundant prototypes.
(current_popup_menu): Remove redundant declaration.
(colormap_t): Member 'name' is now 'const char *'.
(add_system_logical_colors_to_map): Fix signed/unsigned warnings.
(x_decode_color, x_set_border_pixel)
(x_clear_under_internal_border, x_set_name, hook_w32_key)
(reset_w32_kbdhook_state, deliver_wm_chars, w32_backtrace): Now
static.
(w32_load_cursor, w32_key_to_modifier, map_keypad_keys)
(w32_msg_worker, w32_last_error): Provide prototypes.
(funhook, lookup_vk_code): Avoid warnings about missing
parentheses.
(x_default_font_parameter, Fw32_notification_notify): Avoid
warnings about discarding 'const' qualifier.
(Fx_create_frame): Avoid warnings about empty body of 'else'.
(x_screen_planes): Ifdef away unused function.
(Fx_show_tip): Remove unused variables.
(Fw32_battery_status): Avoid warnings about implicit promotion
from float to double.
(Fw32_notification_notify): Initialize 'timeout'.
* src/profiler.c (profiler_cpu_running) [HAVE_ITIMERSPEC]: Only
define the TIMER_SETTIME_RUNNING value if it will be used.
* src/w32notify.c (send_notifications): Ifdef away an empty if
clause. Remove unused variable.
(watch_end, watch_completion): Provide prototypes.
* src/sound.c (sound_warning) [WINDOWSNT]: Don't define: unused.
* src/callproc.c (child_setup, getenv_internal_1) [WINDOWSNT]: Fix
warning with pointer signedness.
* src/gnutls.c (gnutls_x509_crt_get_signature)
(gnutls_alert_send_appropriate) [WINDOWSNT]: Don't define, and
don't load them from the GnuTLS library, as they are no longer
used.
* src/process.c (DATAGRAM_CHAN_P) [!DATAGRAM_SOCKETS]: Don't
define, as it's unused.
* src/unexw32.c (open_input_file, open_output_file)
(close_file_data): Remove redundant prototypes.
(_start): provide prototype.
(mainCRTStartup): Move prototype to file level.
(find_section): Use type-cast to shut up compiler warnings.
(offset_to_section, relocate_offset): Now static.
(find_section): First argument is now a 'const char *'.
(offset_to_section): Ifdef away, as it's unused.
* src/w32heap.h (find_section): Adjust prototype.
* src/dynlib.c (dynlib_reset_last_error): Provide prototype.
* src/dired.c (directory_files_internal_w32_unwind): Avoid
warnings about missing prototypes.
(is_slow_fs) [WINDOWSNT]: Provide prototype at file level.
(directory_files_internal) [WINDOWSNT]: Fix warnings about pointer
signedness.
* src/fileio.c (Ffile_writable_p, Ffile_regular_p) [WINDOWSNT]:
Fix warnings about pointer signedness.
* src/filelock.c (WTMP_FILE) [WINDOWSNT]: Don't define, it's
unused.
* src/sysdep.c (_getpid): Remove redundant prototype.
(sys_subshell) [DOS_NT]: Don't define 'status', it's unused.
[!MSDOS]: Don't define 'st', it's unused.
(init_sys_modes) [DOS_NT]: Don't define 'terminal', it's unused.
(str_collate) [WINDOWSNT]: Avoid warnings about pointer signedness.
* src/keyboard.c (tty_read_avail_input) [WINDOWSNT]: Don't define
n_to_read, as it is not used.
(MAX_ENCODED_BYTES) [WINDOWSNT]: Don't define, as it's unused.
* src/w32font.h (syms_of_w32font): Remove redundant prototype.
* src/xfaces.c (x_display_info) [HAVE_NTGUI]: Remove unused macro.
* src/term.c (init_tty) [DOS_NT]: Ifdef away variables that are
not used by DOS_NT builds, to avoid compiler warnings.
* src/menu.c (current_popup_menu) [HAVE_NTGUI]: Remove redundant
declaration.
* src/dispnew.c (init_display) [WINDOWSNT]: Use type-cast to shut
up compiler warnings.
* src/w32term.h (x_set_window_size, x_get_focus_frame)
(x_make_frame_visible, x_make_frame_invisible, x_iconify_frame)
(x_set_frame_alpha, x_activate_menubar, x_bitmap_icon)
(x_free_frame_resources, x_real_positions)
(display_x_get_resource): Remove redundant prototypes.
* lib-src/ntlib.c (sys_ctime, sys_fopen, sys_chdir, mkostemp)
(sys_rename, gettimeofday): Provide prototypes.
* lib-src/ntlib.h (getuid, geteuid, mkostemp): Remove redundant
declarations.
* lib-src/emacsclient.c (w32_getenv): Argument is now 'const char *'.
(xstrdup, w32_get_resource, w32_window_app, w32_execvp, ttyname)
(close_winsock, initialize_sockets, w32_set_user_model_id)
(w32_find_emacs_process, w32_give_focus) [WINDOWSNT]: Add
prototypes.
(w32_get_resource) [WINDOWSNT]: Fix a warning about signedness
difference.
(w32_set_user_model_id): Update prototype of
SetCurrentProcessExplicitAppUserModelID to avoid compiler
warnings.
(start_daemon_and_retry_set_socket) [WINDOWSNT]: Use type-cast to
shut up compiler warnings.
* lib-src/etags.c (MAXPATHLEN) [WINDOWSNT]: Remove unused macro.
2016-05-21 17:06:33 +00:00
|
|
|
int sys_chdir (const char *);
|
|
|
|
int mkostemp (char *, int);
|
|
|
|
int sys_rename (const char *, const char *);
|
2017-08-12 08:29:37 +00:00
|
|
|
int sys_open (const char *, int, int);
|
Fix compiler warnings in the MinGW build
* configure.ac [mingw32]: Don't add -Wpointer-sign, and add
-Wno-pointer-sign, to keep the noise level down.
* nt/mingw-cfg.site (gl_cv_warn_c__Wredundant_decls): Disable
-Wredundant-decls, as that produces a lot of noise due to
redeclaration of time-related functions by gnulib.
* nt/runemacs.c (set_user_model_id): Fix argument type of
'SetCurrentProcessExplicitAppUserModelID'.
* src/image.c (x_create_bitmap_from_file) [HAVE_NTGUI]: Don't
declare 'dpyinfo', as it is unused.
(xpm_load): Fix warnings about pointer signedness.
* src/w32proc.c (IsValidLocale, init_winsock): Remove redundant
prototypes.
(sys_spawnve): Avoid warnings about discarding 'const' qualifier.
(sys_select): Provide prototype.
(g_b_init_compare_string_w): Move declaration to file scope.
* src/w32heap.c (dumped_data_commit): Now static.
(FREEABLE_P): Avoid warnings about pointer comparison with integer.
(mmap_realloc): Cast to 'char *' for arithmetics on void pointers.
* src/w32console.c (ctrl_c_handler, sys_tputs, sys_tgetstr)
(evalcost, cmputc, cmcheckmagic, cmcostinit, cmgoto, Wcm_clear):
Provide prototypes.
* src/w32.c (globals_of_w32, conv_sockaddr_to_lisp): Remove
redundant prototypes.
(w32_get_internal_run_time, map_w32_filename): Provide prototype.
(init_environment, sys_ctime): Avoid warnings about discarding
'const' qualifier.
Include utimens.h.
(sys_ctime, sys_chdir, sys_creat, sys_fopen, sys_mkdir)
(sys_open, sys_rename, sys_rmdir, is_slow_fs, term_winsock)
(sys_close, sys_dup2, sys_read, sys_write, sys_localtime): Provide
prototypes.
(sys_rename_replace): Use %d to avoid compiler warnings.
(_wsa_errlist): Make the message text 'const char *', to avoid
compilation warnings.
(dynlib_reset_last_error): Move prototype to file scope.
(w32_get_resource): First argument is now 'const char *'.
* src/w32uniscribe.c (syms_of_w32uniscribe): Provide prototype.
(otf_features): Second argument is no 'const char *'.
* src/w32term.c (free_frame_menubar, x_wm_set_size_hint)
(x_set_window_size): Remove redundant prototypes.
(XChangeGC, XGetGCValues, w32_draw_underwave)
(w32_draw_rectangle, w32_shift_glyphs_for_insert, x_mouse_leave)
(x_calc_absolute_position, x_destroy_window): Now static.
(menubar_selection_callback): Move prototype to file scope.
* src/w32font.c (g_b_init_get_glyph_outline_w): Remove redundant
declaration.
(w32_to_x_charset): Fix warnings about discarding 'const' qualifier.
(w32font_full_name): Fix warnings about implicit conversion of
'float' to 'double'.
* src/w32reg.c (w32_get_rdb_resource): Fix warnings about
discarding 'const' qualifier.
* src/w32menu.c (syms_of_w32menu, globals_of_w32menu)
(set_frame_menubar): Remove redundant prototypes.
(menubar_selection_callback, w32_menu_display_help): Provide
prototypes.
(simple_dialog_show): Avoid warnings about discarding 'const'
qualifier.
* src/w32fns.c (syms_of_w32fns, globals_of_w32fns)
(free_frame_menubar, w32_strerror, x_set_menu_bar_lines)
(x_set_tool_bar_lines, x_set_internal_border_width): Remove
redundant prototypes.
(current_popup_menu): Remove redundant declaration.
(colormap_t): Member 'name' is now 'const char *'.
(add_system_logical_colors_to_map): Fix signed/unsigned warnings.
(x_decode_color, x_set_border_pixel)
(x_clear_under_internal_border, x_set_name, hook_w32_key)
(reset_w32_kbdhook_state, deliver_wm_chars, w32_backtrace): Now
static.
(w32_load_cursor, w32_key_to_modifier, map_keypad_keys)
(w32_msg_worker, w32_last_error): Provide prototypes.
(funhook, lookup_vk_code): Avoid warnings about missing
parentheses.
(x_default_font_parameter, Fw32_notification_notify): Avoid
warnings about discarding 'const' qualifier.
(Fx_create_frame): Avoid warnings about empty body of 'else'.
(x_screen_planes): Ifdef away unused function.
(Fx_show_tip): Remove unused variables.
(Fw32_battery_status): Avoid warnings about implicit promotion
from float to double.
(Fw32_notification_notify): Initialize 'timeout'.
* src/profiler.c (profiler_cpu_running) [HAVE_ITIMERSPEC]: Only
define the TIMER_SETTIME_RUNNING value if it will be used.
* src/w32notify.c (send_notifications): Ifdef away an empty if
clause. Remove unused variable.
(watch_end, watch_completion): Provide prototypes.
* src/sound.c (sound_warning) [WINDOWSNT]: Don't define: unused.
* src/callproc.c (child_setup, getenv_internal_1) [WINDOWSNT]: Fix
warning with pointer signedness.
* src/gnutls.c (gnutls_x509_crt_get_signature)
(gnutls_alert_send_appropriate) [WINDOWSNT]: Don't define, and
don't load them from the GnuTLS library, as they are no longer
used.
* src/process.c (DATAGRAM_CHAN_P) [!DATAGRAM_SOCKETS]: Don't
define, as it's unused.
* src/unexw32.c (open_input_file, open_output_file)
(close_file_data): Remove redundant prototypes.
(_start): provide prototype.
(mainCRTStartup): Move prototype to file level.
(find_section): Use type-cast to shut up compiler warnings.
(offset_to_section, relocate_offset): Now static.
(find_section): First argument is now a 'const char *'.
(offset_to_section): Ifdef away, as it's unused.
* src/w32heap.h (find_section): Adjust prototype.
* src/dynlib.c (dynlib_reset_last_error): Provide prototype.
* src/dired.c (directory_files_internal_w32_unwind): Avoid
warnings about missing prototypes.
(is_slow_fs) [WINDOWSNT]: Provide prototype at file level.
(directory_files_internal) [WINDOWSNT]: Fix warnings about pointer
signedness.
* src/fileio.c (Ffile_writable_p, Ffile_regular_p) [WINDOWSNT]:
Fix warnings about pointer signedness.
* src/filelock.c (WTMP_FILE) [WINDOWSNT]: Don't define, it's
unused.
* src/sysdep.c (_getpid): Remove redundant prototype.
(sys_subshell) [DOS_NT]: Don't define 'status', it's unused.
[!MSDOS]: Don't define 'st', it's unused.
(init_sys_modes) [DOS_NT]: Don't define 'terminal', it's unused.
(str_collate) [WINDOWSNT]: Avoid warnings about pointer signedness.
* src/keyboard.c (tty_read_avail_input) [WINDOWSNT]: Don't define
n_to_read, as it is not used.
(MAX_ENCODED_BYTES) [WINDOWSNT]: Don't define, as it's unused.
* src/w32font.h (syms_of_w32font): Remove redundant prototype.
* src/xfaces.c (x_display_info) [HAVE_NTGUI]: Remove unused macro.
* src/term.c (init_tty) [DOS_NT]: Ifdef away variables that are
not used by DOS_NT builds, to avoid compiler warnings.
* src/menu.c (current_popup_menu) [HAVE_NTGUI]: Remove redundant
declaration.
* src/dispnew.c (init_display) [WINDOWSNT]: Use type-cast to shut
up compiler warnings.
* src/w32term.h (x_set_window_size, x_get_focus_frame)
(x_make_frame_visible, x_make_frame_invisible, x_iconify_frame)
(x_set_frame_alpha, x_activate_menubar, x_bitmap_icon)
(x_free_frame_resources, x_real_positions)
(display_x_get_resource): Remove redundant prototypes.
* lib-src/ntlib.c (sys_ctime, sys_fopen, sys_chdir, mkostemp)
(sys_rename, gettimeofday): Provide prototypes.
* lib-src/ntlib.h (getuid, geteuid, mkostemp): Remove redundant
declarations.
* lib-src/emacsclient.c (w32_getenv): Argument is now 'const char *'.
(xstrdup, w32_get_resource, w32_window_app, w32_execvp, ttyname)
(close_winsock, initialize_sockets, w32_set_user_model_id)
(w32_find_emacs_process, w32_give_focus) [WINDOWSNT]: Add
prototypes.
(w32_get_resource) [WINDOWSNT]: Fix a warning about signedness
difference.
(w32_set_user_model_id): Update prototype of
SetCurrentProcessExplicitAppUserModelID to avoid compiler
warnings.
(start_daemon_and_retry_set_socket) [WINDOWSNT]: Use type-cast to
shut up compiler warnings.
* lib-src/etags.c (MAXPATHLEN) [WINDOWSNT]: Remove unused macro.
2016-05-21 17:06:33 +00:00
|
|
|
|
2013-03-26 08:21:27 +00:00
|
|
|
/* MinGW64 defines _TIMEZONE_DEFINED and defines 'struct timespec' in
|
|
|
|
its system headers. */
|
|
|
|
#ifndef _TIMEZONE_DEFINED
|
Support x64 build on MS-Windows with MSVC.
src/w32term.h (SCROLL_BAR_PACK, SCROLL_BAR_UNPACK): Define for x64.
(SET_SCROLL_BAR_W32_WINDOW): Cast ID to intptr_t, for
compatibility with x64.
src/w32term.c (w32_draw_underwave): Don't use GCC extensions for
defining an XRectangle structure.
src/w32proc.c (RVA_TO_PTR, w32_executable_type): Fix pointer
arithmetics for compatibility with x64.
src/w32menu.c (add_menu_item): Use UINT_PTR instead of UINT, for
compatibility with x64.
src/w32heap.h: Adjust prototypes and declarations.
src/w32heap.c (RVA_TO_PTR, allocate_heap, sbrk, init_heap)
(round_heap): Use DWORD_PTR, ptrdiff_t and size_t instead of
DWORD, long, and unsigned long, for compatibility with x64.
(allocate_heap) [_WIN64]: Reserve 32GB of memory.
(sbrk): Argument is now of type ptrdiff_t.
src/w32fns.c (HMONITOR): Condition declaration on _WIN32_WINNT being
less than 0x0500.
(w32_msg_pump): Use WPARAM type for 'result'.
src/w32.c (init_environment, get_emacs_configuration): Support AMD64
architecture.
(init_ntproc): Cast arguments of _open_osfhandle to intptr_t, for
compatibility with x64.
src/vm-limit.c (lim_data): Now size_t.
(check_memory_limits): Adjust prototypes of real_morecore and
__morecore to receive argument of type ptrdiff_t. Use size_t for
five_percent and data_size.
src/unexw32.c: Use DWORD_PTR instead of DWORD for file-scope
variables, for compatibility with x64.
(rva_to_section, offset_to_section, relocate_offset)
(OFFSET_TO_RVA, RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET)
(PTR_TO_RVA, RVA_TO_PTR, OFFSET_TO_PTR, get_section_info)
(copy_executable_and_dump_data): Use DWORD_PTR instead of DWORD
for compatibility with x64.
src/sysdep.c (STDERR_FILENO): Define if not already defined.
src/ralloc.c (real_morecore): Argument type is now ptrdiff_t.
(__morecore): Argument type is now ptrdiff_t.
(ROUNDUP, MEM_ROUNDUP): Use size_t instead of 'unsigned long'.
(relinquish): Use ptrdiff_t type for 'excess'.
(r_alloc_sbrk): Argument type is now ptrdiff_t.
src/makefile.w32-in (HEAPSIZE): Get value from EMACS_HEAPSIZE.
(bootstrap-temacs-CMD, bootstrap-temacs-SH): Use $(EMACS_PURESIZE)
instead of a literal number.
src/gmalloc.c [WINDOWSNT]: Include w32heap.h.
(min): Define only if not already defined.
src/frame.c (x_report_frame_params): Use EMACS_UINT for the return
value of FRAME_X_WINDOW, to fit a 64-bit pointer on 64-bit Windows
hosts.
src/image.c (x_bitmap_pixmap): Return ptrdiff_t, not int, since
'bitmaps' is a pointer.
src/dispextern.h (x_bitmap_pixmap): Adjust prototype.
src/alloc.c (gdb_make_enums_visible): Now conditional on __GNUC__.
nt/makefile.w32-in ($(TRES)): Use $(EMACS_MANIFEST).
nt/inc/sys/socket.h: Don't map Winsock error codes to standard ones
that are already defined.
nt/inc/ms-w32.h (EMACS_INT, EMACS_UINT, EMACS_INT_MAX, PRIuMAX)
(pI, _INTPTR) [_MSC_VER]: Fix definitions for MSVC.
[_MSC_VER]: Add pragmas to suppress some MSVC warnings.
nt/preprep.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_move_sections, ADJUST_IMPORT_RVA, main): Use
DWORD_PTR instead of DWORD for compatibility with x64.
nt/nmake.defs: Support AMD64.
(EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST): New macros.
nt/gmake.defs: (EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST):
New macros.
nt/addsection.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_add_section, main): Use DWORD_PTR instead of
DWORD, for compatibility with x64.
nt/emacs-x64.manifest: New file.
nt/emacs-x86.manifest: Renamed from emacs.manifest.
lib-src/ntlib.c (gettimeofday): Copy from src/w32.c. lib/gettime.
needs this function.
2012-09-30 21:36:42 +00:00
|
|
|
struct timezone
|
|
|
|
{
|
|
|
|
int tz_minuteswest; /* minutes west of Greenwich */
|
|
|
|
int tz_dsttime; /* type of dst correction */
|
|
|
|
};
|
2013-03-26 08:21:27 +00:00
|
|
|
#endif
|
Support x64 build on MS-Windows with MSVC.
src/w32term.h (SCROLL_BAR_PACK, SCROLL_BAR_UNPACK): Define for x64.
(SET_SCROLL_BAR_W32_WINDOW): Cast ID to intptr_t, for
compatibility with x64.
src/w32term.c (w32_draw_underwave): Don't use GCC extensions for
defining an XRectangle structure.
src/w32proc.c (RVA_TO_PTR, w32_executable_type): Fix pointer
arithmetics for compatibility with x64.
src/w32menu.c (add_menu_item): Use UINT_PTR instead of UINT, for
compatibility with x64.
src/w32heap.h: Adjust prototypes and declarations.
src/w32heap.c (RVA_TO_PTR, allocate_heap, sbrk, init_heap)
(round_heap): Use DWORD_PTR, ptrdiff_t and size_t instead of
DWORD, long, and unsigned long, for compatibility with x64.
(allocate_heap) [_WIN64]: Reserve 32GB of memory.
(sbrk): Argument is now of type ptrdiff_t.
src/w32fns.c (HMONITOR): Condition declaration on _WIN32_WINNT being
less than 0x0500.
(w32_msg_pump): Use WPARAM type for 'result'.
src/w32.c (init_environment, get_emacs_configuration): Support AMD64
architecture.
(init_ntproc): Cast arguments of _open_osfhandle to intptr_t, for
compatibility with x64.
src/vm-limit.c (lim_data): Now size_t.
(check_memory_limits): Adjust prototypes of real_morecore and
__morecore to receive argument of type ptrdiff_t. Use size_t for
five_percent and data_size.
src/unexw32.c: Use DWORD_PTR instead of DWORD for file-scope
variables, for compatibility with x64.
(rva_to_section, offset_to_section, relocate_offset)
(OFFSET_TO_RVA, RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET)
(PTR_TO_RVA, RVA_TO_PTR, OFFSET_TO_PTR, get_section_info)
(copy_executable_and_dump_data): Use DWORD_PTR instead of DWORD
for compatibility with x64.
src/sysdep.c (STDERR_FILENO): Define if not already defined.
src/ralloc.c (real_morecore): Argument type is now ptrdiff_t.
(__morecore): Argument type is now ptrdiff_t.
(ROUNDUP, MEM_ROUNDUP): Use size_t instead of 'unsigned long'.
(relinquish): Use ptrdiff_t type for 'excess'.
(r_alloc_sbrk): Argument type is now ptrdiff_t.
src/makefile.w32-in (HEAPSIZE): Get value from EMACS_HEAPSIZE.
(bootstrap-temacs-CMD, bootstrap-temacs-SH): Use $(EMACS_PURESIZE)
instead of a literal number.
src/gmalloc.c [WINDOWSNT]: Include w32heap.h.
(min): Define only if not already defined.
src/frame.c (x_report_frame_params): Use EMACS_UINT for the return
value of FRAME_X_WINDOW, to fit a 64-bit pointer on 64-bit Windows
hosts.
src/image.c (x_bitmap_pixmap): Return ptrdiff_t, not int, since
'bitmaps' is a pointer.
src/dispextern.h (x_bitmap_pixmap): Adjust prototype.
src/alloc.c (gdb_make_enums_visible): Now conditional on __GNUC__.
nt/makefile.w32-in ($(TRES)): Use $(EMACS_MANIFEST).
nt/inc/sys/socket.h: Don't map Winsock error codes to standard ones
that are already defined.
nt/inc/ms-w32.h (EMACS_INT, EMACS_UINT, EMACS_INT_MAX, PRIuMAX)
(pI, _INTPTR) [_MSC_VER]: Fix definitions for MSVC.
[_MSC_VER]: Add pragmas to suppress some MSVC warnings.
nt/preprep.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_move_sections, ADJUST_IMPORT_RVA, main): Use
DWORD_PTR instead of DWORD for compatibility with x64.
nt/nmake.defs: Support AMD64.
(EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST): New macros.
nt/gmake.defs: (EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST):
New macros.
nt/addsection.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_add_section, main): Use DWORD_PTR instead of
DWORD, for compatibility with x64.
nt/emacs-x64.manifest: New file.
nt/emacs-x86.manifest: Renamed from emacs.manifest.
lib-src/ntlib.c (gettimeofday): Copy from src/w32.c. lib/gettime.
needs this function.
2012-09-30 21:36:42 +00:00
|
|
|
|
1994-11-01 10:27:02 +00:00
|
|
|
#define MAXPATHLEN _MAX_PATH
|
|
|
|
|
|
|
|
/* Emulate sleep...we could have done this with a define, but that
|
|
|
|
would necessitate including windows.h in the files that used it.
|
|
|
|
This is much easier. */
|
2013-03-30 17:00:51 +00:00
|
|
|
unsigned
|
|
|
|
sleep (unsigned seconds)
|
1994-11-01 10:27:02 +00:00
|
|
|
{
|
|
|
|
Sleep (seconds * 1000);
|
2013-03-30 17:00:51 +00:00
|
|
|
return 0;
|
1994-11-01 10:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the current working directory. */
|
1996-07-15 19:57:23 +00:00
|
|
|
char *
|
1994-11-01 10:27:02 +00:00
|
|
|
getwd (char *dir)
|
|
|
|
{
|
1996-05-03 18:28:37 +00:00
|
|
|
if (GetCurrentDirectory (MAXPATHLEN, dir) > 0)
|
|
|
|
return dir;
|
|
|
|
return NULL;
|
1994-11-01 10:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HANDLE getppid_parent;
|
|
|
|
static int getppid_ppid;
|
|
|
|
|
|
|
|
int
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
getppid (void)
|
1994-11-01 10:27:02 +00:00
|
|
|
{
|
|
|
|
char *ppid;
|
|
|
|
DWORD result;
|
|
|
|
|
1998-05-30 23:37:12 +00:00
|
|
|
ppid = getenv ("EM_PARENT_PROCESS_ID");
|
2003-02-04 14:56:31 +00:00
|
|
|
if (!ppid)
|
1994-11-01 10:27:02 +00:00
|
|
|
{
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
printf ("no pid.\n");
|
1994-11-01 10:27:02 +00:00
|
|
|
return 0;
|
2003-02-04 14:56:31 +00:00
|
|
|
}
|
|
|
|
else
|
1994-11-01 10:27:02 +00:00
|
|
|
{
|
|
|
|
getppid_ppid = atoi (ppid);
|
|
|
|
}
|
|
|
|
|
2003-02-04 14:56:31 +00:00
|
|
|
if (!getppid_parent)
|
1994-11-01 10:27:02 +00:00
|
|
|
{
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
getppid_parent = OpenProcess (SYNCHRONIZE, FALSE, atoi (ppid));
|
2003-02-04 14:56:31 +00:00
|
|
|
if (!getppid_parent)
|
1994-11-01 10:27:02 +00:00
|
|
|
{
|
2016-07-22 17:38:22 +00:00
|
|
|
printf ("Failed to open handle to parent process: %lu\n",
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
GetLastError ());
|
1994-11-01 10:27:02 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result = WaitForSingleObject (getppid_parent, 0);
|
2003-02-04 14:56:31 +00:00
|
|
|
switch (result)
|
1994-11-01 10:27:02 +00:00
|
|
|
{
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
/* The parent is still alive. */
|
|
|
|
return getppid_ppid;
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
/* The parent is gone. Return the pid of Unix init (1). */
|
|
|
|
return 1;
|
|
|
|
case WAIT_FAILED:
|
|
|
|
default:
|
2016-07-22 17:38:22 +00:00
|
|
|
printf ("Checking parent status failed: %lu\n", GetLastError ());
|
1994-11-01 10:27:02 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
}
|
1996-05-03 18:28:37 +00:00
|
|
|
|
|
|
|
char *
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
getlogin (void)
|
1996-05-03 18:28:37 +00:00
|
|
|
{
|
|
|
|
static char user_name[256];
|
|
|
|
DWORD length = sizeof (user_name);
|
|
|
|
|
|
|
|
if (GetUserName (user_name, &length))
|
|
|
|
return user_name;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-03-21 11:31:50 +00:00
|
|
|
unsigned
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
getuid (void)
|
1996-05-03 18:28:37 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-30 17:00:51 +00:00
|
|
|
unsigned
|
|
|
|
geteuid (void)
|
|
|
|
{
|
|
|
|
return getuid ();
|
|
|
|
}
|
|
|
|
|
2010-04-03 02:23:51 +00:00
|
|
|
unsigned
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
getgid (void)
|
2010-04-03 02:23:51 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
getegid (void)
|
2010-04-03 02:23:51 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-05-03 18:28:37 +00:00
|
|
|
int
|
2009-03-21 11:31:50 +00:00
|
|
|
setuid (unsigned uid)
|
1996-05-03 18:28:37 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-03 02:23:51 +00:00
|
|
|
int
|
Fix the MS-Windows build broken by 2011-01-17T19:01:01Z!eggert@cs.ucla.edu and emacs-23/2010-05-21T19:51:48Z!acm@muc.de.
lib/makefile.w32-in:
lib/getopt_.h: New files.
src/s/ms-w32.h (HAVE_MKTIME): Remove.
src/makefile.w32-in (LOCAL_FLAGS): Add -I../lib.
(GNULIB): New variable.
(LIBS): Add $(GNULIB).
$(TEMACS): Depend on $(GNULIB).
<top-level>: Fix font-lock disrupted by a lone `"'.
src/makefile.w32-in (LOCAL_FLAGS): Add -I../lib.
(GETOPTOBJS, GETOPTDEPS): Remove targets.
(MOVEMAILOBJS): Replace $(GETOPTOBJS) with ../lib/$(BLD)/libgnu.$(A).
($(BLD)/movemail.exe): Depend on ../lib/getopt.h.
(ECLIENTOBJS, ETAGSOBJ, CTAGSOBJ, EBROWSEOBJ): Replace getopt.o
and getopt1.o with ../lib/$(BLD)/libgnu.$(A).
(clean): Don't remove getopt.h.
(getopt.h, $(BLD)/getopt.$(O), $(BLD)/getopt1.$(O)): Remove targets.
($(BLD)/ctags.$(O), $(BLD)/etags.$(O)): Replace getopt.h with
$(EMACS_ROOT)/lib/getopt.h.
nt/makefile.w32-in (all-other-dirs-nmake, all-other-dirs-gmake)
(bootstrap-nmake, bootstrap-gmake, bootstrap-clean-nmake)
(bootstrap-clean-gmake, clean-other-dirs-nmake)
(clean-other-dirs-gmake, cleanall-other-dirs-nmake)
(cleanall-other-dirs-gmake, distclean-other-dirs-nmake)
(distclean-other-dirs-gmake, maintainer-clean-other-dirs-nmake)
(maintainer-clean-other-dirs-gmake): Recurse into ../lib as well.
nt/configure.bat: Create lib/makefile.
nt/config.nt (HAVE_MKTIME, BROKEN_MKTIME): Remove.
(HAVE_ATTRIBUTE_ALIGNED, HAVE_C99_STRTOLD, HAVE_DECL_GETENV)
(HAVE_DECL_LOCALTIME_R, HAVE_WCHAR_T, PACKAGE, VERSION, inline)
(_GL_UNUSED, _UNUSED_PARAMETER_): Add definitions, for gnulib.
2011-01-29 12:36:11 +00:00
|
|
|
setregid (unsigned rgid, unsigned gid)
|
2010-04-03 02:23:51 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-05-03 18:28:37 +00:00
|
|
|
struct passwd *
|
2009-03-21 11:31:50 +00:00
|
|
|
getpwuid (unsigned uid)
|
1996-05-03 18:28:37 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
getpass (const char * prompt)
|
|
|
|
{
|
|
|
|
static char input[256];
|
|
|
|
HANDLE in;
|
|
|
|
HANDLE err;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
in = GetStdHandle (STD_INPUT_HANDLE);
|
|
|
|
err = GetStdHandle (STD_ERROR_HANDLE);
|
|
|
|
|
|
|
|
if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
|
|
|
|
{
|
|
|
|
int istty = (GetFileType (in) == FILE_TYPE_CHAR);
|
|
|
|
DWORD old_flags;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (istty)
|
|
|
|
{
|
|
|
|
if (GetConsoleMode (in, &old_flags))
|
|
|
|
SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
|
|
|
|
else
|
|
|
|
istty = 0;
|
|
|
|
}
|
|
|
|
rc = ReadFile (in, input, sizeof (input), &count, NULL);
|
|
|
|
if (count >= 2 && input[count - 2] == '\r')
|
|
|
|
input[count - 2] = '\0';
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
while (ReadFile (in, buf, sizeof (buf), &count, NULL) > 0)
|
|
|
|
if (count >= 2 && buf[count - 2] == '\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WriteFile (err, "\r\n", 2, &count, NULL);
|
|
|
|
if (istty)
|
|
|
|
SetConsoleMode (in, old_flags);
|
|
|
|
if (rc)
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2009-03-21 11:31:50 +00:00
|
|
|
fchown (int fd, unsigned uid, unsigned gid)
|
1996-05-03 18:28:37 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE *
|
Convert some more functions to standard C.
* lib-src/emacsclient.c (get_current_dir_name, w32_get_resource)
(w32_getenv, w32_set_user_model_id, w32_window_app, w32_execvp)
(close_winsock, initialize_sockets, w32_find_emacs_process)
(w32_give_focus):
* lib-src/ntlib.c (getlogin, getuid, getgid, getegid):
* nt/addpm.c (add_registry, main):
* nt/cmdproxy.c (get_env_size):
* nt/ddeclient.c (main):
* nt/runemacs.c (set_user_model_id):
* src/alloc.c (emacs_blocked_free, emacs_blocked_malloc)
(emacs_blocked_realloc, uninterrupt_malloc):
* src/fringe.c (w32_reset_fringes):
* src/image.c (convert_mono_to_color_image, lookup_rgb_color)
(init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper):
* src/sound.c (be2hs, do_play_sound):
* src/vm-limit.c (get_lim_data, ret_lim_data):
* src/w32term.c (x_free_frame_resources):
* src/xfaces.c (x_create_gc, x_free_gc):
Convert definitions to standard C.
2010-07-20 20:21:03 +00:00
|
|
|
sys_fopen (const char * path, const char * mode)
|
1996-05-03 18:28:37 +00:00
|
|
|
{
|
|
|
|
return fopen (path, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sys_chdir (const char * path)
|
|
|
|
{
|
|
|
|
return _chdir (path);
|
|
|
|
}
|
2003-09-01 15:45:59 +00:00
|
|
|
|
2017-08-12 08:29:37 +00:00
|
|
|
int
|
|
|
|
sys_mkdir (const char * path, mode_t mode)
|
|
|
|
{
|
|
|
|
return _mkdir (path);
|
|
|
|
}
|
|
|
|
|
2008-05-09 20:37:32 +00:00
|
|
|
static FILETIME utc_base_ft;
|
|
|
|
static long double utc_base;
|
|
|
|
static int init = 0;
|
|
|
|
|
|
|
|
static time_t
|
|
|
|
convert_time (FILETIME ft)
|
|
|
|
{
|
|
|
|
long double ret;
|
|
|
|
|
|
|
|
if (CompareFileTime (&ft, &utc_base_ft) < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = (long double) ft.dwHighDateTime
|
|
|
|
* 4096.0L * 1024.0L * 1024.0L + ft.dwLowDateTime;
|
|
|
|
ret -= utc_base;
|
|
|
|
return (time_t) (ret * 1e-7L);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
is_exec (const char * name)
|
|
|
|
{
|
|
|
|
char * p = strrchr (name, '.');
|
|
|
|
return
|
|
|
|
(p != NULL
|
|
|
|
&& (stricmp (p, ".exe") == 0 ||
|
|
|
|
stricmp (p, ".com") == 0 ||
|
|
|
|
stricmp (p, ".bat") == 0 ||
|
|
|
|
stricmp (p, ".cmd") == 0));
|
|
|
|
}
|
|
|
|
|
2019-04-15 14:17:01 +00:00
|
|
|
/* We need stat/fsfat below because nt/inc/sys/stat.h defines struct
|
|
|
|
stat that is incompatible with the MS run-time libraries. */
|
2008-05-09 20:37:32 +00:00
|
|
|
int
|
|
|
|
stat (const char * path, struct stat * buf)
|
|
|
|
{
|
|
|
|
WIN32_FIND_DATA wfd;
|
|
|
|
HANDLE fh;
|
|
|
|
int permission;
|
|
|
|
int len;
|
|
|
|
int rootdir = FALSE;
|
|
|
|
char *name = alloca (FILENAME_MAX);
|
|
|
|
|
|
|
|
if (!init)
|
|
|
|
{
|
|
|
|
/* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
st.wYear = 1970;
|
|
|
|
st.wMonth = 1;
|
|
|
|
st.wDay = 1;
|
|
|
|
st.wHour = 0;
|
|
|
|
st.wMinute = 0;
|
|
|
|
st.wSecond = 0;
|
|
|
|
st.wMilliseconds = 0;
|
|
|
|
|
|
|
|
SystemTimeToFileTime (&st, &utc_base_ft);
|
|
|
|
utc_base = (long double) utc_base_ft.dwHighDateTime
|
|
|
|
* 4096.0L * 1024.0L * 1024.0L + utc_base_ft.dwLowDateTime;
|
|
|
|
init = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path == NULL || buf == NULL || *path == '\0')
|
|
|
|
{
|
|
|
|
errno = EFAULT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (_mbspbrk (path, "*?|<>\""))
|
|
|
|
{
|
|
|
|
errno = ENOENT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy (name, path);
|
|
|
|
/* Remove trailing directory separator, unless name is the root
|
|
|
|
directory of a drive in which case ensure there is a trailing
|
|
|
|
separator. */
|
|
|
|
len = strlen (name);
|
|
|
|
rootdir = IS_DIRECTORY_SEP (name[0])
|
|
|
|
|| (len == 3 && name[1] == ':' && IS_DIRECTORY_SEP (name[2]));
|
|
|
|
if (rootdir)
|
|
|
|
{
|
|
|
|
if (GetDriveType (name) < 2)
|
|
|
|
{
|
|
|
|
errno = ENOENT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
memset (&wfd, 0, sizeof (wfd));
|
|
|
|
wfd.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
wfd.ftCreationTime = utc_base_ft;
|
|
|
|
wfd.ftLastAccessTime = utc_base_ft;
|
|
|
|
wfd.ftLastWriteTime = utc_base_ft;
|
|
|
|
strcpy (wfd.cFileName, name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (IS_DIRECTORY_SEP (name[len-1]))
|
|
|
|
name[len - 1] = 0;
|
|
|
|
|
|
|
|
fh = FindFirstFile (name, &wfd);
|
|
|
|
if (fh == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
errno = ENOENT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
FindClose (fh);
|
|
|
|
}
|
|
|
|
buf->st_mode = (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ?
|
|
|
|
S_IFDIR : S_IFREG;
|
|
|
|
buf->st_nlink = 1;
|
|
|
|
buf->st_ino = 0;
|
|
|
|
|
|
|
|
if (name[0] && name[1] == ':')
|
|
|
|
buf->st_dev = tolower (name[0]) - 'a' + 1;
|
|
|
|
else
|
|
|
|
buf->st_dev = _getdrive ();
|
|
|
|
buf->st_rdev = buf->st_dev;
|
|
|
|
|
2019-04-15 14:17:01 +00:00
|
|
|
buf->st_size = wfd.nFileSizeHigh;
|
|
|
|
buf->st_size <<= 32;
|
|
|
|
buf->st_size += wfd.nFileSizeLow;
|
2008-05-09 20:37:32 +00:00
|
|
|
|
|
|
|
/* Convert timestamps to Unix format. */
|
|
|
|
buf->st_mtime = convert_time (wfd.ftLastWriteTime);
|
|
|
|
buf->st_atime = convert_time (wfd.ftLastAccessTime);
|
|
|
|
if (buf->st_atime == 0) buf->st_atime = buf->st_mtime;
|
|
|
|
buf->st_ctime = convert_time (wfd.ftCreationTime);
|
|
|
|
if (buf->st_ctime == 0) buf->st_ctime = buf->st_mtime;
|
|
|
|
|
|
|
|
/* determine rwx permissions */
|
|
|
|
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
|
|
|
permission = S_IREAD;
|
|
|
|
else
|
|
|
|
permission = S_IREAD | S_IWRITE;
|
|
|
|
|
|
|
|
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
permission |= S_IEXEC;
|
|
|
|
else if (is_exec (name))
|
|
|
|
permission |= S_IEXEC;
|
|
|
|
|
|
|
|
buf->st_mode |= permission | (permission >> 3) | (permission >> 6);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Support symlinks on latest versions of MS-Windows.
src/w32.c: Include winioctl.h and aclapi.h.
(is_symlink, chase_symlinks, enable_privilege, restore_privilege)
(revert_to_self): Forward declarations of static functions.
<static BOOL g_b_init_get_security_info>:
<g_b_init_create_symbolic_link>: New static flags.
(globals_of_w32): Initialize them to zero.
(GetSecurityInfo_Proc, CreateSymbolicLink_Proc): New typedefs.
(map_w32_filename): Improve commentary. Simplify switch.
(SYMBOLIC_LINK_FLAG_DIRECTORY): Define if not defined in system
headers (most versions of MinGW w32api don't).
(get_security_info, create_symbolic_link)
(get_file_security_desc_by_handle, is_symlink, chase_symlinks):
New functions.
(sys_access, sys_chmod): Call 'chase_symlinks' to resolve symlinks
in the argument file name.
(sys_access): Call unc_volume_file_attributes only if
GetFileAttributes fails with network-related error codes.
(sys_rename): Diagnose renaming of a symlink when the user doesn't
have the required privileges.
(get_file_security_desc_by_name): Renamed from
get_file_security_desc.
(stat_worker): New function, with most of the guts of 'stat', and
with addition of handling of symlinks and support for 'lstat'. If
possible, get file's attributes and security information by
handle, not by name. Produce S_IFLNK bit for symlinks, when
called from 'lstat'.
(stat, lstat): New functions, call 'stat_worker'.
(symlink, readlink, careadlinkat): Rewritten to create and resolve
symlinks when the underlying filesystem supports them.
lib/src/ntlib.c (lstat): New function, calls 'stat'.
nt/inc/sys/stat.h (S_IFLNK): Define.
(S_ISLNK): A non-trivial definition.
(lstat): Prototype instead of a macro that redirects to 'stat'.
lisp/files.el (file-truename): Don't skip symlink-chasing part on
windows-nt. Incorporate the resolution of 8+3 short aliases on
Windows into the loop that recursively chases symlinks. Compare
directory and its parent case-insensitively on MS-Windows and
MS-DOS.
etc/NEWS: Announce the symlink support on MS-Windows.
2012-08-03 10:23:30 +00:00
|
|
|
int
|
|
|
|
lstat (const char * path, struct stat * buf)
|
|
|
|
{
|
|
|
|
return stat (path, buf);
|
|
|
|
}
|
2013-08-04 17:52:25 +00:00
|
|
|
|
2019-04-15 14:17:01 +00:00
|
|
|
int
|
|
|
|
fstat (int desc, struct stat * buf)
|
|
|
|
{
|
|
|
|
HANDLE fh = (HANDLE) _get_osfhandle (desc);
|
|
|
|
BY_HANDLE_FILE_INFORMATION info;
|
|
|
|
unsigned __int64 fake_inode;
|
|
|
|
int permission;
|
|
|
|
|
|
|
|
if (!init)
|
|
|
|
{
|
|
|
|
/* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
st.wYear = 1970;
|
|
|
|
st.wMonth = 1;
|
|
|
|
st.wDay = 1;
|
|
|
|
st.wHour = 0;
|
|
|
|
st.wMinute = 0;
|
|
|
|
st.wSecond = 0;
|
|
|
|
st.wMilliseconds = 0;
|
|
|
|
|
|
|
|
SystemTimeToFileTime (&st, &utc_base_ft);
|
|
|
|
utc_base = (long double) utc_base_ft.dwHighDateTime
|
|
|
|
* 4096.0L * 1024.0L * 1024.0L + utc_base_ft.dwLowDateTime;
|
|
|
|
init = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (GetFileType (fh) & ~FILE_TYPE_REMOTE)
|
|
|
|
{
|
|
|
|
case FILE_TYPE_DISK:
|
|
|
|
buf->st_mode = S_IFREG;
|
|
|
|
if (!GetFileInformationByHandle (fh, &info))
|
|
|
|
{
|
|
|
|
errno = EACCES;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FILE_TYPE_PIPE:
|
|
|
|
buf->st_mode = S_IFIFO;
|
|
|
|
goto non_disk;
|
|
|
|
case FILE_TYPE_CHAR:
|
|
|
|
case FILE_TYPE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
buf->st_mode = S_IFCHR;
|
|
|
|
non_disk:
|
|
|
|
memset (&info, 0, sizeof (info));
|
|
|
|
info.dwFileAttributes = 0;
|
|
|
|
info.ftCreationTime = utc_base_ft;
|
|
|
|
info.ftLastAccessTime = utc_base_ft;
|
|
|
|
info.ftLastWriteTime = utc_base_ft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
buf->st_mode = S_IFDIR;
|
|
|
|
|
|
|
|
buf->st_nlink = info.nNumberOfLinks;
|
|
|
|
/* Might as well use file index to fake inode values, but this
|
|
|
|
is not guaranteed to be unique unless we keep a handle open
|
|
|
|
all the time. */
|
|
|
|
fake_inode = info.nFileIndexHigh;
|
|
|
|
fake_inode <<= 32;
|
|
|
|
fake_inode += info.nFileIndexLow;
|
|
|
|
buf->st_ino = fake_inode;
|
|
|
|
|
|
|
|
buf->st_dev = info.dwVolumeSerialNumber;
|
|
|
|
buf->st_rdev = info.dwVolumeSerialNumber;
|
|
|
|
|
|
|
|
buf->st_size = info.nFileSizeHigh;
|
|
|
|
buf->st_size <<= 32;
|
|
|
|
buf->st_size += info.nFileSizeLow;
|
|
|
|
|
|
|
|
/* Convert timestamps to Unix format. */
|
|
|
|
buf->st_mtime = convert_time (info.ftLastWriteTime);
|
|
|
|
buf->st_atime = convert_time (info.ftLastAccessTime);
|
|
|
|
if (buf->st_atime == 0) buf->st_atime = buf->st_mtime;
|
|
|
|
buf->st_ctime = convert_time (info.ftCreationTime);
|
|
|
|
if (buf->st_ctime == 0) buf->st_ctime = buf->st_mtime;
|
|
|
|
|
|
|
|
/* determine rwx permissions */
|
|
|
|
if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
|
|
|
permission = S_IREAD;
|
|
|
|
else
|
|
|
|
permission = S_IREAD | S_IWRITE;
|
|
|
|
|
|
|
|
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
permission |= S_IEXEC;
|
|
|
|
|
|
|
|
buf->st_mode |= permission | (permission >> 3) | (permission >> 6);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-05 17:09:28 +00:00
|
|
|
/* On Windows, you cannot rename into an existing file. */
|
|
|
|
int
|
|
|
|
sys_rename (const char *from, const char *to)
|
|
|
|
{
|
|
|
|
int retval = rename (from, to);
|
|
|
|
|
|
|
|
if (retval < 0 && errno == EEXIST)
|
|
|
|
{
|
|
|
|
if (unlink (to) == 0)
|
|
|
|
retval = rename (from, to);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
2017-08-12 08:29:37 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
sys_open (const char * path, int oflag, int mode)
|
|
|
|
{
|
|
|
|
return _open (path, oflag, mode);
|
|
|
|
}
|
2018-08-06 14:50:55 +00:00
|
|
|
|
|
|
|
/* Emulation of nl_langinfo that supports only CODESET.
|
|
|
|
Used in Gnulib regex.c. */
|
|
|
|
char *
|
|
|
|
nl_langinfo (nl_item item)
|
|
|
|
{
|
|
|
|
switch (item)
|
|
|
|
{
|
|
|
|
case CODESET:
|
|
|
|
{
|
|
|
|
/* Shamelessly stolen from Gnulib's nl_langinfo.c, modulo
|
|
|
|
CPP directives. */
|
|
|
|
static char buf[2 + 10 + 1];
|
|
|
|
char const *locale = setlocale (LC_CTYPE, NULL);
|
|
|
|
char *codeset = buf;
|
|
|
|
size_t codesetlen;
|
|
|
|
codeset[0] = '\0';
|
|
|
|
|
|
|
|
if (locale && locale[0])
|
|
|
|
{
|
|
|
|
/* If the locale name contains an encoding after the
|
|
|
|
dot, return it. */
|
|
|
|
char *dot = strchr (locale, '.');
|
|
|
|
|
|
|
|
if (dot)
|
|
|
|
{
|
|
|
|
/* Look for the possible @... trailer and remove it,
|
|
|
|
if any. */
|
|
|
|
char *codeset_start = dot + 1;
|
|
|
|
char const *modifier = strchr (codeset_start, '@');
|
|
|
|
|
|
|
|
if (! modifier)
|
|
|
|
codeset = codeset_start;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
codesetlen = modifier - codeset_start;
|
|
|
|
if (codesetlen < sizeof buf)
|
|
|
|
{
|
|
|
|
codeset = memcpy (buf, codeset_start, codesetlen);
|
|
|
|
codeset[codesetlen] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If setlocale is successful, it returns the number of the
|
|
|
|
codepage, as a string. Otherwise, fall back on Windows
|
|
|
|
API GetACP, which returns the locale's codepage as a
|
|
|
|
number (although this doesn't change according to what
|
|
|
|
the 'setlocale' call specified). Either way, prepend
|
|
|
|
"CP" to make it a valid codeset name. */
|
|
|
|
codesetlen = strlen (codeset);
|
|
|
|
if (0 < codesetlen && codesetlen < sizeof buf - 2)
|
|
|
|
memmove (buf + 2, codeset, codesetlen + 1);
|
|
|
|
else
|
|
|
|
sprintf (buf + 2, "%u", GetACP ());
|
|
|
|
codeset = memcpy (buf, "CP", 2);
|
|
|
|
|
|
|
|
return codeset;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return (char *) "";
|
|
|
|
}
|
|
|
|
}
|