#!/bin/sh
# @(#)$Mu: tools/stringify,v 1.11 $
##
## stringify
##	Convert standard input to an array of C strings,
##	if an argument is given then it is used as the name of the string,
##	otherwise the string will be called "string"; each line of input is
##	converted to one array element in the output and the output array is
##	NULL terminated.
##
## Copyright (C) 1996  Eric A. Howe
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
##   Authors:	Eric A. Howe (mu@echo-on.net)
##

if [ $# -ge 1 ]; then
	name=$1
else
	name=string
fi

echo "char *${name}[] = {"

##
## convert ^L's to blank lines and quote
##
tr -d '\014' | sed -e 's/"/\\"/g' -e 's/^/"/'  -e 's/$/\\n",/'

##
## NULL terminate
##
echo '(char *)0'
echo '};'

exit 0
