<pre style='margin:0'>
Chris Jones (cjones051073) pushed a commit to branch master
in repository macports-legacy-support.
</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/3b0b2715257f0c63707eef94a2e652e41440c577">https://github.com/macports/macports-legacy-support/commit/3b0b2715257f0c63707eef94a2e652e41440c577</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 3b0b2715257f0c63707eef94a2e652e41440c577
</span>Author: Marcus Calhoun-Lopez <marcuscalhounlopez@gmail.com>
AuthorDate: Thu Apr 7 12:22:01 2022 -0700
<span style='display:block; white-space:pre;color:#404040;'> wrap copyfile_state_get
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Rust expects `copyfile_state_get` to support `COPYFILE_STATE_COPIED`.
</span>---
README.md | 5 +++
include/MacportsLegacySupport.h | 3 ++
include/copyfile.h | 35 ++++++++++++++++++
src/macports_legacy_copyfile.c | 78 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 121 insertions(+)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/README.md b/README.md
</span><span style='display:block; white-space:pre;color:#808080;'>index dfe279d..fa33e9f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/README.md
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/README.md
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -29,6 +29,11 @@ Wrapped headers and replaced functions are:
</span> in namespace <code>std::</code>.</td>
<td>see <code>math.h</code></td>
</tr>
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ <tr>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ <td><code>copyfile.h</code></td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ <td>Wraps <code>copyfile_state_get</code> to support <code>COPYFILE_STATE_COPIED</code></td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ <td>OSX10.5</td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ </tr>
</span> <tr>
<td><code>dirent.h</code></td>
<td>Adds <code>fdopendir</code> function</td>
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/MacportsLegacySupport.h b/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 0e7ec2e..adc061f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/MacportsLegacySupport.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -163,4 +163,7 @@
</span> /* for now, just forward call to CFPropertyListCreateWithStream */
#define __MP_LEGACY_SUPPORT_CoreFoundation__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
<span style='display:block; white-space:pre;background:#e0ffe0;'>+/* copyfile and its associated functions have gained functionality over the years */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define __MP_LEGACY_SUPPORT_COPYFILE_WRAP__ (__APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #endif /* _MACPORTS_LEGACYSUPPORTDEFS_H_ */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/copyfile.h b/include/copyfile.h
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..c9f819e
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/copyfile.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,35 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2022
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Permission to use, copy, modify, and distribute this software for any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * purpose with or without fee is hereby granted, provided that the above
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * copyright notice and this permission notice appear in all copies.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _MACPORTS_COPYFILE_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _MACPORTS_COPYFILE_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* MP support header */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "MacportsLegacySupport.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Include the primary system copyfile.h */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include_next <copyfile.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MP_LEGACY_SUPPORT_COPYFILE_WRAP__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define COPYFILE_STATE_STATUS_CB 6
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define COPYFILE_STATE_STATUS_CTX 7
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define COPYFILE_STATE_COPIED 8
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* _MACPORTS_COPYFILE_H_ */
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports_legacy_copyfile.c b/src/macports_legacy_copyfile.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..bc5de25
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports_legacy_copyfile.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,78 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 2022
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Permission to use, copy, modify, and distribute this software for any
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * purpose with or without fee is hereby granted, provided that the above
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * copyright notice and this permission notice appear in all copies.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* MP support header */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "MacportsLegacySupport.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* copyfile and its associated functions wrap */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if __MP_LEGACY_SUPPORT_COPYFILE_WRAP__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdlib.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <dlfcn.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/stat.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <copyfile.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int copyfile_state_get(copyfile_state_t s, uint32_t flag, void * dst)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int (*real_copyfile_state_get)(copyfile_state_t s, uint32_t flag, void * dst);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char *file_name;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int file_descriptor;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ struct stat file_stat;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ real_copyfile_state_get = dlsym(RTLD_NEXT, "copyfile_state_get");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (real_copyfile_state_get == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ exit(EXIT_FAILURE);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ switch(flag)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ case COPYFILE_STATE_COPIED:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* since copyfile did not recored how many bytes were copied, return the size of the destination file */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* first check if the file descriptor has been set */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = real_copyfile_state_get(s, COPYFILE_STATE_DST_FD, &file_descriptor);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ( ret < 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ( file_descriptor != -2 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = fstat(file_descriptor, &file_stat);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* the file descriptor was not set, so check the file name */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = real_copyfile_state_get(s, COPYFILE_STATE_DST_FILENAME, &file_name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ( ret < 0 ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ret;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ( file_name == NULL ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* neither the file descriptor nor the file name has been set */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return real_copyfile_state_get(s, flag, dst);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ret = stat(file_name, &file_stat);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *(off_t*)dst = file_stat.st_size;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ case COPYFILE_STATE_STATUS_CB:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ case COPYFILE_STATE_STATUS_CTX:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* copyfile did not run the callback function, so return default (which is an error) */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return real_copyfile_state_get(s, flag, dst);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* __MP_LEGACY_SUPPORT_COPYFILE_WRAP__ */
</span></pre><pre style='margin:0'>
</pre>