[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_DStringNAppend

Overview

Append n-characters of a string to an Ns_DString

Syntax

    char *Ns_DStringNAppend(
    Ns_DString *dsPtr,
    char *string,
    int length
    );

Description

The Ns_DStringNAppend function appends a string up to the specified number of characters, plus a terminating null character.( Unlike the Tcl_DStringAppend function, which only works with string data, the AOLserver Ns_DStringNAppend function can append binary data.) The string may overflow from static space to the heap as a result of calling this function. It returns the string associated with the current Ns_DString.

Examples

The resulting Ns_DString in this example, ds, would contain "foo\0" and have a length of 3:

    Ns_DString ds;
    Ns_DStringInit(&ds);
    Ns_DStringNAppend(&ds, "fooasdf", 3);
    printf("%s\n", ds.string);
    Ns_DStringFree(&ds); /* finished with dstring */

If you need a null-terminated list of null-terminated strings, such as "foo\0bar\0\0", you would add one to the length of the appended strings to get the extra terminating null character. For example:

    Ns_DString ds;
    Ns_DStringInit(&ds);
    Ns_DStringNAppend(&ds, "foo", 4);
    Ns_DStringNAppend(&ds, "bar", 4);

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.