ocran 1.4.4-x86_64-linux → 1.4.6-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/src/error.c ADDED
@@ -0,0 +1,100 @@
1
+ #ifdef _WIN32
2
+ #include <windows.h>
3
+ #endif
4
+ #include <string.h>
5
+ #include <stdio.h>
6
+ #include <stdarg.h>
7
+ #include <stdbool.h>
8
+ #include "error.h"
9
+
10
+ static bool debug_mode = false;
11
+
12
+ // Enable debug mode
13
+ void EnableDebugMode()
14
+ {
15
+ debug_mode = true;
16
+ }
17
+
18
+ static bool vformat_message(char *buffer, size_t buffer_size, const char *label,
19
+ const char* format, va_list args)
20
+ {
21
+ if (!buffer || buffer_size < 2) {
22
+ return false;
23
+ }
24
+
25
+ size_t offset = 0;
26
+
27
+ if (label) {
28
+ int label_needed = snprintf(buffer, buffer_size, "%s: ", label);
29
+ if (label_needed < 0 || (size_t)label_needed >= buffer_size) {
30
+ return false;
31
+ }
32
+ offset = (size_t)label_needed;
33
+ }
34
+
35
+ int needed = vsnprintf(buffer + offset, buffer_size - offset, format, args);
36
+ if (needed < 0) {
37
+ return false;
38
+ } else if ((size_t)needed >= buffer_size - offset - 2) {
39
+ offset = buffer_size - 2;
40
+ } else {
41
+ offset += (size_t)needed;
42
+ }
43
+ buffer[offset++] = '\n';
44
+ buffer[offset] = '\0';
45
+ return true;
46
+ }
47
+
48
+ static void print_message(const char *label, const char *format, va_list args)
49
+ {
50
+ char text[4096];
51
+ if (vformat_message(text, sizeof(text), label, format, args)) {
52
+ fputs(text, stderr);
53
+ } else {
54
+ fputs("log message formatting failed\n", stderr);
55
+ }
56
+ }
57
+
58
+ // Prints a fatal error message to stderr.
59
+ void PrintFatalMessage(const char *format, ...)
60
+ {
61
+ va_list args;
62
+ va_start(args, format);
63
+ print_message("FATAL", format, args);
64
+ va_end(args);
65
+ }
66
+
67
+ // Displays a fatal error message via a message box.
68
+ #ifdef _WIN32
69
+ void PrintFatalMessageBox(const char *format, ...)
70
+ {
71
+ char TextBuffer[1024];
72
+ va_list args;
73
+ va_start(args, format);
74
+ vsnprintf(TextBuffer, 1024, format, args);
75
+ va_end(args);
76
+ MessageBox(NULL, TextBuffer, "OCRAN", MB_OK | MB_ICONWARNING);
77
+ }
78
+ #endif
79
+
80
+ // Prints an application level error message to stderr if in debug mode.
81
+ void PrintAppErrorMessage(const char *format, ...)
82
+ {
83
+ if (!debug_mode) return;
84
+
85
+ va_list args;
86
+ va_start(args, format);
87
+ print_message("ERROR", format, args);
88
+ va_end(args);
89
+ }
90
+
91
+ // Prints a debug message to stderr if in debug mode.
92
+ void PrintDebugMessage(const char *format, ...)
93
+ {
94
+ if (!debug_mode) return;
95
+
96
+ va_list args;
97
+ va_start(args, format);
98
+ print_message("DEBUG", format, args);
99
+ va_end(args);
100
+ }
data/src/error.h ADDED
@@ -0,0 +1,66 @@
1
+ #include <stdarg.h>
2
+
3
+ // Exit code definitions
4
+ #define EXIT_CODE_SUCCESS (0)
5
+ #define EXIT_CODE_FAILURE (-1)
6
+
7
+ /**
8
+ * EnableDebugMode - Enable debug mode
9
+ *
10
+ * This function enables debug mode and attaches a console for debug output.
11
+ */
12
+ void EnableDebugMode();
13
+
14
+ /**
15
+ * PrintFatalMessage - Prints a fatal error message to stderr.
16
+ *
17
+ * This function prints a formatted error message to stderr. The message is
18
+ * prefixed with "FATAL: ".
19
+ *
20
+ * @param format The format of the error message to be displayed. This is a printf-like
21
+ * format string followed by additional arguments.
22
+ */
23
+ void PrintFatalMessage(const char *format, ...);
24
+
25
+ /**
26
+ * PrintFatalMessageBox - Displays a fatal error message via a message box.
27
+ *
28
+ * This function displays a formatted error message in a message box with the
29
+ * caption 'OCRAN' and an icon of MB_ICONWARNING.
30
+ *
31
+ * @param format The format of the error message to be displayed. This is a printf-like
32
+ * format string followed by additional arguments.
33
+ */
34
+ #ifdef _WIN32
35
+ void PrintFatalMessageBox(const char *format, ...);
36
+ #endif
37
+
38
+ #if defined(_CONSOLE) || !defined(_WIN32)
39
+ #define FATAL(...) PrintFatalMessage(__VA_ARGS__)
40
+ #else
41
+ #define FATAL(...) PrintFatalMessageBox(__VA_ARGS__)
42
+ #endif
43
+
44
+ /**
45
+ * PrintAppErrorMessage - Prints an application level error message to stderr if in debug mode.
46
+ *
47
+ * This function prints a formatted error message to stderr. The message is
48
+ * prefixed with "ERROR: ".
49
+ *
50
+ * @param format The format of the error message to be displayed. This is a printf-like
51
+ * format string followed by additional arguments.
52
+ */
53
+ void PrintAppErrorMessage(const char *format, ...);
54
+ #define APP_ERROR(...) PrintAppErrorMessage(__VA_ARGS__)
55
+
56
+ /**
57
+ * PrintDebugMessage - Prints a debug message to stderr if in debug mode.
58
+ *
59
+ * This function prints a formatted debug message to stderr. The message is
60
+ * prefixed with "DEBUG: ".
61
+ *
62
+ * @param format The format of the debug message to be displayed. This is a printf-like
63
+ * format string followed by additional arguments.
64
+ */
65
+ void PrintDebugMessage(const char *format, ...);
66
+ #define DEBUG(...) PrintDebugMessage(__VA_ARGS__)
data/src/inst_dir.c ADDED
@@ -0,0 +1,376 @@
1
+ #include <stdlib.h>
2
+ #include <string.h>
3
+ #ifndef _WIN32
4
+ #include <unistd.h>
5
+ #include <errno.h>
6
+ #endif
7
+ #include "error.h"
8
+ #include "system_utils.h"
9
+ #include "inst_dir.h"
10
+
11
+ // Static variable to hold the installation directory path.
12
+ static char *InstDir = NULL;
13
+
14
+ /**
15
+ * @brief Checks whether the installation directory is configured.
16
+ *
17
+ * @return true if InstDir is non-NULL and not empty; false otherwise.
18
+ */
19
+ static inline bool IsInstDirSet(void)
20
+ {
21
+ return InstDir != NULL && InstDir[0] != '\0';
22
+ }
23
+
24
+ // Creates an installation directory with a unique name in the specified target directory.
25
+ static char *create_uniq_dir(const char *target_dir)
26
+ {
27
+ char *base_path = JoinPath(target_dir, "ocran" "XXXXXX");
28
+ if (!base_path) {
29
+ APP_ERROR("Failed to construct a base path");
30
+ return NULL;
31
+ }
32
+ return CreateUniqueDirectory(base_path);
33
+ }
34
+
35
+ // Creates a debug installation directory next to the executable.
36
+ static char *create_debug_extract_inst_dir(void)
37
+ {
38
+ char *image_path = GetImagePath();
39
+ if (!image_path) {
40
+ APP_ERROR("Failed to get executable name");
41
+ return NULL;
42
+ }
43
+
44
+ char *image_dir = GetParentPath(image_path);
45
+ free(image_path);
46
+ if (!image_dir) {
47
+ APP_ERROR("Failed to obtain the directory path of the executable file");
48
+ return NULL;
49
+ }
50
+
51
+ char *inst_dir = create_uniq_dir(image_dir);
52
+
53
+ if (!inst_dir) {
54
+ APP_ERROR("Failed to create installation directory in '%s'", image_dir);
55
+ free(image_dir);
56
+ return NULL;
57
+ }
58
+
59
+ free(image_dir);
60
+ return inst_dir;
61
+ }
62
+
63
+ // Creates a temporary installation directory in the system's temp directory.
64
+ static char *create_temporary_inst_dir(void)
65
+ {
66
+ char *temp_dir = GetTempDirectoryPath();
67
+ if (!temp_dir) {
68
+ APP_ERROR("Failed to obtain the temporary directory path");
69
+ return NULL;
70
+ }
71
+
72
+ char *inst_dir = create_uniq_dir(temp_dir);
73
+ if (!inst_dir) {
74
+ APP_ERROR("Failed to create installation directory in '%s'", temp_dir);
75
+ free(temp_dir);
76
+ return NULL;
77
+ }
78
+
79
+ free(temp_dir);
80
+ return inst_dir;
81
+ }
82
+
83
+ const char *CreateInstDir(bool is_extract_to_exe_dir)
84
+ {
85
+ if (InstDir != NULL) {
86
+ APP_ERROR("Installation directory has already been set");
87
+ return NULL;
88
+ }
89
+
90
+ char *inst_dir = NULL;
91
+
92
+ if (is_extract_to_exe_dir) {
93
+ inst_dir = create_debug_extract_inst_dir();
94
+ } else {
95
+ inst_dir = create_temporary_inst_dir();
96
+ }
97
+ if (!inst_dir) {
98
+ return NULL;
99
+ }
100
+
101
+ /* Normalize 8.3 short names (e.g. a TEMP under C:\Users\RUNNER~1) so all
102
+ paths derived from the extraction dir use one consistent spelling. */
103
+ char *long_dir = ToLongPath(inst_dir);
104
+ free(inst_dir);
105
+ if (!long_dir) {
106
+ return NULL;
107
+ }
108
+
109
+ InstDir = long_dir;
110
+ return InstDir;
111
+ }
112
+
113
+ // Sets the installation directory to the executable's own directory
114
+ // (installer/wrapper mode, RUN_IN_EXE_DIR). No directory is created and
115
+ // the directory must never be deleted by the stub.
116
+ const char *SetInstDirToExeDir(void)
117
+ {
118
+ if (InstDir != NULL) {
119
+ APP_ERROR("Installation directory has already been set");
120
+ return NULL;
121
+ }
122
+
123
+ char *image_path = GetImagePath();
124
+ if (!image_path) {
125
+ APP_ERROR("Failed to get executable name");
126
+ return NULL;
127
+ }
128
+
129
+ char *image_dir = GetParentPath(image_path);
130
+ free(image_path);
131
+ if (!image_dir) {
132
+ APP_ERROR("Failed to obtain the directory path of the executable file");
133
+ return NULL;
134
+ }
135
+
136
+ /* Normalize 8.3 short names for a consistent spelling (see CreateInstDir) */
137
+ char *long_dir = ToLongPath(image_dir);
138
+ free(image_dir);
139
+ if (!long_dir) {
140
+ return NULL;
141
+ }
142
+
143
+ InstDir = long_dir;
144
+ return InstDir;
145
+ }
146
+
147
+ // Frees the allocated memory for the installation directory path.
148
+ void FreeInstDir(void)
149
+ {
150
+ free(InstDir);
151
+ InstDir = NULL;
152
+ }
153
+
154
+ // Returns the path to the installation directory.
155
+ const char *GetInstDir()
156
+ {
157
+ if (!IsInstDirSet()) {
158
+ APP_ERROR("Installation directory has not been set");
159
+ return NULL;
160
+ }
161
+
162
+ return InstDir;
163
+ }
164
+
165
+ // Concatenates the installation directory path with a relative path.
166
+ char *ExpandInstDirPath(const char *rel_path)
167
+ {
168
+ if (!IsInstDirSet()) {
169
+ APP_ERROR("Installation directory has not been set");
170
+ return NULL;
171
+ }
172
+
173
+ if (!rel_path || !*rel_path) {
174
+ APP_ERROR("relative path is NULL or empty");
175
+ return NULL;
176
+ }
177
+
178
+ if (!IsCleanRelativePath(rel_path)) {
179
+ APP_ERROR("invalid relative path '%s'", rel_path);
180
+ return NULL;
181
+ }
182
+
183
+ char *full_path = JoinPath(InstDir, rel_path);
184
+ if (!full_path) {
185
+ APP_ERROR("Failed to build full path");
186
+ }
187
+ return full_path;
188
+ }
189
+
190
+ // Deletes the installation directory and all its contents.
191
+ bool DeleteInstDir(void)
192
+ {
193
+ if (!IsInstDirSet()) {
194
+ APP_ERROR("Installation directory has not been set");
195
+ return false;
196
+ }
197
+
198
+ return DeleteRecursively(InstDir);
199
+ }
200
+
201
+ // Replaces placeholders in a string with the installation directory path.
202
+ char *ReplaceInstDirPlaceholder(const char *tmpl)
203
+ {
204
+ if (!IsInstDirSet()) {
205
+ APP_ERROR("Installation directory has not been set");
206
+ return NULL;
207
+ }
208
+
209
+ const char *replacement = InstDir;
210
+ size_t replacement_len = strlen(replacement);
211
+ size_t c = 0;
212
+
213
+ for (const char *p = tmpl; *p; p++) { if (*p == PLACEHOLDER) c++; }
214
+ size_t replaced_len = strlen(tmpl) - c + replacement_len * c + 1;
215
+ char *replaced = calloc(replaced_len, sizeof(*replaced));
216
+ if (!replaced) {
217
+ APP_ERROR("Memory allocation failed for placeholder replacement");
218
+ return NULL;
219
+ }
220
+
221
+ char *out = replaced;
222
+ for (const char *in = tmpl; *in; in++) {
223
+ if (*in == PLACEHOLDER) {
224
+ memcpy(out, replacement, replacement_len);
225
+ out += replacement_len;
226
+ } else {
227
+ *out = *in;
228
+ out++;
229
+ }
230
+ }
231
+ *out = '\0';
232
+
233
+ return replaced;
234
+ }
235
+
236
+ bool CreateDirectoryUnderInstDir(const char *rel_path)
237
+ {
238
+ if (!IsInstDirSet()) {
239
+ APP_ERROR("Installation directory has not been set");
240
+ return false;
241
+ }
242
+
243
+ if (!rel_path) {
244
+ APP_ERROR("relative path is NULL");
245
+ return false;
246
+ }
247
+
248
+ /* Treat empty string as a no-op and return success */
249
+ if (rel_path[0] == '\0') {
250
+ return true;
251
+ }
252
+
253
+ char *dir = ExpandInstDirPath(rel_path);
254
+ if (!dir) {
255
+ APP_ERROR("Failed to build full path");
256
+ return false;
257
+ }
258
+
259
+ bool result = CreateDirectoriesRecursively(dir);
260
+ if (!result) {
261
+ APP_ERROR(
262
+ "Failed to create directory under installation directory: '%s'",
263
+ dir
264
+ );
265
+ }
266
+
267
+ free(dir);
268
+ return result;
269
+ }
270
+
271
+ bool ExportFileToInstDir(const char *rel_path, const void *buf, size_t len)
272
+ {
273
+ bool result = false;
274
+ char *path = NULL;
275
+
276
+ if (!IsInstDirSet()) {
277
+ APP_ERROR("Installation directory has not been set");
278
+ goto cleanup;
279
+ }
280
+
281
+ if (rel_path == NULL || *rel_path == '\0') {
282
+ APP_ERROR("Relative path is null or empty");
283
+ goto cleanup;
284
+ }
285
+
286
+ DEBUG("ExportFileToInstDir: rel_path=\"%s\", len=%zu", rel_path, len);
287
+
288
+ if (len > 0 && buf == NULL) {
289
+ APP_ERROR("Buffer pointer is NULL for non-zero length");
290
+ goto cleanup;
291
+ }
292
+
293
+ path = ExpandInstDirPath(rel_path);
294
+ if (!path) {
295
+ goto cleanup;
296
+ }
297
+
298
+ if (!ExportFile(path, buf, len)) {
299
+ APP_ERROR("Failed to export file: %s", path);
300
+ goto cleanup;
301
+ }
302
+
303
+ result = true;
304
+
305
+ cleanup:
306
+ if (path) {
307
+ free(path);
308
+ }
309
+ return result;
310
+ }
311
+
312
+ #ifndef _WIN32
313
+ bool CreateSymlinkUnderInstDir(const char *rel_link_path, const char *target)
314
+ {
315
+ if (!IsInstDirSet()) {
316
+ APP_ERROR("Installation directory has not been set");
317
+ return false;
318
+ }
319
+
320
+ if (!rel_link_path || !*rel_link_path) {
321
+ APP_ERROR("rel_link_path is NULL or empty");
322
+ return false;
323
+ }
324
+
325
+ if (!target || !*target) {
326
+ APP_ERROR("target is NULL or empty");
327
+ return false;
328
+ }
329
+
330
+ char *link_path = ExpandInstDirPath(rel_link_path);
331
+ if (!link_path) {
332
+ return false;
333
+ }
334
+
335
+ bool result = false;
336
+ char *parent = GetParentPath(link_path);
337
+ if (parent && *parent && !CreateDirectoriesRecursively(parent)) {
338
+ APP_ERROR("Failed to create parent directory for symlink '%s'", link_path);
339
+ goto cleanup;
340
+ }
341
+
342
+ if (symlink(target, link_path) < 0) {
343
+ APP_ERROR("Failed to create symlink '%s' -> '%s': %s", link_path, target, strerror(errno));
344
+ goto cleanup;
345
+ }
346
+
347
+ DEBUG("CreateSymlinkUnderInstDir: '%s' -> '%s'", link_path, target);
348
+ result = true;
349
+
350
+ cleanup:
351
+ if (parent) {
352
+ free(parent);
353
+ }
354
+ free(link_path);
355
+ return result;
356
+ }
357
+ #endif /* _WIN32 */
358
+
359
+ bool SetEnvWithInstDir(const char *name, const char *value)
360
+ {
361
+ char *replaced_value = ReplaceInstDirPlaceholder(value);
362
+ if (!replaced_value) {
363
+ APP_ERROR("Failed to replace the value placeholder");
364
+ return false;
365
+ }
366
+
367
+ DEBUG("SetEnv(%s, %s)", name, replaced_value);
368
+
369
+ bool result = SetEnvVar(name, replaced_value);
370
+ if (!result) {
371
+ APP_ERROR("Failed to set environment variable: %s", name);
372
+ }
373
+
374
+ free(replaced_value);
375
+ return result;
376
+ }
data/src/inst_dir.h ADDED
@@ -0,0 +1,171 @@
1
+ #include <stdbool.h>
2
+ #include <stddef.h>
3
+
4
+ /**
5
+ * @brief Creates an installation directory with a unique name.
6
+ *
7
+ * Attempts to create a directory within the specified target directory. This
8
+ * directory is assigned a unique name based on the "ocran" prefix to avoid
9
+ * conflicts. The function manages the lifetime of the created directory path's
10
+ * memory, which should not be freed by the caller.
11
+ * If directory cleanup is needed, call FreeInstDir().
12
+ *
13
+ * @param is_extract_to_exe_dir
14
+ * If true, the extraction directory will be created in the same folder as
15
+ * the executable; if false, it will be created in the system’s temporary
16
+ * directory.
17
+ * @return
18
+ * A pointer to the created directory path if successful, NULL if an error
19
+ * occurred. The returned path should not be freed by the caller.
20
+ */
21
+ const char *CreateInstDir(bool is_extract_to_exe_dir);
22
+
23
+ /**
24
+ * @brief Sets the installation directory to the executable's own directory.
25
+ *
26
+ * Unlike CreateInstDir, no new directory is created: the stub runs the
27
+ * application directly from the directory the executable resides in
28
+ * (installer/wrapper mode, RUN_IN_EXE_DIR). The directory must never be
29
+ * deleted by the stub.
30
+ *
31
+ * @return
32
+ * A pointer to the directory path if successful, NULL if an error
33
+ * occurred. The returned path should not be freed by the caller.
34
+ */
35
+ const char *SetInstDirToExeDir(void);
36
+
37
+ /**
38
+ * @brief Free the allocated installation directory path
39
+ * and reset the internal pointer to NULL.
40
+ *
41
+ * Frees memory previously allocated for the installation directory path
42
+ * and clears the stored pointer so that GetInstDir() returns NULL until
43
+ * a new directory is set.
44
+ */
45
+ void FreeInstDir(void);
46
+
47
+ /**
48
+ * @brief Get the current installation directory path.
49
+ *
50
+ * @return
51
+ * A pointer to the installation directory path if set, or NULL if the
52
+ * directory has not been initialized or has been freed.
53
+ */
54
+ const char *GetInstDir(void);
55
+
56
+ /**
57
+ * @brief Concatenates the installation directory path with a given
58
+ * relative path.
59
+ *
60
+ * This function guarantees that the resulting path will not escape the
61
+ * installation directory. It will fail and return NULL if any of the following
62
+ * conditions are met:
63
+ * - the installation directory (InstDir) is not set or is empty
64
+ * - rel_path is NULL or empty
65
+ * - rel_path contains prohibited path elements such as "." or "..", including
66
+ * patterns like "/./" or "/../"
67
+ *
68
+ * @param rel_path
69
+ * A relative path to be combined with the installation directory path.
70
+ * Must not be absolute, must not be empty, and must not contain any "." or
71
+ * ".." segments (e.g., "/./", "/../", "./", "../").
72
+ *
73
+ * @return
74
+ * A newly allocated string representing the full path on success; NULL on
75
+ * error (and an appropriate error message is logged).
76
+ */
77
+ char *ExpandInstDirPath(const char *rel_path);
78
+
79
+ /**
80
+ * @brief Deletes the installation directory and its contents.
81
+ *
82
+ * @return true if the directory and its contents were deleted successfully,
83
+ * false otherwise.
84
+ */
85
+ bool DeleteInstDir(void);
86
+
87
+ // Placeholder character used in paths.
88
+ #define PLACEHOLDER '|'
89
+
90
+ /**
91
+ * @brief Replace placeholders in a template string
92
+ * with the installation directory path.
93
+ *
94
+ * @param tmpl
95
+ * The template string containing placeholder characters defined by the
96
+ * PLACEHOLDER macro, which will be replaced by the installation directory
97
+ * path.
98
+ * @return
99
+ * A newly allocated string with all PLACEHOLDER occurrences replaced by the
100
+ * installation directory path. Returns NULL on failure.
101
+ */
102
+ char *ReplaceInstDirPlaceholder(const char *tmpl);
103
+
104
+ /**
105
+ * @brief Recursively create a directory under the installation directory.
106
+ *
107
+ * This function ensures that a directory exists at the specified relative
108
+ * path under the installation directory. An empty rel_path is treated as
109
+ * already existing (returns true). If rel_path is NULL, ExpandInstDirPath
110
+ * fails, or directory creation fails, the function returns false and logs
111
+ * an error.
112
+ *
113
+ * @param rel_path
114
+ * A relative path to a directory under the installation directory.
115
+ * NULL is invalid (returns false). An empty string is treated as
116
+ * already existing (returns true).
117
+ *
118
+ * @return
119
+ * true if the directory already exists or was created successfully;
120
+ * false on error (and an error is logged).
121
+ */
122
+ bool CreateDirectoryUnderInstDir(const char *rel_path);
123
+
124
+ /**
125
+ * @brief Atomically write a file under the installation dir.
126
+ *
127
+ * This function writes the given buffer as a file at the specified
128
+ * relative path under the installation directory. It validates rel_path
129
+ * and buf, expands the full path, creates any missing parent directories,
130
+ * and writes the data atomically. If len is zero, an empty file is
131
+ * created.
132
+ *
133
+ * @param rel_path
134
+ * A relative file path under the installation directory. NULL or empty
135
+ * string is invalid (returns false).
136
+ * @param buf
137
+ * Pointer to the data to write. Must be non-NULL if len > 0.
138
+ * @param len
139
+ * Number of bytes to write. Zero creates an empty file. Values above
140
+ * MAXDWORD cause an error.
141
+ *
142
+ * @return
143
+ * true on success; false on failure (error logged via APP_ERROR/DEBUG).
144
+ */
145
+ bool ExportFileToInstDir(const char *rel_path, const void *buf, size_t len);
146
+
147
+ /**
148
+ * @brief Expands any installation-directory placeholder found in 'value' and
149
+ * sets the environment variable.
150
+ *
151
+ * @param name Environment variable name to set (must not be NULL).
152
+ * @param value Value string that may include a placeholder for the
153
+ * installation directory.
154
+ *
155
+ * @return true on success; false on failure.
156
+ */
157
+ bool SetEnvWithInstDir(const char *name, const char *value);
158
+
159
+ /**
160
+ * @brief Create a symlink under the installation directory (POSIX only).
161
+ *
162
+ * Creates a symbolic link at rel_link_path that points to target.
163
+ * Both paths are relative to the installation directory.
164
+ * The target is treated as a bare filename within the same directory.
165
+ *
166
+ * @param rel_link_path Relative path for the new symlink (e.g. "bin/libruby.so").
167
+ * @param target Symlink target filename (e.g. "libruby.so.3.2.0").
168
+ *
169
+ * @return true on success; false on failure.
170
+ */
171
+ bool CreateSymlinkUnderInstDir(const char *rel_link_path, const char *target);