[Xcb] New aux function

Barton C Massey bart at cs.pdx.edu
Sun Jan 15 18:48:12 PST 2006


Keithp asserts that it can and does happen in things like
server ID strings.  I doubt it would happen in an extension
name, but we should probably remain standards-compliant.

	Bart

In message <43CABB8C.1080207 at brandeis.edu> you wrote:
> Ew. Are their any cases where nulls are embedded?  I was thinking this
> function would be used for returning names as a bunch of extensions
> simple return a one word name.  Though I guess there's nothing to
> prevent a null from being in there (there are no docs for some of these)
> I haven't seen any yet and the code in xlib appends a null to these strings.
> 
> Jeremy
> 
> Barton C Massey wrote:
> > The problem with this, as we've talked about before, is that
> > some strings returned by the server may already have
> > embedded nulls, in which case all the C functions will do
> > the wrong thing.
> > 
> > What is needed, I fear, is an aux library for dealing with
> > X-style counted strings, with the standard stuff in it (from
> > strings.h and stdio.h, for starters).
> > 
> > Alternatively, your conversion function could transform
> > embedded nulls in the string into something else.  Maybe the
> > converter should translate to UTF, and use the null in the
> > Unicode reserved area as a representation of embedded null
> > bytes?
> > 
> > 	Bart
> > 
> > In message <43CAA789.10206 at brandeis.edu> you wrote:
> > 
> >>I was thinking putting a new function in aux/convenient that takes a
> >>string in a reply and returns a new string with a terminating null.
> >>
> >>Something like:
> >>
> >>char *XCBAuxExtractString(char *s, int n) {
> >>    char *str;
> >>    str = (char *)malloc(sizeof(char) * (n+1));
> >>    strncpy(str, s, n);
> >>    str[n] = '\0';
> >>    return str;
> >>}
> >>
> >>Good/bad/ugly/thoughts?
> >>
> >>Jeremy
> >>_______________________________________________
> >>Xcb mailing list
> >>Xcb at lists.freedesktop.org
> >>http://lists.freedesktop.org/mailman/listinfo/xcb


More information about the Xcb mailing list