Back to index

php5  5.3.10
fpm_trace.c
Go to the documentation of this file.
00001 
00002        /* $Id: fpm_trace.c,v 1.1 2008/07/20 20:59:00 anight Exp $ */
00003        /* (c) 2007,2008 Andrei Nigmatulin */
00004 
00005 #include "fpm_config.h"
00006 
00007 #include <sys/types.h>
00008 
00009 #include "fpm_trace.h"
00010 
00011 int fpm_trace_get_strz(char *buf, size_t sz, long addr) /* {{{ */
00012 {
00013        int i;
00014        long l;
00015        char *lc = (char *) &l;
00016 
00017        if (0 > fpm_trace_get_long(addr, &l)) {
00018               return -1;
00019        }
00020 
00021        i = l % SIZEOF_LONG;
00022        l -= i;
00023        for (addr = l; ; addr += SIZEOF_LONG) {
00024               if (0 > fpm_trace_get_long(addr, &l)) {
00025                      return -1;
00026               }
00027               for ( ; i < SIZEOF_LONG; i++) {
00028                      --sz;
00029                      if (sz && lc[i]) {
00030                             *buf++ = lc[i];
00031                             continue;
00032                      }
00033                      *buf = '\0';
00034                      return 0;
00035               }
00036               i = 0;
00037        }
00038 }
00039 /* }}} */
00040 
00041