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

View File

@ -72,8 +72,9 @@ static void client_load_unique_id() {
static void client_load_cert() { static void client_load_cert() {
FILE *fd = fopen(certificateFileName, "r"); FILE *fd = fopen(certificateFileName, "r");
if (fd == NULL) { if (fd == NULL) {
printf("Generating certificate\n"); printf("Generating certificate...");
struct CertKeyPair cert = generateCertKeyPair(); struct CertKeyPair cert = generateCertKeyPair();
printf("done\n");
saveCertKeyPair(certificateFileName, p12FileName, keyFileName, cert); saveCertKeyPair(certificateFileName, p12FileName, keyFileName, cert);
freeCertKeyPair(cert); freeCertKeyPair(cert);
fd = fopen(certificateFileName, "r"); fd = fopen(certificateFileName, "r");
@ -85,7 +86,7 @@ static void client_load_cert() {
} }
if (!(cert = PEM_read_X509(fd, NULL, NULL, NULL))) { 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); 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(); EVP_MD_CTX *ctx = EVP_MD_CTX_create();
if (ctx == NULL) { 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; return -1;
} }
const EVP_MD *md = EVP_get_digestbyname("SHA256"); const EVP_MD *md = EVP_get_digestbyname("SHA256");
if (md == NULL) { 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; goto cleanup;
} }
int rc = EVP_DigestInit_ex(ctx, md, NULL); int rc = EVP_DigestInit_ex(ctx, md, NULL);
if (rc != 1) { 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; goto cleanup;
} }
rc = EVP_DigestSignInit(ctx, NULL, md, NULL, pkey); rc = EVP_DigestSignInit(ctx, NULL, md, NULL, pkey);
if (rc != 1) { 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; goto cleanup;
} }
rc = EVP_DigestSignUpdate(ctx, msg, mlen); rc = EVP_DigestSignUpdate(ctx, msg, mlen);
if (rc != 1) { 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; goto cleanup;
} }
size_t req = 0; size_t req = 0;
rc = EVP_DigestSignFinal(ctx, NULL, &req); rc = EVP_DigestSignFinal(ctx, NULL, &req);
if (rc != 1) { 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; goto cleanup;
} }
if (!(req > 0)) { 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; goto cleanup;
} }
*sig = OPENSSL_malloc(req); *sig = OPENSSL_malloc(req);
if (*sig == NULL) { 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; goto cleanup;
} }
*slen = req; *slen = req;
rc = EVP_DigestSignFinal(ctx, *sig, slen); rc = EVP_DigestSignFinal(ctx, *sig, slen);
if (rc != 1) { 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()); ERR_get_error());
goto cleanup; goto cleanup;
} }
if (req != *slen) { 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); req, *slen);
goto cleanup; goto cleanup;
} }

View File

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

View File

@ -23,6 +23,5 @@
pthread_t main_thread_id; pthread_t main_thread_id;
void quit() { void quit() {
printf("Close thread %d\n", main_thread_id);
pthread_kill(main_thread_id, SIGTERM); 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) { static void stream(STREAM_CONFIGURATION* config, const char* address, const char* app, bool sops, bool localaudio) {
int appId = client_get_app_id(address, app); int appId = client_get_app_id(address, app);
if (appId<0) { if (appId<0) {
printf("Can't find app %s\n", app); fprintf(stderr, "Can't find app %s\n", app);
exit(-1); exit(-1);
} }
@ -67,7 +67,7 @@ static void stream(STREAM_CONFIGURATION* config, const char* address, const char
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
int err = getaddrinfo(address, NULL, &hints, &res); int err = getaddrinfo(address, NULL, &hints, &res);
if (err<0 || res == NULL) { if (err<0 || res == NULL) {
printf("Can't resolve host: %s\n", address); fprintf(stderr, "Can't resolve host: %s\n", address);
exit(-1); exit(-1);
} }
@ -146,7 +146,7 @@ char* get_path(char* name) {
static void pair_check(void) { static void pair_check(void) {
if (!client_is_paired(NULL)) { 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); exit(-1);
} }
} }

View File

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

View File

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

View File

@ -25,12 +25,10 @@ static FILE* fd;
static const char* fileName = "fake.h264"; static const char* fileName = "fake.h264";
void decoder_renderer_setup(int width, int height, int redrawRate, void* context, int drFlags) { 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"); fd = fopen(fileName, "w");
} }
void decoder_renderer_release() { void decoder_renderer_release() {
printf("decoder_renderer_release\n");
fclose(fd); 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); XML_SetCharacterDataHandler(parser, _xml_write_data);
if (! XML_Parse(parser, data, len, 1)) { if (! XML_Parse(parser, data, len, 1)) {
int code = XML_GetErrorCode(parser); int code = XML_GetErrorCode(parser);
printf("%s\n", XML_ErrorString(code)); fprintf(stderr, "XML Error: %s\n", XML_ErrorString(code));
return 1; return 1;
} }
*result = search.memory; *result = search.memory;
@ -120,7 +120,7 @@ struct app_list* xml_applist(char* data, size_t len) {
XML_SetCharacterDataHandler(parser, _xml_write_data); XML_SetCharacterDataHandler(parser, _xml_write_data);
if (! XML_Parse(parser, data, len, 1)) { if (! XML_Parse(parser, data, len, 1)) {
int code = XML_GetErrorCode(parser); int code = XML_GetErrorCode(parser);
printf("%s\n", XML_ErrorString(code)); fprintf(stderr, "XML Error %s\n", XML_ErrorString(code));
exit(-1); exit(-1);
} }