summaryrefslogtreecommitdiffhomepage
path: root/src/internal
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/argv/argv.h95
-rw-r--r--src/internal/mdso_errinfo_impl.c2
-rw-r--r--src/internal/mdso_errinfo_impl.h2
-rw-r--r--src/internal/mdso_hexfmt_impl.c35
-rw-r--r--src/internal/mdso_hexfmt_impl.h14
-rw-r--r--src/internal/mdso_object_impl.h16
-rw-r--r--src/internal/perk/perk_structs.h4
7 files changed, 142 insertions, 26 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 973983a..85de781 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -1,6 +1,6 @@
/****************************************************************************/
/* argv.h: a thread-safe argument vector parser and usage screen generator */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************************/
@@ -83,6 +83,7 @@ enum argv_error {
ARGV_ERROR_INTERNAL,
ARGV_ERROR_SHORT_OPTION,
ARGV_ERROR_LONG_OPTION,
+ ARGV_ERROR_VENDOR_OPTION,
ARGV_ERROR_OPTARG_NONE,
ARGV_ERROR_OPTARG_REQUIRED,
ARGV_ERROR_OPTARG_PARADIGM,
@@ -398,7 +399,11 @@ static void argv_scan(
fval = ch;
}
} else {
- ferr = ARGV_ERROR_SHORT_OPTION;
+ if ((ch == &parg[0][1]) && (ch[0] == 'W') && ch[1]) {
+ ferr = ARGV_ERROR_VENDOR_OPTION;
+ } else {
+ ferr = ARGV_ERROR_SHORT_OPTION;
+ }
}
} else if (!fnoscan && (fhybrid || is_long_option(ch))) {
@@ -413,49 +418,72 @@ static void argv_scan(
ch = *parg;
}
- if (fhybrid && !(option->flags & ARGV_OPTION_HYBRID_SWITCH))
+ /* now verify the proper setting of option values */
+ if (fhybrid && !(option->flags & ARGV_OPTION_HYBRID_SWITCH)) {
ferr = ARGV_ERROR_HYBRID_NONE;
- else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY))
+
+ } else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY)) {
ferr = ARGV_ERROR_HYBRID_ONLY;
- else if (option->optarg == ARGV_OPTARG_NONE) {
+
+ } else if (option->optarg == ARGV_OPTARG_NONE) {
if (val[0]) {
ferr = ARGV_ERROR_OPTARG_NONE;
ctx->errch = val + 1;
- } else
+ } else {
fval = false;
+ }
+
} else if (val[0] && (option->flags & ARGV_OPTION_HYBRID_JOINED)) {
fval = true;
ch = val;
- } else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE))
- ferr = ARGV_ERROR_HYBRID_SPACE;
- else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL))
+
+ } else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE)) {
+ if (option->optarg == ARGV_OPTARG_OPTIONAL) {
+ fval = false;
+
+ } else {
+ ferr = ARGV_ERROR_HYBRID_SPACE;
+ }
+
+ } else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL)) {
ferr = ARGV_ERROR_HYBRID_EQUAL;
- else if (fhybrid && (val[0]==',') && !(option->flags & ARGV_OPTION_HYBRID_COMMA))
+
+ } else if (fhybrid && (val[0]==',') && !(option->flags & ARGV_OPTION_HYBRID_COMMA)) {
ferr = ARGV_ERROR_HYBRID_COMMA;
- else if (!fhybrid && (val[0]==','))
+
+ } else if (!fhybrid && (val[0]==',')) {
ferr = ARGV_ERROR_HYBRID_COMMA;
- else if (val[0] && !val[1])
+
+ } else if (val[0] && !val[1]) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (val[0] && val[1]) {
+
+ } else if (val[0] && val[1]) {
fval = true;
ch = ++val;
+
} else if (option->optarg == ARGV_OPTARG_REQUIRED) {
- if (!val[0] && !*parg)
+ if (!val[0] && !*parg) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (*parg && is_short_option(*parg))
+
+ } else if (*parg && is_short_option(*parg)) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (*parg && is_long_option(*parg))
+
+ } else if (*parg && is_long_option(*parg)) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else if (*parg && is_last_option(*parg))
+
+ } else if (*parg && is_last_option(*parg)) {
ferr = ARGV_ERROR_OPTARG_REQUIRED;
- else
+
+ } else {
fval = true;
+ }
} else {
/* ARGV_OPTARG_OPTIONAL */
fval = val[0];
}
- } else
+ } else {
ferr = ARGV_ERROR_LONG_OPTION;
+ }
}
if (ferr == ARGV_ERROR_OK)
@@ -531,7 +559,11 @@ static const char * argv_program_name(const char * program_path)
static void argv_show_error(int fd, struct argv_ctx * ctx)
{
- char opt_short_name[2] = {0,0};
+ const char * src;
+ char * dst;
+ char * cap;
+ char opt_vendor_buf[256];
+ char opt_short_name[2] = {0,0};
if (ctx->erropt && ctx->erropt->short_name)
opt_short_name[0] = ctx->erropt->short_name;
@@ -547,6 +579,27 @@ static void argv_show_error(int fd, struct argv_ctx * ctx)
argv_dprintf(fd,"'--%s' is not a valid long option\n",ctx->errch);
break;
+ case ARGV_ERROR_VENDOR_OPTION:
+ src = ctx->errch;
+ dst = opt_vendor_buf;
+ cap = &opt_vendor_buf[sizeof(opt_vendor_buf)];
+
+ for (; src && *src && dst<cap; ) {
+ if ((*src == '=') || (*src == ',') || (*src == ':')) {
+ src = 0;
+ } else {
+ *dst++ = *src++;
+ }
+ }
+
+ if (dst == cap)
+ dst--;
+
+ *dst = '\0';
+
+ argv_dprintf(fd,"'-%s' is not a valid vendor option\n",opt_vendor_buf);
+ break;
+
case ARGV_ERROR_OPTARG_NONE:
argv_dprintf(fd,"'%s' is not a valid option value for [%s%s%s%s%s] "
"(option values may not be specified)\n",
@@ -851,7 +904,7 @@ static void argv_usage_impl(
/* color */
if (fcolor) {
color = (color == ccyan) ? cblue : ccyan;
- argv_dprintf(fd,color);
+ argv_dprintf(fd,color,0);
}
/* description, using either paradigm or argname if applicable */
diff --git a/src/internal/mdso_errinfo_impl.c b/src/internal/mdso_errinfo_impl.c
index d7ea6ae..28a663c 100644
--- a/src/internal/mdso_errinfo_impl.c
+++ b/src/internal/mdso_errinfo_impl.c
@@ -1,6 +1,6 @@
/****************************************************************/
/* mdso: midipix dso scavenger */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************/
diff --git a/src/internal/mdso_errinfo_impl.h b/src/internal/mdso_errinfo_impl.h
index 4b4b693..6c83033 100644
--- a/src/internal/mdso_errinfo_impl.h
+++ b/src/internal/mdso_errinfo_impl.h
@@ -1,6 +1,6 @@
/****************************************************************/
/* mdso: midipix dso scavenger */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************/
diff --git a/src/internal/mdso_hexfmt_impl.c b/src/internal/mdso_hexfmt_impl.c
new file mode 100644
index 0000000..33d337b
--- /dev/null
+++ b/src/internal/mdso_hexfmt_impl.c
@@ -0,0 +1,35 @@
+/****************************************************************/
+/* mdso: midipix dso scavenger */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
+/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
+/****************************************************************/
+
+#include <stdint.h>
+
+char buf[256] = {0};
+
+static unsigned char mdso_hexfmt[16] = {
+ '0','1','2','3','4','5','6','7',
+ '8','9','a','b','c','d','e','f',
+};
+
+void mdso_write_hex_64(char * ch, uint64_t val)
+{
+ ch[0xf] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xe] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xd] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xc] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xb] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xa] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x9] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x8] = mdso_hexfmt[val % 16]; val >>= 4;
+
+ ch[0x7] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x6] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x5] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x4] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x3] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x2] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x1] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x0] = mdso_hexfmt[val % 16]; val >>= 4;
+}
diff --git a/src/internal/mdso_hexfmt_impl.h b/src/internal/mdso_hexfmt_impl.h
new file mode 100644
index 0000000..1ad74d1
--- /dev/null
+++ b/src/internal/mdso_hexfmt_impl.h
@@ -0,0 +1,14 @@
+/****************************************************************/
+/* mdso: midipix dso scavenger */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
+/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
+/****************************************************************/
+
+#ifndef MDSO_HEXFMT_IMPL_H
+#define MDSO_HEXFMT_IMPL_H
+
+#include <stdint.h>
+
+void mdso_write_hex_64(char * ch, uint64_t val);
+
+#endif
diff --git a/src/internal/mdso_object_impl.h b/src/internal/mdso_object_impl.h
index 3442856..539a77d 100644
--- a/src/internal/mdso_object_impl.h
+++ b/src/internal/mdso_object_impl.h
@@ -1,6 +1,6 @@
/****************************************************************/
/* mdso: midipix dso scavenger */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************/
@@ -31,3 +31,17 @@ static inline void mdso_obj_write_quad(unsigned char * ch, uint64_t val)
ch[6] = val >> 48;
ch[7] = val >> 56;
}
+
+static inline void mdso_obj_write_dec(unsigned char * ch, uint64_t dec)
+{
+ int digits;
+ uint64_t val;
+
+ *ch = '0';
+
+ for (digits=0,val=dec; val; digits++)
+ val /= 10;
+
+ for (val=dec; val; val/=10)
+ ch[--digits] = (val % 10) + '0';
+}
diff --git a/src/internal/perk/perk_structs.h b/src/internal/perk/perk_structs.h
index 4dd2ffc..9ffb480 100644
--- a/src/internal/perk/perk_structs.h
+++ b/src/internal/perk/perk_structs.h
@@ -326,13 +326,13 @@ struct pe_raw_coff_symbol_name {
unsigned char cs_zeroes [0x04]; /* 0x00 */
unsigned char cs_offset [0x04]; /* 0x04 */
} long_name;
- };
+ } cs_u;
};
struct pe_raw_coff_strtbl {
unsigned char cst_size [0x04]; /* 0x00 */
- unsigned char cst_data[]; /* 0x04 */
+ unsigned char cst_data []; /* 0x04 */
};