Ejemplo n.º 1
0
bool
GIFLoad::InitFrame(int codeSize)
{
	fCodeSize = codeSize;
	if (fCodeSize == 1)
		fCodeSize++;

	fBits = fCodeSize + 1;
	fClearCode = 1 << fCodeSize;
	fEndCode = fClearCode + 1;
	fNextCode = fClearCode + 2;
	fMaxCode = (1 << fBits) - 1;

	fPass = 0;

	if (fInterlaced)
		fRow = gl_pass_starts_at[0];
	else
		fRow = 0;

	fBitCount = 0;
	fBitBuffer = 0;
	fByteCount = 0;
	fOldCodeLength = 0;
	fNewCode = 0;
	fScanlinePosition = 0;

	ResetTable();
	return true;
}
Ejemplo n.º 2
0
void MainExitServer()
{
	lprintf("ExitServer terminating server\n");
	
	ExitAsyncConnections();
	
	CloseAllSessions(); /* gotta do this before anything, cause it uses kod, accounts */
	
	CloseDefaultChannels();
	
	ResetLoadMotd();
	ResetLoadBof();
	
	ResetTable();
	ResetBufferPool();
	ResetSysTimer();
	ResetDLlist();
	ResetNameID();
	ResetAccount();
	ResetUser();
	ResetString();
	ResetRoomData();
	ResetResource();
	ResetTimer();
	ResetList();
	ResetObject();
	ResetMessage();
	ResetClass();
	
	ResetConfig();
	
	DeleteAllBlocks();
}
Ejemplo n.º 3
0
void TOrdEntryForm::ResetForm()
{
  if (ResetTable()) {
    TransferFromDataList(OvcVirtualListbox1->ItemIndex, TR);
    TransferToForm();
    UpdateTable();
    RecState = rsEdit;
  }
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
void __fastcall TOrdEntryForm::LastButtonClick(TObject *Sender)
{
  if (OvcVirtualListbox1->NumItems > 0) {
    if (ResetTable()) {
      UpdateIfModified();
      OvcVirtualListbox1->ItemIndex--;
      MoveToRecord(OvcVirtualListbox1->ItemIndex, TR);
    }
  }
}
Ejemplo n.º 5
0
//---------------------------------------------------------------------------
void __fastcall TOrdEntryForm::OvcNotebook1PageChange(TObject *Sender,
  int Index, bool &AllowChange)
{
  AllowChange = true;
  if (Index == 0) {
    if (InvalidRecord()) {
      AllowChange = WillNotSave() && ResetTable();
      if (AllowChange) {
        InsertHotkey1->Enabled = true;
        DeleteHotkey1->Enabled = true;
        RecState = rsDefault;
      }
    }
    else {
      AllowChange = ResetTable();
      if (AllowChange) {
        InsertHotkey1->Enabled = true;
        DeleteHotkey1->Enabled = true;
        UpdateIfModified();
      }
    }
  }
  if (OvcNotebook1->PageIndex == 0) {
    InsertHotkey1->Enabled = false;
    DeleteHotkey1->Enabled = false;
    if (OvcVirtualListbox1->NumItems > 0 && RecState != rsNew) {
      TransferFromDataList(OvcVirtualListbox1->ItemIndex, TR);
      TransferToForm();
      RecState = rsEdit;
    }
    else {
      InitOrderFormTransfer(TR);
      TransferToForm();
      RecState = rsNew;
    }
  }
}
Ejemplo n.º 6
0
bool
GIFLoad::ReadGIFImageData()
{
	unsigned char newEntry[ENTRY_COUNT];
	unsigned char codeSize;
	if (fInput->Read(&codeSize, 1) < 1)
		return false;

	if (codeSize > fPalette->size_in_bits) {
		if (debug) {
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - "
				"Code_size should be %d, not %d, allowing it\n",
				fCodeSize, codeSize);
		}
		if (!InitFrame(codeSize))
			return false;
	} else if (codeSize < fPalette->size_in_bits) {
		if (debug) {
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - "
				"Code_size should be %d, not %d\n", fCodeSize, codeSize);
		}
		return false;
	} else if (!InitFrame(fPalette->size_in_bits))
		return false;

	if (debug)
		syslog(LOG_INFO, "GIFLoad::ReadGIFImageData() - Starting LZW\n");

	while ((fNewCode = NextCode()) != -1 && fNewCode != fEndCode) {
		if (fNewCode == fClearCode) {
			ResetTable();
			fNewCode = NextCode();
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1))
				goto bad_end;

			if (fNewCode == -1 || fNewCode == fEndCode) {
				if (debug) {
					syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - "
						"Premature fEndCode or error reading fNewCode\n");
				}
				goto bad_end;
			}
			continue;
		}

		// explicitly check for lack of clear code at start of file
		if (fOldCodeLength == 0) {
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1))
				goto bad_end;

			continue;
		}

		// error out if we're trying to access an out-of-bounds index
		if (fNextCode >= ENTRY_COUNT)
			goto bad_end;

		if (fTable[fNewCode] != NULL) {
			// exists in table

			if (!OutputColor(fTable[fNewCode], fEntrySize[fNewCode]))
				goto bad_end;

			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (unsigned int x = 0; x < fOldCodeLength; x++)
				newEntry[x] = fOldCode[x];

			//memcpy(newEntry + fOldCodeLength, fTable[fNewCode], 1);
			newEntry[fOldCodeLength] = fTable[fNewCode][0];
		} else {
			// does not exist in table

			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (unsigned int x = 0; x < fOldCodeLength; x++)
				newEntry[x] = fOldCode[x];

			//memcpy(newEntry + fOldCodeLength, fOldCode, 1);
			newEntry[fOldCodeLength] = fOldCode[0];

			if (!OutputColor(newEntry, fOldCodeLength + 1))
				goto bad_end;
		}
		fTable[fNextCode] = MemblockAllocate(fOldCodeLength + 1);
		if (fTable[fNextCode] == NULL)
			goto bad_end;

		//memcpy(fTable[fNextCode], newEntry, fOldCodeLength + 1);
		for (unsigned int x = 0; x < fOldCodeLength + 1; x++)
			fTable[fNextCode][x] = newEntry[x];

		fEntrySize[fNextCode] = fOldCodeLength + 1;

		//memcpy(fOldCode, fTable[fNewCode], fEntrySize[fNewCode]);
		for (int x = 0; x < fEntrySize[fNewCode]; x++)
			fOldCode[x] = fTable[fNewCode][x];

		fOldCodeLength = fEntrySize[fNewCode];
		fNextCode++;

		if (fNextCode > fMaxCode && fBits < LZ_MAX_BITS) {
			fBits++;
			fMaxCode = (1 << fBits) - 1;
		}
	}

	MemblockDeleteAll();
	if (fNewCode == -1)
		return false;

	if (debug)
		syslog(LOG_INFO, "GIFLoad::ReadGIFImageData() - Done\n");

	return true;

bad_end:
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Reached a bad end\n");

	MemblockDeleteAll();
	return false;
}
Ejemplo n.º 7
0
bool
GIFLoad::ReadGIFImageData() 
{
	unsigned char newEntry[4096];
	
	unsigned char cs;
	fInput->Read(&cs, 1);
	if (cs == fPalette->size_in_bits) {
		if (!InitFrame(fPalette->size_in_bits))
			return false;
	} else if (cs > fPalette->size_in_bits) {
		if (debug)
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Code_size should be %d, not "
				"%d, allowing it\n", fCodeSize, cs);
		if (!InitFrame(cs))
			return false;
	} else if (cs < fPalette->size_in_bits) {
		if (debug)
			syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Code_size should be %d, not "
				"%d\n", fCodeSize, cs);
		return false;
	}
	
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Starting LZW\n");
	
	while ((fNewCode = NextCode()) != -1 && fNewCode != fEndCode) {
		if (fNewCode == fClearCode) {
			ResetTable();
			fNewCode = NextCode();
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1)) goto bad_end;
			if (fNewCode == -1 || fNewCode == fEndCode) {
				if (debug)
					syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Premature fEndCode "
						"or error\n");
				goto bad_end;
			}
			continue;
		}
		
		// Explicitly check for lack of clear code at start of file
		if (fOldCodeLength == 0) {
			fOldCode[0] = fNewCode;
			fOldCodeLength = 1;
			if (!OutputColor(fOldCode, 1))
				goto bad_end;
			continue;
		}
		
		if (fTable[fNewCode] != NULL) { // Does exist in table
			if (!OutputColor(fTable[fNewCode], fEntrySize[fNewCode]))
				goto bad_end;
			
			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (int x = 0; x < fOldCodeLength; x++) {
				newEntry[x] = fOldCode[x];
			}
			
			//memcpy(newEntry + fOldCodeLength, fTable[fNewCode], 1);
			newEntry[fOldCodeLength] = *fTable[fNewCode];
		} else { // Does not exist in table
			//memcpy(newEntry, fOldCode, fOldCodeLength);
			for (int x = 0; x < fOldCodeLength; x++) {
				newEntry[x] = fOldCode[x];
			}
			
			//memcpy(newEntry + fOldCodeLength, fOldCode, 1);
			newEntry[fOldCodeLength] = *fOldCode;
			
			if (!OutputColor(newEntry, fOldCodeLength + 1))
				goto bad_end;
		}
		fTable[fNextCode] = MemblockAllocate(fOldCodeLength + 1);

		//memcpy(fTable[fNextCode], newEntry, fOldCodeLength + 1);
		for (int x = 0; x < fOldCodeLength + 1; x++) {
			fTable[fNextCode][x] = newEntry[x];
		}
		
		fEntrySize[fNextCode] = fOldCodeLength + 1;
		
		//memcpy(fOldCode, fTable[fNewCode], fEntrySize[fNewCode]);
		for (int x = 0; x < fEntrySize[fNewCode]; x++) {
			fOldCode[x] = fTable[fNewCode][x];
		}
		
		fOldCodeLength = fEntrySize[fNewCode];
		fNextCode++;
		
		if (fNextCode > fMaxCode && fBits != 12) {
			fBits++;
			fMaxCode = (1 << fBits) - 1;
		}
	}

	MemblockDeleteAll();
	if (fNewCode == -1)
		return false;
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Done\n");
	return true;
	
bad_end:
	if (debug)
		syslog(LOG_ERR, "GIFLoad::ReadGIFImageData() - Reached a bad end\n");
	MemblockDeleteAll();
	return false;
}