add newheader.cxx
This commit is contained in:
parent
d7cb3ba181
commit
7bf7db4c2e
|
|
@ -19,8 +19,7 @@
|
|||
#define INSTALL_SCRIPTS \
|
||||
ctattach.drv ctunattach.drv ctquery ctdelta ctihave ctallihave \
|
||||
ctunco ctattachcc cttimewarp get-cttree update-cttree get-delta \
|
||||
ctsanity ctmkelem ctmkdir ctci ctco ctrm ctmv ctmake neartool \
|
||||
newheader
|
||||
ctsanity ctmkelem ctmkdir ctci ctco ctrm ctmv ctmake neartool
|
||||
|
||||
#define INSTALL_CONFIG \
|
||||
dtool.cshrc dtool.init dtool.emacs dtool.alias \
|
||||
|
|
|
|||
|
|
@ -1,106 +0,0 @@
|
|||
#! /bin/csh -f
|
||||
#
|
||||
# Automatically generate a header file for $1
|
||||
#
|
||||
if ( ${#argv} < 1 ) then
|
||||
echo You need to specify a filename... ala test.{c++,C,h,sal,ss}
|
||||
exit 1
|
||||
endif
|
||||
|
||||
# Let's do it
|
||||
|
||||
# flags
|
||||
set hfile=0
|
||||
set cfile=0
|
||||
set cppfile=0
|
||||
set salfile=0
|
||||
|
||||
if ( `basename $1 .h` != $1 ) set hfile=1
|
||||
if ( `basename $1 .hh` != $1 ) set hfile=1
|
||||
if ( `basename $1 .c` != $1 ) set cfile=1
|
||||
if ( `basename $1 .c++` != $1 ) set cppfile=1
|
||||
if ( `basename $1 .cxx` != $1 ) set cppfile=1
|
||||
if ( `basename $1 .cc` != $1 ) set cppfile=1
|
||||
if ( `basename $1 .C` != $1 ) set cppfile=1
|
||||
if ( `basename $1 .I` != $1 ) set cppfile=1
|
||||
if ( `basename $1 .i` != $1 ) set cppfile=1
|
||||
if ( `basename $1 .ii` != $1 ) set cppfile=1
|
||||
if ( `basename $1 .sal` != $1 ) set salfile=1
|
||||
if ( `basename $1 .ss` != $1 ) set salfile=1
|
||||
if ( `basename $1 .el` != $1 ) set salfile=1
|
||||
if ( `basename $1 .stk` != $1 ) set salfile=1
|
||||
|
||||
if ( ! ( $hfile || $cfile || $cppfile || $salfile ) ) then
|
||||
echo Usage: $0 filename.ext
|
||||
echo where ext is one of .h .hh .c .c++ .cxx .cc .C .sal .ss .el or .stk
|
||||
exit 1
|
||||
endif
|
||||
|
||||
# echo $hfile $cppfile $salfile
|
||||
if ( $hfile || $cppfile ) then
|
||||
|
||||
cat <<END_OF_PROTO
|
||||
// Filename: $1
|
||||
// Created by: `whoami` (`/bin/date '+%d%b%y'`)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
END_OF_PROTO
|
||||
|
||||
else if ( $cfile ) then
|
||||
|
||||
cat <<END_OF_PROTO
|
||||
/* Filename: $1
|
||||
* Created by: `whoami` (`/bin/date '+%d%b%y'`)
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* PANDA 3D SOFTWARE
|
||||
* Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
*
|
||||
* All use of this software is subject to the terms of the Panda 3d
|
||||
* Software license. You should have received a copy of this license
|
||||
* along with this source code; you will also find a current copy of
|
||||
* the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
*
|
||||
* To contact the maintainers of this program write to
|
||||
* panda3d-general@lists.sourceforge.net .
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
END_OF_PROTO
|
||||
|
||||
else
|
||||
#
|
||||
# Scheme
|
||||
#
|
||||
cat <<END_OF_PROTO
|
||||
;; Filename: $1
|
||||
;; Created by: `whoami` (`/bin/date '+%d%b%y'`)
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
|
||||
;;;*Description
|
||||
|
||||
;;;.
|
||||
|
||||
;;;*Public
|
||||
|
||||
;;;*Private
|
||||
END_OF_PROTO
|
||||
endif
|
||||
|
||||
echo
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// The program built in this directory is just a utility tool intended
|
||||
// for use within the VR Studio. Don't build it otherwise.
|
||||
#define BUILD_DIRECTORY $[CTPROJS]
|
||||
#if $[CTPROJS]
|
||||
|
||||
#define LOCAL_LIBS dtoolbase
|
||||
|
||||
#begin bin_target
|
||||
#define TARGET newheader
|
||||
#define SOURCES \
|
||||
newheader.cxx
|
||||
#end bin_target
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
// Filename: newheader.cxx
|
||||
// Created by: drose (05Jul04)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dtoolbase.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char *cxx_style =
|
||||
"// Filename: %s\n"
|
||||
"// Created by: %s (%s)\n"
|
||||
"//\n"
|
||||
"////////////////////////////////////////////////////////////////////\n"
|
||||
"//\n"
|
||||
"// PANDA 3D SOFTWARE\n"
|
||||
"// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved\n"
|
||||
"//\n"
|
||||
"// All use of this software is subject to the terms of the Panda 3d\n"
|
||||
"// Software license. You should have received a copy of this license\n"
|
||||
"// along with this source code; you will also find a current copy of\n"
|
||||
"// the license at http://etc.cmu.edu/panda3d/docs/license/ .\n"
|
||||
"//\n"
|
||||
"// To contact the maintainers of this program write to\n"
|
||||
"// panda3d-general@lists.sourceforge.net .\n"
|
||||
"//\n"
|
||||
"////////////////////////////////////////////////////////////////////\n"
|
||||
"\n";
|
||||
|
||||
char *c_style =
|
||||
"/* Filename: %s\n"
|
||||
" * Created by: %s (%s)\n"
|
||||
" *\n"
|
||||
" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
|
||||
" *\n"
|
||||
" * PANDA 3D SOFTWARE\n"
|
||||
" * Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved\n"
|
||||
" *\n"
|
||||
" * All use of this software is subject to the terms of the Panda 3d\n"
|
||||
" * Software license. You should have received a copy of this license\n"
|
||||
" * along with this source code; you will also find a current copy of\n"
|
||||
" * the license at http://etc.cmu.edu/panda3d/docs/license/ .\n"
|
||||
" *\n"
|
||||
" * To contact the maintainers of this program write to\n"
|
||||
" * panda3d-general@lists.sourceforge.net .\n"
|
||||
" *\n"
|
||||
" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"
|
||||
"\n";
|
||||
|
||||
struct FileDef {
|
||||
const char *extension;
|
||||
const char *header;
|
||||
};
|
||||
|
||||
FileDef file_def[] = {
|
||||
{ "h", cxx_style },
|
||||
{ "cxx", cxx_style },
|
||||
{ "I", cxx_style },
|
||||
{ "T", cxx_style },
|
||||
{ "c", c_style },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
void
|
||||
generate_header(const char *header, const string &filename) {
|
||||
char *username = getenv("USER");
|
||||
if (username == NULL) {
|
||||
username = "";
|
||||
}
|
||||
|
||||
static const size_t max_date_buffer = 128;
|
||||
char date_buffer[max_date_buffer];
|
||||
time_t now = time(NULL);
|
||||
strftime(date_buffer, max_date_buffer, "%d%b%y", localtime(&now));
|
||||
|
||||
printf(header, filename.c_str(), username, date_buffer);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
if (argc < 2) {
|
||||
cerr << "Must specify the filename to generate a header for.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
string filename = argv[1];
|
||||
size_t dot = filename.rfind('.');
|
||||
if (dot == string::npos) {
|
||||
// No extension, no header.
|
||||
return 0;
|
||||
}
|
||||
|
||||
string extension = filename.substr(dot + 1);
|
||||
|
||||
size_t i = 0;
|
||||
while (file_def[i].extension != NULL) {
|
||||
if (extension == file_def[i].extension) {
|
||||
generate_header(file_def[i].header, filename);
|
||||
return 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// No matching extension, no problem.
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue