Header comment changes.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 29 Jul 2007 19:04:35 +0000 (19:04 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 29 Jul 2007 19:04:35 +0000 (19:04 +0000)
12 files changed:
lib/silcutil/silcasync.h
lib/silcutil/silcbase64.c
lib/silcutil/silcbase64.h
lib/silcutil/silcbuffer.h
lib/silcutil/silcbuffmt.h
lib/silcutil/silccond.h
lib/silcutil/silcdlist.h
lib/silcutil/silcenv.h
lib/silcutil/silcfdstream.h
lib/silcutil/silcfsm.h
lib/silcutil/silchashtable.h
lib/silcutil/silcmime.h

index 0cc2190ecadd7dd23d7705644628e0b9faa5dd21..6e7469839e8ea06dfd953ee43fd89831295fdbf4 100644 (file)
@@ -278,7 +278,7 @@ SilcAsyncOperation silc_async_alloc(SilcAsyncOperationAbort abort_cb,
  *    silc_async_abort.  Since this use pre-allocated context, the function
  *    silc_async_free need not be called.  This function is equivalent
  *    to silc_async_alloc except this does not allocate any memory.  The `op'
- *    needs not be uninitialized.
+ *    needs not be uninitialized.  This returns always TRUE.
  *
  *    If the `pause_cb' is provided then the upper layer may also halt and
  *    then later resume the execution of the operation, by calling the
index c5c4242e8a1c3d65532541973479054f7f089963..441ccbc888c5f8d1c2fc4b5463a8d673d4a793ec 100644 (file)
@@ -36,6 +36,8 @@ char *silc_base64_encode(SilcStack stack, unsigned char *data, SilcUInt32 len)
   j = 0;
 
   pem = silc_scalloc(stack, ((len * 8 + 5) / 6) + 5, sizeof(*pem));
+  if (!pem)
+    return NULL;
 
   for (i = 0; i < len; i++) {
     c = data[i];
@@ -127,6 +129,8 @@ unsigned char *silc_base64_decode(SilcStack stack,
     len = base64_len;
 
   data = silc_scalloc(stack, ((len * 6) / 8), sizeof(*data));
+  if (!data)
+    return NULL;
 
   for (i = 0; i < len; i++) {
     c = base64[i];
index e060d4d716d413b2df137b70b6b175c42e47bcc0..98effa135a89105e1395eaaf510c987c12ec4064 100644 (file)
@@ -38,7 +38,7 @@
  * DESCRIPTION
  *
  *    Encodes data into Base 64 (PEM) encoding. Returns NULL terminated
- *    Base 64 encoded data string.
+ *    Base 64 encoded data string.  Returns NULL if system is out of memory.
  *
  *    If `stack' is non-NULL the returned buffer is allocated from `stack'.
  *
@@ -55,7 +55,7 @@ char *silc_base64_encode(SilcStack stack, unsigned char *data, SilcUInt32 len);
  * DESCRIPTION
  *
  *    Same as silc_base64_encode() but puts newline ('\n') every 72
- *    characters.
+ *    characters.  Returns NULL if system is out of memory.
  *
  *    If `stack' is non-NULL the returned buffer is allocated from `stack'.
  *
@@ -74,7 +74,8 @@ char *silc_base64_encode_file(SilcStack stack,
  *
  * DESCRIPTION
  *
- *    Decodes Base 64 (PEM) into data. Returns the decoded data.
+ *    Decodes Base 64 (PEM) into data. Returns the decoded data.  Returns
+ *    NULL if the data is not valid Base 64 encoded data.
  *
  *    If `stack' is non-NULL the returned buffer is allocated from `stack'.
  *
index d98877bf812cf5220cabfe33ebc93bb6af41325b..0a249cb0c812841954863e94dc78d532d3f80c7a 100644 (file)
@@ -238,7 +238,8 @@ SilcUInt32 silc_buffer_taillen(SilcBuffer x)
  *
  * DESCRIPTION
  *
- *    Allocates new SilcBuffer and returns it.  Returns NULL on error.
+ *    Allocates new SilcBuffer and returns it.  Returns NULL if system is
+ *    out of memory.
  *
  ***/
 
@@ -276,7 +277,8 @@ SilcBuffer silc_buffer_alloc(SilcUInt32 len)
  *
  * DESCRIPTION
  *
- *    Allocates new SilcBuffer and returns it.
+ *    Allocates new SilcBuffer and returns it.  Returns NULL if system is
+ *    out of memory.
  *
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
@@ -503,7 +505,8 @@ void silc_buffer_set(SilcBuffer sb, unsigned char *data, SilcUInt32 data_len)
  *
  *    Pulls current data area towards end. The length of the currently
  *    valid data area is also decremented. Returns pointer to the data
- *    area before pulling. Returns NULL on error.
+ *    area before pulling. Returns NULL if the pull would lead to buffer
+ *    overflow or would go beyond the valid data area.
  *
  * EXAMPLE
  *
@@ -548,7 +551,8 @@ unsigned char *silc_buffer_pull(SilcBuffer sb, SilcUInt32 len)
  *
  *    Pushes current data area towards beginning. Length of the currently
  *    valid data area is also incremented. Returns a pointer to the
- *    data area before pushing. Returns NULL on error.
+ *    data area before pushing. Returns NULL if the push would lead to
+ *    buffer underflow or would go under the valid data area.
  *
  * EXAMPLE
  *
@@ -593,7 +597,7 @@ unsigned char *silc_buffer_push(SilcBuffer sb, SilcUInt32 len)
  *
  *    Pulls current tail section towards end. Length of the current valid
  *    data area is also incremented. Returns a pointer to the data area
- *    before pulling. Returns NULL on error.
+ *    before pulling. Returns NULL if the pull would lead to buffer overflow.
  *
  * EXAMPLE
  *
@@ -638,7 +642,8 @@ unsigned char *silc_buffer_pull_tail(SilcBuffer sb, SilcUInt32 len)
  *
  *    Pushes current tail section towards beginning. Length of the current
  *    valid data area is also decremented. Returns a pointer to the
- *    tail section before pushing. Returns NULL on error.
+ *    tail section before pushing. Returns NULL if the push would lead to
+ *    buffer underflow or go under valid tail area.
  *
  * EXAMPLE
  *
@@ -684,7 +689,8 @@ unsigned char *silc_buffer_push_tail(SilcBuffer sb, SilcUInt32 len)
  * DESCRIPTION
  *
  *    Puts data at the head of the buffer. Returns pointer to the copied
- *    data area. Returns NULL on error.
+ *    data area. Returns NULL if the data is longer that the current head
+ *    area.
  *
  * EXAMPLE
  *
@@ -724,7 +730,8 @@ unsigned char *silc_buffer_put_head(SilcBuffer sb,
  * DESCRIPTION
  *
  *    Puts data at the start of the valid data area. Returns a pointer
- *    to the copied data area.  Returns NULL on error.
+ *    to the copied data area.  Returns NULL if the data is longer than the
+ *    current data area.
  *
  * EXAMPLE
  *
@@ -764,7 +771,8 @@ unsigned char *silc_buffer_put(SilcBuffer sb,
  * DESCRIPTION
  *
  *    Puts data at the tail of the buffer. Returns pointer to the copied
- *    data area.  Returns NULL on error.
+ *    data area.  Returns NULL if the data is longer than the current tail
+ *    area.
  *
  * EXAMPLE
  *
@@ -803,7 +811,7 @@ unsigned char *silc_buffer_put_tail(SilcBuffer sb,
  *
  *    Allocates `len' bytes size buffer and moves the tail area automatically
  *    `len' bytes so that the buffer is ready to use without calling the
- *    silc_buffer_pull_tail.  Returns NULL on error.
+ *    silc_buffer_pull_tail.  Returns NULL if system is out of memory.
  *
  ***/
 
@@ -828,7 +836,7 @@ SilcBuffer silc_buffer_alloc_size(SilcUInt32 len)
  *
  *    Allocates `len' bytes size buffer and moves the tail area automatically
  *    `len' bytes so that the buffer is ready to use without calling the
- *    silc_buffer_pull_tail.
+ *    silc_buffer_pull_tail.  Returns NULL if system is out of memory.
  *
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
@@ -943,7 +951,7 @@ void silc_buffer_end(SilcBuffer sb)
  *
  *    Generates copy of a SilcBuffer. This copies everything inside the
  *    currently valid data area, nothing more. Use silc_buffer_clone to
- *    copy entire buffer.  Returns NULL on error.
+ *    copy entire buffer.  Returns NULL if system is out of memory.
  *
  ***/
 
@@ -971,7 +979,7 @@ SilcBuffer silc_buffer_copy(SilcBuffer sb)
  *
  *    Generates copy of a SilcBuffer. This copies everything inside the
  *    currently valid data area, nothing more. Use silc_buffer_clone to
- *    copy entire buffer.
+ *    copy entire buffer.  Returns NULL if system is out of memory.
  *
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
@@ -1005,7 +1013,7 @@ SilcBuffer silc_buffer_scopy(SilcStack stack, SilcBuffer sb)
  *
  *    Clones SilcBuffer. This generates new SilcBuffer and copies
  *    everything from the source buffer. The result is exact clone of
- *    the original buffer.  Returns NULL on error.
+ *    the original buffer.  Returns NULL if system is out of memory.
  *
  ***/
 
@@ -1035,7 +1043,7 @@ SilcBuffer silc_buffer_clone(SilcBuffer sb)
  *
  *    Clones SilcBuffer. This generates new SilcBuffer and copies
  *    everything from the source buffer. The result is exact clone of
- *    the original buffer.
+ *    the original buffer.  Returns NULL if system is out of memory.
  *
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
@@ -1072,7 +1080,7 @@ SilcBuffer silc_buffer_sclone(SilcStack stack, SilcBuffer sb)
  *    Reallocates buffer. Old data is saved into the new buffer. The buffer
  *    is exact clone of the old one except that there is now more space
  *    at the end of buffer.  This always returns the same `sb' unless `sb'
- *    was NULL. Returns NULL on error.
+ *    was NULL. Returns NULL if system is out of memory.
  *
  ***/
 
@@ -1113,7 +1121,7 @@ SilcBuffer silc_buffer_realloc(SilcBuffer sb, SilcUInt32 newsize)
  *
  *    Reallocates buffer. Old data is saved into the new buffer. The buffer
  *    is exact clone of the old one except that there is now more space
- *    at the end of buffer.
+ *    at the end of buffer.  Returns NULL if system is out of memory.
  *
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
@@ -1171,7 +1179,7 @@ SilcBuffer silc_buffer_srealloc(SilcStack stack,
  *
  *    Same as silc_buffer_realloc but moves moves the tail area
  *    automatically so that the buffer is ready to use without calling the
- *    silc_buffer_pull_tail.  Returns NULL on error.
+ *    silc_buffer_pull_tail.  Returns NULL if system is out of memory.
  *
  ***/
 
@@ -1197,7 +1205,7 @@ SilcBuffer silc_buffer_realloc_size(SilcBuffer sb, SilcUInt32 newsize)
  *
  *    Same as silc_buffer_srealloc but moves moves the tail area
  *    automatically so that the buffer is ready to use without calling the
- *    silc_buffer_pull_tail.
+ *    silc_buffer_pull_tail.  Returns NULL if system is out of memory.
  *
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
@@ -1233,7 +1241,7 @@ SilcBuffer silc_buffer_srealloc_size(SilcStack stack,
  *    is at least the size of `size'.  If there is more space than `size'
  *    in the data area this does not do anything.  If there is enough
  *    space in the tail area this merely moves the tail area to reveal
- *    the extra space.  Returns FALSE on error.
+ *    the extra space.  Returns FALSE if system is out of memory.
  *
  ***/
 
@@ -1267,7 +1275,7 @@ SilcBool silc_buffer_enlarge(SilcBuffer sb, SilcUInt32 size)
  *    is at least the size of `size'.  If there is more space than `size'
  *    in the data area this does not do anything.  If there is enough
  *    space in the tail area this merely moves the tail area to reveal
- *    the extra space.  Returns FALSE on error.
+ *    the extra space.  Returns FALSE if system is out of memory.
  *
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
index fc213001030a9de89db0b5c6c8a605126fe87f4f..d1745d1a8b85428111d01a858b68ba1d89094f7f 100644 (file)
@@ -120,10 +120,10 @@ typedef int (*SilcBufferUnformatFunc)(SilcStack stack, SilcBuffer buffer,
  *
  * DESCRIPTION
  *
- *    Formats a buffer from a variable argument list.  Returns -1 on error
- *    and the length of the formatted buffer otherwise.  The buffer is
- *    enlarged automatically during formatting, if it doesn't already have
- *    enough space.
+ *    Formats a buffer from a variable argument list.  Returns -1 if the
+ *    system is out of memory and the length of the formatted buffer otherwise.
+ *    The buffer is enlarged automatically during formatting, if it doesn't
+ *    already have enough space.
  *
  * EXAMPLE
  *
@@ -181,7 +181,8 @@ int silc_buffer_format(SilcBuffer dst, ...);
  * DESCRIPTION
  *
  *    Same as silc_buffer_format but uses `stack' to allocate the memory.
- *    if `stack' is NULL reverts back to silc_buffer_format call.
+ *    if `stack' is NULL reverts back to silc_buffer_format call.  Returns
+ *    -1 if system is out of memory.
  *
  *    Note that this call consumes the `stack'.  The caller should push the
  *    stack before calling the function and pop it later.
@@ -198,7 +199,8 @@ int silc_buffer_sformat(SilcStack stack, SilcBuffer dst, ...);
  * DESCRIPTION
  *
  *    Formats a buffer from a variable argument list indicated by the `ap'.
- *    Returns -1 on error and the length of the formatted buffer otherwise.
+ *    Returns -1 if system is out of memory and the length of the formatted
+ *    buffer otherwise.
  *
  ***/
 int silc_buffer_format_vp(SilcBuffer dst, va_list ap);
@@ -212,7 +214,8 @@ int silc_buffer_format_vp(SilcBuffer dst, va_list ap);
  * DESCRIPTION
  *
  *    Same as silc_buffer_format_vp but uses `stack' to allocate the memory.
- *    if `stack' is NULL reverts back to silc_buffer_format_vp call.
+ *    if `stack' is NULL reverts back to silc_buffer_format_vp call.  Returns
+ *    -1 if system is out of memory.
  *
  *    Note that this call consumes the `stack'.  The caller should push the
  *    stack before calling the function and pop it later.
@@ -306,7 +309,7 @@ int silc_buffer_sunformat_vp(SilcStack stack, SilcBuffer src, va_list ap);
  *    be end with SILC_STRFMT_END argument.  This allows that a string in
  *    the list can be NULL, in which case it is skipped.  This automatically
  *    allocates the space for the buffer data but `dst' must be already
- *    allocated by the caller.
+ *    allocated by the caller.  Returns -1 if system is out of memory.
  *
  * EXAMPLE
  *
@@ -331,7 +334,8 @@ int silc_buffer_strformat(SilcBuffer dst, ...);
  *    the list can be NULL, in which case it is skipped.  This automatically
  *    allocates the space for the buffer data but `dst' must be already
  *    allocated by the caller.  This function is equivalent to
- *    silc_buffer_strformat but allocates memory from `stack'.
+ *    silc_buffer_strformat but allocates memory from `stack'.  Returns -1
+ *    if system is out of memory.
  *
  *    Note that this call consumes the `stack'.  The caller should push the
  *    stack before calling the function and pop it later.
index 08110d8145b1cbd24c0c1039ffe0c9f34f49cd6f..59918a48ef3aa6b4d14bf7204cc5476bb6b11b1f 100644 (file)
@@ -75,7 +75,8 @@ typedef struct SilcCondStruct *SilcCond;
  *    Allocates SILC Condition variable context.  The condition must
  *    be allocated before it can be used.  It is freed by the
  *    silc_cond_free function.  This returns TRUE and allocated
- *    condition in to the `cond' pointer and FALSE on error.
+ *    condition in to the `cond' pointer and FALSE if system is out of
+ *    memory.
  *
  ***/
 SilcBool silc_cond_alloc(SilcCond *cond);
index 9c951e49e6cb89be237f4d7f1e2160efb2716099..2a5030a3ff3c96269a9169283da8d23294a68383 100644 (file)
@@ -90,7 +90,8 @@ typedef struct SilcDListEntryStruct {
  *
  * DESCRIPTION
  *
- *    Initializes SilcDList.  Returns the SilcDList context or NULL on error.
+ *    Initializes SilcDList.  Returns the SilcDList context or NULL if system
+ *    is out of memory.
  *
  ***/
 
index 925caa3d5dcc44f7f98b17d6c084c0062ad2c538..f8474c6c4e562c41538f0467c48a2995910ce03b 100644 (file)
@@ -41,7 +41,7 @@
  *    Sets the environment variable named `variable' with value `value'
  *    to the environment.  If the `variable' already exists in the
  *    environment its value is changed to `value'.  Returns FALSE if the
- *    value could not be set or if environment variable are not supported.
+ *    value could not be set or if environment variables are not supported.
  *
  ***/
 SilcBool silc_setenv(const char *variable, const char *value);
index 64946c3f6374494e1b7f19c8e1e94d16ae027206..604c0b9022a810035bb4fcdba4a4cccf37bdc8ad 100644 (file)
@@ -44,7 +44,7 @@
  *
  *    Creates file descriptor stream for the open file descriptor indicated
  *    by `fd'.  The stream is closed with the silc_stream_close and destroyed
- *    with the silc_stream_destroy.
+ *    with the silc_stream_destroy.  Returns NULL if system is out of memory.
  *
  *    If the silc_stream_set_notifier is called the stream is set to
  *    non-blocking mode.
@@ -67,7 +67,8 @@ SilcStream silc_fd_stream_create(int fd, SilcStack stack);
  *    Creates file descriptor stream for the open file descriptors indicated
  *    by `read_fd' and `write_fd'.  The `read_fd' must be opened for reading
  *    and `write_fd' opened for writing.  The stream is closed with the
- *    silc_stream_close and destroyed with the silc_stream_destroy.
+ *    silc_stream_close and destroyed with the silc_stream_destroy.  Returns
+ *    NULL if system is out of memory.
  *
  *    If the silc_stream_set_notifier is called the stream is set to
  *    non-blocking mode.
@@ -90,7 +91,7 @@ SilcStream silc_fd_stream_create2(int read_fd, int write_fd, SilcStack stack);
  *    Same as silc_fd_stream_create but creates the stream by opening the
  *    file indicated by `filename'.  If the `reading' is TRUE the file is
  *    opened for reading.  If the `writing' is TRUE the file is opened
- *    for writing.
+ *    for writing.  Returns NULL if system is out of memory.
  *
  *    If the silc_stream_set_notifier is called the stream is set to
  *    non-blocking mode.
@@ -113,7 +114,8 @@ SilcStream silc_fd_stream_file(const char *filename, SilcBool reading,
  * DESCRIPTION
  *
  *    Same as silc_fd_stream_file but creates the stream by opening `read_file'
- *    for reading and `write_file' for writing.
+ *    for reading and `write_file' for writing.  Returns NULL if system is
+ *    out of memory.
  *
  *    If the silc_stream_set_notifier is called the stream is set to
  *    non-blocking mode.
@@ -136,7 +138,7 @@ SilcStream silc_fd_stream_file2(const char *read_file, const char *write_file,
  *
  *    Returns the file descriptors associated with the stream.  The 'write_fd'
  *    is available only if the stream was created with silc_fd_stream_create2
- *    function.
+ *    function.  Returns FALSE if the information is not available.
  *
  ***/
 SilcBool silc_fd_stream_get_info(SilcStream stream,
index c80a19b706984cc6470674b45de23660182f7f8c..701182e375501a2829ee18c156dab0a3142b2299 100644 (file)
@@ -403,6 +403,7 @@ do {                                                \
  *    caller must free the returned context with silc_fsm_free.  The
  *    `fsm_context' is delivered to every FSM state function.  The `schedule'
  *    is the caller's scheduler and the FSM will be run in the scheduler.
+ *    Returns NULL if system is out of memory.
  *
  * EXAMPLE
  *
@@ -481,7 +482,7 @@ SilcBool silc_fsm_init(SilcFSM fsm,
  *    thread context with silc_fsm_free.  If the 'real_thread' is TRUE
  *    then the thread will actually be executed in real thread, if platform
  *    supports them.  The `thread_context' is delivered to every state
- *    function in the thread.
+ *    function in the thread.  Returns NULL if the system is out of memory.
  *
  * NOTES
  *
@@ -905,7 +906,8 @@ typedef struct SilcFSMEventObject SilcFSMEventStruct;
  *    some event happens, some thread moves to a specific state or similar.
  *    The FSM Events may also be used in FSM threads that are executed in
  *    real system threads.  It is safe to wait and signal the event from
- *    threads.  The `fsm' must be the machine, not a thread.
+ *    threads.  The `fsm' must be the machine, not a thread.  Returns NULL
+ *    if system is out of memory or `fsm' is not FSM machine.
  *
  *    Use the macros SILC_FSM_EVENT_WAIT and SILC_FSM_EVENT_TIMEDWAIT to wait
  *    for the event.  Use the SILC_FSM_EVENT_SIGNAL macro to signal all the
index 6cecb2741a1cfdfa0ff0f52167a8ce7357e0d688..f7d7f21a9d29e2972b0975c69251dfd8e82abb16 100644 (file)
@@ -192,7 +192,7 @@ typedef void (*SilcHashForeach)(void *key, void *context, void *user_context);
  *    it should be a prime. The `hash', `compare' and `destructor' are
  *    the hash function, the key comparison function and key and context
  *    destructor function, respectively. The `hash' is mandatory, the others
- *    are optional.
+ *    are optional.  Returns NULL if system is out of memory.
  *
  ***/
 SilcHashTable silc_hash_table_alloc(SilcStack stack,
index 82aa8eeada800b5687992bc14c96ed05e4e08fad..664b526a06adbaaa137947327282a30b437c5edc 100644 (file)
@@ -71,7 +71,8 @@ typedef struct SilcMimeAssemblerStruct *SilcMimeAssembler;
  *
  * DESCRIPTION
  *
- *    Allocates SILC Mime message context.
+ *    Allocates SILC Mime message context.  Returns NULL if system is out of
+ *    memory.
  *
  ***/
 SilcMime silc_mime_alloc(void);
@@ -97,7 +98,8 @@ void silc_mime_free(SilcMime mime);
  *
  * DESCRIPTION
  *
- *    Allocates MIME fragment assembler.
+ *    Allocates MIME fragment assembler.  Returns NULL if system is out of
+ *    memory.
  *
  ***/
 SilcMimeAssembler silc_mime_assembler_alloc(void);