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