Example #1
0
static trap_retval DoTrapAccess( trap_elen num_in_mx, in_mx_entry_p mx_in, trap_elen num_out_mx, mx_entry_p mx_out )
{
    uint_8              __far *msgptr;
    unsigned_8          j;
    struct {
        mx_entry16      in;
        mx_entry16      out;
        unsigned_16     retlen;
    }                   __far *callstruct;
    unsigned            len;
    unsigned            copy;

    callstruct = (void __far *)PMData->parmarea;
    msgptr = (void __far *)&callstruct[1];
    callstruct->in.ptr.s.segment = RMData.segm.rm;
    callstruct->in.ptr.s.offset = (unsigned)msgptr - (unsigned)PMData;
    callstruct->in.len = 0;
    for( j = 0; j < num_in_mx; ++j ) {
        _fmemcpy( msgptr, mx_in[j].ptr, mx_in[j].len );
        callstruct->in.len += mx_in[j].len;
        msgptr += mx_in[j].len;
    }

    callstruct->out.len = 0;
    if( mx_out != NULL ) {
        callstruct->out.ptr.s.segment = RMData.segm.rm;
        callstruct->out.ptr.s.offset = (unsigned)msgptr - (unsigned)PMData;
        for( j = 0; j < num_out_mx; ++j ) {
            callstruct->out.len += mx_out[j].len;
        }
    } else {
        callstruct->out.ptr.a = 0;
    }
    GoToRealMode( RMTrapAccess );
    if( callstruct->retlen == (unsigned_16)REQUEST_FAILED ) {
        return( REQUEST_FAILED );
    }
    if( mx_out != NULL ) {
        /* msgptr is pointing at the start of the output buffer */
        j = 0;
        for( len = callstruct->retlen; len != 0; len -= copy ) {
            copy = len;
            if( copy > mx_out[j].len )
                copy = mx_out[j].len;
            _fmemcpy( mx_out[j].ptr, msgptr, copy );
            ++j;
            msgptr += copy;
        }
    } else {
        callstruct->retlen = 0;
    }
    if( TRP_REQUEST( mx_in ) == REQ_CONNECT ) {
        if( ( (connect_ret *)mx_out->ptr )->max_msg_size > MAX_MSG_SIZE ) {
            ( (connect_ret *)mx_out->ptr )->max_msg_size = MAX_MSG_SIZE;
        }
    }
    return( callstruct->retlen );
}
Example #2
0
void alias_streamfrom(char far *p)
{	TAlias *ptr;
	size_t len;
#ifdef DEBUG
	unsigned cnt = 0;
#endif

#ifdef DEBUG_ALIASES
	dbg_outsn("[Alias dump]");
	for(len = 0; len < 4; ++len) {
		dbg_print("%04x ", len * 8);
		for(cnt = 0; cnt < 8; ++cnt)
			dbg_print("%02X ", (unsigned char)p[len * 8 + cnt]);
		dbg_outs("     ");
		for(cnt = 0; cnt < 8; ++cnt) {
			unsigned char ch = (unsigned char)p[len * 8 + cnt];
			if(isprint(ch))
				dbg_outc(ch);
			else dbg_outc('.');
		}
		dbg_outc('\n');
	}
	cnt = 0;
#endif

	last = 0;
	while(*p) {
		/* newly create the alias */
		if((ptr = (TAlias *) malloc(sizeof(TAlias))) == NULL)
			break;

		len = _fstrlen(p) + 1;
		if((ptr->name = malloc(len)) == NULL) {
			free(ptr);
			break;
		}
		_fmemcpy(ptr->name, p, len);
		p += len;

		len = _fstrlen(p) + 1;
		if((ptr->subst = malloc(len)) == NULL) {
			free(ptr->name);
			free(ptr);
			break;
		}
		_fmemcpy(ptr->subst, p, len);
		p += len;

#ifdef DEBUG
		++cnt;
#endif

		if(last)	last = last->next = ptr;
		else		last = first = ptr;
	}
	if(last)		last->next = NULL;
	dprintf(("[KSWAP: %u alias(es) read from dynamic context]\n", cnt));
}
Example #3
0
int exec(const char *cmd, char *cmdLine, const unsigned segOfEnv)
{
#ifdef FEATURE_XMS_SWAP
#	define buf dosCMDTAIL
#	define memcpy _fmemcpy
#else
  unsigned char buf[128];
#endif
  struct fcb fcb1,
    fcb2;
  struct ExecBlock execBlock;
  int retval;


  assert(cmd);
  assert(cmdLine);
  assert(strlen(cmdLine) <= 125);

  invalidateNLSbuf();

  /* generate Pascal string from the command line */
  memcpy(&buf[1], cmdLine, buf[0] = strlen(cmdLine));
  memcpy(&buf[1] + buf[0], "\xd", 2);

  /* fill FCBs */
  if ((cmdLine = parsfnm(cmdLine, &fcb1, 1)) != 0)
    parsfnm(cmdLine, &fcb2, 1);

  saveSession();

#ifdef FEATURE_XMS_SWAP
	if(XMSisactive() && swapOnExec == TRUE) {
		/* Copy the prepared values into the buffers in CSWAP.ASM module */
		_fmemcpy(dosFCB1, &fcb1, sizeof(fcb1));
		_fmemcpy(dosFCB2, &fcb2, sizeof(fcb1));
		assert(strlen(cmd) < 128);
		_fstrcpy(dosCMDNAME, cmd);
		dosParamDosExec.envSeg = segOfEnv; 

		retval = XMSexec();
		} else
#endif
	{
	  /* fill execute structure */
	  execBlock.segOfEnv = segOfEnv;
	  execBlock.cmdLine = (char far *)buf;
	  execBlock.fcb1 = (struct fcb far *)&fcb1;
	  execBlock.fcb2 = (struct fcb far *)&fcb2;

	  retval = lowLevelExec((char far*)cmd, (struct ExecBlock far*)&execBlock);
	}

  restoreSession();
				
  return decode_exec_result(retval);
}
Example #4
0
/*-------
 * ParseAttributes
 *
 *	Description:	Parse attribute string moving values into the aAttr array
 *	Input	 :	lpszAttributes - Pointer to attribute string
 *	Output	 :	None (global aAttr normally updated)
 *-------
 */
void		INTFUNC
ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg)
{
	LPCSTR		lpsz;
	LPCSTR		lpszStart;
	char		aszKey[MAXKEYLEN];
	int			cbKey;
	char		value[MAXPGPATH];

	CC_conninfo_init(&(lpsetupdlg->ci));

	for (lpsz = lpszAttributes; *lpsz; lpsz++)
	{
		/*
		 * Extract key name (e.g., DSN), it must be terminated by an
		 * equals
		 */
		lpszStart = lpsz;
		for (;; lpsz++)
		{
			if (!*lpsz)
				return;			/* No key was found */
			else if (*lpsz == '=')
				break;			/* Valid key found */
		}
		/* Determine the key's index in the key table (-1 if not found) */
		cbKey = lpsz - lpszStart;
		if (cbKey < sizeof(aszKey))
		{
			_fmemcpy(aszKey, lpszStart, cbKey);
			aszKey[cbKey] = '\0';
		}

		/* Locate end of key value */
		lpszStart = ++lpsz;
		for (; *lpsz; lpsz++)
			;

		/* lpsetupdlg->aAttr[iElement].fSupplied = TRUE; */
		_fmemcpy(value, lpszStart, MIN(lpsz - lpszStart + 1, MAXPGPATH));

		mylog("aszKey='%s', value='%s'\n", nullcheck(aszKey), nullcheck(value));

		/* Copy the appropriate value to the conninfo  */
		if (!copyAttributes(&lpsetupdlg->ci, aszKey, value))
			copyCommonAttributes(&lpsetupdlg->ci, aszKey, value);
	}
	return;
}
///////////////////////////////////////////////////////////////////////////
//
//      US_TextScreen() - Puts up the startup text screen
//      Note: These are the only User Manager functions that can be safely called
//              before the User Mgr has been started up
//
///////////////////////////////////////////////////////////////////////////
void
US_TextScreen(void)
{
	word    i,n;

	USL_ClearTextScreen();

	_fmemcpy(MK_FP(0xb800,0),7 + &introscn,80 * 25 * 2);

	// Check for TED launching here
	for (i = 1;i < _argc;i++)
	{
		n = US_CheckParm(_argv[i],ParmStrings);
		if (n == 0)
		{
			tedlevelnum = atoi(_argv[i + 1]);
			if (tedlevelnum >= 0)
			{
				tedlevel = true;
				return;
			}
			else
				break;
		}
		else if (n == 1)
		{
			NoWait = true;
			return;
		}
	}
}
Example #6
0
void Alph_In(int *num, int max_len, int x, int y, alph *font) {
int column, index, c;
int *columns;
char temp;
unsigned char far **source;

  *num=0;
  columns=new int [max_len];
  max_len--;
  index=0;
  columns[index]=x;
  while ((temp=getch())!=13) {  // 13=enter
    if (temp==27) { // 27=esc. Clear line.
      Draw_Box(x,y,columns[index]-x,font->height,255);
      index=0;
      columns[index]=x;
    } else if (temp==8) { // 8=backspace
      index--;
      if (index<0) index=0;
      Draw_Box(columns[index],y,columns[index+1]-columns[index],font->height,255);
    } else if (index<=max_len) {
      if ((temp>='0')&&(temp<='9'))
        if ((*num*10)<(MAXINT-10)) {
          source=font->numbers[temp-'0'];
          for (c=0;c<font->height;c++)
            _fmemcpy(&screen[columns[index]+((y+c)<<8)+((y+c)<<6)],&source[c][1],source[c][0]);
          columns[index+1]=columns[index]+source[0][0]+1;
          *num=*num*10+temp-'0';
          index++;
        }
    }
  }
  delete columns;
}
Example #7
0
VOIDPTR HFMemCopy(VOIDPTR pDest, VOIDPTR pSrc, DWORD dwNBytes)
{
  BYTEPTR pByteDest;
  BYTEPTR pByteSrc;

  pByteDest = (BYTEPTR)pDest;
  pByteSrc =  (BYTEPTR)pSrc;

  VOIDPTR theReturn = (VOIDPTR)(pByteDest[dwNBytes]);
  DWORD count = 0;
  size_t theMemCpySize;
  while (dwNBytes != 0)
  {
   if (dwNBytes > 0xFFFF)
     theMemCpySize = 0xFFFF;
   else
     theMemCpySize = (size_t)dwNBytes;
   if (_fmemcpy(&pByteDest[count*0x10000], &pByteSrc[count*0x10000], theMemCpySize) == NULL)
     return NULL;
   dwNBytes -= theMemCpySize;
   count++;
  }
  return theReturn;

}
Example #8
0
void Alph_Write(int num, int x, int y, alph *font) {
char c;
int column;
char power;
int digit;
unsigned char far **source;

  digit=0;
  column=x;
  power=0;
  digit=num;
  while (digit>=10) {
    power++;
    digit=digit/10;
  }
  while (power>=0) {
    digit=num/pow(10,power);
    source=font->numbers[digit];
    for (c=0;c<font->height;c++)
      _fmemcpy(&screen[column+((y+c)<<8)+((y+c)<<6)],&source[c][1],source[c][0]);
    column+=source[0][0]+1;
    num-=(digit*pow(10,power));
    power--;
  }
}
Example #9
0
void GUImain( void )
{
#if defined(__OSI__) || __WATCOMC__ < 1000
    {
    long    result;

#if defined(__OSI__)
    _Extender = 1;
#endif
    result = DPMIAllocateLDTDescriptors( 1 );
    if( result < 0 ) {
        StartupErr( LIT( Unable_to_get_rm_sel ) );
    }
    _ExtenderRealModeSelector = result & 0xffff;
    if( DPMISetSegmentLimit( _ExtenderRealModeSelector, 0xfffff ) ) {
        StartupErr( LIT( Unable_to_get_rm_sel ) );
    }
    }
#endif
    SaveOrigVectors();
    Orig28.a = MyGetRMVector( 0x28 );

    RMData.a = DPMIAllocateDOSMemoryBlock( _NBPARAS( RMSegEnd - RMSegStart ) );
    if( RMData.s.pm == 0 ) {
        StartupErr( LIT( Unable_to_alloc_DOS_mem ) );
    }
    PMData = MK_FP( RMData.s.pm, 0 );
    _fmemcpy( PMData, RMSegStart, RMSegEnd - RMSegStart );
    if( _osmajor == 2 ) {
        PMData->fail = 0;
    } else {
        PMData->fail = 3;
    }
    DebugMain();
}
Example #10
0
void Session::draw( void ) {

  was_updated = 0;


  // We start from the bottom of the screen and calculate where the top of
  // the screen is.  If we have a partial line of output on the bottom
  // of the screen we need to make it look like the bottom of the screen
  // is one line lower in the virtual buffer so that we display the
  // partial line.

  int16_t start_y = output_y;
  if ( output_x ) start_y++;


  int16_t topRow = start_y - Screen::outputRows - backScrollOffset;
  if ( topRow < 0 ) topRow += virtBufferRows;

  uint8_t far *startAddr = (uint8_t far *)virtBuffer + (topRow*BYTES_PER_ROW);

  uint8_t far *screenBase = Screen::screenBase;

  for ( uint16_t i=0; i < Screen::outputRows; i++ ) {
    _fmemcpy( screenBase, startAddr, BYTES_PER_ROW );
    screenBase += BYTES_PER_ROW;
    startAddr += BYTES_PER_ROW;

    if ( (topRow + i) == (virtBufferRows - 1) ) {
      // Wrapped
      startAddr = (uint8_t far *)virtBuffer;
    }
  }

}
Example #11
0
void EnumItemsFromBottom(BOOL (*fn)(LPBRTABLE, LPSTR), LPSTR lpData)
{
    BRDATA lpBrData = (BRDATA) GLOBALLOCK(hClBrData);
    LPBRTABLE lpBrowser = (LPBRTABLE) GLOBALLOCK(lpBrData->hBrowser);
    
	LPBRTABLE lpLevel;
    LEVEL_TYPE level = lpBrData->lDepth;

	while (level >= lpBrData->lFocusedLevel &&
           FindLevel_BrTable(lpBrowser, level--, &lpLevel, FALSE)) {
        WORD wCount = LEVELCOUNT((lpLevel - SIZE_BRLEVEL));
        WORD wLevelSize = lpBrData->sItemSize * wCount;
        GLOBALHANDLE hCopy = GLOBALALLOC(GHND, wLevelSize);
        
        if (hCopy)
        {
            LPBRTABLE lpItem = GLOBALLOCK(hCopy);

            _fmemcpy(lpItem, lpLevel, wLevelSize);
            while (wCount--) {
                (*fn)(lpItem, lpData);
                lpItem = MOVE_TO_NEXT_ITEM(lpItem, lpBrData->sItemSize);
            }
            
            GLOBALUNLOCK(hCopy);
            GLOBALFREE(hCopy);
        }
        else
            break;
    }

    GLOBALUNLOCK(lpBrData->hBrowser);
    GLOBALUNLOCK(hClBrData);
}
Example #12
0
/***********************************************************************
* 
*	Save the old Signals
*
************************************************************************/
void SaveOldSigs(OBJDCLASS *objd, int *nOldSigs, SIGNALINFO **lpOldSigs)
	{
	objd->sigs->CheckSignals();
	*nOldSigs = objd->sigs->m_nUserSignals;
	*lpOldSigs = (SIGNALINFO *)new char[sizeof(SIGNALINFO) * (objd->sigs->m_nUserSignals)];
	_fmemcpy((LPSTR)*lpOldSigs, (LPSTR)objd->sigs->m_userSignals, *nOldSigs * sizeof(SIGNALINFO));
	}
Example #13
0
VBoolean UUEXPORT UUVBClipFile(
HWND owner,							// New owner of clipboard
const char *tfile)					// Text file to put on clipboard
{
	HGLOBAL mh = NULL;
	char _huge *mp = NULL;
	char wrk[1024];
	FILE *inf = NULL;
	long fsize;
	unsigned int block;
	VBoolean rc = VBFALSE;
	
if ((inf = fopen(tfile, "rb")) == NULL)
	return(VBFALSE);				// Couldn't get the source file
	
if ((fsize = _filelength(_fileno(inf))) <= 0 ||	// Couldn't open clipboard
   (mh = GlobalAlloc(GMEM_MOVEABLE, fsize + 10)) == NULL ||		// Couldn't allocate memory
   (mp = GlobalLock(mh)) == NULL) 	// No lock
	goto emex;
	
while (fsize > 0) {
	block = (fsize > sizeof(wrk)) ? sizeof(wrk) : (unsigned int) fsize;
	if (fread(wrk, sizeof(char), block, inf) != block)
		goto emex;					// Couldn't read the block
	_fmemcpy(mp, wrk, block);		// Copy it
	mp += block;					// Point to next memory dest
	fsize -= block;
	}
	
*mp = EOS;							// The last char is always a null

GlobalUnlock(mh);
mp = NULL;							// Unlock the block so we can put it on the clipboard

if (OpenClipboard(owner) == 0)
	goto emex;						// Couldn't prep the clipboard
	
if (EmptyClipboard() == 0 ||		// Couldn't empty it
   SetClipboardData(CF_TEXT, mh) == NULL) {		// Couldn't set the new data
	CloseClipboard();
	goto emex;
	}
	
CloseClipboard();

rc = VBTRUE;						// OK!

emex:

if (mp != NULL)
	GlobalUnlock(mh);				// Have to unlock

if (!rc && mh != NULL)
	GlobalFree(mh);					// Error---free the memory
	
fclose(inf);

return(rc);
}
Example #14
0
static void HugeMemCopy( void __far *dst, void __far *src, unsigned bytes )
{
    long                offset, selector;
    long                bytes_before_segment_end;

    offset = FP_OFF( dst );
    selector = FP_SEG( dst );
    bytes_before_segment_end = 0x10000L - offset;
    if( bytes_before_segment_end < bytes ) {
        _fmemcpy( dst, src, bytes_before_segment_end );
        bytes -= bytes_before_segment_end;
        selector += HUGE_SHIFT;
        dst = MK_FP( selector, 0 );
        src = (char *)src + bytes_before_segment_end;
    }
    _fmemcpy( dst, src, bytes );
}
Example #15
0
//--------------------------------------------------------------------------
//
//      HMA::copy.
//
//      Copy a block from the HMA to conventional memory.
//
unsigned HMA::copy (void far* to, const HMAptr& from, unsigned len)
{
    if (!from.hma->valid())
        return 0;
    if (len > from.hma->size() - from.offset)
        len = from.hma->size() - from.offset;
    _fmemcpy (to, MK_FP (0xFFFF, 0x0010 + from.offset), len);
    return len;
}
Example #16
0
//--------------------------------------------------------------------------
//
//      HMA::copy.
//
//      Copy a block from conventional memory to the HMA.
//
unsigned HMA::copy (const HMAptr& to, void far* from, unsigned len)
{
    if (!to.hma->valid())
        return 0;
    if (len > to.hma->size() - to.offset)
        len = to.hma->size() - to.offset;
    _fmemcpy (MK_FP (0xFFFF, 0x0010 + to.offset), from, len);
    return len;
}
Example #17
0
VOID DeleteVertex(LEVEL_DATA *pLevel, INT nIndex)
{
  INT i, j, n;
  POLYGON huge *p;

  if (nIndex < pLevel->nVertices - 1)
  {
    for(i = nIndex; i < pLevel->nVertices - 1; ++i)
    {
      _fmemcpy( pLevel->pVertexData + i,
                pLevel->pVertexData + i + 1,
                sizeof(VERTEX) );
    }

    //
    //  Adjust the polygon vertex offsets.
    //

    p = pLevel->pPolygonData;

    for(i = 0; i < pLevel->nPolygons; ++i)
    {
      n = (p->flags & 7) + 3;

      for(j = 0; j < n; ++j)
      {
        if (p->vertices[j] == nIndex)
        {
          MsgBox( hwndMDIClient,
                  MB_ICONEXCLAMATION,
                  "Vertex deleted while still in use! (Yes, this means something is really f'd up!)" );
        }
        else if (p->vertices[j] > nIndex)
        {
          --p->vertices[j];
        }
      }

      ++p;
    }
  }

  //
  //  Zero the empty vertex.
  //

  --pLevel->nVertices;

  _fmemset(pLevel->pVertexData + pLevel->nVertices, 0, sizeof(VERTEX));

  pLevel->bRebuildZone = TRUE;

  return;

} // DeleteVertex
Example #18
0
void restoreSession(void)
{
	assert(ctxt == 0);
	if(ctxtSavePtr) {
		dprintf(("[MEM: restore context: %u bytes]\n", ctxtSavedSize));
		ctxtCreateMemBlock(ctxtSavedSize);
		_fmemcpy( MK_FP(ctxt,0), ctxtSavePtr, ctxtSavedSize);		
		free(ctxtSavePtr);
		ctxtSavePtr = 0;
	}
}
Example #19
0
void FAR * _fmemmove(void FAR *dest, void FAR *src, size_t count)
{
      void FAR *target =  dest;
      FarBytePtr to = (FarBytePtr)dest, from = (FarBytePtr)src;

      if (src >= dest)
            _fmemcpy(dest, src, count);
      else  for (to += count, from += count; count; --count)
                  *--to = *--from;
      return target;
}
Example #20
0
BOOL NewVertex(LEVEL_DATA *pLevel, LONG x, LONG y, LONG z)
{
  INT nIndex;
  VERTEX vertex;
  VERTEX huge *p;

  if (pLevel->nVertices == MAX_NUM_VERTICES)
  {
    MsgBox( hwndMDIClient,
            MB_ICONEXCLAMATION,
            "Out of vertex data space" );

    return FALSE;
  }

  _fmemset(&vertex, 0, sizeof(VERTEX));

  vertex.flags = 0;
  vertex.x = (float)x;
  vertex.y = (float)y;
  vertex.z = (float)z;
  vertex.group_index = -1;
  vertex.sprite_index = -1;
  vertex.noise_index = -1;
  vertex.lifeform_index = -1;
  vertex.item_index = -1;
  vertex.trigger_index = -1;

  //
  //  If we already have that vertex then just make sure it isn't hidden.
  //

  nIndex = FindVertex(pLevel, 0, &vertex);

  if (nIndex != -1)
  {
    p = pLevel->pVertexData + nIndex;
    p->flags &= ~VF_HIDDEN;
    return TRUE;
  }

  //
  //  Record the new vertex.
  //

  _fmemcpy(pLevel->pVertexData + pLevel->nVertices, &vertex, sizeof(VERTEX));

  ++pLevel->nVertices;

  pLevel->bRebuildZone = TRUE;

  return TRUE;

} // NewVertex
Example #21
0
void Grab_Alph(char type, pcx_picture *source, alph *alphabet, char index, int x1,int y1,int width) {
// At this point the data is simply copied with no transparences. This will
// require major change eventualy, but for a routine writen under duress,
// you can't ask too much.
char c, len, longest;
unsigned char far **buffer;
unsigned char far **dest;

  buffer=new unsigned char far * [alphabet->height];
  for (c=0;c<alphabet->height;c++)
    buffer[c]=new unsigned char far [width+1];

  longest=0;

  for (c=0;c<alphabet->height;c++) {                 // dump char to buffer.
    _fmemcpy(buffer[c],&source->image[(y1+c)*320+x1],width);
    len=width-1;
    while (buffer[c][len]==0) len--;   // count 0s from end so that I and W
    len++;                           // and the like can be different sized.
    if (len>longest) longest=len;
  }

  switch (type) {
    case 0:       dest=alphabet->upper[index];
                  break;
    case 1:       dest=alphabet->lower[index];
                  break;
    case 2:       dest=alphabet->numbers[index];
                  break;
    case 3:       dest=alphabet->other[index];
  }
  for (c=0;c<alphabet->height;c++) {
    dest[c]=new unsigned char far [longest+1];
    dest[c][0]=longest;
    _fmemcpy(&dest[c][1],buffer[c],longest);
  }

  for (c=0;c<alphabet->height;c++)
    delete buffer[c];
  delete buffer;
}
Example #22
0
void Save_Behind(sprite *pict) {
unsigned char far *background, far *offset, far *endline, far *workback;

  workback=pict->behind;
  endline=screen+((pict->y+pict->ysize)<<8)+((pict->y+pict->ysize)<<6)+pict->x;

  for (offset=screen+(pict->y<<8)+(pict->y<<6)+pict->x;
      offset<endline;offset+=320) {
    _fmemcpy(workback, offset, pict->xsize);
    workback+=pict->xsize;
  }
}
Example #23
0
char *_fdupstr(const char far * const s)
{	size_t len;
	char *p;

	chkHeap
	if((p = malloc(len = _fstrlen(s) + 1)) == 0)
		return 0;
	_fmemcpy(TO_FP(p), s, len);

	chkHeap
	return p;
}
Example #24
0
File: Map.c Project: mike2718/WinVi
PMAP DupMapping(PMAP m)
{	PMAP n;

	if ((n = calloc(1, sizeof(*n))) == NULL) return (NULL);
	AllocStringA(&n->Name, m->Name);
	AllocStringA(&n->InputDisplay, m->InputDisplay);
	AllocStringA(&n->Replace, m->Replace);
	n->ReplaceMap = _fcalloc(lstrlen((PSTR)m->ReplaceMap) + 2, 1);
	if (n->ReplaceMap != NULL)
		_fmemcpy(n->ReplaceMap, m->ReplaceMap, lstrlen((LPSTR)m->ReplaceMap)+2);
	n->InputMatch = _fcalloc(lstrlen((PSTR)m->InputMatch) + 2, 1);
	if (n->InputMatch != NULL)
		_fmemcpy(n->InputMatch, m->InputMatch, lstrlen((LPSTR)m->InputMatch)+2);
	n->Flags = m->Flags;
	if (n->Name == NULL || n->InputDisplay == NULL || n->Replace	== NULL
						|| n->InputMatch   == NULL || n->ReplaceMap	== NULL) {
		FreeMappings(n);
		return (NULL);
	}
	return (n);
}
Example #25
0
/*
 * GetDebugInterruptData:
 *
 * called by someone to find out if the fault they got was a 32-bit fault.
 * If it was a 32-bit fault, then the register data is copied into a
 * specified data area.
 *
 * This routine must be followed by a DoneWithInterrupt call, otherwise
 * the INT1/INT3 IDT hooks will not be restored.
 */
int FAR PASCAL GetDebugInterruptData( LPVOID data )
{
    if( !OurOwnInt ) {
        return( false );
    }
    if( data != NULL ) {
        _fmemcpy( data, &SaveEAX, sizeof( interrupt_struct ) );
    }
    IntAccessed++;
    return( true );

} /* GetDebugInterruptData */
Example #26
0
VOID DeletePolygon(LEVEL_DATA *pLevel, INT nIndex)
{
  INT i;
  POLYGON huge *p;

  if (nIndex < pLevel->nPolygons - 1)
  {
    for(i = nIndex; i < pLevel->nPolygons - 1; ++i)
    {
      _fmemcpy( pLevel->pPolygonData + i,
                pLevel->pPolygonData + i + 1,
                sizeof(POLYGON) );
    }

    //
    //  Adjust the polygon links.
    //

    p = pLevel->pPolygonData;

    for( i = 0; i < pLevel->nPolygons; ++i )
    {
      if (p->flags & PF_LINKED)
      {
        if (p->polygon_link == nIndex)
        {
          MsgBox( hwndMDIClient,
                  MB_ICONEXCLAMATION,
                  "Polygon deleted while still in use!" );
        }
        else if (p->polygon_link > nIndex)
        {
          --p->polygon_link;
        }
      }

      ++p;
    }
  }

  //
  //  Zero the empty vertex.
  //

  --pLevel->nPolygons;

  _fmemset(pLevel->pPolygonData + pLevel->nPolygons, 0, sizeof(POLYGON));

  pLevel->bRebuildZone = TRUE;

  return;

} // DeletePolygon
Example #27
0
static void AppendMenuItemW(INT MenuGroup, PWSTR pString)
{	LPPOPUPLIST NewItem;

	if (PopupInUse+1 /*NULL element at end*/ >= PopupAllocated) {
		LPLPPOPUPLIST np;

		if ((np = _fcalloc(PopupAllocated+100, sizeof(LPPOPUPLIST))) == NULL)
			return;
		if (PopupInUse) {
			_fmemcpy(np, PopupList, PopupInUse*sizeof(LPPOPUPLIST));
			_ffree(PopupList);
		}
		PopupList = np;
		PopupAllocated += 100;
	}
	NewItem = _fcalloc(1, sizeof(POPUPLIST) + wcslen(pString)*sizeof(WCHAR));
	if (NewItem != NULL) {
		int i;

		wcscpy(NewItem->Name, pString);
		if ((i = wcslen(pString)) > MaxLen) MaxLen = i;
		NewItem->MenuGroup = (BYTE)MenuGroup;
		/*binary array search...*/
		{	int i, d;

			if (PopupInUse) {
				BOOL Less;

				for (d=PopupInUse-1; d & (d-1); d &= d-1);
				/*d = largest power of 2 less than PopupInUse*/
				i = d;
				if (i) i += i-1;
				for (;;) {
					Less = i < PopupInUse
						   && ( PopupList[i]->MenuGroup <  MenuGroup ||
							   (PopupList[i]->MenuGroup == MenuGroup
								&& lstrcmpiW(PopupList[i]->Name, pString) < 0));
					if (Less) i += d;
					else i -= d;
					if (!d) break;
					d >>= 1;
				}
				if (Less) ++i;
			} else i = 0;
			if (i < PopupInUse)
				_fmemmove(PopupList+i+1, PopupList+i,
						  (PopupInUse-i)*sizeof(LPPOPUPLIST));
			assert(i >= 0);
			assert(i < PopupAllocated);
			++PopupInUse;
			PopupList[i] = NewItem;
		}
Example #28
0
/*
 * DoneWithInterrupt:
 *
 * called when someone is done handling a 32-bit fault.  The registers
 * are copied back to the data area for reloading by WDEBUG.386, and
 * the IDT is reset to point at our int1/3 handler.
 */
void FAR PASCAL DoneWithInterrupt( LPVOID data )
{
    if( data != NULL ) {
        _fmemcpy( &SaveEAX, data, sizeof( interrupt_struct ) );
    }
    IntAccessed--;
    if( IntAccessed <= 0 ) {
        IDTInit( IDTSel );
        HookIDT( ReflectInt1Int3 );
        OurOwnInt = false;
    }

} /* DoneWithInterrupt */
Example #29
0
//--------------------------------------------------------------------------
//
//      HMA::copy.
//
//      Copy a block from one offset in the HMA to another.  The two
//      blocks should not overlap.
//
unsigned HMA::copy (const HMAptr& to, const HMAptr& from, unsigned len)
{
    if (!to.hma->valid() || !from.hma->valid())
        return 0;
    if (len > to.hma->size() - to.offset)
        len = to.hma->size() - to.offset;
    if (len > from.hma->size() - from.offset)
        len = from.hma->size() - from.offset;
    _fmemcpy (MK_FP (0xFFFF, 0x0010 + to.offset),
              MK_FP (0xFFFF, 0x0010 + from.offset),
              len);
    return len;
}
Example #30
0
int mkPhysDir(int dr, char *path)
/* make physical path, that means, that for drive dr any SUBST/JOIN must
   be broken for mkdir
   dr: 0 == A:
   path: to make
*/
{	CDS hdir, FAR*dir;
	int err, reSubst;
	unsigned joined;
	
	if((dir = cds(dr)) == NULL)
		fatal(E_cds, buf[0]);

	if(0 != (reSubst = (dir->flags & (SUBST | JOIN)))) {
		int oldCreatDir;
		char buf[sizeof(dummyDrvA)];

		*strcpy(buf, dummyDrvA) += dr;
		oldCreatDir = creatDir;
		creatDir = 0;	/* prevent from reEnter */
		chkStruc(nrJoined);
		joined = *nrJoined;

		_fmemcpy(&hdir, dir, sizeof(hdir));	/* keep old CDS entry */

		switchSubst(dr, buf, 0);	/* log -> phys Mapping */
		creatDir = oldCreatDir;
	}

	/* now: logical dr points to physical dr */
	err = mkDir(dr, path, creatDir == 2);

	if(reSubst) {
		*nrJoined = joined;	/* CDS restaurieren */
		_fmemcpy(dir, &hdir, sizeof(hdir));
	}
	return err;
}