Integer type name change.
[silc.git] / lib / silcutil / symbian / silcepocsockconn.cpp
1 /*
2
3   silcepocsockconn.cpp 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2002 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19 /* $Id$ */
20
21 #include "silcincludes.h"
22
23 /* Writes data from encrypted buffer to the socket connection. If the
24    data cannot be written at once, it will be written later with a timeout. 
25    The data is written from the data section of the buffer, not from head
26    or tail section. This automatically pulls the data section towards end
27    after writing the data. */
28
29 int silc_socket_write(SilcSocketConnection sock)
30 {
31   /* XXX */
32 }
33
34 /* Reads data from the socket connection into the incoming data buffer.
35    It reads as much as possible from the socket connection. This returns
36    amount of bytes read or -1 on error or -2 on case where all of the
37    data could not be read at once. */
38
39 int silc_socket_read(SilcSocketConnection sock)
40 {
41   /* XXX */
42 }
43
44 /* Returns human readable socket error message. These are copied from the
45    PuTTY. */
46
47 #define PUT_ERROR(s) 
48 do {
49   if (strlen(s) > err_len)
50     return FALSE;
51   memset(error, 0, error_len);
52   memcpy(error, s, strlen(s));
53   return TRUE;
54 } while(0)
55
56 bool silc_socket_get_error(SilcSocketConnection sock, char *error,
57                            SilcUInt32 error_len)
58 {
59   if (sock->sock_error == KErrNone)
60     return FALSE;
61
62   switch (sock->sock_error) {
63   case KErrNotFound:
64     PUT_ERROR("Item not found. (NotFound)");
65   case KErrGeneral:
66     PUT_ERROR("Uncategorized error. (General)");
67   case KErrCancel:
68     PUT_ERROR("Operation cancelled. (Cancel)");
69   case KErrNoMemory:
70     PUT_ERROR("A memory allocation failed. (NoMemory)");
71   case KErrNotSupported:
72     PUT_ERROR("A function is not supported in a given context. "
73               "(NotSupported)");
74   case KErrArgument:
75     PUT_ERROR("An argument is out of range. (Argument)");
76   case KErrBadHandle:
77     PUT_ERROR("Bad handle. (BadHandle)");
78   case KErrOverflow:
79     PUT_ERROR("Overflow. (Overflow)");
80   case KErrUnderflow:
81     PUT_ERROR("Underflow. (Underflow)");
82   case KErrAlreadyExists:
83     PUT_ERROR("The resource already exists. (AlreadyExists)");
84   case KErrPathNotFound:
85     PUT_ERROR("In the context of file operations, the path was "
86               "not found. (PathNotFound)");
87   case KErrDied:
88     PUT_ERROR("A handle refers to a thread which has died (Died)");
89   case KErrInUse:
90     PUT_ERROR("A requested resource is already in use. (InUse)");
91   case KErrServerTerminated:
92     PUT_ERROR("A client/server operation cannot execute, because the "
93               "server has terminated. (ServerTerminated)");
94   case KErrServerBusy:
95     PUT_ERROR("A client/server operation cannot execute, because the server "
96               "is busy. (ServerBusy)");
97   case KErrNotReady:
98     PUT_ERROR("Resource not ready. Not initialized, or has no power. "
99               "(NotReady)");
100   case KErrUnknown:
101     PUT_ERROR("A device is of unknown type. (Unknown)");
102   case KErrCorrupt:
103     PUT_ERROR("Corrupted. (Corrupt)");
104   case KErrAccessDenied:
105     PUT_ERROR("Access denied. (AccessDenied)");
106   case KErrLocked:
107     PUT_ERROR("The operation cannot be performed, because the resource "
108               "is locked. (Locked)");
109   case KErrWrite:
110     PUT_ERROR("During a file write operation, not all the data could "
111               "be written. (Write)");
112   case KErrDisMounted:
113     PUT_ERROR("A volume which was to be used for a file system operation "
114               "has been dismounted. (DisMounted)");
115   case KErrEof:
116     PUT_ERROR("End of file has been reached. (Eof)");
117   case KErrDiskFull:
118     PUT_ERROR("A write operation could not complete, because the disk "
119               "was full. (DiskFull)");
120   case KErrBadDriver:
121     PUT_ERROR("A driver DLL was of the wrong type. (BadDriver)");
122   case KErrBadName:
123     PUT_ERROR("Name did not conform with the required syntax. (BadName)");
124   case KErrCommsLineFail:
125     PUT_ERROR("The communication line failed. (CommsLineFail)");
126   case KErrCommsFrame:
127     PUT_ERROR("A frame error occurred in a communications operation. "
128               "(CommsFrame)");
129   case KErrCommsOverrun:
130     PUT_ERROR("An overrun was detected by a communications driver. "
131               "(CommsOverrun)");
132   case KErrCommsParity:
133     PUT_ERROR("A parity error occurred in communications. (CommsParity)");
134   case KErrTimedOut:
135     PUT_ERROR("An operation timed out. (TimedOut)");
136   case KErrCouldNotConnect:
137     PUT_ERROR("A session could not connect. (CouldNotConnect)");
138   case KErrCouldNotDisconnect:
139     PUT_ERROR("A session could not disconnect. (CouldNotDisconnect)");
140   case KErrDisconnected:
141     PUT_ERROR("The required session was disconnected. (Disconnected)");
142   case KErrBadLibraryEntryPoint:
143     PUT_ERROR("A library entry point was not of the required type. "
144               "(BadLibraryEntryPoint)");
145   case KErrBadDescriptor:
146     PUT_ERROR("A non-descriptor parameter was passed. (BadDescriptor)");
147   case KErrAbort:
148     PUT_ERROR("An operation was aborted (Abort)");
149   case KErrTooBig:
150     PUT_ERROR("A number was too big (TooBig)");
151   case KErrDivideByZero:
152     PUT_ERROR("A divide-by-zero operation was attempted. (DivideByZero)");
153   case KErrBadPower:
154     PUT_ERROR("Insufficient power was available to complete an operation. "
155               "(BadPower)");
156   case KErrWouldBlock:
157     PUT_ERROR("Network error: Resource temporarily unavailable (WouldBlock)");
158   case KErrNetUnreach:
159     PUT_ERROR("Network unreachable. (NetUnreach)");
160   case KErrHostUnreach:
161     PUT_ERROR("Host unreachable. (HostUnreach)");
162   case KErrNoProtocolOpt:
163     PUT_ERROR("No such protocol option. (NoProtocolOpt)");
164   case KErrUrgentData:
165     PUT_ERROR("Urgent data arrived. (UrgentData)");
166   case KInvalSocket:
167     PUT_ERROR("Got NULL sokcet.");
168   }
169
170   return FALSE;
171 }