Exemple #1
0
Fichier : void.c Projet : xtools/xt
char *xt_core_basic_void_get_as_string(void *object)
{
  xt_core_trace_exit("TODO: implement/test");

  assert(object);
  char *string;

  string = malloc(10 + 1);
  if (string) {
    snprintf(string, 10 + 1, "%p", object);
  } else {
    xt_core_trace_exit("malloc");
  }

  return string;
}
Exemple #2
0
int main(int argc, char *argv[])
{
  xt_config_file_t *conf;
  unsigned short port_min;
  unsigned short port_max;
  xt_case_list_t *node_ip_list;
  char *node_ip;

  conf = xt_config_file_create("config/file.test.conf");
  if (xt_core_bool_true) {

    if (!xt_config_file_find_as_unsigned_short
        (conf, "port_min", &port_min, DEFAULT_PORT_MIN)) {
      xt_core_trace_exit("x_config_file_find_as_unsigned_short");
    }

    if (!xt_config_file_find_as_unsigned_short
        (conf, "port_max", &port_max, DEFAULT_PORT_MAX)) {
      xt_core_trace_exit("x_config_file_find_as_unsigned_short");
    }

    if (!xt_config_file_find_list_as_strings
        (conf, "node_ips[list]", &node_ip_list)) {
      xt_core_trace_exit("x_config_file_find_list");
    }

    printf("port_min:%i\n", port_min);
    printf("port_max:%i\n", port_max);
    if (node_ip_list) {
      xt_case_list_iterate_start(node_ip_list);
      while ((node_ip = xt_case_list_iterate_next(node_ip_list))) {
        printf("node_ip:%s\n", node_ip);
      }
    }
  }
  xt_config_file_destroy(conf);

  return 0;
}
Exemple #3
0
Fichier : csv.c Projet : xtools/xt
xt_case_array_t *create_index_to_name_array(xt_file_csv_t *csv,
    xt_file_basic_t *file)
{
  assert(csv);
  assert(file);
  xt_case_array_t *index_to_name;
  char *first_line;
  xt_case_list_t *line_list;
  xt_case_list_t *field_names;
  char *field_name;
  unsigned long field_index;

  index_to_name = xt_case_array_create(csv->field_count,
      xt_core_string_compare, xt_core_string_copy,
      xt_core_string_destroy);
  if (index_to_name) {
    line_list = xt_file_basic_get_as_line_list(file);
    if (line_list) {
      first_line = xt_case_list_find_first(line_list);
      if (first_line) {
        field_names = xt_case_list_create_strings_from_string
          (first_line, ",");
        if (field_names) {
          field_index = 0;
          xt_case_list_iterate_start(field_names);
          while ((field_name = xt_case_list_iterate_next(field_names))) {
            xt_case_array_add(index_to_name, field_index, field_name);
            field_index++;
          }
          xt_case_list_dont_destroy_objects(field_names);
          xt_case_list_destroy(field_names);
        } else {
          xt_core_trace("x_case_list_create_strings_from_string");
        }
      } else {
        xt_core_trace_exit("");
      }
      xt_case_list_destroy(line_list);
    } else {
      xt_core_trace("x_file_basic_get_as_line_list");
    }
  } else {
    xt_core_trace("x_case_array_add");
  }

  return index_to_name;
}
Exemple #4
0
Fichier : int.c Projet : xtools/xt
char *xt_core_basic_int_get_as_string(void *int_object)
{
  assert(int_object);
  int *i;
  char *string;

  i = int_object;

  string = malloc(10 + 1);
  if (string) {
    snprintf(string, 10 + 1, "%i", *i);
  } else {
    xt_core_trace_exit("malloc");
  }

  return string;
}
Exemple #5
0
int main(int argc, char *argv[])
{
  ta_system_t *ta_system;
  ta_server_t ta_server;
  xt_net_server_system_t *http_server;
  unsigned short http_server_min_port;
  unsigned short http_server_max_port;
  xt_net_engine_iengine_t http_iengine;
  xt_core_imessage_t http_imessage;
  xt_net_post_ipost_t http_ipost;
  xt_core_objects_t objects;
  xt_file_basic_t *log_file;
  xt_core_log_t *log;
  FILE *log_file_file;
  xt_config_system_t *config;
  char *atom_directory;
  unsigned long identities_shard_count;
  unsigned short clear_all_identities_period_minutes;

  xt_core_objects_init(&objects);

  log_file = xt_file_basic_create
    (LOG_FILENAME, XT_FILE_MODE_TRUNCATE_OR_CREATE_FOR_WRITE);
  if (!log_file) {
    xt_core_trace_exit("xt_file_basic_create");
  }

  log = xt_core_log_create(stdout);
  if (!log) {
    xt_core_trace_exit("xt_core_log_create");
  }

  log_file_file = xt_file_basic_get_file(log_file);
  if (log_file_file) {
    if (!xt_core_log_add_file(log, log_file_file)) {
      xt_core_log_trace_exit(log, " ta ", "xt_core_log_add_file");
    }
  } else {
    xt_core_log_trace_exit(log, " ta ", "xt_file_basic_get_file");
  }

#ifdef XT_BUILD_DEMO
  xt_core_log_enter(log, " ta ", "demo build");
#endif
#ifdef XT_BUILD_DEVELOPMENT
  xt_core_log_enter(log, " ta ", "development build");
#endif
#ifdef XT_BUILD_RELEASE
  xt_core_log_enter(log, " ta ", "release build");
#endif

  config = xt_config_system_create(argc, argv, CONF_FILENAME, &objects);
  if (!config) {
    xt_core_log_trace_exit(log, " ta ", "xt_config_system_create");
  }

  xt_config_system_find_as_string(config, "atom_directory", &atom_directory,
      DEFAULT_ATOM_DIRECTORY);
  xt_core_log_enter(log, " ta ", "using atom directory %s", atom_directory);

  xt_config_system_find_as_unsigned_short(config, "http_server_min_port",
      &http_server_min_port, DEFAULT_HTTP_SERVER_MIN_PORT);
  xt_config_system_find_as_unsigned_short(config, "http_server_max_port",
      &http_server_max_port, DEFAULT_HTTP_SERVER_MAX_PORT);
  xt_core_log_enter(log, " ta ", "using http server port range %i..%i",
      http_server_min_port, http_server_max_port);

  xt_config_system_find_as_unsigned_long(config, "identities_shard_count",
      &identities_shard_count, DEFAULT_IDENTITIES_SHARD_COUNT);
  xt_core_log_enter(log, " ta ", "identities_shard_count is %i",
      identities_shard_count);

  xt_config_system_find_as_unsigned_short(config,
      "clear_all_identities_period_minutes",
      &clear_all_identities_period_minutes,
      DEFAULT_CLEAR_ALL_IDENTITIES_PERIOD_MINUTES);
  xt_core_log_enter(log, " ta ", "clear_all_identities_period_minutes is %i",
      clear_all_identities_period_minutes);

  xt_net_engine_iengine_init(&http_iengine, ta_http_engine_create,
      ta_http_engine_destroy, ta_http_engine_get_handler_for_message,
      ta_http_engine_maintain, ta_http_engine_run, ta_http_engine_start,
      ta_http_engine_stop);

  xt_core_imessage_init(&http_imessage, xt_net_http_message_destroy,
      xt_net_http_message_get_client_socket, xt_net_http_message_get_engine_id,
      xt_net_http_message_get_type);

  xt_net_post_ipost_init(&http_ipost, xt_net_http_post_compare,
      xt_net_http_post_create, xt_net_http_post_create_decoy,
      xt_net_http_post_destroy, xt_net_http_post_destroy_decoy,
      xt_net_http_post_get_last_receive_activity_time,
      xt_net_http_post_get_socket, xt_net_http_post_get_stats,
      xt_net_http_post_receive_message, xt_net_http_post_receive_messages,
      xt_net_http_post_send_message, xt_net_http_post_send_messages,
      xt_net_http_post_is_socket_closed, xt_net_http_post_mod,
      xt_net_http_post_compare_equal);

  ta_system = ta_system_create(identities_shard_count,
      clear_all_identities_period_minutes, log);
  if (!ta_system) {
    xt_core_log_trace_exit(log, " ta ", "ta_system_create");
  }

  ta_server_init(&ta_server, atom_directory, ta_system, log);

  http_server = xt_net_server_system_create("ta", http_server_min_port,
      http_server_max_port, HTTP_SERVER_MAX_THREADS, &http_imessage,
      &http_ipost, ta_get_engine_name, XT_NET_SERVER_SYSTEM_NO_CONFIG_SYSTEM,
      log);
  if (!http_server) {
    xt_core_log_trace_exit(log, " ta ", "xt_net_server_system_create");
  }

  if (!xt_net_server_system_register_engine(http_server, XT_NET_ENGINE_HTTP,
          &ta_server, &http_iengine, 4, 8, XT_NET_MAINTAIN_1_MINUTE,
          XT_NET_MESSAGE_TYPE_COUNT_NONE)) {
    xt_core_log_trace_exit(log, " ta ", "xt_net_server_register_engine");
  }

  if (!xt_net_server_system_start(http_server)) {
    xt_core_log_trace_exit(log, " ta ", "xt_net_server_start");
  }

  xt_net_server_system_destroy(http_server);
  ta_server_free(&ta_server);
  ta_system_destroy(ta_system);
  xt_file_basic_destroy(log_file);
  xt_config_system_destroy(config);
  xt_core_log_destroy(log);

  return 0;
}
Exemple #6
0
void xt_net_client_system_print(void *client_object)
{
  xt_core_trace_exit("TODO: implement");
}
Exemple #7
0
char *xt_net_client_system_get_as_string(void *client_object)
{
  xt_core_trace_exit("TODO: implement");
  return NULL;
}
Exemple #8
0
void *xt_net_client_system_copy(void *client_object)
{
  xt_core_trace_exit("TODO: implement");
  return NULL;
}
void *ta_identity_copy(void *identity_object)
{
  assert(identity_object);
  xt_core_trace_exit("TODO: implement");
  return NULL;
}
Exemple #10
0
Fichier : item.c Projet : xtools/xt
void *xt_case_wait_cache_item_copy(void *item_object)
{
  xt_core_trace_exit("TODO: implement");
}