diff options
author | Norbert Preining <norbert@preining.info> | 2020-10-12 03:04:00 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-10-12 03:04:00 +0000 |
commit | 0ce40abb18ec02ec6fd6bcc5f21612c88daa7578 (patch) | |
tree | 416289fe1448873fd8ca33051f50ad85bffa8aaa /support/dktools/dk4exep8.c | |
parent | fdb18507cd80dc17f5a5256153d34668b4f4e61c (diff) |
CTAN sync 202010120303
Diffstat (limited to 'support/dktools/dk4exep8.c')
-rw-r--r-- | support/dktools/dk4exep8.c | 400 |
1 files changed, 0 insertions, 400 deletions
diff --git a/support/dktools/dk4exep8.c b/support/dktools/dk4exep8.c deleted file mode 100644 index 506205ac74..0000000000 --- a/support/dktools/dk4exep8.c +++ /dev/null @@ -1,400 +0,0 @@ -/* -Copyright (C) 2015-2020, Dirk Krause -SPDX-License-Identifier: BSD-3-Clause -*/ - -/* - WARNING: This file was generated by the dkct program (see - http://dktools.sourceforge.net/ for details). - Changes you make here will be lost if dkct is run again! - You should modify the original source and run dkct on it. - Original source: dk4exep8.ctr -*/ - -/** @file dk4exep8.c The dk4exep8 module. -*/ - - -#line 69 "dk4exep8.ctr" - -#include "dk4conf.h" - -#ifndef DK4USE_H_INCLUDED -#include "dk4use.h" -#endif - -#ifndef DK4EXEP8_H_INCLUDED -#include "dk4exep8.h" -#endif - -#ifndef DK4STR8_H_INCLUDED -#include "dk4str8.h" -#endif - -#ifndef DK4MEM_H_INCLUDED -#include "dk4mem.h" -#endif - -#ifndef DK4PATH8_H_INCLUDED -#include "dk4path8.h" -#endif - -#ifndef DK4STAT8_H_INCLUDED -#include "dk4stat8.h" -#endif - -#ifndef DK4STAT_H_INCLUDED -#include "dk4stat.h" -#endif - -#ifndef DK4MAO8D_H_INCLUDED -#include "dk4mao8d.h" -#endif - -#ifndef DK4MPL_H_INCLUDED -#include "dk4mpl.h" -#endif - -#ifndef DK4UNUSED_H_INCLUDED -#include "dk4unused.h" -#endif - -#if DK4_ON_WINDOWS -#ifndef WINDOWS_H_INCLUDED -#include <windows.h> -#define WINDOWS_H_INCLUDED 1 -#endif -#ifndef WINBASE_H_INCLUDED -#include <winbase.h> -#define WINBASE_H_INCLUDED 1 -#endif -#endif - -#if DK4_HAVE_SYS_TYPES_H -#ifndef SYS_TYPES_H_INCLUDED -#include <sys/types.h> -#define SYS_TYPES_H_INCLUDED 1 -#endif -#endif - -#if DK4_HAVE_SYS_STAT_H -#ifndef SYS_STAT_H_INCLUDED -#include <sys/stat.h> -#define SYS_STAT_H_INCLUDED 1 -#endif -#endif - -#ifndef STDLIB_H_INCLUDED -#include <stdlib.h> -#define STDLIB_H_INCLUDED 1 -#endif - -#if DK4_HAVE_ERRNO_H -#ifndef ERRNO_H_INCLUDED -#include <errno.h> -#define ERRNO_H_INCLUDED 1 -#endif -#endif - -#if DK4_HAVE_UNISTD_H -#ifndef UNISTD_H_INCLUDED -#include <unistd.h> -#define UNISTD_H_INCLUDED 1 -#endif -#endif - -#if DK4_HAVE_STRING_H -#ifndef STRING_H_INCLUDED -#include <string.h> -#define STRING_H_INCLUDED 1 -#endif -#endif - -#if DK4_HAVE_ASSERT_H -#ifndef ASSERT_H_INCLUDED -#include <assert.h> -#define ASSERT_H_INCLUDED 1 -#endif -#endif - - - - -#line 172 "dk4exep8.ctr" - - - -static const char * const dk4execpath_c8_kw[] = { -/* 0 */ "PATH", -#if DK4_HAVE_BACKSLASH_AS_SEP -/* 1 */ "\\", -#else -/* 1 */ "/", -#endif -NULL -}; - - - -#if !DK4_ON_WINDOWS - -/** Retrieve name of executable file by PATH environment variable - inspection. - @param buffer Buffer to store result. - @param sz Size of buffer. - @param argv0 First command line word. - @param erp Error report, may be NULL. - @return 1 on success, 0 on error. -*/ -static -int -dk4execpath_c8_inspect_path( - char *buffer, size_t sz, const char * argv0, dk4_er_t *erp -) -{ - dk4_stat_t stbuf; - char *envpath; - char *mycopy; - char *p1; - char *p2; - int back = 0; - int cc = 1; - -#if DK4_USE_ASSERT - assert(NULL != buffer); - assert(0 < sz); - assert(NULL != argv0); -#endif - envpath = getenv(dk4execpath_c8_kw[0]); - if (NULL != envpath) { - mycopy = dk4str8_dup(envpath, erp); - if (NULL != mycopy) { - p1 = mycopy; - while ((NULL != p1) && (0 != cc) && (0 == back)) { - p2 = dk4str8_chr(p1, ':'); - if (NULL != p2) { *(p2++) = '\0'; } - if (0 != dk4str8_cpy_s(buffer, sz, p1, erp)) { - if (0 != dk4str8_cat_s(buffer, sz, dk4execpath_c8_kw[1], erp)) { - if (0 != dk4str8_cat_s(buffer, sz, argv0, erp)) { - if (0 != dk4stat_c8(&stbuf, buffer, NULL)) { - if (0 != dk4stat_is_regular(&stbuf, NULL)) { - back = 1; - } - } else { - -#line 232 "dk4exep8.ctr" - } - } else { - cc = 0; - } - } else { - cc = 0; - } - } else { - cc = 0; - } - p1 = p2; - } - dk4mem_free(mycopy); - } - } else { - dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND); - } - return back; -} - -#endif - - - -#if !DK4_ON_WINDOWS -#if DK4_HAVE_PROC_PID_EXE -static const char * const dk4exep8_kw[] = { -/* 0 */ "/proc/", -/* 1 */ "/exe" -}; -#endif -#endif - - -#if DK4_USE_PRAGMA_WARNING_DISABLE -#pragma warning( push ) -#pragma warning( disable: 4100 ) -#endif - -int -dk4execpath_c8( - char *buffer, - size_t sz, -#if DK4_ON_WINDOWS - const char * DK4_ARG_UNUSED(argv0), -#else - const char *argv0, -#endif - dk4_er_t *erp -) -{ -#if DK4_ON_WINDOWS - DWORD res; - DWORD dwsz; -#else -#if DK4_HAVE_GETEXECNAME - char cwd[DK4_MAX_PATH]; - const char *enptr; -#endif -#if DK4_HAVE_PROC_PID_EXE - char numbuf[64]; - char fnbuf[sizeof(numbuf)+11]; - ssize_t rlres; - int res; -#endif -#endif - int back = 0; -#if DK4_ON_WINDOWS - DK4_UNUSED_ARG(argv0) -#endif - - -#line 303 "dk4exep8.ctr" -#if DK4_USE_ASSERT - assert(NULL != buffer); - assert(0 < sz); -#endif - if ((NULL != buffer) && (0 < sz)) { -#if DK4_ON_WINDOWS - if ((dk4_um_t)0xFFFFFFFFUL >= (dk4_um_t)sz) { - dwsz = (DWORD)sz; - } else { - dwsz = 0xFFFFFFFFUL; - } - res = GetModuleFileNameA(GetModuleHandle(NULL), buffer, dwsz); - if (0 < res) { - if ((dk4_um_t)res < (dk4_um_t)sz) { - buffer[res] = '\0'; - back = 1; - } else { - dk4error_set_simple_error_code(erp, DK4_E_BUFFER_TOO_SMALL); - } - } else { - /* ERROR: Failed to find executable file name */ - dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND); - } -#else -#if DK4_HAVE_GETEXECNAME - - -#line 329 "dk4exep8.ctr" - -#if 0 - /* Prototype is const char *getexecname(void); - */ - if (0 == getexecname(buffer, sz)) { - back = 1; - -#line 335 "dk4exep8.ctr" - } -#endif - - enptr = getexecname(); - if (NULL != enptr) { - if ('/' == *enptr) { - if (strlen(enptr) < sz) { - strcpy(buffer, enptr); - back = 1; - } else { - dk4error_set_simple_error_code(erp, DK4_E_BUFFER_TOO_SMALL); - } - } else { - errno = 0; - if (NULL != getcwd(cwd, sizeof(cwd))) { - if ((strlen(cwd) + strlen(dk4execpath_c8_kw[1]) + strlen(enptr)) < sz) - { - strcpy(buffer, cwd); - strcat(buffer, dk4execpath_c8_kw[1]); - strcat(buffer, enptr); - back = 1; - } - else - { - dk4error_set_simple_error_code(erp, DK4_E_BUFFER_TOO_SMALL); - } - } else { - /* ERROR: Current directory not found */ - dk4error_set_idetails(erp, DK4_E_SYSTEM, errno); - } - } - } -#endif -#if DK4_HAVE_PROC_PID_EXE - if (0 == back) { - -#line 370 "dk4exep8.ctr" - res = dk4ma_write_c8_decimal_unsigned( - numbuf, sizeof(numbuf), (dk4_um_t)getpid(), 0, NULL - ); - if (0 != res) { - -#line 374 "dk4exep8.ctr" - if (0 != dk4str8_cpy_s(fnbuf, sizeof(fnbuf), dk4exep8_kw[0], NULL)) { - - -#line 376 "dk4exep8.ctr" - if (0 != dk4str8_cat_s(fnbuf, sizeof(fnbuf), numbuf, NULL)) { - - -#line 378 "dk4exep8.ctr" - if (0 != dk4str8_cat_s(fnbuf,sizeof(fnbuf),dk4exep8_kw[1],NULL)) { - - -#line 380 "dk4exep8.ctr" - rlres = readlink(fnbuf, buffer, sz); - - -#line 382 "dk4exep8.ctr" - if (0 < rlres) { - -#line 383 "dk4exep8.ctr" - if ((size_t)rlres < sz) { - -#line 384 "dk4exep8.ctr" - buffer[rlres] = '\0'; - -#line 385 "dk4exep8.ctr" - back = 1; - -#line 386 "dk4exep8.ctr" - } - } - } - } - } - } - } -#endif - if (0 == back) { - -#line 395 "dk4exep8.ctr" - if (NULL != argv0) { - back = dk4execpath_c8_inspect_path(buffer, sz, argv0, erp); - if (0 != back) { - -#line 398 "dk4exep8.ctr" - } - } else { - dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); - } - } -#endif - } else { - dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); - } - -#line 407 "dk4exep8.ctr" - return back; -} - - -#if DK4_USE_PRAGMA_WARNING_DISABLE -#pragma warning( pop ) -#endif - |