diff options
author | cvs2svn <> | 2001-04-22 20:19:33 +0400 |
---|---|---|
committer | cvs2svn <> | 2001-04-22 20:19:33 +0400 |
commit | 5d4fccc3d56bd742f02859523f271cc3787bc84a (patch) | |
tree | cd7692a4ea819384d0feb361d82063d694340d1f | |
parent | 4a39e41e48923241b90cb82881c60758d4f2ee87 (diff) |
This commit was manufactured by cvs2svn to create tag 'cygwin-1-1-8'.cygwin-1-1-8
Sprout from cygwin-1-3-1 2001-04-22 16:19:29 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch 'cygwin-1-3-1'.'
Cherrypick from master 2000-08-02 20:13:18 UTC DJ Delorie <dj@redhat.com> 'add winsup.h':
winsup/cygwin/cygrun.c
winsup/cygwin/regexp/regerror.c
Delete:
winsup/cygwin/lib/_cygwin_S_IEXEC.cc
winsup/cygwin/shortcut.c
winsup/cygwin/shortcut.h
-rw-r--r-- | winsup/cygwin/cygrun.c | 3 | ||||
-rw-r--r-- | winsup/cygwin/lib/_cygwin_S_IEXEC.cc | 27 | ||||
-rw-r--r-- | winsup/cygwin/regexp/regerror.c | 10 | ||||
-rw-r--r-- | winsup/cygwin/shortcut.c | 166 | ||||
-rw-r--r-- | winsup/cygwin/shortcut.h | 28 |
5 files changed, 1 insertions, 233 deletions
diff --git a/winsup/cygwin/cygrun.c b/winsup/cygwin/cygrun.c index 3086d7594..8aa3e30a1 100644 --- a/winsup/cygwin/cygrun.c +++ b/winsup/cygwin/cygrun.c @@ -15,7 +15,6 @@ details. */ #include <stdio.h> #include <windows.h> -#include <stdlib.h> int main(int argc, char **argv) @@ -30,7 +29,7 @@ main(int argc, char **argv) exit (0); } - putenv("CYGWIN_TESTING=1"); + setenv("CYGWIN_TESTING", "1"); SetEnvironmentVariable("CYGWIN_TESTING", "1"); memset(&sa, 0, sizeof(sa)); diff --git a/winsup/cygwin/lib/_cygwin_S_IEXEC.cc b/winsup/cygwin/lib/_cygwin_S_IEXEC.cc deleted file mode 100644 index 5f57c94d3..000000000 --- a/winsup/cygwin/lib/_cygwin_S_IEXEC.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* _cygwin_S_IEXEC.cc: stat helper stuff - - Copyright 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -extern "C" { -#include "winsup.h" -#include <sys/stat.h> -#include <sys/unistd.h> - -unsigned _cygwin_S_IEXEC = S_IEXEC; -unsigned _cygwin_S_IXUSR = S_IXUSR; -unsigned _cygwin_S_IXGRP = S_IXGRP; -unsigned _cygwin_S_IXOTH = S_IXOTH; -unsigned _cygwin_X_OK = X_OK; -}; - -extern int __declspec (dllimport) _check_for_executable; -struct _cygwin_bob__ -{ - _cygwin_bob__ () {_check_for_executable = 1;} -} _cygwin_dummy_bob__; diff --git a/winsup/cygwin/regexp/regerror.c b/winsup/cygwin/regexp/regerror.c index 0f6159bb7..afd7a861a 100644 --- a/winsup/cygwin/regexp/regerror.c +++ b/winsup/cygwin/regexp/regerror.c @@ -1,13 +1,3 @@ -/* regerror.c - - Copyright 1996, 1998, 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - #include "winsup.h" #include "regexp.h" #include <stdio.h> diff --git a/winsup/cygwin/shortcut.c b/winsup/cygwin/shortcut.c deleted file mode 100644 index b47cec52a..000000000 --- a/winsup/cygwin/shortcut.c +++ /dev/null @@ -1,166 +0,0 @@ -/* shortcut.c: Read shortcuts. This part of the code must be in C because - the C++ interface to COM doesn't work without -fvtable-thunk - which is too dangerous to use. - - Copyright 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#include "winsup.h" -#include <shlobj.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/mount.h> -#include <errno.h> -#include "shortcut.h" - -/* TODO: - Currently duplicated from path.h. Later rearrangement of path.h - to allow including from plain C would be better. */ -/* This is needed to avoid including path.h which is a pure C++ header. */ -#define PATH_SYMLINK MOUNT_SYMLINK -#define PATH_EXEC MOUNT_EXEC -#define PATH_CYGWIN_EXEC MOUNT_CYGWIN_EXEC -#define PATH_ALL_EXEC (PATH_CYGWIN_EXEC | PATH_EXEC) - -/* TODO: Ditto. */ -static BOOL -has_exec_chars (const char *buf, int len) -{ - return len >= 2 && - ((buf[0] == '#' && buf[1] == '!') || - (buf[0] == ':' && buf[1] == '\n') || - (buf[0] == 'M' && buf[1] == 'Z')); -} - -char shortcut_header[SHORTCUT_HDR_SIZE]; -BOOL shortcut_initalized = FALSE; - -void -create_shortcut_header (void) -{ - if (!shortcut_initalized) - { - shortcut_header[0] = 'L'; - shortcut_header[4] = '\001'; - shortcut_header[5] = '\024'; - shortcut_header[6] = '\002'; - shortcut_header[12] = '\300'; - shortcut_header[19] = 'F'; - shortcut_header[20] = '\f'; - shortcut_header[60] = '\001'; - shortcut_initalized = TRUE; - } -} - -static BOOL -cmp_shortcut_header (const char *file_header) -{ - create_shortcut_header (); - return memcmp (shortcut_header, file_header, SHORTCUT_HDR_SIZE); -} - -int -check_shortcut (const char *path, DWORD fileattr, HANDLE h, - char *contents, int *error, unsigned *pflags) -{ - HRESULT hres; - IShellLink *psl = NULL; - IPersistFile *ppf = NULL; - WCHAR wc_path[MAX_PATH]; - char full_path[MAX_PATH]; - char file_header[SHORTCUT_HDR_SIZE]; - WIN32_FIND_DATA wfd; - DWORD len = 0; - int res = 0; - DWORD got = 0; - - /* Initialize COM library. */ - CoInitialize (NULL); - - /* Get a pointer to the IShellLink interface. */ - hres = CoCreateInstance (&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, - &IID_IShellLink, (void **)&psl); - if (FAILED (hres)) - goto close_it; - /* Get a pointer to the IPersistFile interface. */ - hres = psl->lpVtbl->QueryInterface (psl, &IID_IPersistFile, (void **)&ppf); - if (FAILED (hres)) - goto close_it; - /* Load the shortcut. */ - MultiByteToWideChar(CP_ACP, 0, path, -1, wc_path, MAX_PATH); - hres = ppf->lpVtbl->Load (ppf, wc_path, STGM_READ); - if (FAILED (hres)) - goto close_it; - /* Read the files header information. This is used to check for a - Cygwin or U/WIN shortcut or later to check for executable files. */ - if (!ReadFile (h, file_header, SHORTCUT_HDR_SIZE, &got, 0)) - { - *error = EIO; - goto close_it; - } - /* Try the description (containing a POSIX path) first. */ - if (fileattr & FILE_ATTRIBUTE_READONLY) - { - /* Check header if the shortcut is really created by Cygwin or U/WIN. */ - if (got == SHORTCUT_HDR_SIZE && !cmp_shortcut_header (file_header)) - { - hres = psl->lpVtbl->GetDescription (psl, contents, MAX_PATH); - if (FAILED (hres)) - goto file_not_symlink; - len = strlen (contents); - } - } - /* No description or not R/O: Check the "official" path. */ - if (len == 0) - { - /* Convert to full path (easy way) */ - if ((path[0] == '\\' && path[1] == '\\') - || (_toupper (path[0]) >= 'A' && _toupper (path[0]) <= 'Z' - && path[1] == ':')) - len = 0; - else - { - len = GetCurrentDirectory (MAX_PATH, full_path); - if (path[0] == '\\') - len = 2; - else if (full_path[len - 1] != '\\') - strcpy (full_path + len++, "\\"); - } - strcpy (full_path + len, path); - /* Set relative path inside of IShellLink interface. */ - hres = psl->lpVtbl->SetRelativePath (psl, full_path, 0); - if (FAILED (hres)) - goto file_not_symlink; - /* Get the path to the shortcut target. */ - hres = psl->lpVtbl->GetPath (psl, contents, MAX_PATH, &wfd, 0); - if (FAILED(hres)) - goto file_not_symlink; - } - res = strlen (contents); - if (res) /* It's a symlink. */ - *pflags = PATH_SYMLINK; - goto close_it; - -file_not_symlink: - /* Not a symlink, see if executable. */ - if (!(*pflags & PATH_ALL_EXEC) && has_exec_chars (file_header, got)) - *pflags |= PATH_EXEC; - -close_it: - /* Release the pointer to IPersistFile. */ - if (ppf) - ppf->lpVtbl->Release(ppf); - /* Release the pointer to IShellLink. */ - if (psl) - psl->lpVtbl->Release(psl); - /* Uninitialize COM library. */ - CoUninitialize (); - CloseHandle (h); - - return res; -} diff --git a/winsup/cygwin/shortcut.h b/winsup/cygwin/shortcut.h deleted file mode 100644 index 87e7ff156..000000000 --- a/winsup/cygwin/shortcut.h +++ /dev/null @@ -1,28 +0,0 @@ -/* shortcut.h: Hader file for shortcut.c - - Copyright 2001 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* The header written to a shortcut by Cygwin or U/WIN. */ -#define SHORTCUT_HDR_SIZE 76 - -extern char shortcut_header[]; -extern BOOL shortcut_initalized; - -extern void create_shortcut_header (); - -int check_shortcut (const char *path, DWORD fileattr, HANDLE h, - char *contents, int *error, unsigned *pflags); - -#ifdef __cplusplus -}; -#endif |