]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/win32/compat/compat.h
authorGit Backport Process <git@bacula.org>
Wed, 5 Aug 2020 07:59:49 +0000 (09:59 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 1 Mar 2022 14:36:17 +0000 (15:36 +0100)
This commit is the result of the squash of the following main commits:

Author: Henrique <henrique.faria@baculasystems.com>
Date:   Tue Apr 30 20:07:27 2019 -0300

    win32: added flock implementation

Author: RadosÅ‚aw Korzeniewski <radekk@inteos.pl>
Date:   Mon Jul 16 14:33:42 2018 +0200

    Fix bsock compilation on windows based on Eric's patch.

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Wed Jul 4 10:50:46 2018 +0200

    win32: Fix director compilation

Author: Alain Spineux <alain@baculasystems.com>
Date:   Mon Mar 26 18:23:06 2018 +0200

    win32: update compat.cpp "file" functions to use new path functions

    - statDir
    - stat 2
    - GetApplicationName
    - win32_chmod win32_chdir win32_mkdir
    - win32_getcwd file_open utime
    - symlink
    - stat
    - breaddir
    - opendir

bacula/src/win32/compat/compat.h

index 53b0c54d0796158787d92b11c845ff198c5e04f4..d5ae60cafb7c3a35948ef6ae74c5772ecc522467 100644 (file)
 #define __STDC__ 1
 #endif
 
+#ifndef POOLMEM
+typedef char POOLMEM;
+#endif
+
 #include <malloc.h>
 
 #ifdef HAVE_MINGW_W64
@@ -212,6 +216,9 @@ struct stat
     uint64_t    st_blocks;
     uint32_t    st_fattrs;  /* Windows file attributes */
 };
+#ifndef SHUT_RDWR
+#define SHUT_RDWR SD_BOTH
+#endif
 
 #ifndef SOCK_CLOEXEC
 #define SOCK_CLOEXEC 0x00000000
@@ -291,6 +298,15 @@ int chmod(const char *, mode_t mode);
 int fcntl(int fd, int cmd, long arg);
 int fstat(intptr_t fd, struct stat *sb);
 
+
+/* Operations for the `flock' call.  */
+#define        LOCK_SH 1       /* Shared lock.  */
+#define        LOCK_EX 2       /* Exclusive lock.  */
+#define        LOCK_UN 8       /* Unlock.  */
+/* Can be OR'd in to one of the above.  */
+#define        LOCK_NB 4       /* Don't block when locking.  */
+int flock (int fd, int operation);
+
 int inet_aton(const char *cp, struct in_addr *inp);
 int binet_pton(int af, const char *src, void *dst);
 int kill(pid_t pid, int signo);
@@ -336,15 +352,20 @@ DIR *opendir(const char *name);
 int closedir(DIR *dir);
 
 struct passwd {
-    char *foo;
+   char *foo;
+   uid_t pw_uid;
 };
 
 struct group {
-    char *foo;
+   char *foo;
+   gid_t gr_gid;
 };
 
 struct passwd *getpwuid(uid_t);
 struct group *getgrgid(uid_t);
+#define getgrnam(x) NULL
+#define getpwnam(x) NULL
+
 
 #ifdef xxx_needed
 struct sigaction {
@@ -457,6 +478,7 @@ int mkstemp(char *t);
 
 void malloc_trim(int);
 uint64_t get_memory_info(char *buf, int buflen);
+void win32_normalize_fileset_path(POOLMEM *&fname);
 
 #undef ftruncate
 #define ftruncate win32_ftruncate