struct task_s * eval (struct expression_s *expr, struct continuation_s *cont) { switch ( expr->t ) { case EXPRESSION_FUNCTION: return invoke (cont, expr->d.expression_function_v); case EXPRESSION_APPLICATION: { struct continuation_s *ncont = new_continuation (); struct task_s *task = new_task (); ncont->t = CONTINUATION_APP1; init_ptr (&ncont->d.continuation_app1_v.rand, expr->d.expression_application_v.rand); init_ptr (&ncont->d.continuation_app1_v.cont, cont); task->t = TASK_EVAL; init_ptr (&task->d.task_eval_v.expr, expr->d.expression_application_v.rator); init_ptr (&task->d.task_eval_v.cont, ncont); #if 0 /* Harmless but not necessary */ free_continuation (ncont); #endif return task; } } fprintf (stderr, "INTERNAL ERROR: eval() surprised!\n"); return NULL; }
int split(char *str, const char *sep, double **out){ int i = strlen(str); double *buf = init_ptr(i, (double) 0); i = 0; char *pch; char *end_ptr; while(str != NULL){ pch = _strtok(&str, sep); if(strlen(pch) == 0){ delete [] pch; continue; } buf[i++] = strtod(pch, &end_ptr); // Check if double if(*end_ptr) i--; delete [] pch; } *out = init_ptr(i, (double) 0); memcpy(*out, buf, i*sizeof(double)); delete [] buf; return(i); }
/*************************** split() function to, given a string (str), splits into array (out) on char (sep) ***************************/ int split(char *str, const char *sep, int **out){ int i = strlen(str); int *buf = init_ptr(i, 0); i = 0; char *pch; char *end_ptr; while(str != NULL){ pch = _strtok(&str, sep); if(strlen(pch) == 0){ delete [] pch; continue; } buf[i++] = strtol(pch, &end_ptr, 0); // Check if an int if(*end_ptr) i--; delete [] pch; } *out = init_ptr(i, 0); // FGV: why the need for *out?!?!!? memcpy(*out, buf, i*sizeof(int)); delete [] buf; return(i); }
int split(char *str, const char *sep, char ***out){ int i = strlen(str); char **buf = init_ptr(i, 0, (char*) NULL); i = 0; while(str != NULL) buf[i++] = _strtok(&str, sep); *out = init_ptr(i, 0, (char*) NULL); memcpy(*out, buf, i*sizeof(char*)); delete [] buf; return(i); }
int fct_ptr(t_struct *st) { t_ptr *ptr; int i; int pt; int a; ptr = init_ptr(); i = 0; st->pos.y = 0; while (st->tmap[i]) { a = -1; st->pos.x = 0; while (st->tmap[i][++a]) { pt = -1; while (++pt < 9) if (ptr[pt].c == st->tmap[i][a]) (*ptr[pt].ptrf)(st); st->pos.x = st->pos.x + 29; } st->pos.y = st->pos.y + 26; i++; } return (0); }
void push_cont (struct continuation_s* cont) { struct continuation_list *elem = malloc (sizeof(struct continuation_list)); init_ptr (&elem->cont, cont); elem->next = meta_cont; meta_cont = elem; }
struct task_s * run (struct task_s *task) { switch ( task->t ) { case TASK_EVAL: return eval (task->d.task_eval_v.expr, task->d.task_eval_v.cont); case TASK_APP1: { if ( task->d.task_app1_v.erator->t == FUNCTION_D ) { struct function_s *val = new_function (); struct task_s *ntask; val->t = FUNCTION_D1; init_ptr (&val->d.function_d1_v, task->d.task_app1_v.rand); ntask = invoke (task->d.task_app1_v.cont, val); free_function (val); return ntask; } else { struct continuation_s *ncont = new_continuation (); struct task_s *ntask; ncont->t = CONTINUATION_APP; init_ptr (&ncont->d.continuation_app_v.erator, task->d.task_app1_v.erator); init_ptr (&ncont->d.continuation_app_v.cont, task->d.task_app1_v.cont); ntask = eval (task->d.task_app1_v.rand, ncont); free_continuation (ncont); return ntask; } } case TASK_APP: return apply (task->d.task_app_v.erator, task->d.task_app_v.erand, task->d.task_app_v.cont); case TASK_INVOKE: return invoke (task->d.task_invoke_v.cont, task->d.task_invoke_v.val); case TASK_FINAL: /* Should not happen */; } fprintf (stderr, "INTERNAL ERROR: run() surprised!\n"); return NULL; }
// Concat str but duplicates the first one char *strdcat(char *str1, const char *str2){ uint64_t length = strlen(str1) + strlen(str2) + 1; char *str = init_ptr(length, str1); strcat(str, str2); return(str); }
char *join(char *array, uint64_t size, const char *sep){ char *buf = init_ptr(size*5, (char*) NULL); uint64_t len = 0; sprintf(buf, "%c", array[0]); len = strlen(buf); for(uint64_t cnt = 1; cnt < size; cnt++){ sprintf(buf+len, "%s%c", sep, array[cnt]); len = strlen(buf); } char *str = init_ptr(len+1, (char*) NULL); strcpy(str, buf); delete [] buf; return str; }
// Estimate site MAF from (logscaled) GL through an EM // If indF == NULL, assumes uniform prior // Else (0 < indF < 1), assumes HWE with specified level of inbreeding double est_maf(uint64_t n_ind, double **pdg, double F){ double maf; double *indF = init_ptr(n_ind, F); maf = est_maf(n_ind, pdg, indF); free_ptr((void*) indF); return maf; }
int main (int argc, char *argv[]) { struct expression_s *expr; struct continuation_s *finis = new_continuation (); struct continuation_s *cont = new_continuation (); struct task_s *task = new_task (); if ( argc == 1 ) expr = parse (stdin); else if ( argc == 2 ) { FILE *f; f = fopen (argv[1], "r"); if ( ! f ) { perror ("Can't open input file"); exit (1); } expr = parse (f); fclose (f); } else { fprintf (stderr, "Expected zero or one argument"); exit (1); } finis->t = CONTINUATION_FINAL; push_cont(finis); cont->t = CONTINUATION_ABORT; task->t = TASK_EVAL; init_ptr (&task->d.task_eval_v.expr, expr); init_ptr (&task->d.task_eval_v.cont, cont); while ( task->t != TASK_FINAL ) { struct task_s *next_task = run (task); free_task (task); task = next_task; } return 0; }
KPanelExtension* ExtensionProxy::loadExtension(const AppletInfo& info) { KLibLoader* loader = KLibLoader::self(); KLibrary* lib = loader->library(TQFile::encodeName(info.library())); if (!lib) { kdWarning() << "cannot open extension: " << info.library() << " because of " << loader->lastErrorMessage() << endl; return 0; } KPanelExtension* (*init_ptr)(TQWidget *, const TQString&); init_ptr = (KPanelExtension* (*)(TQWidget *, const TQString&))lib->symbol( "init" ); if (!init_ptr) { kdWarning() << info.library() << " is not a kicker extension!" << endl; return 0; } return init_ptr(0, info.configFile()); }
double* read_pos(char *in_pos, uint64_t n_sites){ uint64_t n_fields; char *buf = init_ptr(BUFF_LEN, (const char*) '\0'); char *prev_chr = init_ptr(BUFF_LEN, (const char*) '\0'); uint64_t prev_pos = 0; // Allocate memory double *pos_dist = init_ptr(n_sites+1, (double) INFINITY); // Open file gzFile in_pos_fh = open_gzfile(in_pos, "r"); if(in_pos_fh == NULL) error(__FUNCTION__, "cannot open POS file!"); for(uint64_t s = 1; s <= n_sites; s++){ char **tmp; if( gzgets(in_pos_fh, buf, BUFF_LEN) == NULL) error(__FUNCTION__, "cannot read next site from POS file!"); // Remove trailing newline chomp(buf); // Check if empty if(strlen(buf) == 0) continue; // Parse input line into array n_fields = split(buf, (const char*) " \t", &tmp); // Check if header and skip if(!n_fields || strtod(tmp[1], NULL)==0){ fprintf(stderr, "> Header found! Skipping line...\n"); if(s != 1){ warn(__FUNCTION__, " header found but not on first line. Is this an error?"); fprintf(stderr, "%s/n", buf); } s--; continue; } if(n_fields < 2) error(__FUNCTION__, "wrong POS file format!"); // If first chr to be parsed if(strlen(prev_chr) == 0) strcpy(prev_chr, tmp[0]); if(strcmp(prev_chr, tmp[0]) == 0){ pos_dist[s] = strtod(tmp[1], NULL) - prev_pos; if(pos_dist[s] < 1) error(__FUNCTION__, "invalid distance between adjacent sites!"); }else{ pos_dist[s] = INFINITY; strcpy(prev_chr, tmp[0]); } prev_pos = strtoul(tmp[1], NULL, 0); // Free memory free_ptr((void**) tmp, n_fields); } // Check if file is at EOF gzread(in_pos_fh, buf, 1); if(!gzeof(in_pos_fh)) error(__FUNCTION__, "POS file not at EOF. Check POS file and number of sites!"); gzclose(in_pos_fh); delete [] buf; delete [] prev_chr; return pos_dist; }
struct task_s * invoke (struct continuation_s *cont, struct function_s *val) { switch ( cont->t ) { case CONTINUATION_APP1: { struct task_s *task = new_task (); task->t = TASK_APP1; init_ptr (&task->d.task_app1_v.erator, val); init_ptr (&task->d.task_app1_v.rand, cont->d.continuation_app1_v.rand); init_ptr (&task->d.task_app1_v.cont, cont->d.continuation_app1_v.cont); return task; } case CONTINUATION_APP: { struct task_s *task = new_task (); task->t = TASK_APP; init_ptr (&task->d.task_app_v.erator, cont->d.continuation_app_v.erator); init_ptr (&task->d.task_app_v.erand, val); init_ptr (&task->d.task_app_v.cont, cont->d.continuation_app_v.cont); return task; } case CONTINUATION_DEL: { struct task_s *task = new_task (); task->t = TASK_APP; init_ptr (&task->d.task_app_v.erator, val); init_ptr (&task->d.task_app_v.erand, cont->d.continuation_del_v.erand); init_ptr (&task->d.task_app_v.cont, cont->d.continuation_del_v.cont); return task; } case CONTINUATION_ABORT: { struct task_s *task = new_task (); struct continuation_s *cont = pop_cont (); task->t = TASK_INVOKE; init_ptr (&task->d.task_invoke_v.cont, cont); init_ptr (&task->d.task_invoke_v.val, val); release_continuation(cont); return task; } case CONTINUATION_FINAL: { struct task_s *task = new_task (); task->t = TASK_FINAL; return task; } } fprintf (stderr, "INTERNAL ERROR: invoke() surprised!\n"); return NULL; }
struct expression_s * parse (FILE *input) { int ch; do { ch = getc (input); if ( ch == '#' ) while ( ch != '\n' && ch != EOF ) ch = getc (input); } while ( ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' ); if ( ch == '`' ) { struct expression_s *rator = parse (input); struct expression_s *rand = parse (input); struct expression_s *expr = new_expression (); expr->t = EXPRESSION_APPLICATION; init_ptr (&expr->d.expression_application_v.rator, rator); init_ptr (&expr->d.expression_application_v.rand, rand); #if 0 /* Harmless but not necessary */ free_expression (rator); free_expression (rand); #endif return expr; } else if ( ch == 'i' || ch == 'I' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_I; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 'k' || ch == 'K' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_K; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 's' || ch == 'S' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_S; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 'v' || ch == 'V' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_V; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 'd' || ch == 'D' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_D; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 'e' || ch == 'E' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_E; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 'p' || ch == 'P' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_P; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 'f' || ch == 'F' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_F; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == 'r' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_DOT; fun->d.function_dot_v = '\n'; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == '.' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); int ch2; fun->t = FUNCTION_DOT; ch2 = getc (input); if ( ch2 == EOF ) goto ueof; fun->d.function_dot_v = ch2; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == '@' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_AT; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == '?' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); int ch2; fun->t = FUNCTION_QUES; ch2 = getc (input); if ( ch2 == EOF ) goto ueof; fun->d.function_ques_v = ch2; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == '|' ) { struct function_s *fun = new_function (); struct expression_s *expr = new_expression (); fun->t = FUNCTION_PIPE; expr->t = EXPRESSION_FUNCTION; init_ptr (&expr->d.expression_function_v, fun); #if 0 /* Harmless but not necessary */ free_function (fun); #endif return expr; } else if ( ch == EOF ) { ueof: fprintf (stderr, "Unexpected end of file\n"); exit (1); } else { fprintf (stderr, "Character not recognized: %c\n", ch); exit (1); } return NULL; }
struct task_s * apply (struct function_s *rator, struct function_s *rand, struct continuation_s *cont) { switch ( rator->t ) { case FUNCTION_I: return invoke (cont, rand); case FUNCTION_DOT: putchar (rator->d.function_dot_v); return invoke (cont, rand); case FUNCTION_K1: return invoke (cont, rator->d.function_k1_v); case FUNCTION_K: { struct function_s *val = new_function (); struct task_s *task; val->t = FUNCTION_K1; init_ptr (&val->d.function_k1_v, rand); task = invoke (cont, val); free_function (val); return task; } case FUNCTION_S2: { struct expression_s *e_x = new_expression (); struct expression_s *e_y = new_expression (); struct expression_s *e_z = new_expression (); struct expression_s *e1 = new_expression (); struct expression_s *e2 = new_expression (); struct expression_s *e = new_expression (); struct task_s *task = new_task (); e_x->t = EXPRESSION_FUNCTION; init_ptr (&e_x->d.expression_function_v, rator->d.function_s2_v.x); e_y->t = EXPRESSION_FUNCTION; init_ptr (&e_y->d.expression_function_v, rator->d.function_s2_v.y); e_z->t = EXPRESSION_FUNCTION; init_ptr (&e_z->d.expression_function_v, rand); e1->t = EXPRESSION_APPLICATION; init_ptr (&e1->d.expression_application_v.rator, e_x); init_ptr (&e1->d.expression_application_v.rand, e_z); e2->t = EXPRESSION_APPLICATION; init_ptr (&e2->d.expression_application_v.rator, e_y); init_ptr (&e2->d.expression_application_v.rand, e_z); e->t = EXPRESSION_APPLICATION; init_ptr (&e->d.expression_application_v.rator, e1); init_ptr (&e->d.expression_application_v.rand, e2); task->t = TASK_EVAL; init_ptr (&task->d.task_eval_v.expr, e); init_ptr (&task->d.task_eval_v.cont, cont); #if 0 /* Harmless but not necessary */ free_expression (e_x); free_expression (e_y); free_expression (e_z); free_expression (e1); free_expression (e2); free_expression (e); #endif return task; } case FUNCTION_S1: { struct function_s *val = new_function (); struct task_s *task; val->t = FUNCTION_S2; init_ptr (&val->d.function_s2_v.x, rator->d.function_s1_v); init_ptr (&val->d.function_s2_v.y, rand); task = invoke (cont, val); free_function (val); return task; } case FUNCTION_S: { struct function_s *val = new_function (); struct task_s *task; val->t = FUNCTION_S1; init_ptr (&val->d.function_s1_v, rand); task = invoke (cont, val); free_function (val); return task; } case FUNCTION_V: return invoke (cont, rator); case FUNCTION_D1: { struct continuation_s *ncont = new_continuation (); struct task_s *task = new_task (); ncont->t = CONTINUATION_DEL; init_ptr (&ncont->d.continuation_del_v.erand, rand); init_ptr (&ncont->d.continuation_del_v.cont, cont); task->t = TASK_EVAL; init_ptr (&task->d.task_eval_v.expr, rator->d.function_d1_v); init_ptr (&task->d.task_eval_v.cont, ncont); #if 0 /* Harmless but not necessary */ free_continuation (ncont); #endif return task; } case FUNCTION_D: { struct expression_s *promise = new_expression (); struct function_s *val = new_function (); struct task_s *task; promise->t = EXPRESSION_FUNCTION; init_ptr (&promise->d.expression_function_v, rand); val->t = FUNCTION_D1; init_ptr (&val->d.function_d1_v, promise); task = invoke (cont, val); free_continuation (cont); free_function (val); return task; } case FUNCTION_CONT: return invoke (rator->d.function_cont_v, rand); case FUNCTION_DCONT: { struct function_s *val = new_function (); struct task_s *task = new_task (); struct continuation_s *ncont = new_continuation (); push_cont (cont); val->t = FUNCTION_CONT; init_ptr (&val->d.function_cont_v, rator->d.function_cont_v); task->t = TASK_APP; ncont->t = CONTINUATION_ABORT; init_ptr (&task->d.task_app_v.erator, val); init_ptr (&task->d.task_app_v.erand, rand); init_ptr (&task->d.task_app_v.cont, ncont); return task; } case FUNCTION_P: { struct function_s *val = new_function (); struct task_s *task = new_task (); struct continuation_s *ncont = new_continuation (); push_cont (cont); val->t = FUNCTION_I; task->t = TASK_APP; ncont->t = CONTINUATION_ABORT; init_ptr (&task->d.task_app_v.erator, rand); init_ptr (&task->d.task_app_v.erand, val); init_ptr (&task->d.task_app_v.cont, ncont); return task; } case FUNCTION_F: { struct function_s *val = new_function (); struct task_s *task = new_task (); struct continuation_s *ncont = new_continuation (); val->t = FUNCTION_DCONT; init_ptr (&val->d.function_cont_v, cont); task->t = TASK_APP; ncont->t = CONTINUATION_ABORT; init_ptr (&task->d.task_app_v.erator, rand); init_ptr (&task->d.task_app_v.erand, val); init_ptr (&task->d.task_app_v.cont, ncont); return task; } case FUNCTION_E: { struct task_s *task = new_task (); task->t = TASK_FINAL; return task; } case FUNCTION_AT: { struct function_s *val = new_function (); struct task_s *task = new_task (); current_ch = getchar (); val->t = (current_ch != EOF ? FUNCTION_I : FUNCTION_V); task->t = TASK_APP; init_ptr (&task->d.task_app_v.erator, rand); init_ptr (&task->d.task_app_v.erand, val); init_ptr (&task->d.task_app_v.cont, cont); #if 0 /* Harmless but not necessary */ free_function (val); #endif return task; } case FUNCTION_QUES: { struct function_s *val = new_function (); struct task_s *task = new_task (); val->t = (current_ch == rator->d.function_ques_v ? FUNCTION_I : FUNCTION_V); task->t = TASK_APP; init_ptr (&task->d.task_app_v.erator, rand); init_ptr (&task->d.task_app_v.erand, val); init_ptr (&task->d.task_app_v.cont, cont); #if 0 /* Harmless but not necessary */ free_function (val); #endif return task; } case FUNCTION_PIPE: { struct function_s *val = new_function (); struct task_s *task = new_task (); if ( current_ch != EOF ) { val->t = FUNCTION_DOT; val->d.function_dot_v = current_ch; } else val->t = FUNCTION_V; task->t = TASK_APP; init_ptr (&task->d.task_app_v.erator, rand); init_ptr (&task->d.task_app_v.erand, val); init_ptr (&task->d.task_app_v.cont, cont); #if 0 /* Harmless but not necessary */ free_function (val); #endif return task; } } fprintf (stderr, "INTERNAL ERROR: apply() surprised!\n"); return NULL; }
mt_throws Result loadModule (ConstMemory const filename, void * const app_specific) { #ifdef LIBMARY_GLIB GModule * const module = g_module_open ((gchar const*) makeString (filename)->cstr(), (GModuleFlags) (G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL)); if (!module) { exc_throw (InternalException, InternalException::BackendError); logE_ (_func, "failed to open module ", filename, ": ", g_module_error()); return Result::Failure; } ModuleInitFunc init_ptr; if (!g_module_symbol (module, "libMary_moduleInit_wrapper", (gpointer*) &init_ptr)) { exc_throw (InternalException, InternalException::BackendError); logE_ (_func, "failed to open module ", filename, ": " "g_module_symbol (\"libMary_moduleInit_wrapper\") failed: ", g_module_error()); return Result::Failure; } if (!init_ptr (app_specific)) { logE_ (_func, "could notd initialize module ", filename); return Result::Failure; } return Result::Success; #else libraryLock (); void * const handle = dlopen ( #ifdef LIBMARY_PLATFORM_MACOSX makeString (filename, ".0.dylib")->cstr(), #else makeString (filename, ".so")->cstr(), #endif RTLD_LAZY); if (!handle) { char const * const err_str = dlerror (); libraryUnlock (); exc_throw (InternalException, InternalException::BackendError); logE_ (_func, "dlopen (", filename, ") failed: ", err_str); return Result::Failure; } dlerror (); // Clearing any old error conditions. See man dlsym(3). void * const init_ptr = dlsym (handle, "libMary_moduleInit"); if (!init_ptr) { char const * const err_str = dlerror (); libraryUnlock (); exc_throw (InternalException, InternalException::BackendError); logE_ (_func, "dlsym (", filename, ", libMary_moduleInit) failed: ", err_str); return Result::Failure; } libraryUnlock (); bool const res = ((ModuleInitFunc) init_ptr) (app_specific); if (!res) { exc_throw (InternalException, InternalException::BackendError); logE_ (_func, "module init failed: ", filename); } return res ? Result::Success : Result::Failure; #endif }