1 /* (c) 2007,2008 Andrei Nigmatulin */ 2 3 #include "fpm_config.h" 4 5 #include <sys/types.h> 6 7 #include "fpm_trace.h" 8 fpm_trace_get_strz(char * buf,size_t sz,long addr)9int fpm_trace_get_strz(char *buf, size_t sz, long addr) /* {{{ */ 10 { 11 int i; 12 long l = addr; 13 char *lc = (char *) &l; 14 15 i = l % SIZEOF_LONG; 16 l -= i; 17 for (addr = l; ; addr += SIZEOF_LONG) { 18 if (0 > fpm_trace_get_long(addr, &l)) { 19 return -1; 20 } 21 for ( ; i < SIZEOF_LONG; i++) { 22 --sz; 23 if (sz && lc[i]) { 24 *buf++ = lc[i]; 25 continue; 26 } 27 *buf = '\0'; 28 return 0; 29 } 30 i = 0; 31 } 32 } 33 /* }}} */ 34