title: Trouble understanding how to process C string
body: <p>I'm trying to use Mac OS X's listxattr C function and turn it into something useful in Python. The man page tells me that the function returns a string buffer, which is a "simple NULL-terminated UTF-8 strings and are returned in arbitrary order. No extra padding is provided between names in the buffer."</p>
  
  <p>In my C file, I have it set up correctly it seems (I hope):</p>
  
  <pre><code>  char buffer[size];
    res = listxattr("/path/to/file", buffer, size, options);
  </code></pre>
  
  <p>But when I got to print it, I only get the FIRST attribute ONLY, which was two characters long, even though its size is 25. So then I manually set buffer[3] = 'z' and low and behold when I print buffer again I get the first TWO attributes.</p>
  
  <p>I think I understand what is going on. The buffer is a sequence of NULL-terminated strings, and stops printing as soon as it sees a NULL character. But then how am I supposed to unpack the entire sequence into ALL of the attributes?</p>
  
  <p>I'm new to C and using it to figure out the mechanics of extending Python with C, and ran into this doozy.</p>