void solve_sub(bool emscripten_mode) {

  bool happy = true;

#ifdef HEAP_CHECK
  acf_setup();
#endif

  if (happy) {
    index_from = ac_index_new();
    happy = index_from;
    if (!happy) report_fallback(0);
  }

  if (happy) {
    index_to = ac_index_new();
    happy = index_to;
    if (!happy) report_fallback(1);
  }

  if (happy) {
    CARRAY(masks_from, rules_count);
    happy = masks_from;
    if (!happy) report_fallback(2);
  }

  if (happy) {
    CARRAY(masks_to, rules_count);
    happy = masks_to;
    if (!happy) report_fallback(3);
  }

  if (happy) {
    happy = process_rules();
    if (!happy) report_fallback(4);
  }

  if (happy) {
    happy = ac_index_fix(index_from);
    if (!happy) report_fallback(5);
  }

  if (happy) {
    happy = ac_index_fix(index_to);
    if (!happy) report_fallback(6);
  }

  if (happy) {
    CARRAY(query_from, rules_count);
    happy = query_from;
    if (!happy) report_fallback(7);
  }

  if (happy) {
    CARRAY(query_to, rules_count);
    happy = query_to;
    if (!happy) report_fallback(8);
  }

  if (happy) {
    MALLOC_REMAINING(emscripten_mode);
    happy = results_buffer;
    if (!happy) report_fallback(9);
  }

  if (happy) {
    happy = process_messages(false);
    if (!happy) report_fallback(10);
  }

  if (happy) {

#ifdef HEAP_CHECK
    fprintf(stderr, "\n--=== no fallback ===--\n\n");
#endif

  } else {

    cleanup();
    MALLOC_REMAINING(emscripten_mode);
    if (!results_buffer) abort(); // must work second time
    process_messages(true);

  }

  // fprintf(stderr, "minimal_width %d\n", minimal_width);
  // fprintf(stderr, "candidates_count %d\n", candidates_count);
  // fprintf(stderr, "candidates_length %d\n", candidates_length);
  // fprintf(stderr, "insertions_count %d\n", insertions_count);
  // fprintf(stderr, "insertions_length %d\n", insertions_length);
  // fprintf(stderr, "wildcards_count %d\n", wildcards_count);
  // fprintf(stderr, "wildcards_length %d\n", wildcards_length);
  // fprintf(stderr, "query_successes %d\n", query_successes);
  // fprintf(stderr, "handy_calls %d\n", handy_calls);

}
Exemple #2
0
int server_execute(int index, void *prpc_param[])
{
   int status;

   switch (index) {
   default:
      abort();
      break;

   case RPC_MSCB_INIT:
      status = mscb_init(CSTRING(0), CINT(1), CINT(2));
      break;

   case RPC_MSCB_EXIT:
      status = mscb_exit(CINT(0));
      break;

   case RPC_MSCB_REBOOT:
      status = mscb_reboot(CINT(0), CINT(1));
      break;

   case RPC_MSCB_RESET:
      status = mscb_reset(CINT(0));
      break;

   case RPC_MSCB_PING:
      status = mscb_ping(CINT(0), CINT(1));
      break;

   case RPC_MSCB_INFO:
      status = mscb_info(CINT(0), CINT(1), CARRAY(2));
      break;

   case RPC_MSCB_INFO_VARIABLE:
      status = mscb_info_variable(CINT(0), CINT(1), CINT(2), CARRAY(3));
      break;

   case RPC_MSCB_SET_ADDR:
      status = mscb_set_addr(CINT(0), CINT(1), CINT(2), CINT(3));
      break;

   case RPC_MSCB_SET_NAME:
      status = mscb_set_name(CINT(0), CINT(1), CSTRING(2));
      break;

   case RPC_MSCB_WRITE_GROUP:
      status = mscb_write_group(CINT(0), CINT(1), CBYTE(2), CARRAY(3), CINT(4));
      break;

   case RPC_MSCB_WRITE:
      status = mscb_write(CINT(0), CINT(1), CBYTE(2), CARRAY(3), CINT(4));
      break;

   case RPC_MSCB_FLASH:
      status = mscb_flash(CINT(0), CINT(1));
      break;

   case RPC_MSCB_UPLOAD:
      status = mscb_upload(CINT(0), CINT(1), CARRAY(2), CINT(3), CINT(4));
      break;

   case RPC_MSCB_READ:
      status = mscb_read(CINT(0), CINT(1), CBYTE(2), CARRAY(3), CPINT(4));
      break;

   case RPC_MSCB_READ_RANGE:
      status = mscb_read_range(CINT(0), CINT(1), CBYTE(2), CBYTE(3), CARRAY(4), CPINT(5));
      break;

   case RPC_MSCB_ECHO:
      status = mscb_echo(CINT(0), CINT(1), CBYTE(2), CPBYTE(3));
      break;

   case RPC_MSCB_USER:
      status = mscb_user(CINT(0), CINT(1), CARRAY(2), CINT(3), CARRAY(4), CPINT(5));
      break;

   case RPC_MSCB_ADDR:
      status = mscb_addr(CINT(0), CINT(1), CINT(2), CINT(3), CINT(4));
      break;
   }

   return status;
}