This source file includes following definitions.
- main
static char szMakeversCpp[] = "$Id: makevers.cpp,v 1.3 2011/04/14 15:13:09 doug Exp $";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "portab.hpp"
#include "environ.hpp"
char g_szBuffer2[256];
int main(int argc,char **argv)
{
char szMonth[4];
char szDay[4];
char szYear[5];
char szHour[3];
int iMonth;
char szDirSpec[128];
char szCommand[128];
char szMachtype[128];
char szUid[16];
char szUser[32];
CEnvironment * env = new CEnvironment();
strcpy(szMachtype,env->getmachtype());
strcpy(szUid, env->getuid());
strcpy(szUser, env->getuser());
system("date > date.tmp");
FILE * fd = fopen("date.tmp","r");
if(NULL == fd) {
printf("Sorry, could not open date.tmp for input\n");
exit(EXIT_FAILURE);
}
fgets(g_szBuffer2,sizeof(g_szBuffer2),fd);
fclose(fd);
system("rm -f date.tmp");
memset(szMonth,0,sizeof(szMonth));
memset(szDay,0,sizeof(szDay));
memset(szYear,0,sizeof(szYear));
memset(szHour,0,sizeof(szHour));
strncpy(szMonth,&g_szBuffer2[4],3);
strncpy(szDay,&g_szBuffer2[8],2);
strncpy(szYear,&g_szBuffer2[26],2);
strncpy(szHour,&g_szBuffer2[11],2);
if(0 == strcmp("Jan",szMonth)) iMonth = 1;
if(0 == strcmp("Feb",szMonth)) iMonth = 2;
if(0 == strcmp("Mar",szMonth)) iMonth = 3;
if(0 == strcmp("Apr",szMonth)) iMonth = 4;
if(0 == strcmp("May",szMonth)) iMonth = 5;
if(0 == strcmp("Jun",szMonth)) iMonth = 6;
if(0 == strcmp("Jul",szMonth)) iMonth = 7;
if(0 == strcmp("Aug",szMonth)) iMonth = 8;
if(0 == strcmp("Sep",szMonth)) iMonth = 9;
if(0 == strcmp("Oct",szMonth)) iMonth = 10;
if(0 == strcmp("Nov",szMonth)) iMonth = 11;
if(0 == strcmp("Dec",szMonth)) iMonth = 12;
printf("---------------------------------------------------\n");
printf("makevers.cpp Ver %2d.%02d.%02d%c %s\n",
atoi(szYear),iMonth,atoi(szDay),'a'+atoi(szHour),
szMachtype);
printf("Serial No. 20%s-%04d-654321 Licensed under GNU GPL.\n",
szYear,atoi(szUid));
printf("Copyright(c)20%s Douglas W. Goodall, United States.\n",
szYear);
printf("---------------------------------------------------\n");
fd = fopen("version.hpp","w");
if(NULL == fd) {
printf("Sorry, cannot open version.hpp for output\n");
exit(EXIT_FAILURE);
}
fprintf(fd,"// ---------------------------------------------------\n");
fprintf(fd,"// version.hpp Ver %2d.%02d.%02d%c %s\n",
atoi(szYear),iMonth,atoi(szDay),'a'+atoi(szHour),
szMachtype);
fprintf(fd,"// Serial No. 20%s-%04d-654321 \n",
szYear,atoi(szUid));
fprintf(fd,"// Copyright(c)20%s Douglas W. Goodall, United States.\n",
szYear);
fprintf(fd,"// ---------------------------------------------------\n");
fprintf(fd,"// machine generated by %s\n",__FILE__);
fprintf(fd,"// %s\n",g_szBuffer2);
fprintf(fd,"#define RMJ %d\n",atoi(szYear));
fprintf(fd,"#define RMN %d\n",iMonth);
fprintf(fd,"#define RUP %d\n",atoi(szDay));
fprintf(fd,"#define RTP %d\n",atoi(szHour));
fclose(fd);
if(0 == strcmp(LINUX,szMachtype)) {
char szCopyStr[128];
sprintf(szCopyStr,"/home/%s/src/framewk/bin/copylast",
szUser);
fd = fopen(szCopyStr,"w");
assert(fd);
sprintf(szDirSpec,"/home/%s/src/framewk/%02d%02d20%02d",
szUser,iMonth,atoi(szDay),atoi(szYear));
}
if(0 == strcmp(MACOSX,szMachtype)) {
char szCopyStr[128];
sprintf(szCopyStr,"/Users/%s/src/framewk/bin/copylast",
szUser);
fd = fopen(szCopyStr,"w");
assert(fd);
sprintf(szDirSpec,"/Users/%s/src/framewk/"
"%02d%02d20%02d",
szUser,iMonth,
atoi(szDay),atoi(szYear));
}
fprintf(fd,"#!/bin/bash\n");
if(0 == strcmp(MACOSX,szMachtype)) {
fprintf(fd,"cp -R -n %s/* .\n",szDirSpec);
}
if(0 == strcmp(LINUX,szMachtype)) {
fprintf(fd,"cp -R %s/* .\n",szDirSpec);
}
fprintf(fd,"ls\n");
fclose(fd);
if(0 == strcmp(MACOSX,szMachtype)) {
sprintf(szCommand,"chmod +x /Users/%s/src/framewk/bin/copylast",
szUser);
system(szCommand);
}
if(0 == strcmp(LINUX,szMachtype)) {
sprintf(szCommand,
"chmod +x /home/%s/src/framewk/bin/copylast",
szUser);
system(szCommand);
}
return EXIT_SUCCESS;
}