#!/bin/bash

if test $# -lt 2; then
cat <<EOF
usage:
 $0 name description...
creates C skeleton files name.h and name.c for lumiera
and adds them to the Makefile.am in the current dir
EOF
exit
fi

NAME="$1"
NAME_UPPER="$(echo -n ${NAME} | tr [:lower:] [:upper:])"
shift
DESCRIPTION="$*"

test -f ${NAME}.h || cat >${NAME}.h <<EOF
/*
  ${NAME}.h  -  ${DESCRIPTION}

  Copyright (C)         Lumiera.org
    $(date +%Y),               $(git config user.name) <$(git config user.email)>

  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.
*/

#ifndef LUMIERA_${NAME_UPPER}_H
#define LUMIERA_${NAME_UPPER}_H

//TODO: Support library includes//


//TODO: Forward declarations//


//TODO: Lumiera header includes//


//TODO: System includes//
#include <nobug.h>


/**
 * @file
 *
 */

//TODO: declarations go here//


#endif
/*
// Local Variables:
// mode: C
// c-file-style: "gnu"
// indent-tabs-mode: nil
// End:
*/
EOF

test -f ${NAME}.c || cat >${NAME}.c <<EOF
/*
  ${NAME}.c  -  ${DESCRIPTION}

  Copyright (C)         Lumiera.org
    $(date +%Y),               $(git config user.name) <$(git config user.email)>

  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.
*/

//TODO: Support library includes//


//TODO: Lumiera header includes//
#include "${PWD##*/}/${NAME}.h"

//TODO: internal/static forward declarations//


//TODO: System includes//


/**
 * @file
 *
 */

NOBUG_DEFINE_FLAG_PARENT (${NAME}, /*TODO insert parent flag here */);


//code goes here//



/*
// Local Variables:
// mode: C
// c-file-style: "gnu"
// indent-tabs-mode: nil
// End:
*/
EOF

test -f Makefile.am && ed Makefile.am >/dev/null <<EOF
/\.c\'/s/\(\$(.*)\)\(.*\)\.c\'/\1\2.c \\\\\\
	\1\/${NAME}.c/
/\.h\'/s/\(\$(.*)\)\(.*\)\.h\'/\1\2.h \\\\\\
	\1\/${NAME}.h/
wq
EOF
