Added SilcStack support to SILC File Util API.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 4 Jul 2007 17:21:55 +0000 (17:21 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 4 Jul 2007 17:21:55 +0000 (17:21 +0000)
CHANGES.RUNTIME
apps/irssi/src/silc/core/silc-queries.c
lib/silchttp/tests/test_silchttpserver.c
lib/silcutil/silcbuffer.h
lib/silcutil/silcconfig.c
lib/silcutil/silcfileutil.c
lib/silcutil/silcfileutil.h

index 761361cb6b4f6df59426b8fbb1903c619c179dfe..56734857db201dd4e30ed7dc3b4abde444597727 100644 (file)
@@ -1,4 +1,13 @@
-Wed Jul  4 16:31:05 EEST 2007  Pekka Riikonen <priikone@silcnet.org>
+Wed Jul  4 20:20:05 EEST 2007  Pekka Riikonen <priikone@silcnet.org>
+
+       * Unified the SILC_STR_FUNC callback.  Affected files are
+         lib/silcutil/silcbuffmt.[ch].
+
+       * Added SilcStack support to SILC File Util API.  Affected files
+         are lib/silcutil/silcfileutil.[ch].
+
+       * Added SilcStack support to SILC FD Stream API.  Affected files
+         are lib/silcutil/silcfdstream.[ch].
 
        * Added SilcStack support to SILC Scheduler API.  The scheduler
          now creates stack always.  It can be retrieved by
index 1e7f75132230b18e746d7825f4ed9b32c89f8883..271e3d5e77b41d44ad8e18df7ab5cc68198a15f2 100644 (file)
@@ -292,7 +292,7 @@ void silc_query_attributes_default(SilcClient client,
     /* Put USER_INFO */
     silc_client_attribute_del(silc_client, conn,
                              SILC_ATTRIBUTE_USER_INFO, NULL);
-    tmp = silc_file_readfile(sv, &tmp_len);
+    tmp = silc_file_readfile(sv, &tmp_len, NULL);
     if (tmp) {
       tmp[tmp_len] = 0;
       if (silc_vcard_decode(tmp, tmp_len, &vcard))
@@ -384,7 +384,7 @@ void silc_query_attributes_default(SilcClient client,
     /* Put STATUS_MESSAGE */
     silc_client_attribute_del(silc_client, conn,
                              SILC_ATTRIBUTE_STATUS_MESSAGE, NULL);
-    tmp = silc_file_readfile(sv, &tmp_len);
+    tmp = silc_file_readfile(sv, &tmp_len, NULL);
     if (tmp) {
       mime = silc_mime_decode(NULL, tmp, tmp_len);
       if (mime)
@@ -529,7 +529,7 @@ void silc_query_attributes_default(SilcClient client,
     list = g_strsplit(sv, " ", -1);
     for (entry = list; *entry != NULL; entry++) {
       if (!strncasecmp(*entry, "silc-rsa:", 8)) {
-       tmp = silc_file_readfile((*entry) + 8, &tmp_len);
+       tmp = silc_file_readfile((*entry) + 8, &tmp_len, NULL);
        if (tmp) {
          tmp[tmp_len] = 0;
          pk.type = "silc-rsa";
index e8b3f0a2d095f0285558bfec72df7bbae18cf5a2..cb9050b14f93a6c09b1595de03c7a815e3417ca6 100644 (file)
@@ -65,7 +65,7 @@ static void http_callback_file(SilcHttpServer httpd, SilcHttpConnection conn,
     SILC_LOG_DEBUG(("Filename: '%s'", filename));
 
     if (!usephp) {
-      filedata = silc_file_readfile(filename, &data_len);
+      filedata = silc_file_readfile(filename, &data_len, NULL);
       if (!filedata) {
        silc_http_server_send_error(httpd, conn, "404 Not Found",
                                    "<body><h1>404 Not Found</h1><p>The page you are looking for cannot be located</body>");
index 5ce671175b628994820e5edd63a20efb026cb504..7dec1149a21a5d7b3163ca8368acba4da9eed306 100644 (file)
@@ -961,6 +961,9 @@ SilcBool silc_buffer_enlarge(SilcBuffer sb, SilcUInt32 size)
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
  *
+ *    Note that this call consumes the `stack'.  The caller should push the
+ *    stack before calling the function and pop it later.
+ *
  ***/
 
 static inline
@@ -1005,6 +1008,9 @@ SilcBuffer silc_buffer_salloc(SilcStack stack, SilcUInt32 len)
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
  *
+ *    Note that this call consumes the `stack'.  The caller should push the
+ *    stack before calling the function and pop it later.
+ *
  ***/
 
 static inline
@@ -1034,6 +1040,9 @@ SilcBuffer silc_buffer_salloc_size(SilcStack stack, SilcUInt32 len)
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
  *
+ *    Note that this call consumes the `stack'.  The caller should push the
+ *    stack before calling the function and pop it later.
+ *
  ***/
 
 static inline
@@ -1090,6 +1099,9 @@ SilcBuffer silc_buffer_srealloc(SilcStack stack,
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
  *
+ *    Note that this call consumes the `stack'.  The caller should push the
+ *    stack before calling the function and pop it later.
+ *
  ***/
 
 static inline
@@ -1124,6 +1136,9 @@ SilcBuffer silc_buffer_srealloc_size(SilcStack stack,
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
  *
+ *    Note that this call consumes the `stack'.  The caller should push the
+ *    stack before calling the function and pop it later.
+ *
  ***/
 
 static inline
@@ -1157,6 +1172,9 @@ SilcBool silc_buffer_senlarge(SilcStack stack, SilcBuffer sb, SilcUInt32 size)
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
  *
+ *    Note that this call consumes the `stack'.  The caller should push the
+ *    stack before calling the function and pop it later.
+ *
  ***/
 
 static inline
@@ -1188,6 +1206,9 @@ SilcBuffer silc_buffer_scopy(SilcStack stack, SilcBuffer sb)
  *    This routine use SilcStack are memory source.  If `stack' is NULL
  *    reverts back to normal allocating routine.
  *
+ *    Note that this call consumes the `stack'.  The caller should push the
+ *    stack before calling the function and pop it later.
+ *
  ***/
 
 static inline
index 97760b3f88ee0cf47154cc891d0c96b06d52cee6..4950700577da98f8d0074350acb17d4119b6c7fd 100644 (file)
@@ -263,7 +263,7 @@ SilcConfigFile *silc_config_open(const char *configfile)
   SilcUInt32 filelen;
   SilcConfigFile *ret;
 
-  if (!(buffer = silc_file_readfile(configfile, &filelen)))
+  if (!(buffer = silc_file_readfile(configfile, &filelen, NULL)))
     return NULL;
 
   ret = silc_calloc(1, sizeof(*ret));
index 02620b04b877ee1a91829b24d3bd2cdf8aa2cb45..5404183a6c67a406dcf4f21ee80871420d8c86b2 100644 (file)
@@ -124,7 +124,8 @@ int silc_file_writefile_mode(const char *filename, const char *buffer,
 /* Reads a file to a buffer. The allocated buffer is returned. Length of
    the file read is returned to the return_len argument. */
 
-char *silc_file_readfile(const char *filename, SilcUInt32 *return_len)
+char *silc_file_readfile(const char *filename, SilcUInt32 *return_len,
+                        SilcStack stack)
 {
   int fd;
   char *buffer;
index 80e9d99a45be468e4ec1a3942af1bf135b8e2797..70887760e0dad3e455e44796b141950369fbc47d 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2005 Pekka Riikonen
+  Copyright (C) 1997 - 2007 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
@@ -117,7 +117,8 @@ int silc_file_set_nonblock(int fd);
  *
  * SYNOPSIS
  *
- *    char *silc_file_readfile(const char *filename, SilcUInt32 *return_len);
+ *    char *silc_file_readfile(const char *filename, SilcUInt32 *return_len,
+ *                             SilcStack stack);
  *
  * DESCRIPTION
  *
@@ -129,8 +130,13 @@ int silc_file_set_nonblock(int fd);
  *    If the `return_len' pointer is not NULL, it's filled with the length of
  *    the file.
  *
+ *    If `stack' is non-NULL the returned buffer is allocated from `stack'.
+ *    The allocation consumes `stack' so caller should push the stack before
+ *    calling this function and pop it later.
+ *
  ***/
-char *silc_file_readfile(const char *filename, SilcUInt32 *return_len);
+char *silc_file_readfile(const char *filename, SilcUInt32 *return_len,
+                        SilcStack stack);
 
 /****f* silcutil/SilcFileUtilAPI/silc_file_writefile
  *