15 #define NTDDI_VERSION 0x06010000
16 #define _WIN32_WINNT 0x0601
22 impl_s_no_memory_for_backtrace =
34 #ifdef __EXAMPLE_FOR_CREATING_WITH_CB_WRAPPER_
36 impl_get_<objectId>_object_cb(
47 &afw_s__AdaptiveSystemInfo_,
52 result, &afw_s_description,
53 "<objectId> description.",
58 afw_object_set_property_from_utf8_z(result,
64 result, &impl_s_os, &afw_s_label,
69 result, &impl_s_os, &afw_s_description,
88 &afw_s__AdaptiveSystemInfo_,
93 result, &afw_s_description,
94 "General systems info.",
105 result, &impl_s_os, &afw_s_label,
110 result, &impl_s_os, &afw_s_description,
116 &afw_s_S, 1923, 12, 31, -4, 0, xctx);
119 &afw_s_N, 1923, 12, 31, 12, 30, 14, 999999, -4, 0, xctx);
122 &afw_s_M, 12, 30, 14, 999999, -4, 0, xctx);
125 &afw_s_B,
true, 12, 34, 56, 78, 90, xctx);
128 &afw_s_L,
false, 12, 34, 56, 78, 90, xctx);
131 &afw_s_SS,
true, 100, 200, xctx);
134 &afw_s_NS,
false, 100, 200, xctx);
153 &log_factory->log_type,
157 object = impl_create_general_object(xctx);
160 #ifdef __EXAMPLE_FOR_CREATING_WITH_CB_WRAPPER_
164 &afw_s__AdaptiveSystemInfo_, &afw_s_<objectId>,
165 impl_get_<objectId>_object_cb, NULL,
false, xctx);
176 return GetCurrentProcessId();
184 return &impl_dso_suffix;
207 IMAGEHLP_LINE64 line;
208 const char *filename, *c;
209 char buffer[
sizeof(SYMBOL_INFO) + MAX_SYM_NAME *
sizeof(TCHAR)];
210 DWORD dwDisplacement = 0;
211 DWORD64 dwDisplacement64 = 0;
212 PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
213 pSymbol->SizeOfStruct =
sizeof(SYMBOL_INFO);
214 pSymbol->MaxNameLen = MAX_SYM_NAME;
216 process = GetCurrentProcess();
217 SymInitialize(process, NULL, TRUE);
218 SymSetOptions(SYMOPT_LOAD_LINES);
219 line.SizeOfStruct =
sizeof(IMAGEHLP_LINE64);
221 if (max_backtrace == 0)
return NULL;
222 if (max_backtrace < 0) max = 100;
223 else if (max_backtrace > 99) max = 100;
224 else max = max_backtrace + 1;
234 len = (max + 10) * 100;
236 if (!s)
return &impl_s_no_memory_for_backtrace;
238 if (!result)
return &impl_s_no_memory_for_backtrace;
242 frames = CaptureStackBackTrace(0, max, stack, NULL);
245 for (i = 1; i < frames; i++) {
246 if (SymGetLineFromAddr64(
247 process,(DWORD64)(stack[i]), &dwDisplacement, &line))
249 filename = c = line.FileName;
251 for (; *c; c++)
if (*c ==
'\\') filename = c + 1;
257 SymFromAddr(process, (DWORD64)( stack[i] ),
258 &dwDisplacement64, pSymbol);
261 wlen = snprintf(s, len,
"%i: %s:%d %s\n", i - 1,
262 filename, line.LineNumber,
263 (pSymbol->Name) ? pSymbol->Name :
"");
264 if (wlen < 0 || (
afw_size_t)wlen > len)
break;
269 error = GetLastError();
274 result->len = s - result->s;
Adaptive Framework Core API.
AFW_DEFINE(const afw_object_t *)
#define AFW_UTF8_LITERAL(A_STRING)
String literal initializer.
enum afw_error_code_e afw_error_code_t
unsigned char afw_byte_t
A byte of memory (unsigned).
apr_uint32_t afw_uint32_t
32-bit unsigned integer.
apr_size_t afw_size_t
size_t.
void afw_environment_register_log_type(const afw_utf8_t *log_type, const afw_log_factory_t *log_factory, afw_xctx_t *xctx)
Register an log factory.
afw_object_set_property_as_date_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, int year, int month, int day, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set a date property from parts.
afw_object_set_property_as_dayTimeDuration_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, afw_boolean_t is_positive, int days, int hours, int minutes, int seconds, int microseconds, afw_xctx_t *xctx)
Set a dayTimeDuration property from parts.
#define afw_object_create(p, xctx)
Create an empty unmanaged object in memory.
afw_object_set_property_as_dateTime_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, int year, int month, int day, int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set a dateTime property from parts.
afw_object_set_property_as_time_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, int hour, int minute, int second, int microsecond, int tz_hours_offset, int tz_minutes_offset, afw_xctx_t *xctx)
Set a time property from parts.
afw_object_set_property_as_yearMonthDuration_from_parts(const afw_object_t *instance, const afw_utf8_t *property_name, afw_boolean_t is_positive, int years, int months, afw_xctx_t *xctx)
Set a yearMonthDuration property from parts.
afw_object_set_property_as_string_from_utf8_z(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_utf8_z_t *string_z, afw_xctx_t *xctx)
Set an string property from utf8_z.
afw_os_environment_initialize(afw_xctx_t *xctx)
afw_os environment initialize
afw_os_backtrace(afw_error_code_t code, int max_backtrace, afw_xctx_t *xctx)
Provide a backtrace if possible.
afw_os_get_dso_suffix()
Return the suffix appended to dso file names for this system.
afw_os_get_pid()
Return a process id or similar number.
const afw_log_factory_t * afw_os_log_factory_get()
Get the factory for OS log.
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
afw_runtime_env_set_object(const afw_object_t *object, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set an object pointer in the environment's runtime objects.
afw_runtime_env_set_object_cb_wrapper(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_runtime_object_wrapper_p_cb_t callback, void *data, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set environment object accessed via callback.
Interface afw_log_factory public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Interface afw_xctx public struct.