File: xamsupport.c

package info (click to toggle)
psyco 1.6-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,824 kB
  • ctags: 3,237
  • sloc: ansic: 23,895; python: 5,646; perl: 1,309; makefile: 165; sh: 1
file content (31 lines) | stat: -rw-r--r-- 755 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <Python.h>

static PyObject* any_pointer(PyObject* self, PyObject* args)
{
  char* from;
  int fromlen, i;
  long addr0, start, end, intervallen;
  if (!PyArg_ParseTuple(args, "ls#ll", &addr0, &from, &fromlen, &start, &end))
    return NULL;

  intervallen = end-start;
  for (i=0; i<=fromlen-4; i++)
    {
      long offset = *(long*) (from+i);
      offset -= start;
      if (((unsigned long)(addr0+i+offset)) < intervallen ||
          ((unsigned long) offset) < intervallen)
        return PyInt_FromLong(1);
    }
  return PyInt_FromLong(0);
}

static PyMethodDef XamMethods[] = {
  {"any_pointer", any_pointer, METH_VARARGS},
  {NULL,   NULL}         /* Sentinel */
};

void initxamsupport()
{
  Py_InitModule("xamsupport", XamMethods);
}