Esempio n. 1
0
long core(void)
{
#ifdef __WATCOMC__
  unsigned long cdecl coreleft(void);
  printf("\r%ld\n",(long)coreleft());
  return ((long)coreleft());
#else
  return 0L;
#endif
}
Esempio n. 2
0
void dbg_printmem(void)
{ static unsigned nearLast = 0;
  static unsigned long farLast = 0;

  unsigned nearThis;
  unsigned long farThis;

  switch(heapcheck()) {
  case _HEAPCORRUPT:
    cputs("HEAP CORRUPTED. Cannot proceed!\r\n");
    abort();
  case _HEAPEMPTY:
    cputs("NO HEAP. Cannot proceed!\r\n");
    abort();
  default:
    cputs("Unknown heapcheck() error. Cannot proceed!\r\n");
    abort();
  case _HEAPOK:
    break;
  }

  nearThis = coreleft();
  farThis = farcoreleft();

  dprintf(("[free memory: near=%6u far=%13lu]\n", nearThis, farThis));
  if(nearLast)
    dprintf(("[changed    : near=%6d far=%13ld]\n"
     , nearThis - nearLast , farThis - farLast));

  nearLast = nearThis;
  farLast = farThis;
}
Esempio n. 3
0
File: mau.c Progetto: vbmacher/qsOS
void mauINIT()
{
  textattr(atrINIT);
  cprintf("\nStarting Memory Allocation Unit...");
  textattr(atrBORDER);
  cprintf("\n\tMemory: ");
  textattr(atrIMPTEXT);
  cprintf("%ld", mem);
  textattr(atrBORDER);
  cprintf(" kB");

  // povolenie linky A20
  EnableA20();
  cprintf("\n\tLink A20 enabled...");
  
  // max. pocet poloziek
  if (mem < MAX_ITEMS)
    max_items = mem - 36;
  else
    max_items = MAX_ITEMS - 36;

  // cistenie tabulky pamate
  clear_mem();

  // zaciatok alokovania pamate
  MemStart = MK_FP(0x3400,0); //(fyzicka adresa)

  textattr(atrBORDER);
  cprintf("\n\tFree memory: ");
  textattr(atrIMPTEXT);
  cprintf("%ld", coreleft());
  textattr(atrBORDER);
  cputs(" kB");
}
Esempio n. 4
0
void MemRem(I1 *msg)
{
#if( __TURBOC__ >= 0x295 )
  struct heapinfo hp;   // heap information
  U4 bytes = coreleft();
  fprintf(_ulog, "%s:\n", msg);
  fprintf(_ulog, "  Unallocated heap memory:  %ld bytes\n", bytes);

# if( MEMTEST > 1 )
  switch(heapcheck()) {
  case _HEAPEMPTY:
    fprintf(_ulog, "The heap is empty.\n");
    break;
  case _HEAPOK:
    fprintf(_ulog, "The heap is O.K.\n");
    break;
  case _HEAPCORRUPT:
    fprintf(_ulog, "The heap is corrupted.\n");
    break;
  }  // end switch

  fprintf(_ulog, "Heap: loc, size, used?\n");
  hp.ptr = NULL;
  while(heapwalk(&hp) == _HEAPOK) {
    fprintf(_ulog, "[%p]%8lu %s\n",
            hp.ptr, hp.size, hp.in_use ? "used" : "free");
  }
# endif
}
Esempio n. 5
0
long get_free_mem(void)
{
    long mem;

    lock_kernel();
    mem = (long)coreleft();
    unlock_kernel();

    return mem;
}
Esempio n. 6
0
void main(void)
{
	int		i;
	MyNode	*n;

	cout << "Memory at start: " << coreleft() << " bytes\n";

	// Create a queue of 10 nodes.

	for (i = 0; i < 10; i++) {
		n = new MyNode(i);
		q.put(n);
		}

	cout << "Memory after creating queue: " << coreleft() << " bytes\n";

	dumpQueue(q);

	// Kill the queue and display it

	q.empty();
	dumpQueue(q);

	// Create a queue of 10 nodes.

	for (i = 0; i < 10; i++) {
		n = new MyNode(i);
		q.put(n);
		}

	dumpQueue(q);

	// Remove all the nodes from the queue with get()

	while ((n = q.get()) != NULL) {
		cout << "Removed " << n->id() << endl;
		delete n;
		}

	dumpQueue(q);

	cout << "Memory at end: " << coreleft() << " bytes\n";
}
Esempio n. 7
0
void main( int argc, char *argv[] )
  {
   if (argc!=4)
     {
      cout<<" argc "<<argc<<" \nUsage \n"<<argv[0]
          <<" File_X_col File_To_Build_Spline File_To_Write\n"
          <<" File_To_Build_Spline: NumX_Grid 50 Misfit 0.1+ data\n";
      exit(1);
     };     
   char tmp[256];
   double Misf,Mis;
   int NumX;
   fstream f_out(argv[3],ios::out);
   TData<real> *in=NULL,*in1=NULL,*out=NULL;
cout<<" coreleft "<<coreleft()<<"\n";
   InputTDataF(argv[1],in);
cout<<" NC "<<in->N<<" NR "<<in->I[0]<<"\n";
   InputTDataF(argv[2],in1);
cout<<" NC "<<in1->N<<" NR "<<in1->I[0]<<"\n";
   fstream f_in(argv[2],ios::in);f_in>>tmp>>NumX>>tmp>>Misf;f_in.close();
   DataRegister("TDataF",out);
   int NC=in1->N,NR=in->I[0];
   int *I=new int[in1->N];for (int k=0;k<NC;k++) I[k]=NR;
   out->SetDim(NC,I);movmem(in->D[0],out->D[0],sizeof(out->D[0][0])*NR);
cout<<" NC "<<NC<<" NR "<<NR<<"\n";
   CurveSpline *S=new CurveSpline[NC-1];
   int n=NumX;
   Mis=Misf;
//   TData<double> **S=new TData<double>*[NC-1];
   for (k=1;k<NC;k++) {S[k-1].Generate(NumX,Misf,0,*in1,0,k);NumX=n;Misf=Mis;}
cout<<" Constructed\n";
cout<<" coreleft "<<coreleft()<<"\n";

// for (k=1;k<NR;k++) {cout<<out->D[0][k]<<"\n";}
   for (k=1;k<NC;k++) {S[k-1].Evaluate(*out,0,k);}
   OutputTDataF(f_out,*out);
   delete in;delete in1;delete out;delete I;
//   for (k=0;k<NC-1;k++) delete S[k];
   delete S;
   f_out.close();
cout<<" coreleft "<<coreleft()<<"\n";
  }; 
Esempio n. 8
0
int cmd_memory(char *param)
{
	displayString(TEXT_MEMORY_ENVIRONMENT
		, mcb_length(env_glbSeg), env_freeCount(env_glbSeg));
	displayString(TEXT_MEMORY_CONTEXT
		, mcb_length(ctxt), env_freeCount(ctxt));
	displayTag(TEXT_MEMORY_CTXT_ALIAS, CTXT_TAG_ALIAS);
	displayTag(TEXT_MEMORY_CTXT_HISTORY, CTXT_TAG_HISTORY);
	displayTag(TEXT_MEMORY_CTXT_DIRSTACK, CTXT_TAG_DIRSTACK);
	displayTag1(TEXT_MEMORY_CTXT_LASTDIR, CTXT_TAG_LASTDIR);
/*	displayTag1(TEXT_MEMORY_CTXT_BATCH, CTXT_TAG_BATCH);
	not used, yet -- 2001/06/11 ska*/
	displayTag1(TEXT_MEMORY_CTXT_SWAPINFO, CTXT_TAG_SWAPINFO);
	displayString(TEXT_MEMORY_HEAP, (unsigned long)coreleft());

	return 0;
}
Esempio n. 9
0
int cmd_memory(char *param)
{
	displayString(TEXT_MEMORY_ENVIRONMENT
		, mcb_length(env_glbSeg), env_freeCount(env_glbSeg));
	displayString(TEXT_MEMORY_CONTEXT
		, mcb_length(ctxtSegm), env_freeCount(ctxtSegm));
	displayTag(TEXT_MEMORY_CTXT_ALIAS, CTXT_TAG_ALIAS);
	displayTag(TEXT_MEMORY_CTXT_HISTORY, CTXT_TAG_HISTORY);
	displayTag(TEXT_MEMORY_CTXT_DIRSTACK, CTXT_TAG_DIRSTACK);
	displayTag1(TEXT_MEMORY_CTXT_LASTDIR, CTXT_TAG_LASTDIR);
	displayTag1(TEXT_MEMORY_CTXT_ARG, CTXT_TAG_ARG);
	displayTag1(TEXT_MEMORY_CTXT_SWAPINFO, CTXT_TAG_SWAPINFO);
	displayTag1(TEXT_MEMORY_CTXT_EXEC, CTXT_TAG_EXEC);
	displayTag1(TEXT_MEMORY_CTXT_STRING, CTXT_TAG_STRING);
	displayTag2(TEXT_MEMORY_CTXT_FLAG, CTXT_TAG_FLAG);
	displayTag2(TEXT_MEMORY_CTXT_IVAR, CTXT_TAG_IVAR);
	displayString(TEXT_MEMORY_HEAP, (unsigned long)coreleft(), getFree);
	displaySize(TEXT_MEMORY_DOSMEM, DOSalloc(0, 0x80 | 0x10));

	return 0;
}
Esempio n. 10
0
void design (void) {
	int updflag=0;
	int dx,dy,tempx,n;
	int lastcell=1;
	int tempint;
	int drawmode=0;
	char tempstr[32];
	char tempfname[32];
	char tempstr2[12];
	char tempstr3[32];
	int new_col=0;
	int bc_x=0,bc_y=0,bc_w=0,bc_h=0;		// Block copy x,y and width,height
	int tx,ty;

	disy=0;
	designflag=1;
	gamecount=0;
	tempstr[0]='\0';
	tempfname[0]='\0';
	setorigin();
	dx=objs[0].x/16;
	dy=objs[0].y/16;
	drawboard();
	fontcolor (&statvp,1,0);
	clearvp (&statvp);

	do {
		if (drawmode) {
			setboard (dx,dy,lastcell);
			drawcell (dx,dy);
			updflag=1;
			}
		fontcolor (&statvp,3,0);						// memory usage
		wprint (&statvp,248,1,2,"       ");
		ultoa (coreleft(),tempstr3,10);
		wprint (&statvp,290-(1+strlen(tempstr3)*6),1,2,tempstr3);
		tempstr3[0]='\0';

		fontcolor (&statvp,1,0);
		wprint (&statvp,248,21,2, "# objs: ");
		fontcolor (&statvp,3,0);
		wprint (&statvp,296,21,2,itoa(numobjs,tempstr2,10));

		drawshape (&gamevp,0x0100,dx*16+4,dy*16+4);
		do {
			checkctrl(0);
			} while ((dx1==0)&&(dy1==0)&&(key==0)&&(updflag==0));
		updflag=0;
		modboard(dx,dy);
		upd_objs(0);
		refresh(0);
		purgeobjs();
		if ((dx1!=0)||(dy1!=0)) {
			dx+=dx1*(1+fire1*(scrnxs/2-1));
			dy+=dy1*(1+fire1*(scrnys/2-1));
			if (dx<0) dx=0;
			if (dx>=boardxs) dx=boardxs-1;
			if (dy<0) dy=0;
			if (dy>=boardys) dy=boardys-1;
			if ((dx*16)<gamevp.vpox) {
				gamevp.vpox-=scrnxs*8;
				if (gamevp.vpox<0) gamevp.vpox=0;
				drawboard();
				};
			if ((dx*16)>=(gamevp.vpox+16*scrnxs-16)) {
				gamevp.vpox+=scrnxs*8;
				if (gamevp.vpox>=(16*(boardxs-scrnxs)+8))
					gamevp.vpox=16*(boardxs-scrnxs)+8;
				drawboard();
				};
			if ((16*dy)<gamevp.vpoy) {
				gamevp.vpoy-=scrnys*8;
				if (gamevp.vpoy<0) gamevp.vpoy=0;
				drawboard();
				};
			if ((16*dy)>=(gamevp.vpoy+16*(scrnys-1))) {
				gamevp.vpoy+=scrnys*8;
				if (gamevp.vpoy>=(16*(boardys-scrnys+1)))
					gamevp.vpoy=(boardys-scrnys+1)*16;
				drawboard();
				};
			};

		switch (toupper(key)) {
			case k_f1:					// Mark top left corner of block
				bc_x=dx; bc_y=dy; break;
			case k_f2:
				// Mark bottom right corner of block and copy
				//	block of tile numbers into temp array bc_array
				if(dx<bc_x) break;
					// 0-width or negative width rectangle	(can't do that)
				if(dy<bc_y) break;
					// 0-height or negative height rectangle (can't do that)
				bc_w=(dx-bc_x)+1; bc_h=(dy-bc_y)+1;
				if((bc_w>normxs)||(bc_h>normys)) {			// Too big!!
					bc_w=0; bc_h=0; break;
					};
				for(ty=0; ty<bc_h; ty++) {
					for(tx=0; tx<bc_w; tx++) {
						bc_array[(ty*bc_w)+tx]=board(bc_x+tx,bc_y+ty);
						};
					};	break;
			case k_f3:
				for(ty=0; ty<bc_h; ty++) {
					for(tx=0; tx<bc_w; tx++) {
						setboard(dx+tx, dy+ty, bc_array[(ty*bc_w)+tx]);
						};
					};	updflag=1; break;
			case k_f4:
				do {
					upd_colors (); gamecount++; checkctrl0(0);
					} while (key==0); break;
			case enter:
				clearvp (&statvp);
				wprint (&statvp,2,1,1,"Put:");
				fontcolor (&statvp,6,0);
				winput (&statvp,2,11,1,tempstr,16);
				strupr (tempstr);
				for (tempint=0; tempint<numinfotypes; tempint++) {
					if (strcmp (tempstr,info[tempint].na)==0) {
						lastcell=tempint;
						setboard(dx,dy,tempint);
						shm_want[(info[tempint].sh>>8)&0x3f]=1;
						shm_do(); break;
						};
					};
				updflag=1; break;
			case 9: drawmode=!drawmode; break;				// tab
			case 'K': lastcell=board(dx,dy); break;
			case ' ':
				setboard(dx,dy,lastcell);
				updflag=1; break;
			case 'I':
				pl.score=1000;
				printhi (1);
				pl.score=0; break;
			case 'V':
				if (pl.numinv==0) addinv (inv_hero);
				else {
					pl.numinv=0;
					init_inv();
					};
				pl.score=0;
				pl.level=0; break;
			case 'H':
				tempint=board(dx,dy);
				tempx=dx;
				while (board(tempx,dy)==tempint) {
					setboard(tempx,dy,lastcell);
					drawcell (tempx,dy);
					tempx--;
					};
				tempx=dx+1;
				while (board(tempx,dy)==tempint) {
					setboard(tempx,dy,lastcell);
					drawcell (tempx,dy);
					tempx++;
					}; break;
			case 'O': updflag=objdesign(dx,dy); break;	// Object Mgmt
			case 'U':
				for (n=0; n<numobjs; n++) {
//					if (((kindflags[objs[n].objkind]&f_inside)==0)&&
//						(objs[n].inside!=NULL)) {
//						objs[n].inside=NULL;
//						sound(240);
//						delay(500);
//						nosound();
//						};
					setobjsize (n);
					}; break;
			case 'Z':
				infname ("Clear?",tempfname);
				if (toupper(tempfname[0])=='Y') {
					init_brd();
					init_objs();
					drawboard();
					}; break;
			case 'L':
				infname ("Load:",tempfname);
				if (tempfname[0]!='\0') {
					loadboard (tempfname);
					setorigin();
					dx=objs[0].x/16; dy=objs[0].y/16;
					drawboard();
					}; break;
			case 'Y':												// Disalign Y
				clearvp (&statvp);
				wprint (&statvp,2,1,1,"Dis Y:");
				itoa (disy,tempstr,10);
				winput (&statvp,2,11,1,tempstr,16);
				disy=atoi (tempstr);
				strupr (tempstr); break;
			case 'N':
				infname ("New board?",tempfname);
				if (toupper (tempfname[0])=='Y') {
					zapobjs();
					init_brd();
					}; break;
			case 'S':
				infname ("Save:",tempfname);
				if (tempfname[0]!='\0') saveboard (tempfname); break;
			case 'C':
				clearvp (&statvp);
				wprint (&statvp,2,1,1,"New Color:");
				fontcolor (&statvp,6,0);
				itoa (new_col,tempstr,10);
				winput (&statvp,2,11,1,tempstr,16);
				new_col=atoi (tempstr);

				switch (new_col) {
					case 0: setcolor (250,0,0,0);
						setcolor (251,0,0,0); break;				// reset all
					case 1: setcolor (251,0,0,0); break;		// reset #251
					case 2: setcolor (250,0,0,32);		 		// dk. blue sky
						setcolor (251,0,0,32); break;
					case 3:												// lt. blue sky
						setcolor (176,8,16,25); setcolor (177,8,20,29);
						setcolor (178,12,24,33); setcolor (179,16,28,41);
						setcolor (180,20,32,45); setcolor (181,24,40,49);
						setcolor (182,28,44,57); setcolor (183,36,48,60);
						setcolor (250,36,48,60); setcolor (251,36,48,60); break;
					case 4:												// yellow sky
						setcolor (176,32,0,0); setcolor (177,40,0,0);
						setcolor (178,52,0,0); setcolor (179,60,0,0);
						setcolor (180,60,28,0); setcolor (181,60,40,0);
						setcolor (182,60,52,0); setcolor (183,60,60,0);
						setcolor (250,60,60,0);	setcolor (251,60,60,0); break;
					case 5:												// emerald sky
						setcolor (176,0,12,12); setcolor (177,0,18,17);
						setcolor (178,0,25,23); setcolor (179,0,32,27);
						setcolor (180,0,39,32); setcolor (181,0,46,35);
						setcolor (182,0,53,38); setcolor (183,0,60,40);
						setcolor (250,0,60,40); setcolor (251,0,60,40); break;
					case 6: setcolor (250,32,32,24);				// olive green
						setcolor (251,32,32,24); break;
					case 7:												// violet sky
						setcolor (176,13,5,22); setcolor (177,18,8,27);
						setcolor (178,23,13,33); setcolor (179,29,19,39);
						setcolor (180,35,25,45); setcolor (181,42,32,51);
						setcolor (182,49,40,57); setcolor (183,57,50,63);
						setcolor (250,57,50,63); setcolor (251,57,50,63); break;
					case 8: setcolor (250,23,23,23);				// factory grey
						setcolor (251,23,23,23); break;
					case 9: setcolor (250,12,23,63);		 		// royal blue
						setcolor (251,12,23,63); break;
					case 10: setcolor (250,20,20,23);			// factory grey v3
						setcolor (251,20,20,23); break;
					};
			};
		} while (key!=escape);
Esempio n. 11
0
    void MM_Startup (void)
    {
        id0_int_t i;
        id0_unsigned_long_t length;
        //void id0_far 	*start;
        id0_unsigned_t 	segstart,seglength,endfree;

        if (mmstarted)
            MM_Shutdown ();

        mmstarted = true;
        bombonerror = true;

//
// set up the linked list (everything in the free list)
//
        mmhead = NULL;
        mmfree = &mmblocks[0];
        for (i=0; i<MAXBLOCKS-1; i++)
            mmblocks[i].next = &mmblocks[i+1];
        mmblocks[i].next = NULL;

//
// get all available near conventional memory segments
//
        length = EMULATED_NEAR_PARAGRAPHS*16 - SAVENEARHEAP;
        seglength = length / 16;			// now in paragraphs
        segstart = EMULATED_NEAR_SEG;
        mminfo.nearheap = length;
#if 0
        length=coreleft();
        start = (void id0_far *)(nearheap = malloc(length));

        length -= 16-(FP_OFF(start)&15);
        length -= SAVENEARHEAP;
        seglength = length / 16;			// now in paragraphs
        segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
        mminfo.nearheap = length;
#endif

        // locked block of unusable low memory
        // from 0 to start of near heap

        // Formerly known as GETNEWBLOCK
        if( !(mmnew=mmfree) )
        {
            Quit("MM_GETNEWBLOCK: No free blocks!");
        }
        mmfree=mmfree->next;  // fill in start and next after a spot is found

        mmhead = mmnew;				// this will always be the first node
        mmnew->start = 0;
        mmnew->length = segstart;
        mmnew->attributes = LOCKBIT;
        endfree = segstart+seglength;
        mmrover = mmhead;

//
// get all available far conventional memory segments
//
        length = EMULATED_FAR_PARAGRAPHS*16 - SAVEFARHEAP;
        seglength = length / 16;			// now in paragraphs
        segstart = EMULATED_FAR_SEG;
        mminfo.farheap = length;
        mminfo.mainmem = mminfo.nearheap + mminfo.farheap;
#if 0
        length=farcoreleft();
        start = farheap = farmalloc(length);

        length -= 16-(FP_OFF(start)&15);
        length -= SAVEFARHEAP;
        seglength = length / 16;			// now in paragraphs
        segstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
        mminfo.farheap = length;
        mminfo.mainmem = mminfo.nearheap + mminfo.farheap;
#endif

        // locked block of unusable near heap memory (usually just the stack)
        // from end of near heap to start of far heap

        // Formerly known as GETNEWBLOCK
        if( !(mmnew=mmfree) )
        {
            Quit("MM_GETNEWBLOCK: No free blocks!");
        }
        mmfree=mmfree->next;  // fill in start and next after a spot is found

        mmnew->start = endfree;
        mmnew->length = segstart-endfree;
        mmnew->attributes = LOCKBIT;
        mmrover->next = mmnew;
        endfree = segstart+seglength;
        mmrover = mmnew;


//
// detect EMS and allocate 64K at page frame
//
        mminfo.EMSmem = 0x10000; // Looks unused
#if 0
        if (MML_CheckForEMS())
        {
            MM_MapEMS();					// map in used pages
            mminfo.EMSmem = 0x10000l;
        }
        else
        {
            mminfo.EMSmem = 0;
        }
#endif

//
// detect XMS and get upper memory blocks
//
        mminfo.XMSmem = 0; // Unused
#if 0
        if (MML_CheckForXMS())
        {

        }
        else
        {
            mminfo.XMSmem = 0;
        }
#endif


//
// cap off the list
//
        // locked block of high memory (video, rom, etc)
        // from end of far heap or EMS/XMS to 0xffff
        // Formerly known as GETNEWBLOCK
        if( !(mmnew=mmfree) )
        {
            Quit("MM_GETNEWBLOCK: No free blocks!");
        }
        mmfree=mmfree->next;  // fill in start and next after a spot is found

        mmnew->start = endfree;
        mmnew->length = 0xffff-endfree;
        mmnew->attributes = LOCKBIT;
        mmnew->next = NULL;
        mmrover->next = mmnew;

//
// allocate the misc buffer
//
        mmrover = mmhead;		// start looking for space after low block

        MM_GetPtr (&bufferseg,BUFFERSIZE);
    }
Esempio n. 12
0
void main(void)
{
	int		i;

	cout << endl << endl;

	cout << "Memory at start: " << coreleft() << " bytes\n";

	SArray<int>	a(10),b(a),c;

	// Create an array of 10 elements

	for (i = 10; i > 1; i--) {
		a.add(i);
		}

	cout << "Memory after creating array: " << coreleft() << " bytes\n";

	dumpArray(a);
	dumpArray(b);

	// Sort the array a and copy it to c

	a.sort();
	c = a;
	dumpArray(c);

	// Insert a number of elements in sorted order

	a.setDelta(10);
	for (i = 100; i < 120; i++) {
		a.addSorted(i);
		}

	dumpArray(a);

	// Display the array using iterators.

	ArrayIterator<int> it1;

	for (it1 = a; it1; it1++)
		cout << it1.node() << " ";
	cout << endl;

	for (it1.restart(); it1;)
		cout << it1++ << " ";
	cout << endl;

	for (it1.restart(10,20); it1;)
		cout << ++it1 << " ";
	cout << endl;

	// Search for an item in the array

	cout << "Index of element 110 (linear search): " << a.search(110) << endl;
	cout << "                     (binary search): " << a.binarySearch(110) << endl;

	cout << "Index of element 200 (linear search): " << a.search(200) << endl;

	cout << "                     (binary search): " << a.binarySearch(200) << endl;

	cout << "Memory at end: " << coreleft() << " bytes\n\n";
}
Esempio n. 13
0
void main ()
{
	short 			temp, num;
	unsigned short 	us_temp;
	short			handle;
	EMMStruct		moveInfo;
	char 			*Mem_Buf;
	char			*Put_Buf;
	FILE			*f_Ptr, *f_Ptr_2;
	unsigned short	count = 0, i = 0;
	unsigned long   lock;

	f_Ptr   = fopen ("e:\\asm_work\\ega3.cpi", "rb");
	f_Ptr_2 = fopen ("e:\\asm_work\\ega3_2.cpi", "wb");

	temp = XMMinstalled ();
	printf ("XMS DRIVER INSTALL : %d\n", temp);
//--------------------------------------------------------
	num = 1;
	temp = GetXMMVersion (num);
	printf ("%x\n", temp);
	num = 2;
	temp = GetXMMVersion (num);
	printf ("%x\n", temp);
	num = 3;
	temp = GetXMMVersion (num);
	printf ("%x\n", temp);
//--------------------------------------------------------
	num = 1;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
	num = 2;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
//--------------------------------------------------------
	num = 50;
	handle = EMBAlloc (num);

	if (handle == -3)
		printf ("Error No.3\n");
	else if (handle == -2)
		printf ("Error No.2\n");
	else if (handle == -1)
		printf ("Error No.1\n");
//--------------------------------------------------------
	num = 1;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
	num = 2;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
//--------------------------------------------------------
	num = 100;
	temp = EMB_reSize (handle, num);

	if (temp == 1)
		printf ("True\n");
	else if (temp == -1)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
	else if (temp == -6)
		printf ("Error No.6\n");
//--------------------------------------------------------
	num = 1;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
	num = 2;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
//--------------------------------------------------------
	lock = EMB_Lock (handle);

	if (lock == 5)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
//--------------------------------------------------------
	num = 1;
	temp = EMB_HandleInfo (handle, num);
	printf ("Lock Block Count : %d\n", temp);
	num = 2;
	temp = EMB_HandleInfo (handle, num);
	printf ("EMB Handle Count : %d\n", temp);
	num = 3;
	temp = EMB_HandleInfo (handle, num);
	printf ("Block Length : %d\n", temp);
//--------------------------------------------------------
	printf ("Main MEM : %lu\n", coreleft ());

	Mem_Buf = (char *) malloc (50 * 1024);
	if (Mem_Buf == NULL)
			printf ("Base Mem Alloc Error\n");

	printf ("Main MEM : %lu\n", coreleft ());

	while (!feof (f_Ptr))
	{
//		printf ("in put %d\n", count);
		Mem_Buf[count] = fgetc (f_Ptr);
		count++;
	}
	putchar ('\n');

//--------------------------------------------------------
/*	moveInfo.Length 	  = 50 * 1024L;
	moveInfo.SourceHandle = 0;
	moveInfo.SourceOffset = (unsigned long) Mem_Buf;
	moveInfo.DestHandle   = handle;
	moveInfo.DestOffset   = 0;

	temp = MoveEMB (&moveInfo); */
	temp = MEMtoEMB (Mem_Buf, handle, 0L, 50 * 1024L);
	if (temp == -1)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
	else if (temp == -6)
		printf ("Error No.6\n");
	else if (temp == -7)
		printf ("Error No.7\n");
	else if (temp == -8)
		printf ("Error No.8\n");
	else if (temp == -9)
		printf ("Error No.9\n");
	else if (temp == -10)
		printf ("Error No.10\n");

	Put_Buf = (char *) malloc (50 * 1024);

/*	moveInfo.Length 	  = 50 * 1024L;
	moveInfo.SourceHandle = handle;
	moveInfo.SourceOffset = 0;
	moveInfo.DestHandle   = 0;
	moveInfo.DestOffset   = (unsigned long) Put_Buf;

	temp = MoveEMB (&moveInfo); */
	temp = EMBtoMEM (handle, 0L, Put_Buf, 50 * 1024L);
	if (temp == -1)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
	else if (temp == -6)
		printf ("Error No.6\n");
	else if (temp == -7)
		printf ("Error No.7\n");
	else if (temp == -8)
		printf ("Error No.8\n");
	else if (temp == -9)
		printf ("Error No.9\n");
	else if (temp == -10)
		printf ("Error No.10\n");

	for (i=0; i < count; i++)
	{
		fputc (Put_Buf[i], f_Ptr_2);
	}
	putchar ('\n');
//--------------------------------------------------------
	temp = EMB_UNLock (handle);
	num = FreeEMB (handle);
	if (num == -1)
		printf ("Error No.1\n");
	else if (num == -2)
		printf ("Error No.2\n");
	else if (num == -3)
		printf ("Error No.3\n");
	else if (num == -4)
		printf ("Error No.4\n");
	else if (num == -5)
		printf ("Error No.5\n");
	else if (num == -6)
		printf ("Error No.6\n");

	free (Mem_Buf);
	printf ("Main MEM : %lu\n", coreleft ());
	free (Put_Buf);
	printf ("Main MEM : %lu\n", coreleft ());
	fclose (f_Ptr);
	fclose (f_Ptr_2);
//--------------------------------------------------------
	num = 1;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
	num = 2;
	us_temp = GetEMBSize (num);
	printf ("%u\n", us_temp);
//--------------------------------------------------------
	num = 50;
	handle = EMBAlloc (num);

	if (handle == -3)
		printf ("Error No.3\n");
	else if (handle == -2)
		printf ("Error No.2\n");
	else if (handle == -1)
		printf ("Error No.1\n");
//--------------------------------------------------------
/*	lock = EMB_Lock (handle);

	if (lock == 5)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n"); */
//--------------------------------------------------------
	char far *S_Buffer = (char far *)farmalloc (10*1024L);
	char far *D_Buffer = (char far *)farmalloc (10*1024L);
	char far *p_lock;
//--------------------------------------------------------
	_fmemset (S_Buffer, 'T', 10*1024);
	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = 0;
	moveInfo.SourceOffset = (unsigned long) S_Buffer;
	moveInfo.DestHandle = handle;
	moveInfo.DestOffset = 0;
	temp = MoveEMB (&moveInfo);

	_fmemset (S_Buffer, 'Z', 10*1024);
	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = 0;
	moveInfo.SourceOffset = (unsigned long) S_Buffer;
	moveInfo.DestHandle = handle;
	moveInfo.DestOffset = (10 * 1024) + 1;
	temp = MoveEMB (&moveInfo);

	if (temp == -1)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
	else if (temp == -6)
		printf ("Error No.6\n");
	else if (temp == -7)
		printf ("Error No.7\n");
	else if (temp == -8)
		printf ("Error No.8\n");
	else if (temp == -9)
		printf ("Error No.9\n");
	else if (temp == -10)
		printf ("Error No.10\n");

	getch ();

	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = handle;
	moveInfo.SourceOffset = 0;
	moveInfo.DestHandle = 0;
	moveInfo.DestOffset = (unsigned long) D_Buffer;
	temp = MoveEMB (&moveInfo);

	if (temp == -1)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
	else if (temp == -6)
		printf ("Error No.6\n");
	else if (temp == -7)
		printf ("Error No.7\n");
	else if (temp == -8)
		printf ("Error No.8\n");
	else if (temp == -9)
		printf ("Error No.9\n");
	else if (temp == -10)
		printf ("Error No.10\n");

	getch ();

	puts (D_Buffer);
	getch ();


	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = handle;
	moveInfo.SourceOffset = (10 * 1024) + 1;
	moveInfo.DestHandle = 0;
	moveInfo.DestOffset = (unsigned long) D_Buffer;
	temp = MoveEMB (&moveInfo);

	if (temp == -1)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
	else if (temp == -6)
		printf ("Error No.6\n");
	else if (temp == -7)
		printf ("Error No.7\n");
	else if (temp == -8)
		printf ("Error No.8\n");
	else if (temp == -9)
		printf ("Error No.9\n");
	else if (temp == -10)
		printf ("Error No.10\n");

	getch ();

	puts (D_Buffer);
	getch ();

//--------------------------------------------------------
/*	p_lock = (char far *) lock;
	_fmemset (S_Buffer, 'T', 10*1024);
	for (i=0; i<(10*1024); i++)
	{
		*(p_lock+i) = *(S_Buffer+i);
	}
	puts (S_Buffer);	*/
//--------------------------------------------------------
/*	_fmemset (S_Buffer, 'T', 10*1024);

	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = 0;
	moveInfo.SourceOffset = (unsigned long) S_Buffer;
	moveInfo.DestHandle = handle;
	moveInfo.DestOffset = lock;
	temp = MoveEMB (&moveInfo);

	if (temp == -1)
		printf ("Error No.1\n");
	else if (temp == -2)
		printf ("Error No.2\n");
	else if (temp == -3)
		printf ("Error No.3\n");
	else if (temp == -4)
		printf ("Error No.4\n");
	else if (temp == -5)
		printf ("Error No.5\n");
	else if (temp == -6)
		printf ("Error No.6\n");
	else if (temp == -7)
		printf ("Error No.7\n");
	else if (temp == -8)
		printf ("Error No.8\n");
	else if (temp == -9)
		printf ("Error No.9\n");
	else if (temp == -10)
		printf ("Error No.10\n");

	getch ();
//--------------------------------------------------------
	puts ("base Mem put start");
	*(S_Buffer+((10*1023)+1)) = 0;
	puts (S_Buffer);
	puts ("base Mem put end");
	getch ();
//--------------------------------------------------------
	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = handle;
	moveInfo.SourceOffset = lock;
	moveInfo.DestHandle = 0;
	moveInfo.DestOffset = (unsigned long)D_Buffer;
	temp = MoveEMB (&moveInfo);
//--------------------------------------------------------
	puts ("xms to mem put start");
	*(D_Buffer+((10*1023)+1)) = 0;
	puts (D_Buffer);
	puts ("xms to mem put end");
	getch ();
//--------------------------------------------------------
	_fmemset (S_Buffer, 'Z', 10*1024);
	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = 0;
	moveInfo.SourceOffset = (unsigned long) S_Buffer;
	moveInfo.DestHandle = handle;
	moveInfo.DestOffset = lock + (10*1024);
	temp = MoveEMB (&moveInfo);
//--------------------------------------------------------
	puts ("mem put start");
	*(S_Buffer+((10*1023)+1)) = 0;
	puts (S_Buffer);
	puts ("mem put end");
//--------------------------------------------------------
	moveInfo.Length = 10*1024;
	moveInfo.SourceHandle = handle;
	moveInfo.SourceOffset = lock + (10*1024);
	moveInfo.DestHandle = 0;
	moveInfo.DestOffset = (unsigned long)D_Buffer;
	temp = MoveEMB (&moveInfo);
//--------------------------------------------------------
	puts ("xms to mem put start");
	*(D_Buffer+((10*1023)+1)) = 0;
	puts (D_Buffer);
	puts ("xms to mem put end");
	getch ();
//--------------------------------------------------------*/
	farfree (S_Buffer);
	farfree (D_Buffer);
//	EMB_UNLock (handle);
	FreeEMB (handle);
//--------------------------------------------------------
}
Esempio n. 14
0
void main(void)
{
	int		i;

	cout << endl << endl;

	cout << "Memory at start: " << coreleft() << " bytes\n";

	IArray<MyNode>	a(10),b(a),c;

	// Create an array of 10 elements

	for (i = 0; i < 10; i++) {
		a.add(new MyNode(i));
		}

	cout << "Memory after creating array: " << coreleft() << " bytes\n";

	dumpArray(a);
	dumpArray(b);
	cout << "a == b > " << ((a == b) ? "TRUE" : "FALSE") << endl;
	c = a;
	dumpArray(c);
	cout << "c == a > " << ((c == a) ? "TRUE" : "FALSE") << endl;

	// Insert a number of elements into the middle of the array

	a.setDelta(10);
	for (i = 100; i < 120; i++) {
		a.insert(new MyNode(i),5);
		}
	dumpArray(a);
	getch();

	// Insert an element at the start and at the end

	a.insert(new MyNode(-1),0);
	a.insert(new MyNode(-2),a.numberOfItems());
	dumpArray(a);
	getch();

	// Now replace some elements in the array

	a.replace(new MyNode(-3),4);
	a.replace(new MyNode(-3),5);
	delete a[6];	a[6] = new MyNode(-4);
	delete a[7];	a[7] = new MyNode(-5);
	dumpArray(a);
	getch();

	// Now remove some elements from the array

	for (i = 0; i < 7; i++)
		a.destroy(4);
	dumpArray(a);

	a.destroy(10);
	dumpArray(a);
	getch();

	// Display the array using iterators.

	IArrayIterator<MyNode> it1;

	for (it1 = a; it1; it1++)
		cout << *it1.node() << " ";
	cout << endl;

	for (it1.restart(); it1;)
		cout << *it1++ << " ";
	cout << endl;

	for (it1.restart(10,20); it1;)
		cout << *++it1 << " ";
	cout << endl;
	getch();

	a.empty();
	dumpArray(a);

	cout << "Memory at end: " << coreleft() << " bytes\n\n";
}
Esempio n. 15
0
int main(int argc, char *argv[]) {
	cout << "Pulse of Prices Databases Ver 1.10 creator of "
		  << __DATE__ << "\n"
			  "Copyright (c) 1995, 1996 by Sergey Gershtein. Ural-Relcom, Ltd.\n"
			  "---------------------------------------------------------------\n"
			  "This program converts Oferta's Pulse database files from "
			  "current directory\n"
			  "into Pulse of Prices Viewer format.\n\n";

#ifndef DEBUG
	char *final_dir=".\\";
	if (argc>1)
		if (argv[1][0]=='?' || argv[1][1]=='?') {
			cout << "Usage: " << argv[0] << " <dest_dir>\n\n"
			"All the Oferta *.dbf files and optionally payments.ini file\n"
			"must be in current directory.  The resulting pulse.* files will\n"
			"be stored in the <dest_dir> directory.\n"
			"Be prepared that it may take a long time to create the bases.\n"
			"You can stop the program at any time by pressing Ctrl-C.\n";
			return 0;
		} else
		final_dir=argv[1];
#else
	if (argc>1)
		cout << "### This version was compiled with DEBUG option set.\n"
		"### It does not understand your argument '"<<argv[1]<<"'\n";
#endif

	cout << "Opening files:\n";

// clearing all the read-only attrs and stuff
   _rtl_chmod(b_address,1,0);
   _rtl_chmod(b_offer,1,0);
   _rtl_chmod(b_product,1,0);
   _rtl_chmod(b_prodtype,1,0);
// opening the bases
   BSS *o_address=open_dbf(b_address);
   cout << "   " << b_address;
   if (!o_address) {
      cout << " - error opening file\n";
      return 1;
   } else
      cout << endl;
   BSS *o_offer = open_dbf(b_offer);
   cout << "   " << b_offer;
   if (!o_offer) {
      cout << " - error opening file\n";
      return 1;
	} else
      cout << endl;
   BSS *o_product = open_dbf(b_product);
   cout << "   " << b_product;
   if (!o_product) {
      cout << " - error opening file\n";
      return 1;
   } else
      cout << endl;
   BSS *o_prodtype = open_dbf(b_prodtype);
   cout << "   " << b_prodtype;
   if (!o_prodtype) {
      cout << " - error opening file\n";
      return 1;
   } else
      cout << endl;

// bases opened.  Now reading... ------------------------ PPF ---------------
#ifndef NOPPF
{
   cout << "Creating pulse.ppf... ";
   if (!ppf.create(final_dir,(ushort)o_address->Amount)) {
      cout << "file creation error!\n";
      return 1;
   }
   ppf.firm = new char[17];
   ppf.address = new char[61];
   ppf.fullname = new char[120];
   for (ushort n=1; n<=o_address->Amount; n++) { // for each record
		if (n%10==1) {
         cout.width(6);
         cout << n << ' ';
         cout << "\x8\x8\x8\x8\x8\x8\x8";
      }
      if (read_dbf(o_address,n)) {
         cout << "Error reading database record!\n";
         return 1;
      }
      if (read_buf(o_address,ppf.firm,NULL,ppf.address,ppf.fullname,
         &ppf.phone[0],&ppf.phone[1],&ppf.phone[2],&ppf.phone[3],&ppf.area)) {
         cout << "Error parsing database record!\n";
         return 1;
      }
      for (char *s=ppf.firm; (*s=upcase(*s))!=0; s++) ; // upcase firm name
      if (!ppf.write()) {
         cout << "Error writing record!\n";
         return 1;
      }
   }
   delete[] ppf.firm;
   delete[] ppf.address;
   delete[] ppf.fullname;
   ppf.close();
   cout << n << " records processed.\n";
}
#endif
// --------------------------- creating PPG file -----------------------------
#ifndef NOPPG
{  int n;
   long dsup=0, ddem=0;
   cout << "Reading groups information...         ";
   for (n=0; n<o_product->Amount; n++) {
      nidx[n]=n+1;
      cout << "\x8\x8\x8\x8\x8\x8\x8";
      cout.width(6);
      cout << (int)n << ' ';
      if (read_dbf(o_product,n+1)) {
         cout << "Error reading database record!\n";
         return 1;
      }
      unsigned int recno;                  
      long last;
      if (read_buf(o_product,NULL,&recno,&g1[n],&last)) {
         cout << "Error parsing database record!\n";
         return 1;
      }
      if (read_dbf(o_prodtype,recno)) {
         cout << "Error reading database prodtyp_.dbf!\n";
         return 1;
      }
      int supply;
      if (read_buf(o_prodtype,NULL,NULL,NULL,&supply)) {
         cout << "Error parsing database prodtyp_.dbf record!\n";
         return 1;
      }
      if (supply) {
         dsup+=last-g1[n]+1;
			g1[n]-=ddem;
      } else { // demand
         ddem+=last-g1[n]+1;
         g1[n]-=dsup;
      }
      g1[n]--; // we start from zero, not one
   }

   cout << "\nSorting groups with InsertSort... ";
   for (int k=(int)o_product->Amount-2; k>=0; k--) {
      char save=nidx[k];   // save k-th element
      long sav1=g1[k];
      for (int j=k+1; (j<=o_product->Amount-1) &&
            cmpgr(o_product,save,nidx[j])>0; j++) {
         nidx[j-1]=nidx[j];
         g1[j-1]=g1[j];
      }
      nidx[j-1] = save;
      g1[j-1] = sav1;
      if (k%7==0) {
         cout.width(3);
         cout << k << "\x8\x8\x8";
      }
   }
   cout << "Done sorting.  \n";

   cout << "Creating pulse.ppg...        ";
   if (!ppg.create(final_dir,(ushort)o_product->Amount)) {
      cout << "file creation error!\n";
		return 1;
   }
   ppg.gname = new char[61];
   for (n=0; n<o_product->Amount; n++) { // for each record
      cout << "\x8\x8\x8\x8\x8\x8\x8";
      cout.width(6);
      cout << (int)n << ' ';
      if (read_dbf(o_product,nidx[n])) {
         cout << "Error reading database record!\n";
         return 1;
      }
      unsigned int recno;
      if (read_buf(o_product,ppg.gname,&recno,&ppg.gfirst,&ppg.gsize)) {
         cout << "Error parsing database record!\n";
         return 1;
      }
      ppg.gsize-=(--ppg.gfirst); // number of records, not the last record
      long gf=ppg.gfirst;
      ppg.gfirst=g1[n];   // not absolute one, but address in the index
      if (read_dbf(o_prodtype,recno)) {
         cout << "Error reading database prodtyp_.dbf!\n";
         return 1;
      }
      int supply;
      if (read_buf(o_prodtype,NULL,NULL,NULL,&supply)) {
         cout << "Error parsing database prodtyp_.dbf record!\n";
         return 1;
      }
      ppg.issupply = !(ppg.isdemand=(supply==0));
		if (!ppg.write()) {
         cout << "Error writing record!\n";
         return 1;
      }
      g1[n]=gf; // now g1 contains what gfirst used to be
   }
   delete[] ppg.gname;
   ppg.close();
   cout << "records processed.\n";
}
#endif
// creating .ppd file (uff..)
{
   try {
      ppi.paym = new Paym[30];   // let's start with 30 payment methods
      ulong pmno[30];            // number of times payment methods are used
      ppi.npaym = 0;
#ifdef DEBUG
      cout << "## coreleft: " << coreleft() << endl;
#endif
		ushort cblno=(ushort)((coreleft()-20000)/2048/4);
		VArrayL ndx(o_offer->Amount*2+2,"s_index.$$$",2048,cblno);
		cout << "Virtual array created: " << cblno << " 2048-element blocks allocated"
				  " for buffer\n";
		cout << "Memory should left afterwards: " << (coreleft() - ((long)cblno)*2048*4) << endl;
		cout << "Creating pulse.ppd... ";
		ppd.dupdate.Today();
		ppd.dcreate = ppd.dupdate;
		if (!ppd.create(final_dir)) {
			cout << "file creation error!\n";
			return 1;
		}
		for (long n=1; n<=o_offer->Amount; n++) { // for each record
			if (n%19==1) {
				cout.width(7);
				cout << n << ' ';
				cout << "\x8\x8\x8\x8\x8\x8\x8\x8";
         }
         if (read_dbf(o_offer,n)) {
            cout << "Error reading database record!\n";
            return 1;
         }
         double dprice;
         char payment[4];
         char date[7];
         if (read_buf(o_offer,NULL,NULL,&ppd.drec.fcode,NULL,&dprice,
             payment,date,ppd.drec.ad)) {
            cout << "Error parsing database record!\n";
            return 1;
         }
         ppd.drec.price=dprice;
         ppd.drec.fcode--;
         date[2]=date[5]=0;
         ppd.drec.dsubmit = Date(atoi(date),atoi(date+3),ppd.dcreate.year());

         for (int i=0; i<ppi.npaym; i++)// do we know this payment method?
            if (upcase(ppi.paym[i].abbr[0])==upcase(payment[0]) &&
                upcase(ppi.paym[i].abbr[1])==upcase(payment[1]) &&
                upcase(ppi.paym[i].abbr[2])==upcase(payment[2]))
                  break;
         if (i>=ppi.npaym) { // new payment method
				ppi.npaym = i+1;
            pmno[i]=0;
            for (int j=0; j<4; j++)
               ppi.paym[i].abbr[j]=payment[j];
            ppi.paym[i].coef=1;  // roubles form by default.
         }
         ppd.drec.pcode = i;
         pmno[i]++;
         for (char *s=ppd.drec.ad; (*s=upcase(*s))!=0; s++) ;
         if ((ndx[n-1]=ppd.write())==0) {
            cout << "Error writing record!\n";
            return 1;
         }
      }
      ppd.close();
      cout << (n-1) << " records processed.\n";
      cout << (int)ppi.npaym << " payment methods were encountered:\n";
      for (int i=0; i<ppi.npaym; i++) {
         if (i>0)
           cout << ", ";
         for (int j=0; j<4; j++)
            cout << ppi.paym[i].abbr[j];
         cout << " - ";
         cout.width(7);
         cout << pmno[i];
      }
      cout << endl;

      // finding minimum course
		cout << "Looking for the USD course... ";
      if (!ppg.open(final_dir)) {
         cout << "Error opening pulse.ppg!\n";
         return 1;
      }
      for (int i0=0; i0<ppg.Ngroups(); i0++) {
         if (!ppg.read()) {
            cout << "Error reading pulse.ppg record "<<i0<<"!\n";
            return 1;
         }
         if (strstr(ppg.gname,"‚€‹ž’€") && ppg.issupply)
            break;
      }
      double usdk=1e+10;
      if(!ppd.open(final_dir)) {
         cout << "Error opening pulse.ppd!\n";
         return 1;
      }
      if (i0>=ppg.Ngroups()) {
         cout << "!!!!!!!!!!!!!!!!! Not found !!!!!!!!!!!!!!!!!!!\n";
         usdk=4700;         // ????
      } else {
         for (i=0;i<ppg.gsize;i++) { // looking for course
            if (!ppd.read(ndx[g1[i0]+i])) {
               cout << "Error reading pulse.ppd records!\n";
               return 1;
            }
            if (strstr(ppd.drec.ad,"��Ž„€†€ USD") &&
                ppd.drec.price<usdk) // found
					 usdk = ppd.drec.price;
         }
         if (usdk<1e+9)
            cout << usdk << " roubles/$\n";
         else {
            cout << "Records not found!\n";
            usdk = 0;
         }
      }
      ppg.close();

      // working with payments.ini file

      cout << "Checking "<<payments_ini<<" file... ";
      ifstream inif(payments_ini,ios::in);
      if (!inif)
         cout << "File not found.\n";
      else { // working with the file
         cout << "File found\n";
         while (!inif.eof()) {
            char pmt[4];
            char line[30];
            inif.read(pmt,4); // read four characters of payment type
            if (inif.eof())
               break;
            inif.getline(line,29);
            for (i=0; i<ppi.npaym; i++)
               if (upcase(ppi.paym[i].abbr[0])==upcase(pmt[0]) &&
                   upcase(ppi.paym[i].abbr[1])==upcase(pmt[1]) &&
						 upcase(ppi.paym[i].abbr[2])==upcase(pmt[2])) { // found
                  char *c;
                  for (c=line; *c<=' '; c++); // skip leading blanks
                  if (*c=='$')  // dollar conversion coef
                     ppi.paym[i].coef = atof(++c)*usdk;
                  else
                     ppi.paym[i].coef = atof(c);
                  cout << "   ";
                  for (int j=0; j<4; j++)
                     cout << ppi.paym[i].abbr[j];
                  cout << " = " << ppi.paym[i].coef << " roubles\n";
                  break;
               } // payment methods found
         } // while not eof
         inif.close();
      } // .ini file found

      // building demand and supply lists
      cout << "Building demand and supply lists... ";
      long nsup=0, ndem=0; // number of supply and demand records
      if (!ppg.open(final_dir)) {
         cout << "Error opening pulse.ppg!\n";
         return 1;
      }
      for (i=0; i<ppg.Ngroups(); i++) {
         if (!ppg.read()) {
            cout << "Error reading pulse.ppg record "<<i<<"!\n";
            return 1;
         }
			if (ppg.issupply)
            nsup+=ppg.gsize;
         else if (ppg.isdemand) {
            ndem+=ppg.gsize;
            for (int j=0; j<ppg.gsize; j++) // set high bit to 1 for demand
               ndx[g1[i]+j]=ndx(g1[i]+j) | 0x80000000l;
         }
         cout.width(7);
         cout << (ndem+nsup) << "\x8\x8\x8\x8\x8\x8\x8";
      }
      cout << "Done           \n   " << nsup << " supply records.\n   "
           << ndem << " demand records.\n";
      ppg.close();
      // creating ppi file -------------------------------------

      cout << "Creating pulse.ppi:\n   ";
      if (!ppi.create(final_dir)) {
         cout << "File creation error!\n";
         return 1;
      }
      if (!ppi.write()) { // writing initial payment info records
         cout << "Error writing payment info records!\n";
         return 1;
      } else
         cout << "Payment information stored.\n";

      cout << "   Writing supply records list... ";
      if (!ppi.iselect(iSupply)) {
         cout << "Error storing index offset!\n";
			return 1;
      }
      for (n=0; n<o_offer->Amount; n++) // for each element
         if ((ndx(n) & 0x80000000l)==0) // supply
            if (!ppi.write(ndx(n))) {
               cout << "Error writing index element!\n";
               return 1;
            } else if (n%33==1) {
               cout.width(7);
               cout << n << "\x8\x8\x8\x8\x8\x8\x8";
            }
      cout << "Done.        \n";

      cout << "   Writing demand records list... ";
      if (!ppi.iselect(iDemand)) {
         cout << "Error storing index offset!\n";
         return 1;
      }
      for (n=0; n<o_offer->Amount; n++) // for each element
         if ((ndx(n) & 0x80000000l)!=0) // demand
            if (!ppi.write(ndx(n)&0x7fffffffl)) {
               cout << "Error writing index element!\n";
               return 1;
            } else if (n%33==1) {
               cout.width(7);
               cout << n << "\x8\x8\x8\x8\x8\x8\x8";
            }
      cout << "Done.        \n";
#ifndef NOASORT
		qsortads(ppd,ndx,0,o_offer->Amount-1);  // quick sort by names
      cout << "   Writing supply records list... ";
      if (!ppi.iselect(iSrtSupply)) {
         cout << "Error storing index offset!\n";
         return 1;
      }
      for (n=0; n<o_offer->Amount; n++) // for each element
         if ((ndx(n) & 0x80000000l)==0) // supply
            if (!ppi.write(n)) {
               cout << "Error writing index element!\n";
               return 1;
            } else if (n%33==1) {
               cout.width(7);
               cout << n << "\x8\x8\x8\x8\x8\x8\x8";
            }
      cout << "Done.        \n";

      cout << "   Writing demand records list... ";
      if (!ppi.iselect(iSrtDemand)) {
         cout << "Error storing index offset!\n";
         return 1;
      }
      for (n=0; n<o_offer->Amount; n++) // for each element
         if ((ndx(n) & 0x80000000l)!=0) // demand
            if (!ppi.write(n/*ndx(n)&0x7fffffffl*/)) {
               cout << "Error writing index element!\n";
               return 1;
            } else if (n%33==1) {
               cout.width(7);
					cout << n << "\x8\x8\x8\x8\x8\x8\x8";
            }
      cout << "Done.        \n";
#endif // alpha sort

      cout << "Building indexes for each payment type:\n";
      cout << "   Supply... ";
      ulong pmcur[30];  // index positions for each payment type
      pmcur[0]=0;
      for (n=0; n<ppi.npaym-1; n++) {
         pmcur[(int)n+1]=pmcur[(int)n]+pmno[(int)n];
         pmno[(int)n]=pmcur[(int)n];

#ifdef DEBUG
         cout << "pmcur[" << n << "]=" << pmcur[n] << " ";
#endif

      }

#ifdef DEBUG
      cout << endl;
#endif

      pmno[(int)n]=pmcur[(int)n];
// now pmno points to the beginnings of the lists, pmcur - to the endings
//      long ll=0;
      for (n=0; n<nsup; n++) {
         if (!ppd.read(ppi(n,TRUE),FALSE)) { // not reading ad string
            cerr << "Error reading data #1!\n";
				return 1;
         }
         union {
            ulong l;
            float f;
         } u;
         u.f = ppd.drec.price;

#ifdef DEBUG
   if (pmcur[ppd.drec.pcode]+o_offer->Amount+1>=o_offer->Amount*2+2) {
      cerr << "@1: pcode=" << (int)ppd.drec.pcode <<
              ", pmcur[pcode]=" << (long)pmcur[ppd.drec.pcode] <<
              ", Amount=" << o_offer->Amount << endl;
   }
#endif

         ndx[pmcur[ppd.drec.pcode]+o_offer->Amount+1]=u.l;
         ndx[pmcur[ppd.drec.pcode]++]=n;

         if (n%13==1) {
            cout.width(7);
            cout << n << "\x8\x8\x8\x8\x8\x8\x8";
         }
      }
      cout << n << " elements done.\n";
      cout << "   Sorting the lists:\n";

      for (n=0; n<ppi.npaym; n++) {  // sorting all lists
         if (pmno[(int)n]>=pmcur[(int)n])
				continue;   // no records for this payment type
#ifdef HEAPSORT
         cout << "     HeapSorting ";
#else
         cout << "     QuickSorting ";
#endif
         for (int j=0; j<4; j++)
            cout << ppi.paym[(int)n].abbr[j];
         cout << "... ";
#ifdef HEAPSORT
         heapsort(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1,TRUE);
#else
         qsortprice(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1,
            TRUE,o_offer->Amount+1);
#endif
#ifdef SORTCHECK
         cout << "DEBUG: Checking sort order...";
         if (!ppd.read(ppi(ndx(pmno[(int)n]),TRUE),FALSE)) {
            cout << "ee!";
            return -1;
         }
         for (long ll=pmno[(int)n]+1; ll<pmcur[(int)n]; ll++) {
            float pr=ppd.drec.price;
            union {
               ulong l;
               float f;
            } u1;
            u1.l=ndx(ll+o_offer->Amount+1);
            if (!ppd.read(ppi(ndx(ll),TRUE))) {
					cout << "ee!";
               return -1;
            }
            if (pr>ppd.drec.price) {
               cout << ll << ": SORT ERROR!\n";
         //      return -1;
            }
            cout.width(8);
            cout << ll << "\x8\x8\x8\x8\x8\x8\x8\x8";
         }
         cout << "Sort OK\n";
#endif
      }

      cout << "   Storing indexes... ";
      for (int jj=0; jj<o_product->Amount; jj++)
         nidx0[nidx[jj]-1]=jj;
      for (int pc=0; pc<ppi.npaym; pc++) {
         ppi.iselect(iPaym+pc*2);
         for (int gr=0; gr<o_product->Amount; gr++)
            gfirst[gr]=glast[gr]=-1;
         for (long n=pmno[pc]; n<pmcur[pc]; n++) {
            ppi.write(ndx(n));
            // finding to which group ndx(n) belongs... Binary search
            int left=0, right=(int)(o_product->Amount-1), mid;
            while (left<right) {
                  mid=(right+left)/2;
                  if (ndx(n)<g1[nidx0[mid]])
                     right=mid-1;
						else if (ndx(n)>=g1[nidx0[mid]] &&
                     (mid==o_product->Amount-1 || ndx(n)<g1[nidx0[mid+1]])) {
                     // found
                     left=mid;
                     break;
                  } else
                     left=mid+1;
               }
            // group found
            if (gfirst[nidx0[left]]==-1)
               gfirst[nidx0[left]]=n-pmno[pc];
            glast[nidx0[left]]=n-pmno[pc];
            // information stored in the array
            if (n%13==1) {
               cout.width(7);
               cout << n << "\x8\x8\x8\x8\x8\x8\x8";
            }
         }
         for (gr=0; gr<o_product->Amount; gr++)
            ppi.writeg(gr,gfirst[gr],glast[gr]);
      }
      cout << nsup << " elements done.\n";

      for (n=0; n<ppi.npaym; n++) {
         pmno[(int)n]=pmcur[(int)n];
      }

// now pmno points to the beginnings of the lists, pmcur - to the endings
      cout << "   Demand... ";
		for (n=0; n<ndem; n++) {
         if (!ppd.read(ppi(n,FALSE),FALSE)) { // demand records
            cerr << "Error reading data #1!\n";
            return 1;
         }
         union {
            ulong l;
            float f;
         } u;
         u.f = ppd.drec.price;
         ndx[pmcur[ppd.drec.pcode]+o_offer->Amount+1]=u.l;
         ndx[pmcur[ppd.drec.pcode]++]=n;
         if (n%13==1) {
            cout.width(7);
            cout << n << "\x8\x8\x8\x8\x8\x8\x8";
         }
      }
      cout << n << " elements done.\n";
      cout << "   Sorting the lists:\n";

      for (n=0; n<ppi.npaym; n++) {  // sorting all lists
         if (pmno[(int)n]>=pmcur[(int)n])
            continue;   // no records for this payment type
#ifdef HEAPSORT
         cout << "     HeapSorting ";
#else
         cout << "     QuickSorting ";
#endif
         for (int j=0; j<4; j++)
				cout << ppi.paym[(int)n].abbr[j];
         cout << "... ";
#ifdef HEAPSORT
         heapsort(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1,FALSE);
#else
         qsortprice(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1,
               FALSE,o_offer->Amount+1);
#endif
      }

      cout << "   Storing indexes... ";
      for (pc=0; pc<ppi.npaym; pc++) {
         ppi.iselect(iPaym+pc*2+1);
         for (long n=pmno[pc]; n<pmcur[pc]; n++) {
            ppi.write(ndx(n));
            if (n%13==1) {
               cout.width(7);
               cout << n << "\x8\x8\x8\x8\x8\x8\x8";
            }
         }
      }
      cout << ndem << " elements done.\n";

      ppd.close(); // NOT TO FORGET
      ppi.close();
      delete[] ppi.paym;
   } catch (VArrayErr err) {
      cout << "Virtual array exception #" << (int)err.code() << "\n";
      return 1;
	} catch (xalloc xa) {
      cout << "Memory allocation failure: " << xa.requested() << "bytes.\n";
      return 1;
   } catch (...) {
      cout << "Unhandled exception!\n";
      return 1;
   }
}

   cout << "Closing Oferta's files... ";
   if (close_dbf(o_address) || close_dbf(o_product) || close_dbf(o_prodtype) ||
      close_dbf(o_offer)) {
         cout << "Error closing Oferta's bases!\n";
         return 1;
      }

   cout << "Done.\n";
   return 0;
}
Esempio n. 16
0
void main(void)
{
	int		i,count;
	MyNode	*n1,*middle,*beforeMiddle,*last;

	cout << "Memory at start: " << coreleft() << " bytes\n";

	// Create a linked list of 10 nodes adding at the head of the list.

	for (i = 0; i < 10; i++) {
		n1 = new MyNode(i);
		l.addToHead(n1);
		if (i == 0)
			last = n1;
		if (i == 5)
			beforeMiddle = n1;
		if (i == 4)
			middle = n1;
		}

	cout << "Memory after creating list: " << coreleft() << " bytes\n";

	dumpList(l);

	// Add a new node after the head of the list and after a middle node

	n1 = new MyNode(20);
	l.addAfter(n1,l.peekHead());
	n1 = new MyNode(21);
	l.addAfter(n1,last);
	n1 = new MyNode(22);
	l.addAfter(n1,middle);

	dumpList(l);

	// Remove the middle object from the list using beforeMiddle as the
	// previous node in the list.

	delete l.removeNext(beforeMiddle);
	dumpList(l);

	// Remove all remaining nodes with removeFromHead().

	count = l.numberOfItems();
	for (i = 0; i < count+5; i++)
		delete l.removeFromHead();

	dumpList(l);

	cout << "Memory: " << coreleft() << " bytes\n";

	for (i = 0; i < 10; i++) {
		n1 = new MyNode(i);
		l.addToHead(n1);
		}

	// Display the list using iterators to move through the list.

	SimpleListIterator<MyNode> it1;

	for (it1 = l; it1; it1++)
		cout << it1.node()->id() << " ";
	cout << endl;

	for (it1.restart(); it1;)
		cout << it1++->id() << " ";
	cout << endl;

	l.empty();

	cout << "Memory at end: " << coreleft() << " bytes\n\n";
}
Esempio n. 17
0
int main(void)
{
  long ul=coreleft();

  printf("core=%ld\n", coreleft());
}
Esempio n. 18
0
void logindaemon (char *name)
//**************************************************************************
//
//
//**************************************************************************
{
#ifndef _AX25K_ONLY
  highestport = init_tnc();
  wdelay(548);
  while (! runterfahren)
  {
    nextopen = 0;
    portsopen = 0;
    for (loginpnum = 1; loginpnum < highestport; loginpnum++)
    {
      switch (portopen[loginpnum])
      {
      case p_closed:
        if (! nextopen) nextopen = loginpnum;
        break;
      case p_open:
        if (linkstate_tnc(loginpnum) >= info_transfer)
        {
          char cstate[70];
          linkcall_tnc(loginpnum, cstate);
          cstate[30] = 0;
          portopen[loginpnum] = p_session;
          closeport_tnc(loginpnum);
          rxdafl[loginpnum] = rxcbuf[loginpnum] = 0;
          fork(P_MAIL, loginpnum, boxusertask, cstate);
        }
        else portsopen++;
        break;
      case p_session:
        if (linkstate_tnc(loginpnum) == disconnected)
        {
          portopen[loginpnum] = p_closed;
          killport(loginpnum);
          doodle(3);
        }
        break;
      case p_connected:
        if (linkstate_tnc(loginpnum) == disconnected)
        {
          portopen[loginpnum] = p_closed;
          taskport0(loginpnum);
        }
        break;
      }
    }
    if (nextopen > 0 && portsopen < 3)
    {
#ifdef __MSDOS__
      if (coreleft() > 20000L) // nur wenn noch genug Speicher frei ist
#endif
      {
        openport_tnc(nextopen); // einen neuen Login zulassen
        portopen[nextopen] = p_open;
      }
    }
#ifdef _AX25K
    ax25k_checklogin();
#endif
    wdelay(246);
  }
#else  //_AX25K_ONLY
  wdelay(548);
  while (! runterfahren)
  {
    ax25k_checklogin();
    wdelay(246);
  }
#endif
  mbtalk("SYSTEM", "ALL", "Mailbox shutdown.");
  trace(replog, "logind", "stop V" VNUMMER " " OPSYSTEM " (%s)", stopreason);
  wdelay(447);
#ifndef _AX25K_ONLY
//  int loginpnum;
  for (loginpnum = 1; loginpnum < highestport; loginpnum++)
    closeport_tnc(loginpnum);
  for (loginpnum = 1; loginpnum < highestport; loginpnum++)
  {
    if ((portopen[loginpnum] == p_session)
        || (portopen[loginpnum] == p_connected))
      killport(loginpnum);
  }
  for (loginpnum = 1; loginpnum < highestport; loginpnum++)
    discport_tnc(loginpnum);
#endif
#ifdef _AX25K
    ax25k_shutdown();
#endif
/*  // tracewin() does that
    for (loginpnum = TASKS; loginpnum; loginpnum--)  //neu
    kill(loginpnum);      //neu
*/
  wdelay(347);
  init_off = 1;
}
Esempio n. 19
0
static void near SquishSquashCycle(void)
{
  time_t now=time(NULL);

  S_LogOpen(config.logfile);

  S_LogMsg("+Begin, " SQNAME " v%s (mem=%ldK - main=%p)", version,
           (long)coreleft()/1024L, (void *)main);

  StatsOpen();

#ifdef __MSDOS__
  {
    long coreneeded;
    long left=coreleft() / 1024L;

    coreneeded = outbufmax/1024L + writebufmax/1024L + maxmsglen/1024L;

    #ifdef __FLAT__
      #define MIN_CORE  1000L
      #define ADDED     200L
    #else
      #define MIN_CORE  200L
      #define ADDED     20L
    #endif

    coreneeded=max(MIN_CORE, coreneeded+ADDED);

    if (left < (long)coreneeded && !fRunZCore)
    {
      S_LogMsg("!> Squish may not have enough free memory to");
      S_LogMsg("!> operate properly.  Current heap memory is %ldK,", left);
      S_LogMsg("!> but the suggested value is %ldK.  You can use the", coreneeded);
      S_LogMsg("!> -m switch to force Squish to run anyway using");
      S_LogMsg("!> the current amount of memory, but this is not");
      S_LogMsg("!> suggested.  (To reduce memory requirements, try");
      S_LogMsg("!> using a lower 'Buffers' setting, disabling");
      S_LogMsg("!> Statistics mode, and removing unnecessary areas.)");
      S_LogClose();

      exit(ERL_ERROR);
    }
  }
#endif

/*  S_LogMsg("@SquishSquashCycle Begin - mode=%04xh", mode);*/

  do
  {
    HoleDeinitHole();
    HoleInitHole();

    if (mode & (MODE_scan | MODE_pack))
      HoleScanHole();

    old_emax=erl_max;
    
    erl_max=FALSE;  /* we haven't reached max_msgs on this run (yet) */
  

    /* Toss messages as necessary */

    if (mode==0 || (mode & MODE_toss))
      Toss_Messages(ar.echotoss, old_emax, start);
  
    /* Now handle any separate scanning */

    if ((mode & MODE_scan) && !erl_max)
    {
      word cflag;
      
      /* Remove the ONEPASS bit from the general flags, since even though   *
       * we may have been doing a toss/scan before, now we're just in       *
       * straight scan mode to pick off leftover areas.                     */

      cflag=config.flag;
      config.flag &= ~FLAG_ONEPASS;
      
      Scan_Messages(*ar.echotoss ? ar.echotoss : NULL,
                    ar.action==ACTION_RESCAN ? &ar.n : NULL,
                    start);

/*      S_LogMsg("@AfterScan - mode=%04xh, erlmax=%d, scan_ctr=%ld, max_msgs=%ld",
               (int)mode, (int)erl_max, (long)scan_ctr, (long)config->max_msgs);*/
                  
      config.flag=cflag;
    }

    /* If we've reached a max_msgs situation and we're in a one-pass        *
     * scan/pack environment, pack it here.                                 */

    if (erl_max && (mode & MODE_sp)==MODE_sp)
    {
/*      S_LogMsg("@BeforePack - erlmax=%d", erlmax);*/
      Munge_Outbound_Area(config.routing, ar.sched);
    }
  } while (erl_max && (mode & MODE_sp)==MODE_sp);

  if (mode & MODE_pack)
  {
    if (ar.do_pack)
      Pack_Messages(config.netmail);

    Munge_Outbound_Area(config.routing, ar.sched);
  }

  if (! ar.leave_packets)
    HoleMoveOut();

  HoleDeinitHole();

  if ((mode & MODE_link) && !erl_max)
    Link_Messages(*ar.echotoss ? ar.echotoss : NULL);
  
  StatsClose();

  now=time(NULL)-now;

  if (now==0)
    now=1;

  S_LogMsg("+End.  Toss=%ld (%ld/s), sent=%ld (%ld/s), mem=%ldK",
           nmsg_tossed, nmsg_tossed/now,
           nmsg_sent, nmsg_sent/now,
           (long)coreleft()/1024L);

  S_LogClose();
}
Esempio n. 20
0
void main(int argc,char *argv[])
  {
   double pnt[5][512];//=new double [10000];
   int Row,Col;
//   memf *f=new memf(argv[1],ios::in,"Graphic  points",1);
//   InputArr(*f->mfbuf,(double*)(&pnt),Row,Col,5,512);
   fstream in(argv[1],ios::in);
cout<<coreleft();ChRead();
   InputArr(in,&pnt[0][0],Row,Col,5,512 );
cout<<argv[1]<<"  "<<Row<<"  "<<Col<<"\n";
   if (Row<2) exit(1);
cout<<coreleft();ChRead();

   int graphdrive=DETECT,graphmode;
   initgraph(&graphdrive,&graphmode,"");
   cleardevice();
   setcolor(YELLOW);
   int color=YELLOW;
   GrArr *ar;
   ar=new GrArr(&pnt[0][0],&pnt[1][0],Row);
cout<<coreleft();ChRead();
   GrScr *sum=AxGraph(ar,"X- text","Y - text ");
   sum->LstAdd(ar);
   for (int k=2;k<Col;k++)
    {
     ar=new GrArr(&pnt[0][0],&pnt[k][0],Row);
     ar->PixColor(++color);
     sum->LstAdd(ar);
    }
   Rect Gr=sum->MaxGrDim();
   sum->GrDim(Gr);
   cout<<" Beg to Show\n";ChRead();
   sum->Show();
   ChRead();
   Rect cur=sum->ScrDim();
   sum->ScrDim( ar->BlowRect(cur,ar->CentRect(cur),0.5) );
   ChRead(); //   sum->Hide();
cout<<coreleft();ChRead();
delete sum;
   ChRead();
   closegraph();
cout<<coreleft();ChRead();
  
   graphdrive=DETECT,graphmode;
   initgraph(&graphdrive,&graphmode,"");
   cleardevice();
   setcolor(YELLOW);
   color=YELLOW;
   ar=new GrArr(&pnt[0][0],&pnt[1][0],Row);
cout<<coreleft();ChRead();
   sum=AxGraph(ar,"X- text","Y - text ");
   sum->LstAdd(ar);
   for (k=2;k<Col;k++)
    {
     ar=new GrArr(&pnt[0][0],&pnt[k][0],Row);
     ar->PixColor(++color);
     sum->LstAdd(ar);
    }
   Gr=sum->MaxGrDim();
   sum->GrDim(Gr);
   cout<<" Beg to Show\n";ChRead();
   sum->Show();
   ChRead();
   cur=sum->ScrDim();
   sum->ScrDim( ar->BlowRect(cur,ar->CentRect(cur),0.5) );
   ChRead(); //   sum->Hide();
cout<<coreleft();ChRead();
delete sum;
   ChRead();
   closegraph();
cout<<coreleft();
  };
Esempio n. 21
0
File: Main.c Progetto: bochaqos/tol
/*------------------------------------------------------------------------------

 FUNCTION NAME: Main_Main

 DESCRIPTION: Main application routine

 PARAMETERS:
   - INPUT:

   - OUTPUT:

 RETURN: Nothing

 NOTES:

------------------------------------------------------------------------------*/
void Main_Main (void)
{
t_uchar     Lines[2] = {9,ETC};
unsigned long AuxInitialFreeMemory = 0;

  /* Precalculate Terminal Type */
  (void) Util_GetTerminalType();
 
#if defined (FEDORA_VERSION)
  /* Cleans /etc/rc.local by deleting old MAEL settings */
  /* Util_RemoveIpLinesFromRcLocal(); */
#endif
  
#if defined (NT_VERSION)
  _setcursortype (_NOCURSOR);
  clrscr ();
#endif

  /* Debug */ /*printf ("_stklen = %lu\n", (t_ulong) _stklen); getch (); */
  /* Debug */ /*printf ("stackavail = %lu\n", (t_ulong) stackavail()); getch (); */
  
  /*
  for (;;)
  {
    int Key;
    printf ("%d\n", (Key = getch ()));
    if (Key == '!')
      exit (0);
  }
  */

  /* Debug: Heap test */
  /*
  #if !defined (NT_VERSION)
    printf ("Total memory available before init = %lu bytes\n", (t_ulong) coreleft ());
    getch ();
  #endif
  */
  /* MAEL Version */
  #if defined(FEDORA_VERSION)
    /* TO DO */

  #else

  #if !defined (NT_VERSION)
    /* Gets free memory before initializations */
    AuxInitialFreeMemory = coreleft ();
  #endif

  #endif /* MAEL Version */

  /* Initializtions */
  Main_Init ();

  /* DEBUG Parallel ports */
  /*
  {
    int STATUS;
  
    STATUS = Parallel_SendBuffer (1, "MAMONEZ MAMONEZ MAMONEZ", 23);
    printf("\nSTATUS = %d\n", STATUS);
    getch();
    Main_EndApp ();
    exit (0);
  }
  */
  /* Stores initil free memory in dynamic database */
  DB_GLOBAL_DYNAMIC.DB_INITIAL_FREE_MEMORY = AuxInitialFreeMemory;

  /* Debug: Heap test */
  /*
  #if !defined (NT_VERSION)
    printf ("Total memory available after init  = %lu bytes\n", (t_ulong) coreleft ());
    getch ();
  #endif
  */
  /* Debug */
  /*
  {
    t_uchar KbStatus = 0, Aux = 0;
    t_ushort Idx;
    
    for (;;)
    {
      bioskey (2);
      _asm cli;
      for (Idx = 0; 
           Idx < 1000 &&
           (inportb (0x64) & 0x02); 
           Idx++);
      if (!(inportb (0x64) & 0x02))
        outport (0x64, 0xe0);
      _asm sti;
      _asm cli;
      outport (0x60, 0xee);
      _asm sti;
      delay (100);
      Aux = inportb (0x64);
      if (KbStatus != Aux)
      {
        KbStatus = Aux;
        printf ("0x64 = %x\n", KbStatus);
      }
    }
  }
  for (;;)
  {
    int Mask;
    char Key;
    Mask = inportb (0x0279);
    printf ("%X\n", Mask);
    Key = getch ();
    if (Key == '!')
      exit (0);
  } */ /* endfor */

  /*
  {
    char Buffer[100], str[100];
  
    Buffer[0] = '&';
    Buffer[1] = '%';
    Buffer[2] = 'O';
    Buffer[3] = 'M';
    Buffer[4] = 0x80;
    strcpy (str, "123456789012345678901234567890123456789012345678901234567890");
    Printer_Write (0, (char *) Buffer,  5);
    Printer_Write (0, (char *) str,  strlen (str));
    Printer_LineFeed (0);
    Printer_Write (0, (char *) Buffer,  5);
    Printer_Write (0, (char *) Buffer,  5);
    Printer_Write (0, (char *) Buffer,  5); 
  } */ /* Debug */

#ifdef PC_TERMINAL

  /*size = imagesize (1, 0, 17, 25);
  clearviewport ();
  putpixel(0, 0, WHITE);
  putpixel(1, 0, 1);
  putpixel(1, 1, 1);
  putpixel(10, 11, BLUE);
  putpixel(12, 10, BLUE);
  putpixel(13, 10, WHITE);
  putpixel(14, 10, BLUE);
  putpixel(15, 10, BLUE);
  putpixel(16, 10, WHITE);
  putpixel(17, 10, BLUE);
  getimage (1, 0, 17, 25, image);
  getch ();

  Main_EndApp();
  printf ("image size = %d\n", (int) size);
  for (idx = 0; idx < size; idx++)
    printf ("%02x ", (int) image[idx]);
  return 0;*/

  /* Test printer port */
  /*{ */
    /*outportb (0x037A, inportb (0x037A) | 0x04); */
  /*
    int Key, Mask;
    Key = 0;
    while (Key != '!')
    {
      Mask = biosprint (2, 0, 0);
   */
      /*Mask = inportb (0x0379); */
   /*
      printf ("Printer Status = %x\n", Mask);
      if (Mask & 0x01) printf ("                 Device timeout\n");
      if (Mask & 0x08) printf ("                 I/O error     \n");
      if (Mask & 0x10) printf ("                 Selected      \n");
      if (Mask & 0x20) printf ("                 Out of paper  \n");
      if (Mask & 0x40) printf ("                 Acknowledge   \n");
      if (Mask & 0x80) printf ("                 Not busy      \n");
      if (Mask & 0x01) printf ("                 Device timeout\n");
      if (Mask & 0x01) printf ("                 Device timeout\n");
      printf ("\n! to exit: ");
   */
      /*Mask = inportb (0x037A); */
      /*printf ("Printer Control = %x\n", Mask); */
   /*
      Key = getch ();
   */
      /*if (Key == 'c' || Key == 'C') */
      /*{ */
      /*  outportb (0x0378, 25); */
      /*  outportb (0x037A, inportb (0x037A) | 0x01); */
      /*  outportb (0x037A, inportb (0x037A) & (~0x01)); */
      /*  delay (1); */
      /*  continue; */
      /*} */
/*
    }
    return 0;
  } 
*/

#endif
  
#ifdef STANDALONE_VERSION
  {

  int GameIdx;

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para Standalone Version                              */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL.DB_TERMINAL.OperationMode = OPERATIONMODE_STANDALONE;

  DB_GLOBAL.DB_TERMINAL.TimeZone       = 0;
  DB_GLOBAL.DB_TERMINAL.MaxTicketPrice = 1000000;
  DB_GLOBAL.DB_TERMINAL.AppMinVersion  = 10;
  DB_GLOBAL.DB_TERMINAL.Agency         = 123;
  DB_GLOBAL.DB_TERMINAL.Province       = 51;
  DB_GLOBAL.DB_TERMINAL.AgencyHostId   = 1234567;
  strcpy (DB_GLOBAL.DB_TERMINAL.PhoneNumber, "935408394");
  DB_GLOBAL.DB_TERMINAL.DialMode       = 'T';
  strcpy (DB_GLOBAL.DB_TERMINAL.OwnerName, "CBA DEMO");
  strcpy (DB_GLOBAL.DB_TERMINAL.OwnerAddress, "C. CBA s/n");
  Util_TranslateSpecialChars (DB_GLOBAL.DB_TERMINAL.OwnerAddress);
  strcpy (DB_GLOBAL.DB_TERMINAL.OwnerCityZip, "08320");
  strcpy (DB_GLOBAL.DB_TERMINAL.OwnerPhone, "935550538");
  strcpy (DB_GLOBAL.DB_TERMINAL.CurrencyString, "$");
  DB_GLOBAL.DB_TERMINAL.TicketConfBeforePrint = TRUE;
/*  DB_GLOBAL.DB_TERMINAL.MaxIdleTime    = 15 * 60000; */ /* 15 minutes in msec */
  DB_GLOBAL.DB_TERMINAL.MaxIdleTime    = 0; /* No autologin */

  for (GameIdx = 0; GameIdx < MAX_GAMES; GameIdx++)
  { /* Non zero init. data */
    DB_GLOBAL_DYNAMIC.DB_GAMES.Game[GameIdx].MaxTicketPrice = 100000;
  } /* endfor */

  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames = 0;

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos por juego para Standalone Version                    */
  /*-------------------------------------------------------------------------*/

#if defined (LNSE)
  /* 25-06-03 Duvi Appending Standalone Data on DB_GLOBAL_DYNAMIC for 
     Cucu Game  replacing SUPER8 game. 
     29-07-10 Duvi. Codigo Eliminado. Buscar en SourceSafe como se poblaba la 
     tabla para Super8 o CuCu
  */

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_BORRATINA                                  */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_BORRATINA;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Borratina");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[0].DrawName, "MATUTINO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[1].DrawName, "VESPERTINO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[2].DrawName, "URUGUAY");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[3].DrawName, "NOCTURNO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[4].DrawName, "PRIMERA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 10;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "NACIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].LotteryName, "P. BB.AA.");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].LotteryName, "CORDOBA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].LotteryName, "SANTA FE");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[4].LotteryName, "PIZZI");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[4].BetPrice = 0.5;
  /* RFS 218 - Q10L */
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[5].LotteryName, "EXT 6");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[5].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[6].LotteryName, "EXT 7");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[6].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[7].LotteryName, "EXT 8");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[7].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[8].LotteryName, "EXT 9");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[8].BetPrice = 0.5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[9].LotteryName, "EXT 10");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[9].BetPrice = 0.5;

  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;
  /* End RFS 17 - CUCU */

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_QUINI6                                     */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_QUINI6;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Quini6");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 4;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 3;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].LotteryName, "Premio Extra");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].BetPrice = 0;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].LotteryName, "REVANCHA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].BetPrice = 3;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].LotteryName, "Sale o Sale");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].BetPrice = 3;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_Q6NG                                       */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_Q6NG;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Q6 Perdedoras");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 4;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 3;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].LotteryName, "Premio Extra");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].BetPrice = 0;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].LotteryName, "REVANCHA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].BetPrice = 3;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].LotteryName, "Sale o Sale");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].BetPrice = 3;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_LOTO                                       */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_LOTO;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Loto");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  /*DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 0x8F; 

  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 4;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 2;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].LotteryName, "YAPA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].BetPrice = 0;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].LotteryName, "DESQUITE");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].BetPrice = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].LotteryName, "SOS");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;  

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_QUINIELA                                   */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_QUINIELA;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "La Quiniela");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[0].DrawName, "MATUTINO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[1].DrawName, "VESPERTINO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[2].DrawName, "URUGUAY");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[3].DrawName, "NOCTURNO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[4].DrawName, "SABADO");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].DrawData[5].DrawName, "PRIMERA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 10;
  
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "NACIONAL");
  /* RFS 0913: $0.50 not allowed for Amounts. Min Bet Price is $1 now */
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;

  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].LotteryName, "P. BB.AA.");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].BetPrice = 0;
  
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].LotteryName, "CORDOBA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[2].BetPrice = 0;
  
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].LotteryName, "SANTA FE");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[3].BetPrice = 0;
  
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[4].LotteryName, "PIZZI");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[4].BetPrice = 0;

  /* 01-03-04 Duvi RFS 218 - Q10L - Appending Standalone Data on DB_GLOBAL_DYNAMIC for Q10L.*/
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[5].LotteryName, "EXT6");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[5].BetPrice = 0;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[6].LotteryName, "EXT7");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[6].BetPrice = 0;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[7].LotteryName, "EXT8");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[7].BetPrice = 0;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[8].LotteryName, "EXT9");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[8].BetPrice = 0; 
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[9].LotteryName, "EXT10");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[9].BetPrice = 0;
  /* End. RFS 218 */ 
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_POCEADA                                    */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_POCEADA;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "La Quiniela Poceada");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;
  
  /* RFS 1141 - Leo_20120911_1703
   * Game key definition
   */
  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_TOMBOLINA                                    */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_TOMBOLINA;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "La Tombolina");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 3;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_BRINCO                                     */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_BRINCO;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Brinco");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_PRODE_TRD                                  */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_PRODE_TRD;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Prode Tradicional");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

#if defined (ENABLE_GAME_PRODE_BANCA)
  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_PRODE_BNC                                  */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_PRODE_BNC;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Banca de Prode");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;
#endif

#if defined (ENABLE_GAME_PRODE_RESULTADOS)
  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_PRODE_RSL                                  */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_PRODE_RSL;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Prode Resultados");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;
#endif

#if defined (ENABLE_GAME_PRODE_GOL)
  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_PRODE_GOL                                  */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_PRODE_GOL;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Prode Primer Gol");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;
#endif

#if defined (ENABLE_GAME_TRIFECTA)
  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_TRIFECTA                                   */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_TRIFECTA;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Trifecta");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;
#endif

  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_LOTO5;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "Loto 5");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 2;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 2;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].LotteryName, "PREMIO EXTRA");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[1].BetPrice = 0;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

#if defined (HORSES_GAMES)
  /*-------------------------------------------------------------------------*/
  /* Poblacion de Datos para GAME_HORSES                                     */
  /*-------------------------------------------------------------------------*/
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameType = GAME_HORSES;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameDescription, "HIPICOS");
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].GameAuxName, "TICKET NO VALIDO");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Permissive = 15;
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].NumLotteries = 1;
  strcpy (DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].LotteryName, "TRADICIONAL");
  DB_GLOBAL_DYNAMIC.DB_GAMES.Game[DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames].Lottery[0].BetPrice = 1;
  DB_GLOBAL_DYNAMIC.DB_GAMES.NumGames++;

#endif

#endif

  }

  DB_GLOBAL.DB_TERMINAL.InitializedTerminal = TRUE;

#endif

  /* Infinite loop until exit flag */
  Auto_PushReaderState (READER_DISABLE);
  for (;;)
  {
    DB_GLOBAL_DYNAMIC.DB_MODE_SALE    = FALSE;
    DB_GLOBAL_DYNAMIC.DB_PERM_TICKET  = FALSE;
    DB_GLOBAL_DYNAMIC.DB_PERM_BETSLIP = FALSE;

    GrphText_CursorAttribute (FALSE, LINE_1, FONT_7X5);
    GrphText_Cls (TRUE);
    GrphText_Format (Lines);

#if defined (SCANNER_DEBUG)
    (void) Util_MaintainDebugLog(PDISCAN_DEBUG_LOG, 
                                 CBA_MAX_LOG_SIZE, 
                                 CBA_MIN_LOG_SIZE);
#endif

    /* XPS 22-JUL-2003 */
    /* Inicialize game horses */
    #if defined (HORSES_GAMES)
      Config_InitHorsesEnvironment ();
      Config_InitHorsesGamesList ();
    #endif

    /* User login procedure */
    Display_UserLogin ();

    /* Clear Display */
    GrphText_CursorAttribute (FALSE, LINE_1, FONT_7X5);
    GrphText_Cls (TRUE);

    DB_GLOBAL_DYNAMIC.DB_MODE_SALE = TRUE;
    Display_Cabecera ();
    Auto_ResetReader ();
    Auto_PushReaderState (READER_ENABLE);

    /* Loop in manual module */
    Manual_SetSimKeysState (TRUE);
    Manual_Secuencia();
    Manual_SetSimKeysState (FALSE);

    /* Clears display */
    GrphText_Cls(TRUE);
    Auto_PopReaderState ();

    /* Logout operation */
    Prot_LogInOut (USER_LOGOUT, 0, 0);

  } /* endfor */
  Auto_PopReaderState ();

  Main_EndApp (FALSE, FALSE);

} /* Main_Main */