Cleanup error messages

This commit is contained in:
Iwan Timmer 2015-05-26 16:27:32 +02:00
parent fd8bb4ac1b
commit ea79e1b980
9 changed files with 26 additions and 51 deletions

View File

@ -36,7 +36,6 @@ static OpusDecoder* decoder;
static short pcmBuffer[FRAME_SIZE * CHANNEL_COUNT];
static void audio_renderer_init() {
printf("audio_renderer_init\n");
int rc;
decoder = opus_decoder_create(SAMPLE_RATE, CHANNEL_COUNT, &rc);
@ -73,7 +72,6 @@ static void audio_renderer_init() {
}
static void audio_renderer_release() {
printf("audio_renderer_release\n");
if (decoder != NULL)
opus_decoder_destroy(decoder);

View File

@ -72,8 +72,9 @@ static void client_load_unique_id() {
static void client_load_cert() {
FILE *fd = fopen(certificateFileName, "r");
if (fd == NULL) {
printf("Generating certificate\n");
printf("Generating certificate...");
struct CertKeyPair cert = generateCertKeyPair();
printf("done\n");
saveCertKeyPair(certificateFileName, p12FileName, keyFileName, cert);
freeCertKeyPair(cert);
fd = fopen(certificateFileName, "r");
@ -85,7 +86,7 @@ static void client_load_cert() {
}
if (!(cert = PEM_read_X509(fd, NULL, NULL, NULL))) {
printf("Error loading cert into memory.\n");
fprintf(stderr, "Error loading cert into memory.\n");
exit(-1);
}
@ -146,62 +147,62 @@ static int sign_it(const char *msg, size_t mlen, unsigned char **sig, size_t *sl
EVP_MD_CTX *ctx = EVP_MD_CTX_create();
if (ctx == NULL) {
printf("EVP_MD_CTX_create failed, error 0x%lx\n", ERR_get_error());
fprintf(stderr, "EVP_MD_CTX_create failed, error 0x%lx\n", ERR_get_error());
return -1;
}
const EVP_MD *md = EVP_get_digestbyname("SHA256");
if (md == NULL) {
printf("EVP_get_digestbyname failed, error 0x%lx\n", ERR_get_error());
fprintf(stderr, "EVP_get_digestbyname failed, error 0x%lx\n", ERR_get_error());
goto cleanup;
}
int rc = EVP_DigestInit_ex(ctx, md, NULL);
if (rc != 1) {
printf("EVP_DigestInit_ex failed, error 0x%lx\n", ERR_get_error());
fprintf(stderr, "EVP_DigestInit_ex failed, error 0x%lx\n", ERR_get_error());
goto cleanup;
}
rc = EVP_DigestSignInit(ctx, NULL, md, NULL, pkey);
if (rc != 1) {
printf("EVP_DigestSignInit failed, error 0x%lx\n", ERR_get_error());
fprintf(stderr, "EVP_DigestSignInit failed, error 0x%lx\n", ERR_get_error());
goto cleanup;
}
rc = EVP_DigestSignUpdate(ctx, msg, mlen);
if (rc != 1) {
printf("EVP_DigestSignUpdate failed, error 0x%lx\n", ERR_get_error());
fprintf(stderr, "EVP_DigestSignUpdate failed, error 0x%lx\n", ERR_get_error());
goto cleanup;
}
size_t req = 0;
rc = EVP_DigestSignFinal(ctx, NULL, &req);
if (rc != 1) {
printf("EVP_DigestSignFinal failed (1), error 0x%lx\n", ERR_get_error());
fprintf(stderr, "EVP_DigestSignFinal failed (1), error 0x%lx\n", ERR_get_error());
goto cleanup;
}
if (!(req > 0)) {
printf("EVP_DigestSignFinal failed (2), error 0x%lx\n", ERR_get_error());
fprintf(stderr, "EVP_DigestSignFinal failed (2), error 0x%lx\n", ERR_get_error());
goto cleanup;
}
*sig = OPENSSL_malloc(req);
if (*sig == NULL) {
printf("OPENSSL_malloc failed, error 0x%lx\n", ERR_get_error());
fprintf(stderr, "OPENSSL_malloc failed, error 0x%lx\n", ERR_get_error());
goto cleanup;
}
*slen = req;
rc = EVP_DigestSignFinal(ctx, *sig, slen);
if (rc != 1) {
printf("EVP_DigestSignFinal failed (3), return code %d, error 0x%lx\n", rc,
fprintf(stderr, "EVP_DigestSignFinal failed (3), return code %d, error 0x%lx\n", rc,
ERR_get_error());
goto cleanup;
}
if (req != *slen) {
printf("EVP_DigestSignFinal failed, mismatched signature sizes %ld, %ld\n",
fprintf(stderr, "EVP_DigestSignFinal failed, mismatched signature sizes %ld, %ld\n",
req, *slen);
goto cleanup;
}

View File

@ -22,47 +22,26 @@
#include <stdio.h>
void connection_stage_starting(int stage)
{
printf("connection_stage_starting %d\n", stage);
}
void connection_stage_complete(int stage)
{
printf("connection_stage_complete %d\n", stage);
}
void connection_stage_failed(int stage, long iets)
{
printf("connection_stage_failed %d\n", stage);
}
void connection_connection_started()
{
printf("connection_connection_started\n");
}
void connection_connection_terminated()
{
quit();
printf("connection_connection_terminated\n");
}
void connection_display_message(char *msg)
{
printf("connection_display_message: %s\n", msg);
printf("%s\n", msg);
}
void connection_display_transient_message(char *msg)
{
printf("connection_display_transient_message: %s\n", msg);
printf("%s\n", msg);
}
CONNECTION_LISTENER_CALLBACKS connection_callbacks = {
.stageStarting = connection_stage_starting,
.stageComplete = connection_stage_complete,
.stageFailed = connection_stage_failed,
.connectionStarted = connection_connection_started,
.stageStarting = NULL,
.stageComplete = NULL,
.stageFailed = NULL,
.connectionStarted = NULL,
.connectionTerminated = connection_connection_terminated,
.displayMessage = connection_display_message,
.displayTransientMessage = connection_display_transient_message,

View File

@ -23,6 +23,5 @@
pthread_t main_thread_id;
void quit() {
printf("Close thread %d\n", main_thread_id);
pthread_kill(main_thread_id, SIGTERM);
}

View File

@ -53,7 +53,7 @@ static void applist(const char* address) {
static void stream(STREAM_CONFIGURATION* config, const char* address, const char* app, bool sops, bool localaudio) {
int appId = client_get_app_id(address, app);
if (appId<0) {
printf("Can't find app %s\n", app);
fprintf(stderr, "Can't find app %s\n", app);
exit(-1);
}
@ -67,7 +67,7 @@ static void stream(STREAM_CONFIGURATION* config, const char* address, const char
hints.ai_socktype = SOCK_STREAM;
int err = getaddrinfo(address, NULL, &hints, &res);
if (err<0 || res == NULL) {
printf("Can't resolve host: %s\n", address);
fprintf(stderr, "Can't resolve host: %s\n", address);
exit(-1);
}
@ -146,7 +146,7 @@ char* get_path(char* name) {
static void pair_check(void) {
if (!client_is_paired(NULL)) {
printf("You must pair with the PC first\n");
fprintf(stderr, "You must pair with the PC first\n");
exit(-1);
}
}

View File

@ -104,7 +104,7 @@ void mapping_load(char* fileName, struct mapping* map) {
else if (strcmp("reverse_dpad_y", key) == 0)
map->reverse_dpad_y = strcmp("true", value) == 0;
else
printf("Can't map (%s)\n", key);
fprintf(stderr, "Can't map (%s)\n", key);
}
if (key != NULL)
free(key);

View File

@ -49,7 +49,7 @@ struct CertKeyPair generateCertKeyPair() {
p12 = PKCS12_create("limelight", "GameStream", pkey, x509, NULL, 0, 0, 0, 0, 0);
if (p12 == NULL) {
printf("Error generating a valid PKCS12 certificate.\n");
fprintf(stderr, "Error generating a valid PKCS12 certificate.\n");
}
#ifndef OPENSSL_NO_ENGINE

View File

@ -25,12 +25,10 @@ static FILE* fd;
static const char* fileName = "fake.h264";
void decoder_renderer_setup(int width, int height, int redrawRate, void* context, int drFlags) {
printf("decoder_renderer_setup %dx%d %dfps\n", width, height, redrawRate);
fd = fopen(fileName, "w");
}
void decoder_renderer_release() {
printf("decoder_renderer_release\n");
fclose(fd);
}

View File

@ -100,7 +100,7 @@ int xml_search(char* data, size_t len, char* node, char** result) {
XML_SetCharacterDataHandler(parser, _xml_write_data);
if (! XML_Parse(parser, data, len, 1)) {
int code = XML_GetErrorCode(parser);
printf("%s\n", XML_ErrorString(code));
fprintf(stderr, "XML Error: %s\n", XML_ErrorString(code));
return 1;
}
*result = search.memory;
@ -120,7 +120,7 @@ struct app_list* xml_applist(char* data, size_t len) {
XML_SetCharacterDataHandler(parser, _xml_write_data);
if (! XML_Parse(parser, data, len, 1)) {
int code = XML_GetErrorCode(parser);
printf("%s\n", XML_ErrorString(code));
fprintf(stderr, "XML Error %s\n", XML_ErrorString(code));
exit(-1);
}