Re: send_to_charf, etc

From: Sean Butler (sbutler@DEVEAST.COM)
Date: 12/09/97


I guess I missed the first part of this thread, but why use a macro
for that and not a function?

#include <stdarg.h>

/* Like sprintf it returns the count of the arguments read */
int send_to_charf(ch, const char *format, ...)
{
        char buf[MAX];
        va_list argp;
        int count;

        buf[0] = '\0';
        va_start(argp, format);
        count = vsprintf(buf, format, argp);
        va_end(argp);
        if (buf[0])
                send_to_char(ch, buf);
        return count;
}

NOTE:   I have not tested this, however it is so completely standard
        that i have little doubt about its working.

--Sean

At 05:49 AM 12/9/97 -0600, Chris Jacobson wrote:
>On 12/8/97 6:36 PM, Akuma/Chris Baggett/DOOMer (doomer@BAYOU.COM) stated:
>
>>
>>send_to_charf(ch, "messg %s %d %d", string, number, number);
>>would be changed in the preprocessor to
>>ch->printf("messg %s %d %d", string, number, number);
>>
>
>Macro's don't support varargs (... stuff), unfortunately.  I was messing
>with it the other day, hoping to have a basic BUG() macro, but I'm stuck
>with several versions of bug() macros instead.
>
>- Chris Jacobson

----

     /'''''''''''''''''\'\       The final aspiration of all coders?
    |                   | |
    | /* Sean Butler */ | |      Sean Butler
    |                   | |      Coder for finality.com 4000
    |      exit(0);     | |      xin@finality.com
    |                   | |
    |                   | |
   \\//................\\\//


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST