|
|
@@ -418,35 +418,25 @@ extra_data_on_line: |
|
|
|
} |
|
|
|
|
|
|
|
/**** |
|
|
|
* Extract to Python list |
|
|
|
* Extract to string |
|
|
|
*/ |
|
|
|
|
|
|
|
static int _extract_handle_params(Rocket *self, PyObject *args, long *count) |
|
|
|
static PyObject *Rocket_extract_string(Rocket *self, PyObject *args) |
|
|
|
{ |
|
|
|
long count; |
|
|
|
long offset; |
|
|
|
if (!PyArg_ParseTuple(args, "ll", &offset, count)) |
|
|
|
return -1; |
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "ll", &offset, &count)) |
|
|
|
return NULL; |
|
|
|
if (!self->file) { |
|
|
|
PyErr_SetString(PyExc_Exception, "no file"); |
|
|
|
return -1; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
/* Seek to target location */ |
|
|
|
if (fseek(self->file, offset, SEEK_SET) < 0) { |
|
|
|
PyErr_SetFromErrno(PyExc_OSError); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/**** |
|
|
|
* Extract to string |
|
|
|
*/ |
|
|
|
|
|
|
|
static PyObject *Rocket_extract_string(Rocket *self, PyObject *args) |
|
|
|
{ |
|
|
|
long count; |
|
|
|
if (_extract_handle_params(self, args, &count) < 0) |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
char *str = NULL, *new; |
|
|
|
long len_alloc = 0; |
|
|
|