#include #include #include #define CREATOR "Teviet Creighton" #define USAGE "Usage: %s OUTFILE\n" \ "Generates a template EPSF file with appropriate DSC headers and\n" \ "comments, writing it to OUTFILE. The creation time is set to the\n" \ "current time, the creator is set to \"" CREATOR "\",\n" \ "and the default boundingbox is set to 0 0 100 100, and the title\n" \ "comment is included but left blank.\n" \ "\n" #define LEN 240 /* length of creation time string */ int main( int argc, char **argv ) { time_t timeval; /* creation time */ char timestr[LEN]; /* string representing creation time */ char *basename; /* output file name (excluding directory path) */ FILE *fp; /* output file pointer */ /* Check input arguments. */ if ( argc != 2 ) { fprintf( stderr, USAGE, argv[0] ); return 0; } if ( !( fp = fopen( argv[1], "w" ) ) ) { fprintf( stderr, "%s: could not write to file %s\n", argv[0], argv[1] ); return 1; } basename = strrchr( argv[1], '/' ); if ( basename ) basename++; else basename = argv[1]; /* Set the creation date string. */ memset( timestr, 0, LEN ); if ( ( timeval = time( NULL ) ) != -1 ) strftime( timestr, LEN-1, "%a %b %d %H:%M:%S %Z %Y", localtime( &timeval ) ); /* Write template. */ fprintf( fp, "%%!PS-Adobe-3.0 EPSF-3.0\n" "%%%%Title: %s\n" "%%%%Creator: " CREATOR "\n" "%%%%CreationDate: %s\n" "%%%%Orientation: Portrait\n" "%%%%Pages: 0\n" "%%%%LanguageLevel: 2\n" "%%%%BoundingBox: 0 0 100 100\n" "%%%%EndComments\n\n" "%%%%BeginProlog\n\n" "%%%%EndProlog\n\n" "%%%%EOF\n", basename, timestr ); fclose( fp ); return 0; }