#! /bin/sh
#
#	This script lists the resources found within the specified file.
#	The output of this script is then parsed to determine what resources,
#	variables and functions currently exist for the specified subclass.
#
#	usage:
#		subclass_resources filenam
#	input <...>:
#		< { "aaa", "aaa_class", XtRBool,
#			sizeof( Bool ),
#			Offset( aaa_var ), XtRString, (void*)"aaa_def",
#			OI_RESOURCE_MEMFN_CAST(&purple::res_aaa), NULL,
#			OI_RESOURCE_GET_MEMFN_CAST(&purple::aaa), NULL,
#			OI_RM_MDL_ALL }, >
#	output <...>:
#		stdout
#		<aaa,aaa_class,XtRBool,Bool,aaa_var,XtRString,aaa_def,purple::res_aaa,NULL,purple::aaa,NULL,>
#
sed -n -e '/OI_resource/,/undef/p' $1 | sed -e '

#
# nuke starting and ending lines
#
/OI_resource/d
/undef/d
/};/d

#
# concatenate lines
#
: appnd
/,$/{
	N
	s/ //g
	s/	//g
	s/,\n/,/
	/}/b cntu
	b appnd
}
: cntu

#
# nuke irrelevant information
#
s/OI_RESOURCE_MEMFN_CAST//
s/OI_RESOURCE_GET_MEMFN_CAST//
s/sizeof//
s/Offset//
s/(void\*)//
s/OI_RM_MDL.*}/}/
s/&//g

#
# nuke decoration and whitespace
#
s/(//g
s/)//g
s/}.*$//
s/{//
s/"//g
s/ //g
s/	//g
/^$/d
'
