summaryrefslogtreecommitdiffstats
path: root/progs/tests/functions.py
blob: d1a8cc3434c64a62d51fdbf5d9c0427845676f58 (plain)
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
#!/usr/bin/env python

# $Id: functions.py,v 1.1 2001/11/18 23:16:56 brianp Exp $

# Helper for the getprocaddress.c test.


import string

def PrintHead():
	print """
static const char *functions[] = {"""


def PrintTail():
	print"""
   NULL
};
"""


def PrintFunctions(specFile):

	# init some vars
	prevCategory = ''
	funcName = ''

	f = open(specFile)
	for line in f.readlines():

		# split line into tokens
		tokens = string.split(line)

		if len(tokens) > 0 and line[0] != '#':

			if tokens[0] == 'name':
				if funcName != '':
					if category != prevCategory:
						print '   "-%s",' % category
						prevCategory = category

					print '   "gl%s",' % funcName
				funcName = tokens[1]

			elif tokens[0] == 'category':
				category = tokens[1]

			#endif
		#endif
	#endfor
#enddef


PrintHead()
PrintFunctions("../bin/APIspec")
PrintTail()