File: MMCIFlexmodule.c

package info (click to toggle)
python-biopython 1.68%2Bdfsg-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 46,856 kB
  • sloc: python: 160,306; xml: 93,216; ansic: 9,118; sql: 1,208; makefile: 155; sh: 63
file content (69 lines) | stat: -rw-r--r-- 1,143 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <Python.h>
#include "lex.yy.h"


FILE *fp;

static PyObject *MMCIFlex_open_file(PyObject *self, PyObject *args)
{
	char *filename;

	if (!PyArg_ParseTuple(args, "s", &filename))
		return NULL;

	fp=fopen(filename, "r");

	mmcif_set_file(fp);

	Py_INCREF(Py_None);

	return Py_None;
}


static PyObject *MMCIFlex_close_file(PyObject *self, PyObject *args)
{
	/* verify no arguments */
	if (!PyArg_ParseTuple(args, ""))
		return NULL;

	fclose(fp);

	Py_INCREF(Py_None);

	return Py_None;
}


static PyObject *MMCIFlex_get_token(PyObject *self, PyObject *args)
{
	int flag;
	char *value="";

	/* get token number */
	flag=mmcif_get_token();

	/* if flag==0 we are EOF */
	if(flag)
	{
		value=mmcif_get_string();
	}

	/* return the (tokennumber, string) tuple */
	return Py_BuildValue("(is)", flag, value);
}


static PyMethodDef MMCIFlexMethods[]=
{
	{"open_file",	MMCIFlex_open_file, 	METH_VARARGS},
	{"close_file",	MMCIFlex_close_file,	METH_VARARGS},
	{"get_token",  	MMCIFlex_get_token, 	METH_VARARGS},
	{NULL,      	NULL}        			/* Sentinel */
};


void initMMCIFlex(void)
{
	(void) Py_InitModule("MMCIFlex", MMCIFlexMethods);
}