From: Pekka Riikonen Date: Thu, 7 Feb 2002 18:53:52 +0000 (+0000) Subject: updates. X-Git-Tag: silc.client.0.8.1~102 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=65b7906b7bc9bfade4883bcc4e653efc71b01fa4 updates. --- diff --git a/includes/silcepoc.h b/includes/silcepoc.h new file mode 100644 index 00000000..ab57922a --- /dev/null +++ b/includes/silcepoc.h @@ -0,0 +1,34 @@ +/* + + silcepoc.h + + Author: Pekka Riikonen + + Copyright (C) 2002 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*/ +/* Native EPOC specific includes and definitions. */ + +#ifndef SILCEPOC_H +#define SILCEPOC_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/includes/silcincludes.h b/includes/silcincludes.h index 0291158c..fb68ce56 100644 --- a/includes/silcincludes.h +++ b/includes/silcincludes.h @@ -35,8 +35,10 @@ #endif #if defined(__EPOC32__) +#ifndef SILC_EPOC #define SILC_EPOC #endif +#endif #ifdef SILC_WIN32 #include "silcwin32.h" diff --git a/lib/silcutil/Makefile.am b/lib/silcutil/Makefile.am index af1f7fb7..07fb9461 100644 --- a/lib/silcutil/Makefile.am +++ b/lib/silcutil/Makefile.am @@ -1,14 +1,13 @@ # # Makefile.am # -# Author: Pekka Riikonen +# Author: Pekka Riikonen # -# Copyright (C) 2000 Pekka Riikonen +# Copyright (C) 2000 - 2002 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,8 +20,12 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign if SILC_WIN32 SUBDIRS=win32 else +if SILC_EPOC +SUBDIRS=epoc +else SUBDIRS=unix endif +endif noinst_LIBRARIES = libsilcutil.a diff --git a/lib/silcutil/symbian/silcepocsockconn.cpp b/lib/silcutil/symbian/silcepocsockconn.cpp new file mode 100644 index 00000000..99853dc9 --- /dev/null +++ b/lib/silcutil/symbian/silcepocsockconn.cpp @@ -0,0 +1,171 @@ +/* + + silcepocsockconn.cpp + + Author: Pekka Riikonen + + Copyright (C) 2002 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*/ +/* $Id$ */ + +#include "silcincludes.h" + +/* Writes data from encrypted buffer to the socket connection. If the + data cannot be written at once, it will be written later with a timeout. + The data is written from the data section of the buffer, not from head + or tail section. This automatically pulls the data section towards end + after writing the data. */ + +int silc_socket_write(SilcSocketConnection sock) +{ + /* XXX */ +} + +/* Reads data from the socket connection into the incoming data buffer. + It reads as much as possible from the socket connection. This returns + amount of bytes read or -1 on error or -2 on case where all of the + data could not be read at once. */ + +int silc_socket_read(SilcSocketConnection sock) +{ + /* XXX */ +} + +/* Returns human readable socket error message. These are copied from the + PuTTY. */ + +#define PUT_ERROR(s) +do { + if (strlen(s) > err_len) + return FALSE; + memset(error, 0, error_len); + memcpy(error, s, strlen(s)); + return TRUE; +} while(0) + +bool silc_socket_get_error(SilcSocketConnection sock, char *error, + uint32 error_len) +{ + if (sock->sock_error == KErrNone) + return FALSE; + + switch (sock->sock_error) { + case KErrNotFound: + PUT_ERROR("Item not found. (NotFound)"); + case KErrGeneral: + PUT_ERROR("Uncategorized error. (General)"); + case KErrCancel: + PUT_ERROR("Operation cancelled. (Cancel)"); + case KErrNoMemory: + PUT_ERROR("A memory allocation failed. (NoMemory)"); + case KErrNotSupported: + PUT_ERROR("A function is not supported in a given context. " + "(NotSupported)"); + case KErrArgument: + PUT_ERROR("An argument is out of range. (Argument)"); + case KErrBadHandle: + PUT_ERROR("Bad handle. (BadHandle)"); + case KErrOverflow: + PUT_ERROR("Overflow. (Overflow)"); + case KErrUnderflow: + PUT_ERROR("Underflow. (Underflow)"); + case KErrAlreadyExists: + PUT_ERROR("The resource already exists. (AlreadyExists)"); + case KErrPathNotFound: + PUT_ERROR("In the context of file operations, the path was " + "not found. (PathNotFound)"); + case KErrDied: + PUT_ERROR("A handle refers to a thread which has died (Died)"); + case KErrInUse: + PUT_ERROR("A requested resource is already in use. (InUse)"); + case KErrServerTerminated: + PUT_ERROR("A client/server operation cannot execute, because the " + "server has terminated. (ServerTerminated)"); + case KErrServerBusy: + PUT_ERROR("A client/server operation cannot execute, because the server " + "is busy. (ServerBusy)"); + case KErrNotReady: + PUT_ERROR("Resource not ready. Not initialized, or has no power. " + "(NotReady)"); + case KErrUnknown: + PUT_ERROR("A device is of unknown type. (Unknown)"); + case KErrCorrupt: + PUT_ERROR("Corrupted. (Corrupt)"); + case KErrAccessDenied: + PUT_ERROR("Access denied. (AccessDenied)"); + case KErrLocked: + PUT_ERROR("The operation cannot be performed, because the resource " + "is locked. (Locked)"); + case KErrWrite: + PUT_ERROR("During a file write operation, not all the data could " + "be written. (Write)"); + case KErrDisMounted: + PUT_ERROR("A volume which was to be used for a file system operation " + "has been dismounted. (DisMounted)"); + case KErrEof: + PUT_ERROR("End of file has been reached. (Eof)"); + case KErrDiskFull: + PUT_ERROR("A write operation could not complete, because the disk " + "was full. (DiskFull)"); + case KErrBadDriver: + PUT_ERROR("A driver DLL was of the wrong type. (BadDriver)"); + case KErrBadName: + PUT_ERROR("Name did not conform with the required syntax. (BadName)"); + case KErrCommsLineFail: + PUT_ERROR("The communication line failed. (CommsLineFail)"); + case KErrCommsFrame: + PUT_ERROR("A frame error occurred in a communications operation. " + "(CommsFrame)"); + case KErrCommsOverrun: + PUT_ERROR("An overrun was detected by a communications driver. " + "(CommsOverrun)"); + case KErrCommsParity: + PUT_ERROR("A parity error occurred in communications. (CommsParity)"); + case KErrTimedOut: + PUT_ERROR("An operation timed out. (TimedOut)"); + case KErrCouldNotConnect: + PUT_ERROR("A session could not connect. (CouldNotConnect)"); + case KErrCouldNotDisconnect: + PUT_ERROR("A session could not disconnect. (CouldNotDisconnect)"); + case KErrDisconnected: + PUT_ERROR("The required session was disconnected. (Disconnected)"); + case KErrBadLibraryEntryPoint: + PUT_ERROR("A library entry point was not of the required type. " + "(BadLibraryEntryPoint)"); + case KErrBadDescriptor: + PUT_ERROR("A non-descriptor parameter was passed. (BadDescriptor)"); + case KErrAbort: + PUT_ERROR("An operation was aborted (Abort)"); + case KErrTooBig: + PUT_ERROR("A number was too big (TooBig)"); + case KErrDivideByZero: + PUT_ERROR("A divide-by-zero operation was attempted. (DivideByZero)"); + case KErrBadPower: + PUT_ERROR("Insufficient power was available to complete an operation. " + "(BadPower)"); + case KErrWouldBlock: + PUT_ERROR("Network error: Resource temporarily unavailable (WouldBlock)"); + case KErrNetUnreach: + PUT_ERROR("Network unreachable. (NetUnreach)"); + case KErrHostUnreach: + PUT_ERROR("Host unreachable. (HostUnreach)"); + case KErrNoProtocolOpt: + PUT_ERROR("No such protocol option. (NoProtocolOpt)"); + case KErrUrgentData: + PUT_ERROR("Urgent data arrived. (UrgentData)"); + case KInvalSocket: + PUT_ERROR("Got NULL sokcet."); + } + + return FALSE; +} diff --git a/lib/silcutil/symbian/silcepocthread.cpp b/lib/silcutil/symbian/silcepocthread.cpp new file mode 100644 index 00000000..12ad59cf --- /dev/null +++ b/lib/silcutil/symbian/silcepocthread.cpp @@ -0,0 +1,104 @@ +/* + + silcepocthread.cpp + + Author: Pekka Riikonen + + Copyright (C) 2002 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*/ +/* $Id$ */ + +#include "silcincludes.h" + +#ifdef SILC_THREADS + +/* Thread structure for EPOC */ +typedef struct { + RThread *thread; + SilcThreadStart start_func; + void *context; + bool waitable; +} *SilcEpocThread; + +/* The actual thread function */ + +TInt silc_thread_epoc_start(TAny *context) +{ + SilcEpocThread thread = (SilcEpocThread)context; + + thread->start_func(thread->context); + silc_thread_exit(NULL); + + return 0; +} + +SilcThread silc_thread_create(SilcThreadStart start_func, void *context, + bool waitable) +{ +#ifdef SILC_THREADS + SilcEpocThread thread; + TInt ret; + + SILC_LOG_DEBUG(("Creating new thread")); + + thread = silc_calloc(1, sizeof(*thread)); + thread->start_func = start_func; + thread->context = context; + thread->waitable = waitable; + + /* Create the thread */ + /* XXX Unique name should be given for the thread */ + thread->thread = new RThread(); + ret = thread->thread->Create(NULL, silc_thread_epoc_start, 0, 0, 0, + (TAny *)thread, EOwnerProcess); + if (ret != KErrNone) { + SILC_LOG_ERROR(("Could not create new thread")); + delete thread->thread; + silc_free(thread); + return NULL; + } + + return (SilcThread)thread; +#else + /* Call thread callback immediately */ + (*start_func)(context); + return NULL; +#endif +} + +void silc_thread_exit(void *exit_value) +{ +#ifdef SILC_THREADS + /* XXX */ +#endif +} + +SilcThread silc_thread_self(void) +{ +#ifdef SILC_THREADS + /* XXX */ + return NULL; +#else + return NULL; +#endif +} + +bool silc_thread_wait(SilcThread thread, void **exit_value) +{ +#ifdef SILC_THREADS + /* XXX */ + return TRUE; +#else + return FALSE; +#endif +} diff --git a/lib/silcutil/symbian/silcepocutil.cpp b/lib/silcutil/symbian/silcepocutil.cpp new file mode 100644 index 00000000..b43eda90 --- /dev/null +++ b/lib/silcutil/symbian/silcepocutil.cpp @@ -0,0 +1,49 @@ +/* + + silcepocutil.cpp + + Author: Pekka Riikonen + + Copyright (C) 2002 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*/ +/* $Id$ */ + +#include "silcincludes.h" + +/* XXX TODO or use GNU regex if it compiles */ +char *silc_string_regexify(const char *string) +{ + return strdup(string); +} + +char *silc_string_regex_combine(const char *string1, const char *string2) +{ + return strdup(string1); +} + +int silc_string_regex_match(const char *regex, const char *string) +{ + return TRUE; +} + +int silc_string_match(const char *string1, const char *string2) +{ + return TRUE; +} + +/* Return current time to struct timeval. */ + +int silc_gettimeofday(struct timeval *p) +{ + return gettimeofday(p, NULL); +}