yw_packet_make

Name

yw_packet_make -- make entire packet at once

Synopsis


     #include <yw/packet.h>
   

YwPacket *yw_packet_make(YwPacketType type, P);

DESCRIPTION

This function is quite complex. First packet of type is created (see yw_packet_new(3), for discusion about type argument). Then arguments of char* type are processed in order, they were passed. They specify words to be appended. Type of word is determined based of it's first character. When there is more then one character additional word of type yw_key_word is appended first. This means, that yw_packet_make(yw_call_packet, "k", "hello", "i", 10, YW_END) and yw_packet_make(yw_call_packet, "i" "hello", 10, YW_END) are the same. This feature comes in handy when dealing with tag lists. Then type-depended arguments are poped off the stack, and processing restarts with new char* argument. Words are appended until YW_END is found (which is simply ((char*)0)). Following type characters are supported (format: type character, type of appended word, arguments. Meaning of word appending functions is same as meaning of yw_string_assign_* functions, i.e. encoding can be NULL (use default), and length can be -1 (compute it)):

RETURN VALUE

Pointer to freshly created packet is returned, or NULL in case of error (i.e. bad character for given encoding, or sth like that. This functions bombs when there is error in passed arguments).

EXAMPLES

Here you can find some examples of use:

      yw_packet_make(yw_taglist_packet,
      			"i" "width", 20,
      			"i" "height", 10,
      			"d" "title", "Hello world",
      			YW_END);
      			
      yw_packet_make(yw_call_packet,
      			"k", "frob", YW_END);
      			
      yw_packet_make(yw_call_packet,
      			"k", "frob_with_tags", 
      			"i" "foo", 20,
      			"v" "bumzor_present", 
      			/* void word appended here ^^^ */ 
      			"s" "bar", &str,
      			/* assume _() to return UTF8: */
      			"g" "baz", _("Hello world!"), 
      			/* or maybe it would be wiser to assume 
      			 * _() to return current default 
      			 * encoding?? */
      			"d" "baz_local", _("Hmm... Locale?"),
      			/* use longer versions */
      			"k", "ala_ma", "d", "kota",
      			"k", "kot_ma", "i", 20,
      			YW_END);
    

BUGS

Confusing manpage.

INFO

Generated from: packet.c,v 1.10 2001/05/21 09:58:51 malekith Exp.