lib/eggdrop/memutil.c File Reference

#include <eggdrop/eggdrop.h>

Go to the source code of this file.

Functions

void str_redup (char **str, const char *newstr)
char * egg_mprintf (const char *format,...)
char * egg_msprintf (char *buf, int len, int *final_len, const char *format,...)
char * egg_mvsprintf (char *buf, int len, int *final_len, const char *format, va_list args)

Variables

static const char rcsid [] = "$Id: memutil.c,v 1.22 2006-01-05 20:42:42 sven Exp $"


Function Documentation

char* egg_mprintf ( const char *  format,
  ... 
)

Definition at line 41 of file memutil.c.

References egg_mvsprintf(), and NULL.

Referenced by assoc_get_name(), check_logsizes(), got352(), goterror(), gottopic(), help_parse_syntax(), ircmask_create_separate(), logfile_cycle(), make_password(), module_add_dir(), module_load(), my_create_command(), my_delete_command(), my_link_var(), my_unlink_var(), partymember_new(), print_net(), and real_perl_cmd().

00042 {
00043   va_list args;
00044   char *ptr;
00045 
00046   va_start(args, format);
00047   ptr = egg_mvsprintf(NULL, 0, NULL, format, args);
00048   va_end(args);
00049   return(ptr);
00050 }

char* egg_msprintf ( char *  buf,
int  len,
int *  final_len,
const char *  format,
  ... 
)

Definition at line 52 of file memutil.c.

References egg_mvsprintf().

Referenced by cache_lookup(), chanserv_probe_member(), check_flag_change(), got_actchan(), server_parse_input(), uhost_cache_addref(), uhost_cache_swap(), and user_set_setting().

00053 {
00054   va_list args;
00055   char *ptr;
00056 
00057   va_start(args, format);
00058   ptr = egg_mvsprintf(buf, len, final_len, format, args);
00059   va_end(args);
00060   return(ptr);
00061 }

char* egg_mvsprintf ( char *  buf,
int  len,
int *  final_len,
const char *  format,
va_list  args 
)

Definition at line 63 of file memutil.c.

References NULL.

Referenced by egg_iprintf(), egg_mprintf(), egg_msprintf(), partymember_msgf(), partymember_printf(), printserv(), and putlog().

00064 {
00065   char *output;
00066   int n;
00067 
00068   if (buf && len > 10) output = buf;
00069   else {
00070     output = malloc(512);
00071     len = 512;
00072   }
00073   while (1) {
00074     va_list temp_args;
00075 
00076     len -= 10;
00077     va_copy(temp_args, args);
00078     n = vsnprintf(output, len, format, temp_args);
00079     va_end(temp_args);
00080     if (n > -1 && n < len) break;
00081     if (n > len) len = n+1;
00082     else len *= 2;
00083     len += 10;
00084     if (output == buf) output = malloc(len);
00085     else output = realloc(output, len);
00086     if (!output) return(NULL);
00087   }
00088   if (final_len) {
00089     if (!(n % 1024)) n = strlen(output);
00090     *final_len = n;
00091   }
00092   if (output != buf && len - n > 256) output = realloc(output, n+20);
00093   return(output);
00094 }

void str_redup ( char **  str,
const char *  newstr 
)


Variable Documentation

const char rcsid[] = "$Id: memutil.c,v 1.22 2006-01-05 20:42:42 sven Exp $" [static]

Definition at line 22 of file memutil.c.


Generated on Sun Nov 30 18:43:34 2008 for eggdrop1.9 by  doxygen 1.5.6