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