Example #1
0
static void  assure_windows_ready(void)
{
  bool ok = FALSE;
  DBG_MEM(memout<<" file " <<__FILE__<<" line "<<__LINE__<< checkmem2<<endl);
  DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl);
  settings_loaded = load_ini();
  DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl);
//  if(settings_loaded == FALSE)
    DBG_INI(dout<<"edit.cpp line "<<__LINE__<<" shell_command.s = °"<<settings.shell_command.s<<"°"<<endl);
                   //  checkmem("EDIT.C line 150");
  help_loaded = load_help();
                  //    checkmem("EDIT.C line 152");

  if (!Screen.iscolor()) {           /* color card and color monitor  */
      setting_defaultcolors(0);
  }
  DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl);
  ok = keybd_setup();
  if(!ok)
     err_exit("Failed to setup Keyboard", 23);
//  status_setup();
  my_new_scrap();
  DBG_INI(dout<<"edit.cpp line "<<__LINE__<<" shell_command.s = °"<<settings.shell_command.s<<"°"<<endl);
  DBG_MEM(memout<<" file " <<__FILE__<<" line "<<__LINE__<<checkmem2 <<endl);
}
Example #2
0
static void  process_arg (char *s)
{
switch (s[0]) {
   case '-':                                      /* normal option switch */
      process_option (s+1);           break;
//   case '@':                                      /* resume file name */
//      strcpy (resume_file, s+1);  break;
   case '&':                             /* more switches from environment */
      process_env_string (s+1);   break;
   case '#':                                      /* jump to line number */
      if (active_view) view_gotoline (atoi(s+1)-1);
      else {
         redbox (redbox_locus, 200, eh_continue);
         }
      break;
   default:                                /* assume it is a file to load */
      DBG_MEM(memout<<" file " <<__FILE__<<" line "<<__LINE__<<checkmem2<<endl);
      locate_view (s, 1);  /* load if not found */
      DBG_MEM(memout<<" file " <<__FILE__<<" line "<<__LINE__<<checkmem2<<endl);
      break;
   }
}
Example #3
0
int main()
{
	char pressKey;
	int ret;
	bitmap *bm;
	u_char *w;

	sys_init();
	sleep(2);
	add_dbs_beep(NULL, 0, 1);

	bm = new_bitmap("./test.bmp");
	SetSrceenColor(0xFFFF);

	if (init_fonts() != -1)
	{
		disp_line("123-:+09", 0, 0, disp12_char);
		disp_line("123-:+09", 0, 100, disp36_char);
	}

	char *path_b = gppath(getpid());
	char *path_d = strdup(path_b);
	printf("This program path is: '%s' at '%s'\n", basename(path_b), dirname(path_d));

	u_char dt[7];

	get_bcd_datetime(dt);
	DBG_MEM("BCD datetime:", dt, 7);

/*
	int i;
	for (i=319; i>-320; i--)
	{
		if (i>0)
	{
			disp_bitmap(bm, 0, i, 320-i, 240, 0, 0);
		}
		else
		{
			disp_bitmap(bm, 0, 0, 320+i, 240, 0, -i);
		}
	}
*/
	u_char *buf = NULL;

	u_char factor[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
	u_char key[8]    = {0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};
	u_char m_key[8]  = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

	int p_len = 0;
	u_long t1, t2;

	cpu_card_data_t *ccd = NULL;
	u_long csn;

	/* alarm test code begin 

		DBG("Syn alarm 4 times...");
		ret = add_syn_beep(&t1, 0, 4);
		DBG("OK, wait 5 sec(ret: %d)\n", ret);
		sleep(5);
		DBG("Syn alarm 4 sec...");
		ret = add_syn_beep(&t2, 4000, 0);
		DBG("OK(ret: %d)\n", ret);

		sleep(1);
		terminate_alarm(t2);

	/* alarm test code end */

	while (1)
    {
    	printf("Press 'b' to test beep\n");
    	printf("Press 'c' to test COM1\n");
    	printf("Press 'g' to test GPRS\n");
    	printf("Press 'p' to test PSAM\n");
    	printf("Press 'm' to test MIFARE\n");
    	printf("Press 'e' to enter test screen\n");

    	pressKey=getchar();

    	switch (pressKey)
    	{
    		case 'b': test_beep(); break;
    		case 'c': test_COM1(); break;
    		case 'g': startup_poll(); break;
    		case 'p':
/*    			pc = new_ty_psam_cos();
    			if (NULL == pc)
    			{
    				DBG("Create psam card fail!\n");
    				break;
    			}

    			DBG("Select file 0x3F00...");
    			ret = psam_select_id(pc, &buf, 0x3F00);
    			if (ret == -1)
    			{
    				DBG("fail!\n");
    				break;
    			}
    			DBG_MEM("ok!\nResponse:", buf, ret);

    			DBG("Select file 0x1001...");
    			ret = psam_select_id(pc, &buf, 0x1001);
    			if (ret == -1)
    			{
    				DBG("fail!\n");
    				break;
    			}
    			DBG_MEM("ok!\nResponse:", buf, ret);
    			
    			t1 = get_tickcount();
    			ret = calc_descrypt1(pc, factor, key, 0x0D);
    			t2 = get_tickcount();
    			if (ret == 0)
    			{
    				DBG("Calcuate descrype OK\n");
    				DBG_MEM("factor:", factor, 8);
    				DBG_MEM("key:", key, 8);
    			}
    			else
    				DBG("Calcuate descrypt fail!\n");
*/
    			DBG("Calculate descrype consumed %d ms.\n", t2-t1);

    			break;
    		case 'm':

/*    			ret = get_card_sn(&buf);
    			DBG("Get card SN ret: %d (buf: %d)\n", ret, malloc_usable_size(buf));
    			if (ret != -1)
    				DBG_MEM("SN:", buf, ret);
    			else
    				break;
    			csn = (u_long)(*buf);

    			if ((buf[4] & 0x20))
    			{
    				DBG("**** CPU Card ****\nReset card ...");

    				ret = reset_cpu_card(&buf);
    				if (ret == -1)
    				{
    					DBG("fail!(%d)\n", ret);
    					break;
    				}
    				DBG_MEM("ok!\nATS:", buf, ret);

    				if (NULL == ccd)
    				{
    					DBG("To create cpu_card_data_t...\n");
    				 	ccd = new_cpu_card_data(6001, 1, 21);
    				 	if (NULL == ccd)
    				 	{
    				 		DBG("fail!\n");
    				 		break;
    				 	}
    				 	else
    				 		DBG("Ok.\n");
    				}


    				init_cpu_card_data(ccd, csn, buf, ret, 8, 8);

    				DBG("Fast debit wallet 0.01...");

    				ret = fast_debit_wallet_PUB1(&fmcos2_opr, ccd, 1);
    				if (-1 == ret)
    				{
    					DBG("fail! ret: %d, errno: %d\n", ret, get_cpu_carderr(ccd));
    					break;
    				}
    				DBG("Ok! Balance: %d.%d\n", get_pub_wallet_balance(ccd)/100, get_pub_wallet_balance(ccd)%100);
*/
    				/*


    				memcpy(factor, buf+ret-8, 8);
    				DBG_MEM("factor:", factor, 8);

    				DBG("\nGet Callagne...");
    				ret = rf_get_challenge(&fmcos2_opr, &buf, 4);
    				if (ret == -1)
    				{
    					DBG("fail!(%d)\n", ret);
    					break;
    				}
    				DBG_MEM("ok!\nResponse:", buf, ret);

    				memcpy(key, buf, 4);
    				memset(key+4, 0, 4);
    				DBG_MEM("key:", key, 8);

    				DBG("Calculate descrypt...");
	    			ret = calc_descrypt1(factor, key, 0x0D);
    				if (ret == -1)
    				{
    					DBG("fail!(%d)\n", ret);
    					break;
    				}
    				DBG_MEM("ok!\nResopnse:", key, 8);
    				DBG("Select ADF1...");
    				ret = rf_select_file_id(&fmcos2_opr, &buf, 0x1001);
    				if (ret == -1)
    				{
    					DBG("fail!(%d)\n", ret);
    					break;
    				}
    				DBG_MEM("ok!\nResopnse:", buf, ret);
    				DBG("Read Person file(id=2)...");
    				ret = rf_read_binary(&fmcos2_opr, &buf, 2, 0, NULL, 0);
    				if (ret == -1)
    				{
    					DBG("fail!(%d)\n", ret);
    					break;
    				}
    				DBG_MEM("ok!\nResponse:", buf, ret);
    				DBG("Read wallet file (id=4)...");
    				ret = rf_read_record(&fmcos2_opr, &buf, 1, 4, NULL, 12);
    				if (ret == -1)
    				{
    					DBG("fail!(%d)\n", ret);
    					break;
    				}
    				DBG_MEM("ok!\nResponse:", buf, ret);
    				DBG("Authenticate Key(id=0x0E)...");
    				ret = rf_extern_authent(&fmcos2_opr, &buf, 0x0E, key);
    				if (ret == -1)
    				{
    					DBG("fail!(%d)\n", ret);
    					break;
    				}
    				DBG_MEM("ok!\nResponse:", buf, ret);
	   				t2 = get_tickcount();
    				printf("CPU card time %dms", t2-t1); */
/*    			}
    			else
    			{
	    			DBG("**** Mifare Card ****\nAuthent sector 1...");
	    			ret = authent_mifare_card(m_key, 3, MIFARE_KEYA);
	    			if (ret != 0)
	    			{
	    				DBG("fail!(%d)\n", ret);
	    				break;
	    			}
	    			DBG("ok!\nRead block 0...");
	    			ret = read_mifare_card(&buf, 0);
	    			if (ret == -1)
	    			{
	    				DBG("fail!(%d)\n", ret);
	    				break;
	    			}
	    			DBG("ok!(%d)\n", ret);
	    			DBG_MEM("Block 0:", buf, ret);
	    			DBG("Write x0FF to block 1...");
	    			memset(buf, 0xff, sizeof(buf));
	    			ret = write_mifare_card(buf, 1);
	    			if (ret != 0)
	    			{
	    				DBG("fail!(%d)\n", ret);
	    				break;
	    			}
	    			DBG("ok!\nRead block 1...");
	    			ret = read_mifare_card(&buf, 1);
	    			if (ret == -1)
	    			{
	    				DBG("fail!(%d)\n", ret);
	    				break;
	    			}
	    			DBG("ok!(%d)\n", ret);
	    			DBG_MEM("Block 1:", buf, ret);
    			}*/
    			break; 
    	}
    	if (pressKey=='e')
    		break;
    }

	
}
Example #4
0
void _cdecl main (SHORT argc, char *argv[])
{
//  bool ok = FALSE;
//  char test[5];       // test for trap 05 errors
ULONG ulTimes;          // need for Trap Ctrl-Break Signal

#ifdef TESTING
  if(!dout) {
    DosBeep(500,300);
  }
  if(!memout) {
    DosBeep(1000,300);
  }
#endif

#ifdef ERR_HAND
rc = set_int24();
  if(rc != 0) {
     err_exit("Error initializing error handler", 3);
  }

MYEXCEPTIONREGISTRATIONRECORD myExceptionRegRecord;
myExceptionRegRecord.prev_structure = NULL;
myExceptionRegRecord.ExceptionHandler = MyExceptionHandler;
DosSetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord);
DosSetSignalExceptionFocus(SIG_SETFOCUS, &ulTimes);

if(setjmp(myExceptionRegRecord.env))
   goto OnException;
#endif

  DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl);

filesys_init();
get_current_directory(cwd);               // init cur dir
Mem::vmem_setup();
strcpy(exe_dir, *argv);    // assume loaded via X:\subdir\KED.EXE

DBG_FILE(dout << "EXE_DIR =  " << exe_dir <<endl);
DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl);

assure_windows_ready();

if(!thread_init()) {
   err_exit("Error creating initial threads", 5);
}
process_env_string ("EDITOR");  /* do parameters from environment string */
strcpy (progname,*argv);
argc--;                         /* don't count program name */
argv++;
while (argc--) {                /* process each parameter */
   process_arg (*argv);
   argv++;
   }
if (!*settings.help_path) {     /* help is usually in same dir as program */
    delta_filename (settings.help_path, progname, "*.HLP");
   }

//#ifdef TESTING
//if(!debug_on) {
//   dout.close();
//   memout.close();
//}
//#endif


  assure_1_view();
  DBG_INI(dout<<"edit.cpp line "<<__LINE__<<" shell_command.s = °"<<settings.shell_command.s<<"°"<<endl);
  DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl);
//  ok = load_keys();        //  Version 2.08 
//  if(!ok)
//    err_exit("Failed to load Keyboard driver", 10);

  edit_loop();
//  test[5000] = 'A';                    // test trap array bounds

  goto Ked_Exit;

OnException:
#ifdef ERR_HAND
DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord);
//  Screen.term_mess = "application trapped";
  err_exit(" application trapped", 20);
#endif

Ked_Exit:
#ifdef ERR_HAND
if(ORG_NUMLOCK) {
   DBG_NUML(dout<<" exit - setting NUMLOCK    on"<<endl);
   numlock_set(TRUE);
}
else {
   DBG_NUML(dout<<" exit - setting NUMLOCK    off"<<endl);
   numlock_set(FALSE);   
}
DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord);
#endif

DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl);
DBG_BUGS(dout<<'\n'<<"    Normal Closedown in LOGFILE "<<endl);
}