Exemple #1
0
// sets a json value for a key
int json_object_set_string(json_t *object, char *key, char *value, json_context_t *json_context)
{
  int exit_code = 0;

  json_t *json_string_value = NULL;
  char *value_copied = NULL;

  check_not_null(object);
  check_not_null(key);
  check_not_null(json_context);

  if (value != NULL)
  {
    check_result(malloc_memcpy_string(&value_copied, value), 0);

    json_string_value = json_string(value_copied);
    check_not_null(json_string_value);

    check_result(json_object_set_new(object, key, json_string_value), 0);

    json_string_value = NULL;

    check_result(
      array_add_string(
        &(json_context->strings),
        &(json_context->strings_allocated_count),
        &(json_context->strings_used_count),
        value_copied),
      0);

    value_copied = NULL;
  }
  else
  {
    check_result(json_object_set(object, key, json_null()), 0);
  }

  goto cleanup;

error:

  exit_code = -1;

cleanup:

  if (json_string_value != NULL) { json_free(json_string_value); }
  if (value_copied != NULL) { free(value_copied); }

  return exit_code;
}
Exemple #2
0
// gets a json value from a key
int json_object_get_string(json_t *object, char *key, char **value)
{
  char *value_return = NULL;

  int exit_code = 0;

  check_not_null(object);
  check_not_null(key);
  check_not_null(value);

  json_t *json_string_peek = json_object_get(object, key);
  if (json_string_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_string_peek);
  if (json_typeof_result != JSON_STRING)
  {
    *value = NULL;
    goto cleanup;
  }

  char *value_peek = (char *)json_string_value(json_string_peek);
  if (value_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  check_result(malloc_memcpy_string(&value_return, value_peek), 0);

  *value = value_return;

  goto cleanup;

error:

  if (value_return != NULL) { free(value_return); }

  exit_code = -1;

cleanup:

  return exit_code;
}
double principia__IteratorGetTime(Iterator const* const iterator) {
  journal::Method<journal::IteratorGetTime> m({iterator});
  CHECK_NOTNULL(iterator);
  auto const typed_iterator = check_not_null(
      dynamic_cast<TypedIterator<DiscreteTrajectory<World>> const*>(iterator));
  return m.Return(typed_iterator->Get<double>(
      [](DiscreteTrajectory<World>::Iterator const& iterator) -> double {
        return (iterator.time() - Instant()) / Second;
      }));
}
Exemple #4
0
// gets a json value from a key
int json_object_get_bool(json_t *object, char *key, int **value)
{
  int *value_return = NULL;

  int exit_code = 0;

  check_not_null(object);
  check_not_null(key);
  check_not_null(value);

  json_t *json_boolean_peek = json_object_get(object, key);
  if (json_boolean_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_boolean_peek);
  if (json_typeof_result != JSON_TRUE && json_typeof_result != JSON_FALSE)
  {
    *value = NULL;
    goto cleanup;
  }

  int value_peek = json_boolean_value(json_boolean_peek);
  check_result(malloc_memcpy_int(&value_return, &value_peek), 0);

  *value = value_return;

  goto cleanup;

error:

  if (value_return != NULL) { free(value_return); }

  exit_code = -1;

cleanup:

  return exit_code;
}
Exemple #5
0
// gets a json value from a key
int json_object_get_double(json_t *object, char *key, double **value)
{
  double *value_return = NULL;

  int exit_code = 0;

  check_not_null(object);
  check_not_null(key);
  check_not_null(value);

  json_t *json_number_peek = json_object_get(object, key);
  if (json_number_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_number_peek);
  if (json_typeof_result != JSON_INTEGER && json_typeof_result != JSON_REAL)
  {
    *value = NULL;
    goto cleanup;
  }

  double value_peek = json_number_value(json_number_peek);
  check_result(malloc_memcpy_double(&value_return, &value_peek), 0);

  *value = value_return;

  goto cleanup;

error:

  if (value_return != NULL) { free(value_return); }

  exit_code = -1;

cleanup:

  return exit_code;
}
XYZ principia__IteratorGetXYZ(Iterator const* const iterator) {
  journal::Method<journal::IteratorGetXYZ> m({iterator});
  CHECK_NOTNULL(iterator);
  auto const typed_iterator = check_not_null(
      dynamic_cast<TypedIterator<DiscreteTrajectory<World>> const*>(iterator));
  return m.Return(typed_iterator->Get<XYZ>(
      [](DiscreteTrajectory<World>::Iterator const& iterator) -> XYZ {
        return ToXYZ((iterator.degrees_of_freedom().position() - World::origin)
                         .coordinates() /
                     Metre);
      }));
}
Exemple #7
0
// gets a json value from an index
int json_array_get_int(json_t *array, int index, int **value)
{
  int *value_return = NULL;

  int exit_code = 0;

  check_not_null(array);
  check_not_null(value);

  json_t *json_integer_peek = json_array_get(array, index);
  if (json_integer_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_integer_peek);
  if (json_typeof_result != JSON_INTEGER)
  {
    *value = NULL;
    goto cleanup;
  }

  int value_peek = json_integer_value(json_integer_peek);
  check_result(malloc_memcpy_int(&value_return, &value_peek), 0);

  *value = value_return;

  goto cleanup;

error:

  if (value_return != NULL) { free(value_return); }

  exit_code = -1;

cleanup:

  return exit_code;
}
Exemple #8
0
// gets a json value from an index
int json_array_get_double(json_t *array, int index, double **value)
{
  double *value_return = NULL;

  int exit_code = 0;

  check_not_null(array);
  check_not_null(value);

  json_t *json_real_peek = json_array_get(array, index);
  if (json_real_peek == NULL)
  {
    *value = NULL;
    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_real_peek);
  if (json_typeof_result != JSON_INTEGER && json_typeof_result != JSON_REAL)
  {
    *value = NULL;
    goto cleanup;
  }

  double value_peek = json_real_value(json_real_peek);
  check_result(malloc_memcpy_double(&value_return, &value_peek), 0);

  *value = value_return;

  goto cleanup;

error:

  if (value_return != NULL) { free(value_return); }

  exit_code = -1;

cleanup:

  return exit_code;
}
Exemple #9
0
// gets a json value from a key
int json_object_get_array(json_t *object, char *key, json_t **value, int *size)
{
  int exit_code = 0;

  check_not_null(object);
  check_not_null(key);
  check_not_null(value);
  check_not_null(size);

  json_t *json_array_peek = json_object_get(object, key);
  if (json_array_peek == NULL)
  {
    *value = NULL;
    *size = 0;

    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_array_peek);
  if (json_typeof_result != JSON_ARRAY)
  {
    *value = NULL;
    *size = 0;

    goto cleanup;
  }

  *value = json_array_peek;
  *size = json_array_size(json_array_peek);

  goto cleanup;

error:

  exit_code = -1;

cleanup:

  return exit_code;
}
Exemple #10
0
// gets a json value from an index
int json_array_get_array(json_t *array, int index, json_t **value, int *size)
{
  int exit_code = 0;

  check_not_null(array);
  check_not_null(value);
  check_not_null(size);

  json_t *json_array_peek = json_array_get(array, index);
  if (json_array_peek == NULL)
  {
    *value = NULL;
    *size = 0;

    goto cleanup;
  }

  int json_typeof_result = json_typeof(json_array_peek);
  if (json_typeof_result != JSON_ARRAY)
  {
    *value = NULL;
    *size = 0;

    goto cleanup;
  }

  *value = json_array_peek;
  *size = json_array_size(json_array_peek);

  goto cleanup;

error:

  exit_code = -1;

cleanup:

  return exit_code;
}
Exemple #11
0
static char*
generateServiceProviderContextDump()
{
    LassoServer *serverContext;
    char *ret;

    serverContext = lasso_server_new(
                        TESTSDATADIR "/sp1-la/metadata.xml",
                        TESTSDATADIR "/sp1-la/private-key-raw.pem",
                        NULL, /* Secret key to unlock private key */
                        TESTSDATADIR "/sp1-la/certificate.pem");
    check_not_null(serverContext);
    check_good_rc(lasso_server_add_provider(
                      serverContext,
                      LASSO_PROVIDER_ROLE_IDP,
                      TESTSDATADIR "/idp1-la/metadata.xml",
                      TESTSDATADIR "/idp1-la/public-key.pem",
                      TESTSDATADIR "/ca1-la/certificate.pem"));

    ret = lasso_server_dump(serverContext);
    check_not_null(ret);
    g_object_unref(serverContext);
    return ret;
}
Exemple #12
0
// sets a json value for a key
int json_object_set_int(json_t *object, char *key, int *value, json_context_t *json_context)
{
  int exit_code = 0;

  json_t *json_integer_value = NULL;

  check_not_null(object);
  check_not_null(key);
  check_not_null(json_context);

  if (value != NULL)
  {
    json_integer_value = json_integer(*value);
    check_not_null(json_integer_value);

    check_result(json_object_set_new(object, key, json_integer_value), 0);

    json_integer_value = NULL;
  }
  else
  {
    check_result(json_object_set(object, key, json_null()), 0);
  }

  goto cleanup;

error:

  exit_code = -1;

cleanup:

  if (json_integer_value != NULL) { json_free(json_integer_value); }

  return exit_code;
}
Exemple #13
0
QP principia__IteratorGetQP(Iterator const* const iterator) {
  journal::Method<journal::IteratorGetQP> m({iterator});
  CHECK_NOTNULL(iterator);
  auto const typed_iterator = check_not_null(
      dynamic_cast<TypedIterator<DiscreteTrajectory<World>> const*>(iterator));
  return m.Return(typed_iterator->Get<QP>(
      [](DiscreteTrajectory<World>::Iterator const& iterator) -> QP {
        DegreesOfFreedom<World> const degrees_of_freedom =
            iterator.degrees_of_freedom();
        return {
            ToXYZ(
                (degrees_of_freedom.position() - World::origin).coordinates() /
                Metre),
            ToXYZ(degrees_of_freedom.velocity().coordinates() /
                  (Metre / Second))};
      }));
}
Exemple #14
0
// allocates a json array
json_t *json_array_malloc()
{
  json_t *json_array_return = NULL;

  json_array_return = json_array();
  check_not_null(json_array_return);

  goto cleanup;

error:

  if (json_array_return != NULL) { json_free(json_array_return); }

  json_array_return = NULL;

cleanup:

  return json_array_return;
}
Exemple #15
0
		sm::err_code::error_code	get_hash(const void* data_ptr,boost::uint64_t bytes,SM3_HASH& hash_data){
			sm::err_code::error_code ec;
			const boost::uint8_t* data=(const boost::uint8_t*)data_ptr;
			if(!check_not_null(data)) return sm::err_code::err_bad_parameter;
			sm3_ctx_clear(ctx_);
			// inti and Alignment(to 64 BYTE)
			ec=sm3_ctx_init(data,bytes,ctx_);
			if(!sm::err_code::bad(ec)){
				boost::uint64_t total_bytes=ctx_.origin_data_bytes+ctx_.padding_bytes;
				BOOST_ASSERT( total_bytes%kDataAlignmentBytes==0);
				boost::uint64_t loops=total_bytes/kDataGroupBytes;
				::memcpy(ctx_.hash32,IV32_BE,sizeof ctx_.hash32);
				sm3_data_picker dt_picker(ctx_);
				while (!dt_picker.end()){
					compress(dt_picker);
				}
				hash_data.set_data(ctx_.hash32);
				ec=sm::err_code::err_ok;
			}
			return ec;
		}
// A linear acceleration identical for both bodies.  The test point doesn't
// move.  The resulting acceleration combines centrifugal and linear.
TEST_F(BodySurfaceDynamicFrameTest, LinearAcceleration) {
  Instant const t = t0_ + 0 * Second;
  DegreesOfFreedom<MockFrame> const point_dof =
      {Displacement<MockFrame>({10 * Metre, 20 * Metre, 30 * Metre}) +
           MockFrame::origin,
       Velocity<MockFrame>({0 * Metre / Second,
                            0 * Metre / Second,
                            0 * Metre / Second})};
  DegreesOfFreedom<ICRFJ2000Equator> const centre_dof =
      {Displacement<ICRFJ2000Equator>({0 * Metre, 0 * Metre, 0 * Metre}) +
           ICRFJ2000Equator::origin,
       Velocity<ICRFJ2000Equator>({0 * Metre / Second,
                                   0 * Metre / Second,
                                   0 * Metre / Second})};

  EXPECT_CALL(mock_centre_trajectory_, EvaluateDegreesOfFreedom(t, _))
      .Times(2)
      .WillRepeatedly(Return(centre_dof));
  {
    // The acceleration is linear + centripetal.
    InSequence s;
    EXPECT_CALL(*mock_ephemeris_,
                ComputeGravitationalAccelerationOnMassiveBody(
                    check_not_null(massive_centre_), t))
        .WillOnce(Return(Vector<Acceleration, ICRFJ2000Equator>({
                             -160 * Metre / Pow<2>(Second),
                             120 * Metre / Pow<2>(Second),
                             300 * Metre / Pow<2>(Second)})));
    EXPECT_CALL(*mock_ephemeris_,
                ComputeGravitationalAccelerationOnMasslessBody(_, t))
        .WillOnce(Return(Vector<Acceleration, ICRFJ2000Equator>()));
  }

  // The acceleration is linear + centrifugal.
  EXPECT_THAT(mock_frame_->GeometricAcceleration(t, point_dof),
              AlmostEquals(Vector<Acceleration, MockFrame>({
                               (-120 + 1e3) * Metre / Pow<2>(Second),
                               (-160 + 2e3) * Metre / Pow<2>(Second),
                               -300 * Metre / Pow<2>(Second)}), 2));
}
// The test point is at the origin and in motion.  The acceleration is purely
// due to Coriolis.
TEST_F(BodySurfaceDynamicFrameTest, CoriolisAcceleration) {
  Instant const t = t0_ + 0 * Second;
  // The velocity is opposed to the motion and away from the centre.
  DegreesOfFreedom<MockFrame> const point_dof =
      {Displacement<MockFrame>({0 * Metre, 0 * Metre, 0 * Metre}) +
           MockFrame::origin,
       Velocity<MockFrame>({10 * Metre / Second,
                            20 * Metre / Second,
                            30 * Metre / Second})};
  DegreesOfFreedom<ICRFJ2000Equator> const centre_dof =
      {Displacement<ICRFJ2000Equator>({0 * Metre, 0 * Metre, 0 * Metre}) +
           ICRFJ2000Equator::origin,
       Velocity<ICRFJ2000Equator>()};

  EXPECT_CALL(mock_centre_trajectory_, EvaluateDegreesOfFreedom(t, _))
      .Times(2)
      .WillRepeatedly(Return(centre_dof));
  {
    InSequence s;
    EXPECT_CALL(*mock_ephemeris_,
                ComputeGravitationalAccelerationOnMassiveBody(
                    check_not_null(massive_centre_), t))
        .WillOnce(Return(Vector<Acceleration, ICRFJ2000Equator>({
                             0 * Metre / Pow<2>(Second),
                             0 * Metre / Pow<2>(Second),
                             0 * Metre / Pow<2>(Second)})));
    EXPECT_CALL(*mock_ephemeris_,
                ComputeGravitationalAccelerationOnMasslessBody(_, t))
        .WillOnce(Return(Vector<Acceleration, ICRFJ2000Equator>()));
  }

  // The Coriolis acceleration is towards the centre and opposed to the motion.
  EXPECT_THAT(mock_frame_->GeometricAcceleration(t, point_dof).coordinates(),
              Componentwise(AlmostEquals(400 * Metre / Pow<2>(Second), 1),
                            AlmostEquals(-200 * Metre / Pow<2>(Second), 0),
                            VanishesBefore(1 * Metre / Pow<2>(Second), 110)));
}
// executes the get orders service
int get_orders_service(
  sqlite3 *sql_connection,
  get_orders_request_t *get_orders_request,
  get_orders_response_t **get_orders_response,
  validation_error_t ***validation_errors,
  int *validation_errors_count)
{
  get_orders_response_t *get_orders_response_return = NULL;

  validation_error_t **validation_errors_return = NULL;
  int validation_errors_allocated_count = 0;
  int validation_errors_used_count = 0;

  order_row_t **order_rows = NULL;
  int order_rows_count = 0;

  get_orders_response_order_t *get_orders_response_order = NULL;

  check_not_null(sql_connection);
  check_not_null(get_orders_request);
  check_not_null(get_orders_response);
  check_not_null(validation_errors);
  check_not_null(validation_errors_count);

  check_result(
    get_orders_request_validate(
      get_orders_request,
      &validation_errors_return,
      &validation_errors_allocated_count,
      &validation_errors_used_count),
    0);

  if (validation_errors_return != NULL)
  {
    *validation_errors = validation_errors_return;
    *validation_errors_count = validation_errors_used_count;

    return 0;
  }

  check_result(
    orders_table_select_all(
      sql_connection,
      &order_rows,
      &order_rows_count),
    0);

  get_orders_response_return = get_orders_response_malloc();
  check(get_orders_response_return != NULL, "get_orders_response_return: NULL");

  if (order_rows != NULL)
  {
    check_result(
      order_rows_sort_by_order_id(
        order_rows,
        order_rows_count),
      0);
  }

  get_orders_response_return->orders = malloc(sizeof(get_orders_response_order_t) * order_rows_count);
  check_mem(get_orders_response_return->orders);

  for (int i = 0; i < order_rows_count; i++)
  {
    get_orders_response_order = get_orders_response_order_malloc(
      order_rows[i]->order_id,
      order_rows[i]->customer_name);

    check_not_null(get_orders_response_order);

    get_orders_response_return->orders[i] = get_orders_response_order;
    get_orders_response_return->orders_count++;

    get_orders_response_order = NULL;
  }

  order_rows_free(order_rows, order_rows_count);

  *get_orders_response = get_orders_response_return;

  return 0;

error:

  if (get_orders_response_return != NULL) { get_orders_response_free(get_orders_response_return); }
  if (validation_errors_return != NULL) { validation_errors_free(validation_errors_return, validation_errors_used_count); }
  if (order_rows != NULL) { order_rows_free(order_rows, order_rows_count); }
  if (get_orders_response_order != NULL) { get_orders_response_order_free(get_orders_response_order); }

  return -1;
}
// parses an update order request
int update_order_request_http_parse(
  char **url_tokens,
  int url_tokens_count,
  json_t *json,
  update_order_request_t **update_order_request)
{
  update_order_request_t *update_order_request_return = NULL;

  int *order_id = NULL;
  char *customer_name = NULL;
  update_order_request_order_item_t **update_order_request_order_items = NULL;
  int update_order_request_order_items_count = 0;
  int *total = NULL;

  check_not_null(update_order_request);

  if (json == NULL)
  {
    update_order_request_return = update_order_request_malloc(NULL, NULL, NULL);
    check_not_null(update_order_request_return);

    *update_order_request = update_order_request_return;

    return 0;
  }

  check_result(json_object_get_int(json, "order-id", &order_id), 0);
  check_result(json_object_get_string(json, "customer-name", &customer_name), 0);
  check_result(json_object_get_int(json, "total", &total), 0);

  update_order_request_return = update_order_request_malloc(
    order_id,
    customer_name,
    total);

  check_not_null(update_order_request_return);

  json_t *order_items_json = NULL;
  int order_items_json_count = 0;

  check_result(
    json_object_get_array(
      json,
      "order-items",
      &order_items_json,
      &order_items_json_count),
    0);

  check_result(
    update_order_request_order_items_http_parse(
      order_items_json,
      order_items_json_count,
      &update_order_request_order_items,
      &update_order_request_order_items_count),
    0);

  update_order_request_return->order_items = update_order_request_order_items;
  update_order_request_return->order_items_count = update_order_request_order_items_count;

  free(order_id);
  free(customer_name);
  free(total);

  *update_order_request = update_order_request_return;

  return 0;

error:

  if (update_order_request_return != NULL) { update_order_request_free(update_order_request_return); }
  if (order_id != NULL) { free(order_id); }
  if (customer_name != NULL) { free(customer_name); }
  if (total != NULL) { free(total); }

  if (update_order_request_order_items != NULL)
  {
    update_order_request_order_items_free(update_order_request_order_items, update_order_request_order_items_count);
  }

  return -1;
}
void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t length)
{
	assert(data == NULL || length != 0);

	/* Ignore any latent data coming from a connection we closed. */
	if (this->http_response_index == -2) return;

	if (this->http_response_index == -1) {
		if (data != NULL) {
			/* Append the rest of the response. */
			memcpy(this->http_response.Append((uint)length), data, length);
			return;
		} else {
			/* Make sure the response is properly terminated. */
			*this->http_response.Append() = '\0';

			/* And prepare for receiving the rest of the data. */
			this->http_response_index = 0;
		}
	}

	if (data != NULL) {
		/* We have data, so write it to the file. */
		if (fwrite(data, 1, length, this->curFile) != length) {
			/* Writing failed somehow, let try via the old method. */
			this->OnFailure();
		} else {
			/* Just received the data. */
			this->OnDownloadProgress(this->curInfo, (uint)length);
		}
		/* Nothing more to do now. */
		return;
	}

	if (this->curFile != NULL) {
		/* We've finished downloading a file. */
		this->AfterDownload();
	}

	if ((uint)this->http_response_index >= this->http_response.Length()) {
		/* It's not a real failure, but if there's
		 * nothing more to download it helps with
		 * cleaning up the stuff we allocated. */
		this->OnFailure();
		return;
	}

	delete this->curInfo;
	/* When we haven't opened a file this must be our first packet with metadata. */
	this->curInfo = new ContentInfo;

/** Check p for not being null and return calling OnFailure if that's not the case. */
#define check_not_null(p) { if ((p) == NULL) { this->OnFailure(); return; } }
/** Check p for not being null and then terminate, or return calling OnFailure. */
#define check_and_terminate(p) { check_not_null(p); *(p) = '\0'; }

	for (;;) {
		char *str = this->http_response.Begin() + this->http_response_index;
		char *p = strchr(str, '\n');
		check_and_terminate(p);

		/* Update the index for the next one */
		this->http_response_index += (int)strlen(str) + 1;

		/* Read the ID */
		p = strchr(str, ',');
		check_and_terminate(p);
		this->curInfo->id = (ContentID)atoi(str);

		/* Read the type */
		str = p + 1;
		p = strchr(str, ',');
		check_and_terminate(p);
		this->curInfo->type = (ContentType)atoi(str);

		/* Read the file size */
		str = p + 1;
		p = strchr(str, ',');
		check_and_terminate(p);
		this->curInfo->filesize = atoi(str);

		/* Read the URL */
		str = p + 1;
		/* Is it a fallback URL? If so, just continue with the next one. */
		if (strncmp(str, "ottd", 4) == 0) {
			if ((uint)this->http_response_index >= this->http_response.Length()) {
				/* Have we gone through all lines? */
				this->OnFailure();
				return;
			}
			continue;
		}

		p = strrchr(str, '/');
		check_not_null(p);
		p++; // Start after the '/'

		char tmp[MAX_PATH];
		if (strecpy(tmp, p, lastof(tmp)) == lastof(tmp)) {
			this->OnFailure();
			return;
		}
		/* Remove the extension from the string. */
		for (uint i = 0; i < 2; i++) {
			p = strrchr(tmp, '.');
			check_and_terminate(p);
		}

		/* Copy the string, without extension, to the filename. */
		strecpy(this->curInfo->filename, tmp, lastof(this->curInfo->filename));

		/* Request the next file. */
		if (!this->BeforeDownload()) {
			this->OnFailure();
			return;
		}

		NetworkHTTPSocketHandler::Connect(str, this);
		return;
	}

#undef check
#undef check_and_terminate
}
// formats update order request errors
int update_order_request_http_format_errors(
  validation_error_t **validation_errors,
  int validation_errors_count,
  json_t **json,
  json_context_t *json_context)
{
  json_t *json_return = NULL;
  char *validation_error_code = NULL;

  check_not_null(validation_errors);
  check_not_null(json);
  check_not_null(json_context);

  json_return = json_array_malloc();
  check_not_null(json_return);

  validation_error_code = calloc(1024, sizeof(char));
  check_mem(validation_error_code);

  for (int i = 0; i < validation_errors_count; i++)
  {
    char *validation_error_json = validation_errors_json[validation_errors[i]->error_code];

    if (validation_errors[i]->validation_path->property == UPDATE_ORDER_REQUEST_ORDER_ID)
    {
      check_result_greater(sprintf(validation_error_code, "order-id-%s", validation_error_json), 0);
    }
    else if (validation_errors[i]->validation_path->property == UPDATE_ORDER_REQUEST_CUSTOMER_NAME)
    {
      check_result_greater(sprintf(validation_error_code, "customer-name-%s", validation_error_json), 0);
    }
    else if (validation_errors[i]->validation_path->property == UPDATE_ORDER_REQUEST_ORDER_ITEMS)
    {
      if (validation_errors[i]->validation_path->index == -1)
      {
        check_result_greater(sprintf(validation_error_code, "order-items-%s", validation_error_json), 0);
      }
      else
      {
        check_result(
          update_order_request_order_item_http_format_error(
            validation_errors[i],
            validation_error_code),
          0);
      }
    }
    else if (validation_errors[i]->validation_path->property == UPDATE_ORDER_REQUEST_TOTAL)
    {
      check_result_greater(sprintf(validation_error_code, "total-%s", validation_error_json), 0);
    }
    else
    {
      sentinel("validation_path->property: %d", validation_errors[i]->validation_path->property);
    }

    check_result(
      json_array_add_string(
        json_return,
        validation_error_code,
        json_context),
      0);
  }

  free(validation_error_code);

  *json = json_return;

  return 0;

error:

  if (json_return != NULL) { json_free(json_return); }
  if (validation_error_code != NULL) { free(validation_error_code); }

  return -1;
}