⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make_lic.~cp

📁 This is a CNCPro source file. It is include the G-Code interpreter source.
💻 ~CP
字号:
#include <stdio.h>
#include <string.h>
#include <dir.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#define TRUE 1
#define FALSE 0

int main(int argc, char *argv[])
{
   long lic_num;
   int i, j, ch=0, ch2=0, num, itemp, cnc_price, ace_price, price, database=TRUE;
   static char SSN[10], license[50], first[50], last[50], first2[50], last2[50];
   static char dir[200], user[50], string[200], tdate[20], dealer[50], email[50];
   char *endptr;
   FILE *ofp, *sales;
   struct date datep;

   if(argc!=9)
     {printf("1) make cncpro license\n");
      printf("2) make ACEconverter license\n");
      printf("3) make all licenses\n");
      printf("ESC) exit\n");
      while((ch=getch())!=27 && ch!='1' && ch!='2' && ch!='3');
      if(ch==27) return 0;
      printf("enter user name (first last).\n");
      scanf("%s %s", first, last);
      printf("dealer? (y/n)\n");
      while((ch2=getch())!='y' && ch2!='Y' && ch2!='n' && ch2!='N');
      if(ch2=='Y' || ch2=='y')
        {printf("enter dealer name (first last).\n");
         scanf("%s %s", first2, last2);
         sprintf(dealer,"%s %s",first2, last2);
        }
      printf("enter email.\n");
      scanf("%s", email);
      if(ch=='1' || ch=='3') {printf("price for cncpro?\n"); scanf("%d",&cnc_price);}
      if(ch=='2' || ch=='3') {printf("price for ACEconverter?\n");  scanf("%d",&ace_price);}
      printf("write to database? (y/n)\n");
      while((ch2=getch())!='y' && ch2!='Y' && ch2!='n' && ch2!='N');
      if(ch2=='N' || ch2=='n') database=FALSE;
     }
   else
     {if (argv[1][0]!='1' && argv[1][0]!='2' && argv[1][0]!='3') return 0;
      ch=argv[1][0];
      sprintf(first,"%s",argv[2]);
      sprintf(last,"%s",argv[3]);
      if (strcmp(argv[4],"none")!=0)
        {sprintf(first2,"%s",argv[4]);
         sprintf(last2,"%s",argv[5]);
        }
      sprintf(email,"%s",argv[6]);
      cnc_price=(int) strtol(argv[7],&endptr,10);
      ace_price=(int) strtol(argv[8],&endptr,10);
     }
   system("copy c:\\yeagauto\\ya_suite\\cncpro.lic c:\\yeagauto\\cncpro");
   system("copy c:\\yeagauto\\ya_suite\\ace.lic c:\\yeagauto\\ace");
   getdate(&datep);
   sprintf(tdate,"%d/%d/%d",datep.da_mon,datep.da_day,datep.da_year);
   sprintf(dir,"c:\\yeagauto\\sales\\%s",last);
   mkdir(dir);
   if(last[0]!=0) sprintf(user,"%s %s", first, last);
   else sprintf(user,"%s",first);
   if((i=strlen(first))>=25) {first[25]=0; last[0]=0;}
   else last[24-i]=0;
   user[25]=0;


   if(ch=='3') num=2;
   else num=1;
   for(j=0;j<num;j++)
     {if(ch=='1')
        {price=cnc_price;
         sprintf(SSN,"306881320");
         sprintf(string,"c:\\yeagauto\\cncpro\\cncpro.lic");
        }
      if(ch=='2')
        {price=ace_price;
         sprintf(SSN,"409532060");
         sprintf(string,"c:\\yeagauto\\ace\\ace.lic");
        }
      if(ch=='3')
        {if(j==0)
           {price=cnc_price;
            sprintf(SSN,"306881320");
            sprintf(string,"c:\\yeagauto\\cncpro\\cncpro.lic");
           }
         else
           {price=ace_price;
            sprintf(SSN,"409532060");
            sprintf(string,"c:\\yeagauto\\ace\\ace.lic");
           }
        }
      if((ofp=fopen(string,"w"))==NULL) return 0;
      if((strcmp(SSN,"306881320")==0 && (sales=fopen("c:\\yeagauto\\sales\\cnc_sale.txt","r"))!=NULL) ||
         (strcmp(SSN,"409532060")==0 && (sales=fopen("c:\\yeagauto\\sales\\ace_sale.txt","r"))!=NULL))
        {lic_num=0;
         while(1)
           {while((itemp=fgetc(sales))!=EOF && itemp!='\n');
            if(itemp==EOF) break;
            fscanf(sales,"%09u",&lic_num);
           }
         lic_num++;
         if(database==TRUE) sprintf(license,"%09u",(long)lic_num);
         else
           {if(strcmp(SSN,"306881320")==0) printf("enter cncpro license number (XXXXXXXXX).\n");
            else printf("enter ace license number (XXXXXXXXX).\n");
            scanf("%s", license);
            license[9]=0;
           }
         fclose(sales);
        }
      if((strcmp(SSN,"306881320")==0 && (sales=fopen("c:\\yeagauto\\sales\\cnc_sale.txt","a"))!=NULL) ||
         (strcmp(SSN,"409532060")==0 && (sales=fopen("c:\\yeagauto\\sales\\ace_sale.txt","a"))!=NULL))
        {if(database==TRUE) fprintf(sales,"%-13s%-14s%-8d%-25s%-25s%s\n",license,tdate,price,user,dealer,email);
         fclose(sales);
        }
      fputc(strlen(first)+'D', ofp);
      fputc(strlen(last)+'Y', ofp);
      for(i=0;i<9;i++)
        {if(i<strlen(first)) fputc(user[i]+SSN[i], ofp);
         if(i>strlen(first) && i<strlen(first)+strlen(last)+1) fputc(user[i]+SSN[i], ofp);
         fputc(license[i]+SSN[i], ofp);
         if(i<strlen(first)+strlen(last)) fputc(SSN[i]+user[i], ofp);
         else fputc(SSN[i]+SSN[i], ofp);
        }
      for(i=9;i<strlen(first)+strlen(last)+1;i++) if(i!=strlen(first)) fputc(user[i]+SSN[i%9], ofp);
      fclose(ofp);
     }

   //command line build
   sprintf(string,"del %s\\onefile\\yasoft.exe",dir);
   system(string);
   sprintf(string,"c:\\pcinst\\qbuild.exe cfg=\"c:\\yeagauto\\ya_suite\\yademo.cfg\" rebuild=\"0\" builddir=\"%s\" ver=\"2\"",dir);
   system(string);
   sleep(90);
   system("copy c:\\yeagauto\\ya_suite\\cncpro.lic c:\\yeagauto\\cncpro");
   system("copy c:\\yeagauto\\ya_suite\\ace.lic c:\\yeagauto\\ace");
   sprintf(string,"rename %s\\onefile\\yademo.exe yasoft.exe",dir);
   system(string);
   sprintf(string,"c:\\winzip\\wzzip.exe %s\\onefile\\yasoft.zip %s\\onefile\\yademo.exe yasoft.exe",dir,dir);
   system(string);
   sprintf(string,"del %s\\onefile\\yasoft.exe",dir);
   system(string);
   sprintf(string,"copy %s\\onefile\\yasoft.zip c:\\yeagauto\\sales\\ftp",dir);
   system(string);

   return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -