From: Reuben Thomas Date: Fri, 19 Apr 2024 15:49:08 +0000 (+0200) Subject: gnu: add binding for 'relocate' APIs X-Git-Tag: 0.56.18~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc1924e236f3db5a715d2c053766d31cea1bbb80;p=thirdparty%2Fvala.git gnu: add binding for 'relocate' APIs --- diff --git a/vapi/gnu.vapi b/vapi/gnu.vapi index beaa228cf..fea6371ae 100644 --- a/vapi/gnu.vapi +++ b/vapi/gnu.vapi @@ -70,4 +70,25 @@ namespace Gnu { [CCode (cheader_filename = "quote.h")] public string quote (string arg); + + [CCode (cheader_filename = "relocatable.h", cname = "relocate", type ="const char*")] + char* _gnulib_relocate (char* path); + [CCode (cname = "_vala_gnulib_relocate")] + public string relocate (string path) { + char* newpath = _gnulib_relocate (path); + if (newpath != path) { + // If relocate malloced, then return the value, defeating Vala's + // attempt to strdup it. + return (string) (owned) newpath; + } else { + // Otherwise, allow Vala to strdup the non-malloced return value. + return (string) newpath; + } + } + + [CCode (cheader_filename = "relocatable.h")] + public void set_relocation_prefix (string orig_prefix, string curr_prefix); + + [CCode (cheader_filename = "relocatable.h")] + public string compute_curr_prefix (string orig_installprefix, string orig_installdir, string curr_pathname); }