15 #include "dtoolbase.h"
21 const char *cxx_style =
23 "// Created by: %s (%s)\n"
25 "////////////////////////////////////////////////////////////////////\n"
27 "// PANDA 3D SOFTWARE\n"
28 "// Copyright (c) Carnegie Mellon University. All rights reserved.\n"
30 "// All use of this software is subject to the terms of the revised BSD\n"
31 "// license. You should have received a copy of this license along\n"
32 "// with this source code in a file named \"LICENSE.\"\n"
34 "////////////////////////////////////////////////////////////////////\n"
39 " * Created by: %s (%s)\n"
41 " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
43 " * PANDA 3D SOFTWARE\n"
44 " * Copyright (c) Carnegie Mellon University. All rights reserved.\n"
46 " * All use of this software is subject to the terms of the revised BSD\n"
47 " * license. You should have received a copy of this license along\n"
48 " * with this source code in a file named \"LICENSE.\"\n"
50 " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"
54 const char *extension;
68 generate_header(
const char *header,
const string &filename) {
69 const char *username = getenv(
"USER");
70 if (username == NULL) {
74 static const size_t max_date_buffer = 128;
75 char date_buffer[max_date_buffer];
76 time_t now = time(NULL);
77 strftime(date_buffer, max_date_buffer,
"%d%b%y", localtime(&now));
79 printf(header, filename.c_str(), username, date_buffer);
83 main(
int argc,
char *argv[]) {
85 cerr <<
"Must specify the filename to generate a header for.\n";
89 string filename = argv[1];
90 size_t dot = filename.rfind(
'.');
91 if (dot == string::npos) {
96 string extension = filename.substr(dot + 1);
99 while (file_def[i].extension != NULL) {
100 if (extension == file_def[i].extension) {
101 generate_header(file_def[i].header, filename);