> Both solutions will pad the string with ' ', but I need to pad it with
'\0'.
>
Ah, misunderstood you, try this one:

if (Z_STRLEN_PP(data) > 30) {
  php_stream_write(stream, Z_STRVAL_PP(data), 30);
} else {
  char blanks[30];

  memset(blanks, 0, 30);
  php_stream_write(stream, Z_STRVAL_PP(data), Z_STRLEN_PP(data));
  php_stream_write(stream, blanks, 30 - Z_STRLEN_PP(data));
}

iirc there may be a printf means to specify NULL as the padding character,
or to repeat an aribtrary character for a certain number of characters, but
it's escaping me at the moment.  For the size of your padding this method
should introduce to horrible of a penalty.

-Sara

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to