commit a1cb2c4c66fa5c36c8f3a23fc63b93a0a32d7b76
parent a96ead9bf3f7d4e5ae8371d95cf841b3db19607f
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date: Mon, 13 Sep 2021 22:33:00 -0700
Remove old windows compatibility code
Diffstat:
10 files changed, 1 insertion(+), 451 deletions(-)
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
@@ -14,9 +14,7 @@ DESKTOPFILEPATH=$(datadir)/applications/claws-mail.desktop
noinst_LTLIBRARIES = libclawscommon.la
if OS_WIN32
-arch_sources = w32_reg.c w32_signal.c w32_stat.c \
- w32_stdlib.c w32_string.c w32_time.c \
- w32_unistd.c w32_wait.c w32_account.c
+arch_sources = w32_reg.c
arch_headers = w32lib.h
else
arch_files =
diff --git a/src/common/w32_account.c b/src/common/w32_account.c
@@ -1,151 +0,0 @@
-/* w32_account.c - Account related W32 functions.
- Copyright (C) 2007-2009 g10 Code GmbH
- Copyright (C) 1999-2005 Nullsoft, Inc.
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any
- damages arising from the use of this software.
-
- Permission is granted to anyone to use this software for any
- purpose, including commercial applications, and to alter it and
- redistribute it freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 3. This notice may not be removed or altered from any source
- distribution.
-
- =======[ wk 2007-05-21 ]====
- The code for get_group_name has been taken from NSIS 2.05, module
- UserInfo.c. NSIS bears the above license and along with the
- notice:
- This license applies to everything in the NSIS package, except where
- otherwise noted.
- Thus we make this module available under the same license - note,
- that this lincese is fully compatibe with the GNU GPL 2.0.
-*/
-
-
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <windows.h>
-#include <sddl.h> // for ConvertSidToStringSid()
-
-#include "w32lib.h"
-#include "utils.h"
-
-#ifndef DIM
-#define DIM(v) (sizeof(v)/sizeof((v)[0]))
-#endif
-
-
-/* Return a malloced name of our user group. */
-static char *
-get_group_name (void)
-{
- HANDLE hThread;
- TOKEN_GROUPS *ptg = NULL;
- DWORD cbTokenGroups;
- DWORD i, j;
- SID_IDENTIFIER_AUTHORITY SystemSidAuthority = { SECURITY_NT_AUTHORITY };
- char *group;
- struct
- {
- DWORD auth_id;
- char *name;
- } groups[] =
- {
- /* Every user belongs to the users group, hence
- users comes before guests */
- {DOMAIN_ALIAS_RID_USERS, "User"},
- {DOMAIN_ALIAS_RID_GUESTS, "Guest"},
- {DOMAIN_ALIAS_RID_POWER_USERS, "Power"},
- {DOMAIN_ALIAS_RID_ADMINS, "Admin"}
- };
-
-
- group = NULL;
- if (GetVersion() & 0x80000000)
- {
- /* This is not NT; thus we are always Admin. */
- group = "Admin";
- }
- else if (OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &hThread)
- || OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hThread))
- {
- /* With the token for the current thread or process in hand we
- query the size of the associated group information. Note
- that we expect an error because buffer has been passed as
- NULL. cbTokenGroups will then tell use the required size. */
- if (!GetTokenInformation (hThread, TokenGroups, NULL, 0, &cbTokenGroups)
- && GetLastError () == ERROR_INSUFFICIENT_BUFFER)
- {
- ptg = GlobalAlloc (GPTR, cbTokenGroups);
- if (ptg)
- {
- if (GetTokenInformation ( hThread, TokenGroups, ptg,
- cbTokenGroups, &cbTokenGroups))
- {
-
- /* Now iterate through the list of groups for this
- access token looking for a match against the SID
- we created above. */
- for (i = 0; i < DIM (groups); i++)
- {
- PSID psid = 0;
-
- AllocateAndInitializeSid (&SystemSidAuthority,
- 2,
- SECURITY_BUILTIN_DOMAIN_RID,
- groups[i].auth_id,
- 0, 0, 0, 0, 0, 0,
- &psid);
- if (!psid)
- continue;
- for (j = 0; j < ptg->GroupCount; j++)
- if (EqualSid(ptg->Groups[j].Sid, psid))
- group = groups[i].name;
- FreeSid(psid);
- }
- }
-
- GlobalFree(ptg);
- }
- }
-
- CloseHandle(hThread);
- }
-
- return group? strdup (group):NULL;
-}
-
-
-/* Return true if we are an administrator. The chekc is done only
- once so if the current user has been hadded to the Administrator
- group the process needs to be rerstarted. */
-int
-w32_is_administrator (void)
-{
- static int got_it;
- static int is_admin;
-
- if (!got_it)
- {
- char *name = get_group_name ();
-
- if (name && !strcmp (name, "Admin"))
- is_admin = 1;
- got_it = 1;
- free (name);
- }
-
- return is_admin;
-}
diff --git a/src/common/w32_signal.c b/src/common/w32_signal.c
@@ -1,28 +0,0 @@
-/* w32_signal.c - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "w32lib.h"
-
-int kill( pid_t pid, int sig ){
- return -1;
-}
diff --git a/src/common/w32_stat.c b/src/common/w32_stat.c
@@ -1,30 +0,0 @@
-/* w32_stat.c - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include "w32lib.h"
-
-int lstat( const char *file_name, GStatBuf *buf ){
- return g_stat( file_name, buf );
-}
-
diff --git a/src/common/w32_stdlib.c b/src/common/w32_stdlib.c
@@ -1,38 +0,0 @@
-/* w32_stdlib.c - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "w32lib.h"
-
-long int random( void ){
- return rand();
-}
-
-void srandom( unsigned int seed ){
- srand( seed );
-}
-
-#if MINGW64_VERSION < 200
-int truncate( const char *path, off_t length ){
- return -1;
-}
-#endif
diff --git a/src/common/w32_string.c b/src/common/w32_string.c
@@ -1,53 +0,0 @@
-/* w32_string.c - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "w32lib.h"
-
-#if MINGW64_VERSION < 200
-int strcasecmp( const char *s1, const char *s2 ){
- size_t len1, len2, len;
-
- len1 = strlen( s1 );
- len2 = strlen( s2 );
- len = ( len1 > len2 )? len1 : len2;
-
- return strncasecmp( s1, s2, len );
-}
-
-int strncasecmp( const char *s1, const char *s2, size_t n ){
- int c1;
- int c2;
-
- while (n--) {
- c1 = tolower(*(const unsigned char*)s1++);
- c2 = tolower(*(const unsigned char*)s2++);
- if (c1 != c2)
- return c1 - c2;
- else if (c1 == 0 && c2 == 0)
- break;
- }
-
- return 0;
-}
-#endif /* MINGW64_VERSION < 200 */
diff --git a/src/common/w32_time.c b/src/common/w32_time.c
@@ -1,37 +0,0 @@
-/* w32_time.c - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/timeb.h>
-
-#include "w32lib.h"
-
-#if ! defined (__MINGW32__) || MINGW32_VERSION < 312
-# if MINGW64_VERSION < 200
-int gettimeofday( struct timeval *tv, struct timezone *tz ){
- struct _timeb tstruct;
- _ftime( &tstruct );
- tv->tv_sec = tstruct.time ;
- tv->tv_usec = tstruct.millitm;
- return 1;
-}
-# endif
-#endif
diff --git a/src/common/w32_unistd.c b/src/common/w32_unistd.c
@@ -1,45 +0,0 @@
-/* w32_unistd.c - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "w32lib.h"
-
-int setpgid( pid_t pid, pid_t pgid ){
- return -1;
-}
-
-pid_t getppid( void ){
- return -1;
-}
-
-pid_t fork( void ){
- return -1;
-}
-
-unsigned int sleep( unsigned int seconds ){
- Sleep(seconds * 1000);
- return 0;
-}
-
-int usleep( unsigned long usec ){
- return sleep( 1 );
-}
diff --git a/src/common/w32_wait.c b/src/common/w32_wait.c
@@ -1,28 +0,0 @@
-/* w32_wait.c - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "w32lib.h"
-
-pid_t waitpid( pid_t pid, int *status, int options ){
- return -1;
-}
diff --git a/src/common/w32lib.h b/src/common/w32lib.h
@@ -128,13 +128,6 @@ typedef unsigned int uid_t;
#define S_ISREG(mode) __S_ISTYPE((mode), _S_IFREG)
#endif /* __MINGW32__ */
-/* functions */
-/*** str ***/
-#if MINGW64_VERSION < 200
-int strcasecmp( const char *s1, const char *s2 );
-int strncasecmp( const char *s1, const char *s2, size_t n );
-#endif
-
/*** dir ***/
#ifndef __MINGW32__
typedef void * HANDLE;
@@ -178,43 +171,12 @@ struct timezone {
# endif
#endif
-/*** stat ***/
-int lstat( const char *file_name, GStatBuf *buf );
-
-/*** sys/wait ***/
-pid_t waitpid( pid_t pid, int *status, int options );
-
-/*** sys/time ***/
-#if ! defined (__MINGW32__) || MINGW32_VERSION < 312
-# if MINGW64_VERSION < 200
-int gettimeofday( struct timeval *tv, struct timezone *tz );
-# endif
-#endif
-
-/*** unistd ***/
-int setpgid( pid_t pid, pid_t pgid );
-pid_t getppid( void );
-unsigned int sleep( unsigned int seconds );
-
-/*** stdlib ***/
-long int random( void );
-void srandom( unsigned int seed );
-#if MINGW64_VERSION < 200
-int truncate( const char *path, off_t length );
-#endif
-
-/*** signal ***/
-int kill( pid_t pid, int sig );
-
/*** stdio ***/
#if MINGW64_VERSION < 200
FILE *popen( const char *command, const char *type );
int pclose( FILE *stream );
#endif
-/*** w32_account.c ***/
-int w32_is_administrator (void);
-
/*** misc ***/
int write_w32_registry_string( char *parent, char *section, char *value, char *data );
int write_w32_registry_dword( char *parent, char *section, char *value, int data );