From f3b43606c546a86a43b283b46464972296e1e271 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 31 Dec 2006 15:33:57 +0000 Subject: [PATCH] Symbian compilation fixes. --- lib/silcutil/silcbuffer.h | 2 +- lib/silcutil/silcconfig.c | 9 +++++++-- lib/silcutil/silcschedule.c | 4 +++- lib/silcutil/silcschedule.h | 12 ++++++++++++ lib/silcutil/silcstack.c | 3 ++- lib/silcutil/silcstream.c | 6 +++--- lib/silcutil/silcstringprep.c | 2 +- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/silcutil/silcbuffer.h b/lib/silcutil/silcbuffer.h index 90bc3be5..673c4a7f 100644 --- a/lib/silcutil/silcbuffer.h +++ b/lib/silcutil/silcbuffer.h @@ -1051,7 +1051,7 @@ SilcBuffer silc_buffer_srealloc(SilcStack stack, if (!h) { /* Do slow and stack wasting realloc. The old sb->head is lost and is freed eventually. */ - h = silc_smalloc_ua(stack, newsize); + h = (unsigned char *)silc_smalloc_ua(stack, newsize); if (silc_unlikely(!h)) return NULL; memcpy(h, sb->head, silc_buffer_truelen(sb)); diff --git a/lib/silcutil/silcconfig.c b/lib/silcutil/silcconfig.c index b0c4f816..97760b3f 100644 --- a/lib/silcutil/silcconfig.c +++ b/lib/silcutil/silcconfig.c @@ -98,6 +98,7 @@ static void my_trim_spaces(SilcConfigFile *file) if (*r++ == '\n') file->line++; file->p = r; } + /* Skips the current line until newline (lf or cr) */ static void my_skip_line(SilcConfigFile *file) { @@ -106,6 +107,7 @@ static void my_skip_line(SilcConfigFile *file) file->p = ((*r != '\0' && *r != EOF) ? r + 1 : r); file->line++; } + /* Obtains a text token from the current position until first separator. * a separator is any non alphanumeric character nor "_" or "-" */ static char *my_next_token(SilcConfigFile *file, char *to) @@ -119,6 +121,7 @@ static char *my_next_token(SilcConfigFile *file, char *to) file->p = o; return to; } + /* Obtains a string from the current position. The only difference from * next_token() is that quoted-strings are also accepted */ static char *my_get_string(SilcConfigFile *file, char *to) @@ -146,7 +149,8 @@ static char *my_get_string(SilcConfigFile *file, char *to) /* we don't need quote parsing, fall-back to token extractor */ my_next_token(file, to); return to; -}; +} + /* Skips all comment lines and spaces lines until first useful character */ static void my_skip_comments(SilcConfigFile *file) { @@ -171,6 +175,7 @@ static SilcConfigOption *silc_config_find_option(SilcConfigEntity ent, } return NULL; } + /* Converts a string in the type specified. returns a dynamically * allocated pointer. */ static void *silc_config_marshall(SilcConfigType type, const char *val) @@ -295,7 +300,7 @@ SilcConfigEntity silc_config_init(SilcConfigFile *file) ret = silc_calloc(1, sizeof(*ret)); ret->file = file; return ret; -}; +} /* Returns the original filename of the object file */ diff --git a/lib/silcutil/silcschedule.c b/lib/silcutil/silcschedule.c index 2e546ee8..c0ee5dea 100644 --- a/lib/silcutil/silcschedule.c +++ b/lib/silcutil/silcschedule.c @@ -595,6 +595,8 @@ SilcTask silc_schedule_task_add(SilcSchedule schedule, SilcUInt32 fd, task = (SilcTask)ttask; } else if (silc_likely(type == SILC_TASK_FD)) { + SilcTaskFd ftask; + /* Check if fd is already added */ if (silc_unlikely(silc_hash_table_find(schedule->fd_queue, SILC_32_TO_PTR(fd), @@ -609,7 +611,7 @@ SilcTask silc_schedule_task_add(SilcSchedule schedule, SilcUInt32 fd, goto out; } - SilcTaskFd ftask = silc_calloc(1, sizeof(*ftask)); + ftask = silc_calloc(1, sizeof(*ftask)); if (silc_unlikely(!ftask)) goto out; diff --git a/lib/silcutil/silcschedule.h b/lib/silcutil/silcschedule.h index 44060fdc..4dc15c50 100644 --- a/lib/silcutil/silcschedule.h +++ b/lib/silcutil/silcschedule.h @@ -293,6 +293,14 @@ void silc_schedule_stop(SilcSchedule schedule); * When this returns the program is to be ended. Before this function can * be called, one must call silc_schedule_init function. * + * NOTES + * + * On Windows this will block the program, but will continue dispatching + * window messages, and thus can be used as the main loop of the program. + * + * On Symbian this will return immediately. On Symbian calling + * silc_schedule is same as calling silc_schedule_one. + * ***/ void silc_schedule(SilcSchedule schedule); @@ -311,6 +319,10 @@ void silc_schedule(SilcSchedule schedule); * scheduler. The function will not return in this timeout unless * some other event occurs. * + * Typically this would be called from a timeout or idle task + * periodically (typically from 5-50 ms) to schedule SILC tasks. In + * this case the `timeout_usecs' is usually 0. + * ***/ SilcBool silc_schedule_one(SilcSchedule schedule, int timeout_usecs); diff --git a/lib/silcutil/silcstack.c b/lib/silcutil/silcstack.c index 9432b22d..fabef8ec 100644 --- a/lib/silcutil/silcstack.c +++ b/lib/silcutil/silcstack.c @@ -267,7 +267,8 @@ void *silc_stack_realloc(SilcStack stack, SilcUInt32 old_size, /* Check that `ptr' is last allocation */ sptr = (unsigned char *)stack->stack[si] + SILC_STACK_ALIGN(sizeof(**stack->stack), SILC_STACK_DEFAULT_ALIGN); - if (stack->stack[si]->bytes_left + old_size + (ptr - sptr) != bsize) { + if (stack->stack[si]->bytes_left + old_size + + ((unsigned char *)ptr - (unsigned char *)sptr) != bsize) { SILC_LOG_DEBUG(("Cannot reallocate")); SILC_STACK_STAT(stack, num_errors, 1); return NULL; diff --git a/lib/silcutil/silcstream.c b/lib/silcutil/silcstream.c index 730ce55c..7b8b08af 100644 --- a/lib/silcutil/silcstream.c +++ b/lib/silcutil/silcstream.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 Pekka Riikonen + Copyright (C) 2005 - 2006 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,14 +46,14 @@ SilcBool silc_stream_close(SilcStream stream) void silc_stream_destroy(SilcStream stream) { SilcStreamHeader h = stream; - return h->ops->destroy(stream); + h->ops->destroy(stream); } void silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule, SilcStreamNotifier notifier, void *context) { SilcStreamHeader h = stream; - return h->ops->notifier(stream, schedule, notifier, context); + h->ops->notifier(stream, schedule, notifier, context); } SilcSchedule silc_stream_get_schedule(SilcStream stream) diff --git a/lib/silcutil/silcstringprep.c b/lib/silcutil/silcstringprep.c index 5674eaf3..18ec3e94 100644 --- a/lib/silcutil/silcstringprep.c +++ b/lib/silcutil/silcstringprep.c @@ -19,7 +19,7 @@ #include "silc.h" #include "silcstringprep.h" -#include +#include "stringprep.h" /* We use GNU Libidn which has stringprep to do the magic. Only bad thing is that its interface is idiotic. We have our own API here in case -- 2.24.0