Skip to content
Snippets Groups Projects
Commit a4ad2010 authored by Arie Peterson's avatar Arie Peterson
Browse files

More syntax improvements

parent 349c1047
No related branches found
No related tags found
No related merge requests found
......@@ -57,14 +57,8 @@ static int container_initialise
int main(int argc, char **argv)
{
y_init_logs
(
"cryptops-api",
Y_LOG_MODE_CONSOLE,
Y_LOG_LEVEL_DEBUG,
NULL,
"Starting cryptops-api"
);
y_init_logs("cryptops-api", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG,
NULL, "Starting cryptops-api");
struct _u_instance instance;
if (ulfius_init_instance(&instance, PORT, NULL, NULL) != U_OK)
......@@ -79,16 +73,8 @@ int main(int argc, char **argv)
instance.max_post_body_size = 1024;
// Add api endpoints.
ulfius_add_endpoint_by_val
(
&instance,
"POST",
PREFIX,
"/encryption/unlock",
0,
&callback_encryption_unlock,
NULL
);
ulfius_add_endpoint_by_val(&instance, "POST", PREFIX, "/encryption/unlock",
0, &callback_encryption_unlock, NULL);
// Add default endpoint.
ulfius_set_default_endpoint(&instance, &callback_default, NULL);
......@@ -112,23 +98,13 @@ int main(int argc, char **argv)
if (ret == U_OK)
{
y_log_message
(
Y_LOG_LEVEL_DEBUG,
"Start %sframework on port %d",
((argc == 4 && strcmp("-secure", argv[1]) == 0)?"secure ":""),
instance.port
);
y_log_message(Y_LOG_LEVEL_DEBUG, "Start %sframework on port %d",
((argc == 4 && strcmp("-secure", argv[1]) == 0) ? "secure " : ""),
instance.port);
// Wait for signal from fifo to quit.
y_init_logs
(
"cryptops-api",
Y_LOG_MODE_CONSOLE,
Y_LOG_LEVEL_DEBUG,
NULL,
"Waiting for fifo signal to quit"
);
y_init_logs("cryptops-api", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG,
NULL, "Waiting for fifo signal to quit");
int fifo = 0;
char buf[4];
char fifo_path[] = FIFO_PATH;
......@@ -181,20 +157,16 @@ int callback_encryption_unlock
if (unlock_status == -1)
{
// Experience learns that -1 is returned when the password is wrong.
return send_simple_response
(
response,
403,
"error",
"incorrect password"
);
return send_simple_response(response, 403, "error",
"incorrect password");
}
if (unlock_status != 0)
{
// Something else went wrong with unlocking.
printf("encryption_unlock failed with status %d\n", unlock_status);
return send_simple_response(response, 500, "error", "error during unlocking");
return send_simple_response(response, 500, "error",
"error during unlocking");
}
// If we reach this point, apparently everything went well.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment