Example #1
0
File: main.c Project: JackIrish/ios
int main (int argc, const char * argv[])
{
	char command;
    
	while ( (command = GetCommand() ) != 'q' ) {
		switch( command ) {
			case 'n':
				AddToList( ReadStruct() );
				break;
			case 'l':
			case 'r':
				ListDVDs( command=='l' );
				break;
		}
        printf( "\n----------\n" );
	}
	
	printf( "Goodbye...\n" );
	
	return 0;
}
Example #2
0
int CDb3Mmap::InitModuleNames(void)
{
	DWORD ofsThis = m_dbHeader.ofsModuleNames;
	DBModuleName *dbmn = (struct DBModuleName*)DBRead(ofsThis, NULL);
	while (ofsThis) {
		if (dbmn->signature != DBMODULENAME_SIGNATURE)
			DatabaseCorruption(NULL);

		int nameLen = dbmn->cbName;

		char *mod = (char*)HeapAlloc(m_hModHeap, 0, nameLen + 1);
		memcpy(mod, DBRead(ofsThis + offsetof(struct DBModuleName, name), NULL), nameLen);
		mod[nameLen] = 0;

		AddToList(mod, ofsThis);

		ofsThis = dbmn->ofsNext;
		dbmn = (struct DBModuleName*)DBRead(ofsThis, NULL);
	}
	return 0;
}
Example #3
0
/**
 *
 *  \param list    squeeze or dont-squeeze list
 *  \param name    window name
 *  \param justify left, center, or right
 *  \param num     signed num
 *  \param denom   0 or indicates fraction denom
 */
void
do_squeeze_entry (name_list **list, char *name, int justify, int num, int denom)
{
    int absnum = (num < 0 ? -num : num);

    if (denom < 0) {
	twmrc_error_prefix();
	fprintf (stderr, "negative SqueezeTitle denominator %d\n", denom);
	return;
    }
    if (absnum > denom && denom != 0) {
	twmrc_error_prefix();
	fprintf (stderr, "SqueezeTitle fraction %d/%d outside window\n",
		 num, denom);
	return;
    }
    if (denom == 1) {
	twmrc_error_prefix();
	fprintf (stderr, "useless SqueezeTitle faction %d/%d, assuming 0/0\n",
		 num, denom);
	num = 0;
	denom = 0;
    }

    if (HasShape) {
	SqueezeInfo *sinfo;
	sinfo = (SqueezeInfo *) malloc (sizeof(SqueezeInfo));

	if (!sinfo) {
	    twmrc_error_prefix();
	    fprintf (stderr, "unable to allocate %ld bytes for squeeze info\n",
		     (unsigned long)sizeof(SqueezeInfo));
	    return;
	}
	sinfo->justify = justify;
	sinfo->num = num;
	sinfo->denom = denom;
	AddToList (list, name, (char *) sinfo);
    }
}
Example #4
0
static int
dbg_str_to_signals(char ***args, int *nargs, List **lst)
{
	int				i;
	int				count;
	signal_info *	sig;

	if (dbg_str_to_int(args, nargs, &count) < 0) {
	}

	*lst = NewList();

	for (i = 0; i < count; i++) {
		if (dbg_str_to_signalinfo(args, nargs, &sig) < 0) {
			DestroyList(*lst, FreeMemory);
			return -1;
		}
		AddToList(*lst, (void *)sig);
	}

	return 0;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pFace - 
//-----------------------------------------------------------------------------
void CToolPickFace::CycleSelectFace(CMapFace *pFace)
{
	int nIndex = FindFace(pFace);
	if (nIndex != -1)
	{
		//
		// The face is in our list, update its selection state.
		//
		if (m_Faces[nIndex].eState == FaceState_Partial)
		{
			DeselectFace(nIndex);
		}
		else if (m_Faces[nIndex].eState == FaceState_Select)
		{
			if (m_Faces[nIndex].eOriginalState == FaceState_Partial)
			{
				m_Faces[nIndex].eState = FaceState_Partial;
				pFace->SetSelectionState(SELECT_MULTI_PARTIAL);
			}
			else
			{
				DeselectFace(nIndex);
			}
		}
		else if (m_Faces[nIndex].eState == FaceState_None)
		{
			m_Faces[nIndex].eState = FaceState_Select;
			pFace->SetSelectionState(SELECT_NORMAL);
		}
	}
	else
	{
		//
		// The face is not in our list, add it.
		//
		AddToList(pFace, FaceState_Select);
		pFace->SetSelectionState(SELECT_NORMAL);
	}
}
Example #6
0
/*!
\b Parameters:

\arg \b pNewEntity3d				Pointer to an entity object.

\b Operation:               

This function returns 1 (true) if the entity object passed as parameter exists
and is added to the manager successfully. 
*/
bool IND_Entity3dManager::Add (IND_Entity3d *pNewEntity3d)
{
	Debug->Header ("Adding 3d entity", 5);
	Debug->Header ("Name:", 3);
	Debug->DataInt ((int) pNewEntity3d, 1);

	if (!mOk)
	{
		WriteMessage ();
		return 0;
	}

	// ----- Puts the entinty into the manager -----

	AddToList (pNewEntity3d);

	// ----- Debug -----
	
	Debug->Header("3d entity added", 6);	

	return 1;
}
Example #7
0
static int
dbg_str_to_stackframes(char ***args, int *nargs, List **lst)
{
	int				i;
	int				count;
	stackframe *	sf;

	if (dbg_str_to_int(args, nargs, &count) < 0) {
		return -1;
	}

	*lst = NewList();

	for (i = 0; i < count; i++) {
		if (dbg_str_to_stackframe(args, nargs, &sf) < 0) {
			DestroyList(*lst, FreeStackframe);
			return -1;
		}
		AddToList(*lst, (void *)sf);
	}

	return 0;
}
Example #8
0
static int
dbg_str_to_memory_data(char ***args, int *nargs, List **lst)
{
	int		i;
	int		count;
	char *	str;

	if (dbg_str_to_int(args, nargs, &count) < 0) {
		return -1;
	}

	*lst = NewList();

	for (i = 0; i < count; i++) {
		if (dbg_copy_str(args, nargs, &str) < 0) {
			DestroyList(*lst, free);
			return -1;
		}
		AddToList(*lst, (void *)str);
	}

	return 0;
}
Example #9
0
static int clistcallb(const MemoryPatch& patch, void *data)
{
 char tmp[512];
 int ret;

 if(!lid)
 {
  CHEAT_printf("  /---------------------------------------\\");
  CHEAT_printf("  |  Type  | Affected Addr Range | Name    \\");
  CHEAT_printf("  |-----------------------------------------\\");
 }

 if(patch.type == 'C' || patch.type == 'S')
 {
  trio_snprintf(tmp, 512, "%c %c    | $%08x           | %s", patch.status ? '*' : ' ', patch.type, patch.addr, patch.name.c_str());
  //trio_snprintf(tmp, 512, "%s %c $%08x:%lld:%lld - %s", patch.status ? "*" : " ", patch.type, patch.addr, patch.val, patch.compare, patch.name.c_str());
 }
 else
 {
  uint32 sa = patch.addr;
  uint32 ea = patch.addr + ((patch.mltpl_count - 1) * patch.mltpl_addr_inc) + (patch.length - 1);

  if(patch.mltpl_count == 0 || patch.length == 0)
   trio_snprintf(tmp, 512, "%c %c%s |                     | %s", patch.status ? '*' : ' ', patch.type, patch.conditions.size() ? "+CC" : "   ", patch.name.c_str());
  else
  {
   if(sa == ea)
    trio_snprintf(tmp, 512, "%c %c%s | $%08x           | %s", patch.status ? '*' : ' ', patch.type, patch.conditions.size() ? "+CC" : "   ", sa, patch.name.c_str());
   else
    trio_snprintf(tmp, 512, "%c %c%s | $%08x-$%08x | %s", patch.status ? '*' : ' ', patch.type, patch.conditions.size() ? "+CC" : "   ", sa, ea, patch.name.c_str());
  }
 }

 ret = AddToList(tmp, lid);
 lid++;
 return(ret);
}
Example #10
0
static int srescallb(uint32 a, uint64 last, uint64 current, void *data)
{
 char tmp[256];

 if(searchbytelen == 8)
  trio_snprintf(tmp, 256, "$%08x:%020llu:%020llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current);
 if(searchbytelen == 7)
  trio_snprintf(tmp, 256, "$%08x:%017llu:%017llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current);
 if(searchbytelen == 6)
  trio_snprintf(tmp, 256, "$%08x:%015llu:%015llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current);
 if(searchbytelen == 5)
  trio_snprintf(tmp, 256, "$%08x:%013llu:%013llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current);
 if(searchbytelen == 4)
  trio_snprintf(tmp, 256, "$%08x:%10u:%10u",(unsigned int)a,(unsigned int)last,(unsigned int)current);
 else if(searchbytelen == 3)
  trio_snprintf(tmp, 256, "$%08x:%08u:%08u",(unsigned int)a,(unsigned int)last,(unsigned int)current);
 else if(searchbytelen == 2)
  trio_snprintf(tmp, 256, "$%08x:%05u:%05u",(unsigned int)a,(unsigned int)last,(unsigned int)current);
 else if(searchbytelen == 1)
  trio_snprintf(tmp, 256, "$%08x:%03u:%03u",(unsigned int)a,(unsigned int)last,(unsigned int)current);
 else // > 4
  trio_snprintf(tmp, 256, "$%08x:%020llu:%020llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current);
 return(AddToList(tmp,a));
}
Example #11
0
CSurface3D::CSurface3D(LPCTSTR Name, 
                        double MinX, double MaxX, long NDivsX, TSurfaceXfFn fnXI, TSurfaceXfFn fnXO, 
                        double MinY, double MaxY, long NDivsY, TSurfaceXfFn fnYI, TSurfaceXfFn fnYO, 
                        TSurface3DFn Fn,
                        CSurface3DBoundary *pBoundary) :
  m_E(this, 0, MinX, MaxX, NDivsX, MinY, MaxY, NDivsY)
  {
  m_sName=Name; 

  m_nCalls=0;
  m_nFrameCnt=0;
  m_nBuildCnt=0;
  m_nPanelCnt=0;
  m_nPanelCntMax=ALLOCCNTMAX;
  m_pMRUHead=NULL;
  m_pMRUTail=NULL;


  m_fnZ=Fn;
  m_pBoundary=pBoundary;
  //RemoveElements();
  m_dwLastTicks=GetTickCount();
  AddToList();
  };
//---------------------------------------------------------------------------------
// Purpose: Builds up a list of players that are 'kickable'
//---------------------------------------------------------------------------------
void ManiReservedSlot::BuildPlayerKickList( player_t *player_ptr, int *players_on_server )
{
	player_t	temp_player;
	active_player_t active_player;

	FreeList((void **) &active_player_list, &active_player_list_size);

	for (int i = 1; i <= max_players; i ++)
	{
#if defined ( GAME_CSGO )
		edict_t *pEntity = PEntityOfEntIndex(i);
#else
		edict_t *pEntity = engine->PEntityOfEntIndex(i);
#endif
		if( pEntity && !pEntity->IsFree())
		{
			if ( player_ptr && ( pEntity == player_ptr->entity ) )
				continue;

			IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo( pEntity );
			if (playerinfo && playerinfo->IsConnected())
			{
				Q_strcpy(active_player.steam_id, playerinfo->GetNetworkIDString());
				if (FStrEq("BOT", active_player.steam_id))
				{
					continue;
				}

				INetChannelInfo *nci = engine->GetPlayerNetInfo(i);
				if (!nci)
				{
					continue;
				}

				active_player.entity = pEntity;

				active_player.ping = nci->GetAvgLatency(0);
				const char * szCmdRate = engine->GetClientConVarValue( i, "cl_cmdrate" );
				int nCmdRate = (20 > Q_atoi( szCmdRate )) ? 20 : Q_atoi(szCmdRate);
				active_player.ping -= (0.5f/nCmdRate) + TICKS_TO_TIME( 1.0f ); // correct latency

				// in GoldSrc we had a different, not fixed tickrate. so we have to adjust
				// Source pings by half a tick to match the old GoldSrc pings.
				active_player.ping -= TICKS_TO_TIME( 0.5f );
				active_player.ping = active_player.ping * 1000.0f; // as msecs
				active_player.ping = ((5 > active_player.ping) ? 5:active_player.ping); // set bounds, dont show pings under 5 msecs

				active_player.time_connected = nci->GetTimeConnected();
				Q_strcpy(active_player.ip_address, nci->GetAddress());
				if (gpManiGameType->IsSpectatorAllowed() &&
					playerinfo->GetTeamIndex () == gpManiGameType->GetSpectatorIndex())
				{
					active_player.is_spectator = true;
				}
				else
				{
					active_player.is_spectator = false;
				}
				active_player.user_id = playerinfo->GetUserID();
				Q_strcpy(active_player.name, playerinfo->GetName());

				if ( players_on_server )
					*players_on_server = *players_on_server + 1;

				active_player.kills = playerinfo->GetFragCount();
				active_player.deaths = playerinfo->GetDeathCount();
				Q_strcpy(temp_player.steam_id, active_player.steam_id);
				Q_strcpy(temp_player.ip_address, active_player.ip_address);
				Q_strcpy(temp_player.name, active_player.name);
				temp_player.is_bot = false;

				if (IsPlayerInReserveList(&temp_player))
				{
					continue;
				}

				active_player.index = i;

				if (mani_reserve_slots_include_admin.GetInt() == 1 &&
					gpManiClient->HasAccess(active_player.index, ADMIN, ADMIN_BASIC_ADMIN))
				{
					continue;
				}

				if (gpManiClient->HasAccess(active_player.index, IMMUNITY, IMMUNITY_RESERVE))
				{
					continue;
				}

				AddToList((void **) &active_player_list, sizeof(active_player_t), &active_player_list_size);
				active_player_list[active_player_list_size - 1] = active_player;
			}
		}
	}
}
Example #13
0
void TCopyParamType::DoGetInfoStr(
  const UnicodeString & Separator, intptr_t Options,
  UnicodeString & Result, bool & SomeAttrIncluded,
  const UnicodeString & Link, UnicodeString & ScriptArgs, bool & NoScriptArgs, /*TAssemblyLanguage Language, UnicodeString & AssemblyCode,*/
  bool & NoCodeProperties) const
{
  TCopyParamType Defaults;

  bool SomeAttrExcluded = false;
  NoScriptArgs = false;
  NoCodeProperties = false;
  SomeAttrIncluded = false;
  #define ADD(STR, EXCEPT) \
    if (FLAGCLEAR(Options, EXCEPT)) \
    { \
      AddToList(Result, (STR), Separator); \
      SomeAttrIncluded = true; \
    } \
    else \
    { \
      SomeAttrExcluded = true; \
    }

  bool AsciiFileMaskDiffers = (GetTransferMode() == tmAutomatic) && !(GetAsciiFileMask() == Defaults.GetAsciiFileMask());
  bool TransferModeDiffers = ((GetTransferMode() != Defaults.GetTransferMode()) || AsciiFileMaskDiffers);

  if (FLAGCLEAR(Options, cpaIncludeMaskOnly | cpaNoTransferMode))
  {
    // Adding Transfer type unconditionally
    bool FormatMask;
    int Ident;
    switch (GetTransferMode())
    {
      case tmBinary:
        FormatMask = false;
        Ident = 2;
        break;
      case tmAscii:
        FormatMask = false;
        Ident = 3;
        break;
      case tmAutomatic:
      default:
        FormatMask = !(GetAsciiFileMask() == Defaults.GetAsciiFileMask());
        Ident = FormatMask ? 4 : 5;
        break;
    }
    UnicodeString S = FORMAT(LoadStrPart(COPY_INFO_TRANSFER_TYPE2, 1).c_str(),
      LoadStrPart(COPY_INFO_TRANSFER_TYPE2, Ident).c_str());
    if (FormatMask)
    {
      S = FORMAT(S.c_str(), GetAsciiFileMask().GetMasks().c_str());
    }
    AddToList(Result, S, Separator);

    if (TransferModeDiffers)
    {
      ADD("", cpaIncludeMaskOnly | cpaNoTransferMode);

      /*ScriptArgs += RtfSwitchValue(TRANSFER_SWITCH, Link, TransferModeNames[TransferMode]);
      const wchar_t * TransferModeMembers[] = { L"Binary", L"Ascii", L"Automatic" };
      AssemblyCode += AssemblyProperty(
        Language, TransferOptionsClassName, L"TransferMode", L"TransferMode", TransferModeMembers[TransferMode], false);
      if (AsciiFileMaskDiffers)
      {
        NoScriptArgs = true;
        NoCodeProperties = true;
      }*/
    }
  }
  else
  {
    if (TransferModeDiffers)
    {
      SomeAttrExcluded = true;
      NoScriptArgs = true;
      NoCodeProperties = true;
    }
  }

  if (GetFileNameCase() != Defaults.GetFileNameCase())
  {
    ADD(FORMAT(LoadStrPart(COPY_INFO_FILENAME, 1).c_str(),
      LoadStrPart(COPY_INFO_FILENAME, GetFileNameCase() + 2).c_str()),
      cpaIncludeMaskOnly);

    NoScriptArgs = true;
    NoCodeProperties = true;
  }

  if ((GetInvalidCharsReplacement() == NoReplacement) !=
        (Defaults.GetInvalidCharsReplacement() == NoReplacement))
  {
    DebugAssert(GetInvalidCharsReplacement() == NoReplacement);
    if (GetInvalidCharsReplacement() == NoReplacement)
    {
      ADD(LoadStr(COPY_INFO_DONT_REPLACE_INV_CHARS).c_str(), cpaIncludeMaskOnly);
    }

    NoScriptArgs = true;
    NoCodeProperties = true;
  }

  if ((GetPreserveRights() != Defaults.GetPreserveRights()) ||
      (GetPreserveRights() &&
       ((GetRights() != Defaults.GetRights()) || (GetAddXToDirectories() != Defaults.GetAddXToDirectories()))))
  {
    const int Except = cpaIncludeMaskOnly | cpaNoRights;
    if (DebugAlwaysTrue(GetPreserveRights()))
    {
      UnicodeString RightsStr = GetRights().GetText();
      if (GetAddXToDirectories())
      {
        RightsStr += L", " + LoadStr(COPY_INFO_ADD_X_TO_DIRS);
      }
      ADD(FORMAT(LoadStr(COPY_INFO_PERMISSIONS).c_str(), RightsStr.c_str()),
        Except);
      if (FLAGCLEAR(Options, Except))
      {
//        ScriptArgs += RtfSwitchValue(PERMISSIONS_SWITCH, Link, Rights.Octal);

//        const UnicodeString FilePermissionsClassName = L"FilePermissions";
//        const bool Inline = true;
//        UnicodeString FilePermissions =
//          AssemblyNewClassInstanceStart(Language, FilePermissionsClassName, Inline) +
//          AssemblyProperty(Language, FilePermissionsClassName, L"Octal", Rights.Octal, Inline) +
//          AssemblyNewClassInstanceEnd(Language, Inline);

//        AssemblyCode += AssemblyPropertyRaw(Language, TransferOptionsClassName, L"FilePermissions", FilePermissions, false);
      }
    }

    if ((GetAddXToDirectories() != Defaults.GetAddXToDirectories()) && FLAGCLEAR(Options, Except))
    {
      NoScriptArgs = true;
      NoCodeProperties = true;
    }
  }

  bool APreserveTimeDirs = GetPreserveTime() && GetPreserveTimeDirs();
  if ((GetPreserveTime() != Defaults.GetPreserveTime()) || (APreserveTimeDirs != Defaults.GetPreserveTimeDirs()))
  {
    bool AddPreserveTime = false;
    UnicodeString Str = LoadStr(GetPreserveTime() ? COPY_INFO_TIMESTAMP : COPY_INFO_DONT_PRESERVE_TIME);

    const int ExceptDirs = cpaNoPreserveTimeDirs;
    if (APreserveTimeDirs != Defaults.GetPreserveTimeDirs())
    {
      if (DebugAlwaysTrue(GetPreserveTimeDirs()))
      {
        if (FLAGCLEAR(Options, ExceptDirs))
        {
          Str = FMTLOAD(COPY_INFO_PRESERVE_TIME_DIRS, (Str));
          AddPreserveTime = true;
        }
      }
      ADD("", ExceptDirs);
    }

    const int Except = cpaIncludeMaskOnly | cpaNoPreserveTime;
    if (GetPreserveTime() != Defaults.GetPreserveTime())
    {
      if (FLAGCLEAR(Options, Except))
      {
        AddPreserveTime = true;
      }
      ADD(L"", Except);
    }

    if (AddPreserveTime)
    {
      AddToList(Result, Str, Separator);
    }

    if (FLAGCLEAR(Options, Except))
    {
      if (GetPreserveTime())
      {
        if (GetPreserveTimeDirs() && FLAGCLEAR(Options, ExceptDirs))
        {
          //ScriptArgs += RtfSwitchValue(PRESERVETIME_SWITCH, Link, PRESERVETIMEDIRS_SWITCH_VALUE);
          NoCodeProperties = true;
        }
        else
        {
          DebugFail(); // should never get here
          //ScriptArgs += RtfSwitch(PRESERVETIME_SWITCH, Link);
        }
      }
      else
      {
//        ScriptArgs += RtfSwitch(NOPRESERVETIME_SWITCH, Link);
//        AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"PreserveTimestamp", false, false);
      }
    }
  }

  if ((GetPreserveRights() || GetPreserveTime()) &&
      (GetIgnorePermErrors() != Defaults.GetIgnorePermErrors()))
  {
    if (DebugAlwaysTrue(GetIgnorePermErrors()))
    {
      const int Except = cpaIncludeMaskOnly | cpaNoIgnorePermErrors;
      ADD(LoadStr(COPY_INFO_IGNORE_PERM_ERRORS), Except);
      if (FLAGCLEAR(Options, Except))
      {
        NoScriptArgs = true;
        NoCodeProperties = true;
      }
    }
  }

  if (GetPreserveReadOnly() != Defaults.GetPreserveReadOnly())
  {
    if (DebugAlwaysTrue(GetPreserveReadOnly()))
    {
      const int Except = cpaIncludeMaskOnly | cpaNoPreserveReadOnly;
      ADD(LoadStr(COPY_INFO_PRESERVE_READONLY), Except);
      if (FLAGCLEAR(Options, Except))
      {
        NoScriptArgs = true;
        NoCodeProperties = true;
      }
    }
  }

  if (GetCalculateSize() != Defaults.GetCalculateSize())
  {
    if (DebugAlwaysTrue(!GetCalculateSize()))
    {
      ADD(LoadStr(COPY_INFO_DONT_CALCULATE_SIZE), cpaIncludeMaskOnly);
      // Always false in scripting, in assembly controlled by use of FileTransferProgress
    }
  }

  if (GetClearArchive() != Defaults.GetClearArchive())
  {
    if (DebugAlwaysTrue(GetClearArchive()))
    {
      const int Except = cpaIncludeMaskOnly | cpaNoClearArchive;
      ADD(LoadStr(COPY_INFO_CLEAR_ARCHIVE), Except);
      if (FLAGCLEAR(Options, Except))
      {
        NoScriptArgs = true;
        NoCodeProperties = true;
      }
    }
  }

  if ((GetTransferMode() == tmAscii) || (GetTransferMode() == tmAutomatic))
  {
    if (GetRemoveBOM() != Defaults.GetRemoveBOM())
    {
      if (DebugAlwaysTrue(GetRemoveBOM()))
      {
        const int Except = cpaIncludeMaskOnly | cpaNoRemoveBOM | cpaNoTransferMode;
        ADD(LoadStr(COPY_INFO_REMOVE_BOM), Except);
        if (FLAGCLEAR(Options, Except))
        {
          NoScriptArgs = true;
          NoCodeProperties = true;
        }
      }
    }

    if (GetRemoveCtrlZ() != Defaults.GetRemoveCtrlZ())
    {
      if (DebugAlwaysTrue(GetRemoveCtrlZ()))
      {
        const int Except = cpaIncludeMaskOnly | cpaNoRemoveCtrlZ | cpaNoTransferMode;
        ADD(LoadStr(COPY_INFO_REMOVE_CTRLZ),Except);
        if (FLAGCLEAR(Options, Except))
        {
          NoScriptArgs = true;
          NoCodeProperties = true;
        }
      }
    }
  }

  if (!(GetIncludeFileMask() == Defaults.GetIncludeFileMask()))
  {
    ADD(FORMAT(LoadStr(COPY_INFO_FILE_MASK).c_str(), GetIncludeFileMask().GetMasks().c_str()),
      cpaNoIncludeMask);

//    ScriptArgs += RtfSwitch(FILEMASK_SWITCH, Link, IncludeFileMask.Masks);
//    AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"FileMask", IncludeFileMask.Masks, false);
  }

  DebugAssert(FTransferSkipList.get() == nullptr);
  DebugAssert(FTransferResumeFile.IsEmpty());

  if (GetCPSLimit() > 0)
  {
    intptr_t LimitKB = intptr_t(GetCPSLimit() / 1024);
    ADD(FMTLOAD(COPY_INFO_CPS_LIMIT2, (LimitKB)), cpaIncludeMaskOnly);

//    ScriptArgs += RtfSwitch(SPEED_SWITCH, Link, LimitKB);
//    AssemblyCode += AssemblyProperty(Language, TransferOptionsClassName, L"Speed", LimitKB, false);
  }

  if (GetNewerOnly() != Defaults.GetNewerOnly())
  {
    if (DebugAlwaysTrue(GetNewerOnly()))
    {
      const int Except = cpaIncludeMaskOnly | cpaNoNewerOnly;
      ADD(StripHotkey(LoadStr(COPY_PARAM_NEWER_ONLY)), Except);
      if (FLAGCLEAR(Options, Except))
      {
//        ScriptArgs += RtfSwitch(NEWERONLY_SWICH, Link);
        NoCodeProperties = true;
      }
    }
  }

  bool ResumeThresholdDiffers = ((GetResumeSupport() == rsSmart) && (GetResumeThreshold() != Defaults.GetResumeThreshold()));
  if (((GetResumeSupport() != Defaults.GetResumeSupport()) || ResumeThresholdDiffers) &&
      (GetTransferMode() != tmAscii) && FLAGCLEAR(Options, cpaNoResumeSupport))
  {
    UnicodeString Value;
    UnicodeString CodeState;
    intptr_t ResumeThresholdKB = (GetResumeThreshold() / 1024);
    switch (GetResumeSupport())
    {
      case rsOff:
        Value = ToggleNames[ToggleOff];
        CodeState = L"Off";
        break;

      case rsOn:
        Value = ToggleNames[ToggleOn];
        CodeState = L"On";
        break;

      case rsSmart:
        Value = IntToStr(ResumeThresholdKB);
        break;
    }
//    ScriptArgs += RtfSwitchValue(RESUMESUPPORT_SWITCH, Link, Value);

    const UnicodeString ResumeSupportClassName = L"TransferResumeSupport";
//    const bool Inline = true;
//    UnicodeString ResumeSupportCode =
//      AssemblyNewClassInstanceStart(Language, ResumeSupportClassName, Inline);
    if (GetResumeSupport() == rsSmart)
    {
//      ResumeSupportCode += AssemblyProperty(Language, ResumeSupportClassName, L"Threshold", ResumeThresholdKB, Inline);
    }
    else
    {
//      ResumeSupportCode += AssemblyProperty(Language, ResumeSupportClassName, L"State", L"TransferResumeSupportState", CodeState, Inline);
    }
//    ResumeSupportCode += AssemblyNewClassInstanceEnd(Language, Inline);

//    AssemblyCode += AssemblyPropertyRaw(Language, TransferOptionsClassName, L"ResumeSupport", ResumeSupportCode, false);
  }

  if (SomeAttrExcluded)
  {
    Result += (Result.IsEmpty() ? UnicodeString() : Separator) +
      FORMAT(LoadStrPart(COPY_INFO_NOT_USABLE, 1).c_str(),
        LoadStrPart(COPY_INFO_NOT_USABLE, (SomeAttrIncluded ? 2 : 3)).c_str());
  }
  else if (Result.IsEmpty())
  {
    Result = LoadStr(COPY_INFO_DEFAULT);
  }
  #undef ADD
}
Example #14
0
void AddExportedCode(char * name, unsigned int aSymSz)
{
	AddToList(name, ExportedCode, aSymSz);
}
Example #15
0
void AddExportedData(char * name, unsigned int aSymSz)
{
	AddToList(name, ExportedData, aSymSz);
}
Example #16
0
void AddInstanceToServer(serverInfo *pServer, instanceInfo *pInstance)
{
  AddToList(pServer->instances, pInstance, LIST_INSTANCE);
  pInstance->server = pServer;
}
Example #17
0
//Workaround  for compiler defect(To avoid export of local symbols)
void AddLocalSymbols(char * name)
{
	AddToList(name, LocalSymbols, 0);
}
void TSessionLog::DoAddStartupInfo(TSessionData *Data)
{
  if (Data == nullptr)
  {
    AddSeparator();
    UnicodeString OS = WindowsVersionLong();
    AddToList(OS, WindowsProductName(), L" - ");
    ADF("NetBox %s (OS %s)", FConfiguration->GetProductVersionStr(), OS);
    {
      std::unique_ptr<THierarchicalStorage> Storage(FConfiguration->CreateConfigStorage());
      DebugAssert(Storage.get());
      ADF("Configuration: %s", Storage->GetSource());
    }

#if 0
    typedef BOOL (WINAPI * TGetUserNameEx)(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize);
    HINSTANCE Secur32 = LoadLibrary(L"secur32.dll");
    TGetUserNameEx GetUserNameEx =
      (Secur32 != nullptr) ? reinterpret_cast<TGetUserNameEx>(::GetProcAddress(Secur32, "GetUserNameExW")) : nullptr;
    wchar_t UserName[UNLEN + 1];
    ULONG UserNameSize = _countof(UserName);
    if ((GetUserNameEx == nullptr) || DebugAlwaysFalse(!GetUserNameEx(NameSamCompatible, (LPWSTR)UserName, &UserNameSize)))
    {
      wcscpy_s(UserName, UNLEN, L"<Failed to retrieve username>");
    }
#endif // #if 0
    UnicodeString LogStr;
    if (FConfiguration->GetLogProtocol() <= 0)
    {
      LogStr = L"Normal";
    }
    else if (FConfiguration->GetLogProtocol() == 1)
    {
      LogStr = L"Debug 1";
    }
    else if (FConfiguration->GetLogProtocol() >= 2)
    {
      LogStr = L"Debug 2";
    }
#if 0
    if (FConfiguration->GetLogSensitive())
    {
      LogStr += L", Logging passwords";
    }
#endif // #if 0
    if (FConfiguration->GetLogMaxSize() > 0)
    {
      LogStr += FORMAT(L", Rotating after: %s", SizeToStr(FConfiguration->GetLogMaxSize()));
      if (FConfiguration->GetLogMaxCount() > 0)
      {
        LogStr += FORMAT(L", Keeping at most %d logs", FConfiguration->GetLogMaxCount());
      }
    }
#if 0
    ADF("Log level: %s", LogStr);
    ADF("Local account: %s", UserName);
#endif // #if 0
    ADF("Working directory: %s", GetCurrentDir());
    ADF("Process ID: %d", intptr_t(GetCurrentProcessId()));
#if 0
    ADF("Command-line: %s", GetCmdLineLog());
    if (FConfiguration->GetLogProtocol() >= 1)
    {
      AddOptions(GetGlobalOptions());
    }
#endif // #if 0
    ADF("Time zone: %s", GetTimeZoneLogString());
    if (!AdjustClockForDSTEnabled())
    {
      ADF("Warning: System option \"Automatically adjust clock for Daylight Saving Time\" is disabled, timestamps will not be represented correctly");
    }
#if 0
    ADF("Login time: %s", dt);
#endif // #if 0
    AddSeparator();
  }
  else
  {
#if 0
    ADF("Session name: %s (%s)", Data->GetSessionName(), Data->GetSource());
    ADF("Host name: %s (Port: %d)", Data->GetHostNameExpanded(), Data->GetPortNumber());
    ADF("User name: %s (Password: %s, Key file: %s, Passphrase: %s)",
      Data->GetUserNameExpanded(), LogSensitive(Data->GetPassword()),
      LogSensitive(Data->GetPublicKeyFile()), LogSensitive(Data->GetPassphrase()))
#endif // #if 0
    if (Data->GetUsesSsh())
    {
      ADF("Tunnel: %s", BooleanToEngStr(Data->GetTunnel()));
      if (Data->GetTunnel())
      {
        ADF("Tunnel: Host name: %s (Port: %d)", Data->GetTunnelHostName(), Data->GetTunnelPortNumber());
#if 0
        ADF("Tunnel: User name: %s (Password: %s, Key file: %s)",
          Data->GetTunnelUserName(), BooleanToEngStr(!Data->GetTunnelPassword().IsEmpty()),
          BooleanToEngStr(!Data->GetTunnelPublicKeyFile().IsEmpty()));
        ADF("Tunnel: Local port number: %d", Data->GetTunnelLocalPortNumber());
#endif // #if 0
      }
    }
    ADF("Transfer Protocol: %s", Data->GetFSProtocolStr());
    ADF("Code Page: %d", Data->GetCodePageAsNumber());
    if (Data->GetUsesSsh() || (Data->GetFSProtocol() == fsFTP))
    {
      TPingType PingType;
      intptr_t PingInterval;
      if (Data->GetFSProtocol() == fsFTP)
      {
        PingType = Data->GetFtpPingType();
        PingInterval = Data->GetFtpPingInterval();
      }
      else
      {
        PingType = Data->GetPingType();
        PingInterval = Data->GetPingInterval();
      }
      ADF("Ping type: %s, Ping interval: %d sec; Timeout: %d sec",
        EnumName(PingType, PingTypeNames), PingInterval, Data->GetTimeout());
      ADF("Disable Nagle: %s",
        BooleanToEngStr(Data->GetTcpNoDelay()));
    }
    TProxyMethod ProxyMethod = Data->GetActualProxyMethod();
    {
      UnicodeString fp = FORMAT(L"FTP proxy %d", Data->GetFtpProxyLogonType());
      ADF("Proxy: %s",
        (Data->GetFtpProxyLogonType() != 0) ? fp : EnumName(ProxyMethod, ProxyMethodNames));
    }
    if ((Data->GetFtpProxyLogonType() != 0) || (ProxyMethod != ::pmNone))
    {
      ADF("ProxyHostName: %s (Port: %d); ProxyUsername: %s; Passwd: %s",
        Data->GetProxyHost(), Data->GetProxyPort(),
        Data->GetProxyUsername(), BooleanToEngStr(!Data->GetProxyPassword().IsEmpty()));
      if (ProxyMethod == pmTelnet)
      {
        ADF("Telnet command: %s", Data->GetProxyTelnetCommand());
      }
      if (ProxyMethod == pmCmd)
      {
        ADF("Local command: %s", Data->GetProxyLocalCommand());
      }
    }
    if (Data->GetUsesSsh() || (Data->GetFSProtocol() == fsFTP))
    {
      ADF("Send buffer: %d", Data->GetSendBuf());
    }
    if (Data->GetUsesSsh())
    {
      ADF("SSH protocol version: %s; Compression: %s",
        Data->GetSshProtStr(), BooleanToEngStr(Data->GetCompression()));
      ADF("Bypass authentication: %s",
        BooleanToEngStr(Data->GetSshNoUserAuth()));
      ADF("Try agent: %s; Agent forwarding: %s; TIS/CryptoCard: %s; KI: %s; GSSAPI: %s",
        BooleanToEngStr(Data->GetTryAgent()), BooleanToEngStr(Data->GetAgentFwd()), BooleanToEngStr(Data->GetAuthTIS()),
        BooleanToEngStr(Data->GetAuthKI()), BooleanToEngStr(Data->GetAuthGSSAPI()));
      if (Data->GetAuthGSSAPI())
      {
        ADF("GSSAPI: Forwarding: %s",
          BooleanToEngStr(Data->GetGSSAPIFwdTGT()));
      }
      ADF("Ciphers: %s; Ssh2DES: %s",
        Data->GetCipherList(), BooleanToEngStr(Data->GetSsh2DES()));
      ADF("KEX: %s", Data->GetKexList());
      UnicodeString Bugs;
      for (intptr_t Index = 0; Index < BUG_COUNT; ++Index)
      {
        AddToList(Bugs, EnumName(Data->GetBug(static_cast<TSshBug>(Index)), AutoSwitchNames), L",");
      }
      ADF("SSH Bugs: %s", Bugs);
      ADF("Simple channel: %s", BooleanToEngStr(Data->GetSshSimple()));
      ADF("Return code variable: %s; Lookup user groups: %s",
        Data->GetDetectReturnVar() ? UnicodeString(L"Autodetect") : Data->GetReturnVar(),
        EnumName(Data->GetLookupUserGroups(), AutoSwitchNames));
      ADF("Shell: %s", Data->GetShell().IsEmpty() ? UnicodeString(L"default") : Data->GetShell());
      ADF("EOL: %s, UTF: %s", EnumName(Data->GetEOLType(), EOLTypeNames), EnumName(Data->GetNotUtf(), NotAutoSwitchNames)); // NotUtf duplicated in FTP branch
      ADF("Clear aliases: %s, Unset nat.vars: %s, Resolve symlinks: %s; Follow directory symlinks: %s",
        BooleanToEngStr(Data->GetClearAliases()), BooleanToEngStr(Data->GetUnsetNationalVars()),
        BooleanToEngStr(Data->GetResolveSymlinks()), BooleanToEngStr(Data->GetFollowDirectorySymlinks()));
      ADF("LS: %s, Ign LS warn: %s, Scp1 Comp: %s",
        Data->GetListingCommand(),
        BooleanToEngStr(Data->GetIgnoreLsWarnings()),
        BooleanToEngStr(Data->GetScp1Compatibility()));
    }
    if ((Data->GetFSProtocol() == fsSFTP) || (Data->GetFSProtocol() == fsSFTPonly))
    {
      UnicodeString Bugs;
      for (intptr_t Index = 0; Index < SFTP_BUG_COUNT; ++Index)
      {
        AddToList(Bugs, EnumName(Data->GetSFTPBug(static_cast<TSftpBug>(Index)), AutoSwitchNames), L",");
      }
      ADF("SFTP Bugs: %s", Bugs);
      ADF("SFTP Server: %s", Data->GetSftpServer().IsEmpty() ? UnicodeString(L"default") : Data->GetSftpServer());
    }
    bool FtpsOn = false;
    if (Data->GetFSProtocol() == fsFTP)
    {
      ADF("UTF: %s", EnumName(Data->GetNotUtf(), NotAutoSwitchNames)); // duplicated in UsesSsh branch
      UnicodeString Ftps;
      switch (Data->GetFtps())
      {
      case ftpsImplicit:
        Ftps = L"Implicit TLS/SSL";
        FtpsOn = true;
        break;

      case ftpsExplicitSsl:
        Ftps = L"Explicit SSL/TLS";
        FtpsOn = true;
        break;

      case ftpsExplicitTls:
        Ftps = L"Explicit TLS/SSL";
        FtpsOn = true;
        break;

      default:
        DebugAssert(Data->GetFtps() == ftpsNone);
        Ftps = L"None";
        break;
      }
      // kind of hidden option, so do not reveal it unless it is set
      if (Data->GetFtpTransferActiveImmediately() != asAuto)
      {
        ADF("Transfer active immediately: %s", EnumName(Data->GetFtpTransferActiveImmediately(), AutoSwitchNames));
      }
      ADF("FTPS: %s [Client certificate: %s]",
        Ftps, LogSensitive(Data->GetTlsCertificateFile()));
      ADF("FTP: Passive: %s [Force IP: %s]; MLSD: %s [List all: %s]; HOST: %s",
        BooleanToEngStr(Data->GetFtpPasvMode()),
        EnumName(Data->GetFtpForcePasvIp(), AutoSwitchNames),
        EnumName(Data->GetFtpUseMlsd(), AutoSwitchNames),
        EnumName(Data->GetFtpListAll(), AutoSwitchNames),
        EnumName(Data->GetFtpHost(), AutoSwitchNames));
    }
    if (Data->GetFSProtocol() == fsWebDAV)
    {
      FtpsOn = (Data->GetFtps() != ftpsNone);
      ADF("HTTPS: %s [Client certificate: %s]",
        BooleanToEngStr(FtpsOn), LogSensitive(Data->GetTlsCertificateFile()));
    }
    if (FtpsOn)
    {
      if (Data->GetFSProtocol() == fsFTP)
      {
        ADF("Session reuse: %s", BooleanToEngStr(Data->GetSslSessionReuse()));
      }
      ADF("TLS/SSL versions: %s-%s", GetTlsVersionName(Data->GetMinTlsVersion()), GetTlsVersionName(Data->GetMaxTlsVersion()));
    }
    ADF("Local directory: %s, Remote directory: %s, Update: %s, Cache: %s",
      Data->GetLocalDirectory().IsEmpty() ? UnicodeString(L"default") : Data->GetLocalDirectory(),
      Data->GetRemoteDirectory().IsEmpty() ? UnicodeString(L"home") : Data->GetRemoteDirectory(),
      BooleanToEngStr(Data->GetUpdateDirectories()),
      BooleanToEngStr(Data->GetCacheDirectories()));
    ADF("Cache directory changes: %s, Permanent: %s",
      BooleanToEngStr(Data->GetCacheDirectoryChanges()),
      BooleanToEngStr(Data->GetPreserveDirectoryChanges()));
    ADF("Recycle bin: Delete to: %s, Overwritten to: %s, Bin path: %s",
      BooleanToEngStr(Data->GetDeleteToRecycleBin()),
      BooleanToEngStr(Data->GetOverwrittenToRecycleBin()),
      Data->GetRecycleBinPath());
    if (Data->GetTrimVMSVersions())
    {
      ADF("Trim VMS versions: %s",
        BooleanToEngStr(Data->GetTrimVMSVersions()));
    }
    UnicodeString TimeInfo;
    if ((Data->GetFSProtocol() == fsSFTP) || (Data->GetFSProtocol() == fsSFTPonly) || (Data->GetFSProtocol() == fsSCPonly) || (Data->GetFSProtocol() == fsWebDAV))
    {
      AddToList(TimeInfo, FORMAT(L"DST mode: %s", EnumName(ToInt(Data->GetDSTMode()), DSTModeNames)), L";");
    }
    if ((Data->GetFSProtocol() == fsSCPonly) || (Data->GetFSProtocol() == fsFTP))
    {
      intptr_t TimeDifferenceMin = TimeToMinutes(Data->GetTimeDifference());
      AddToList(TimeInfo, FORMAT(L"Timezone offset: %dh %dm", TimeDifferenceMin / MinsPerHour, TimeDifferenceMin % MinsPerHour), L";");
    }
    ADSTR(TimeInfo);

    if (Data->GetFSProtocol() == fsWebDAV)
    {
      ADF("Compression: %s",
        BooleanToEngStr(Data->GetCompression()));
    }

    AddSeparator();
  }
}
Example #19
0
/* Performs the spread function using the breadth-first strategy. 
 * All neighbors from current cell are checked on getting a cheaper path
 * from current cell. All cells in the coordlist are checked. Every time
 * a neighbor is found which gets a new cost value, its neighbors are
 * checked too.
 * Returns 0 if no error occurs, 1 otherwise. 
 */
static int PerformSpread(
	MAP_REAL8 *outCost, 		/* read-write output costs */
	MAP_INT4 *outId,		/* read-write output id map */
	NODE *coordList,		/* read-write list of cells */
	const MAP_REAL8 *friction,	/* friction map */
	const MAP_REAL8 *maxCost)	/* max cost map */
{
	int 	rNext, cNext, rowNr, colNr, i;
	REAL8 	f;        	/* friction of current cell */
	REAL8 	s, newS;	/* old & new spreadval. of curr. cell */

     	PRECOND(outCost->GetGetTest(outCost) == GET_MV_TEST);
     	PRECOND(outId->GetGetTest(outId) == GET_MV_TEST);
     	PRECOND(friction->GetGetTest(friction) == GET_MV_TEST);
     	PRECOND(maxCost->GetGetTest(maxCost) == GET_MV_TEST);

	while(coordList != NULL)
	{
	 INT4 id;	 /* id of current cell */
	 rowNr = coordList->rowNr; /* cell from which is spread */
	 colNr = coordList->colNr; /* (source cell ) */
	 coordList = RemFromList(coordList);  /* unable */
	 id = Set0BitMatrix(inList,rowNr,colNr);
	 POSTCOND(id != 0); /* was set */

	 AppDynamicProgress();

	 FOR_ALL_LDD_NBS(i)
	 {   /* find new spread value for all neighbors */
	  rNext = RNeighbor(rowNr, i);	
	  cNext = CNeighbor(colNr, i);

	  if(friction->Get(&f, rNext, cNext, friction) &&
	 	outId->Get(&id, rNext, cNext, outId))
	  {
	  	INT4 newId = 0;
	  	if(id != 0)
	  	 outCost->Get(&s, rNext, cNext, outCost); /* already visited */

	 	newS = CalcSpreadValue(&newId, outCost,
	 	       outId, friction, rNext, cNext, f);
	 					
	 	if(newId != 0 && (id == 0 || AppCastREAL4(newS) < s))
		{
		/* a cheaper or first route to this cell
		 * found, inspect the neighbors too. 
		 */
		 	REAL8 maxCostVal;
			BOOL maxCostReached ;
	  	 	maxCost->Get(&maxCostVal, rNext, cNext, maxCost); 
			maxCostReached = maxCostVal <= newS;
			if (!maxCostReached)
			{
			 outCost->Put(newS, rNext, cNext, outCost); /* new costs */
			 outId->Put(newId, rNext, cNext, outId); /* new id */

			 coordList = AddToList(coordList, rNext, cNext);
			 if(coordList == NULL)
				return 1;
			}
		}
	   }
	}
      }
   /* POSTCOND(coordList == NULL); */
   return 0;
}
Example #20
0
/*
==================
Add principal (All other Add use this)
Add main (All public Add use this)
==================
*/
bool IND_SurfaceManager::AddMain	(IND_Surface	*pNewSurface,
                                     IND_Image		*pImage,
                                     int				pBlockSizeX,
                                     int				pBlockSizeY,
                                     IND_Type		pType,
                                     IND_Quality		pQuality)
{
    Debug->Header ("Creating surface", 5);

    if (!mOk || !pNewSurface || !pImage)
    {
        WriteMessage ();
        return 0;
    }

    Debug->Header ("From image:", 3);
    Debug->DataChar (pImage->GetName (), 1);

    Debug->Header ("File name:", 3);
    Debug->DataInt ((int) &pNewSurface->mSurface, 1);

    // Fill attributes
    pNewSurface->mSurface.mAttributes.mType		= pType;
    pNewSurface->mSurface.mAttributes.mQuality  = pQuality;

    // ----- Check IND_Type and IND_Quality of the image and choose a D3D source and destination format -----

    // ----- Source format (Image)------

    int mSrcBpp = pImage->GetBpp () / 8;									// Source bpp
    D3DFORMAT mSrcFormat = GetSourceFormat (pImage);						// D3D Format

    // ----- Destination format (Texture) ------

    D3DFORMAT mDstFormat = GetDestFormat (pNewSurface, pType, pQuality);	// D3D Format

    // ----- Cutting blocks -----

    // ----- Obtaining info in order to store the image -----

    INFO_SURFACE mI;
    mCutter->FillInfoSurface   (pImage, &mI, pBlockSizeX, pBlockSizeY);

    // Fill attributes
    pNewSurface->mSurface.mAttributes.mBlocksX			= mI.mBlocksX;
    pNewSurface->mSurface.mAttributes.mBlocksY			= mI.mBlocksY;
    pNewSurface->mSurface.mAttributes.mSpareX			= mI.mSpareX;
    pNewSurface->mSurface.mAttributes.mSpareY			= mI.mSpareY;
    pNewSurface->mSurface.mAttributes.mNumBlocks		= mI.mBlocksX * mI.mBlocksY;
    pNewSurface->mSurface.mAttributes.mNumTextures		= mI.mBlocksX * mI.mBlocksY;
    pNewSurface->mSurface.mAttributes.mIsHaveGrid		= 0;
    pNewSurface->mSurface.mAttributes.mWidthBlock		= mI.mWidthBlock;
    pNewSurface->mSurface.mAttributes.mHeightBlock		= mI.mHeightBlock;
    pNewSurface->mSurface.mAttributes.mWidth			= mI.mWidthImage;
    pNewSurface->mSurface.mAttributes.mHeight			= mI.mHeightImage;
    pNewSurface->mSurface.mAttributes.mIsHaveSurface	= 1;

    // Allocate space for the vertex buffer
    // This buffer will be used for drawing the IND_Surface using DrawPrimitiveUp
    pNewSurface->mSurface.mVertexArray = new CUSTOMVERTEX2D [mI.mNumVertices];

    // Each block, needs a texture. We use an array of textures in order to store them.
    pNewSurface->mSurface.mTexturesArray = new IND_Surface::TEXTURES [mI.mBlocksX * mI.mBlocksY];

    // Current position of the vertex
    int mPosX = 0;
    int mPosY = mI.mHeightImage;
    int mPosZ = 0;

    // Position in wich we are storing a vertex
    int mPosVer = 0;

    // Position in wich we are storing a texture
    int mCont = 0;

    // Image pointer
    byte *mPtrBlock = pImage->GetPointer ();

    // Vars
    int mActualWidthBlockX;
    int mActualHeightBlockY;
    float mActualU;
    float mActualV;
    int mActualSpareX;
    int mActualSpareY;

    // ----- Cutting blocks -----

    // We iterate the blocks starting from the lower row
    // We MUST draw the blocks in this order, because the image starts drawing from the lower-left corner
    for (int i = mI.mBlocksY; i > 0; i--)
    {
        for (int j = 1; j < mI.mBlocksX + 1; j++)
        {
            // ----- Vertices position of the block -----

            // There are 4 types of blocks: the ones of the right column, the ones of the upper row,
            // the one of the upper-right corner and the rest of blocks.
            // Depending on the block, we store the vertices one way or another.

            // Normal block
            if (i != 1 && j !=  mI.mBlocksX)
            {
                mActualWidthBlockX	= mI.mWidthBlock;
                mActualHeightBlockY	= mI.mHeightBlock;
                mActualU			= 1.0f;
                mActualV			= 1.0f;
                mActualSpareX		= 0;
                mActualSpareY		= 0;
            }

            // The ones of the right column
            if (i != 1 && j ==  mI.mBlocksX)
            {
                mActualWidthBlockX	= mI.mWidthSpareImage;
                mActualHeightBlockY	= mI.mHeightBlock;
                mActualU			= (float) mI.mWidthSpareImage / mI.mWidthBlock;
                mActualV			= 1.0f;
                mActualSpareX		= mI.mSpareX;
                mActualSpareY		= 0;
            }

            // The ones of the upper row
            if (i == 1 && j !=  mI.mBlocksX)
            {
                mActualWidthBlockX	= mI.mWidthBlock;
                mActualHeightBlockY	= mI.mHeightSpareImage;
                mActualU			= 1.0f;
                mActualV			= (float) mI.mHeightSpareImage / mI.mHeightBlock;
                mActualSpareX		= 0;
                mActualSpareY		= mI.mSpareY;
            }

            // The one of the upper-right corner
            if (i == 1 && j ==  mI.mBlocksX)
            {
                mActualWidthBlockX	= mI.mWidthSpareImage;
                mActualHeightBlockY	= mI.mHeightSpareImage;
                mActualU			= (float) mI.mWidthSpareImage / mI.mWidthBlock;
                mActualV			= (float) mI.mHeightSpareImage / mI.mHeightBlock;
                mActualSpareX		= mI.mSpareX;
                mActualSpareY		= mI.mSpareY;
            }

            // ----- Block creation (using the position, uv coordiantes and texture) -----

            // We push into the buffer the 4 vertices of the block
            Push4Vertices  (pNewSurface->mSurface.mVertexArray,			// Pointer to the buffer
                            mPosVer,									// Position in wich we are storing a vertex
                            mPosX,										// x
                            mPosY,										// y
                            mPosZ,										// z
                            mActualWidthBlockX,							// Block width
                            mActualHeightBlockY,						// Block height
                            mActualU,									// U mapping coordinate
                            mActualV);									// V mapping coordinate

            // Cuts a block from the image (bitmap)
            byte *mTempBlock = 0;
            mCutter->CutBlock  (mPtrBlock,
                                mI.mWidthImage,
                                mI.mWidthBlock,
                                mI.mHeightBlock,
                                mActualSpareX,
                                mActualSpareY,
                                mSrcBpp,
                                &mTempBlock);

            // We create a texture using the cutted bitmap block
            pNewSurface->mSurface.mTexturesArray [mCont].mTexture = CreateTexture (	mTempBlock,
                    mI.mWidthBlock,
                    mI.mHeightBlock,
                    mSrcBpp,
                    mSrcFormat,
                    mDstFormat);

            // Free the bitmap cutted block
            DisposeArray (mTempBlock);

            // ----- Advance -----

            // Increase in 4 vertices the position (we have already stored a quad)
            mPosVer += 4;

            // Increase the texture counter (we have alread stored one texture)
            mCont++;

            // ----- Column change -----

            // We point to the next block (memory and screen)
            mPosX += mI.mWidthBlock;
            mPtrBlock += mI.mWidthBlock * mSrcBpp;
        }

        // ----- Row change -----

        // We point to the next block  (memory and screen)
        mPosX = 0;
        mPtrBlock -= mI.mSpareX * mSrcBpp;

        // If this block is in the last row, we take in count the spare areas.
        if (i == 1)
        {
            mPosY -= mI.mSpareY;
            mPtrBlock += (mI.mWidthImage * mSrcBpp) * (mI.mSpareY - 1);
        }
        else
        {
            mPosY -= mI.mHeightBlock;
            mPtrBlock += (mI.mWidthImage * mSrcBpp) * (mI.mHeightBlock - 1);
        }
    }

    // ----- Puts the objet into the manager  -----

    AddToList (pNewSurface);

    // ----- Debug -----


    Debug->Header ("Type:", 3);
    Debug->DataChar (pNewSurface->GetTypeChar (), 1);

    Debug->Header ("Quality:", 3);
    Debug->DataChar (pNewSurface->GetQualityChar (), 1);

    Debug->Header ("Image size:", 3);
    Debug->DataInt (mI.mWidthImage, 0);
    Debug->DataChar ("x", 0);
    Debug->DataInt (mI.mHeightImage, 1);

    Debug->Header ("Block size:", 3);
    Debug->DataInt (mI.mWidthBlock, 0);
    Debug->DataChar ("x", 0);
    Debug->DataInt (mI.mHeightBlock, 1);

    Debug->Header ("Number of blocks:", 3);
    Debug->DataInt (mI.mBlocksX, 0);
    Debug->DataChar ("x", 0);
    Debug->DataInt (mI.mBlocksY, 1);

    Debug->Header ("Spare (Right | Down):", 3);
    Debug->DataInt (mI.mSpareX, 0);
    Debug->DataChar ("x", 0);
    Debug->DataInt (mI.mSpareY, 1);

    Debug->Header ("Not used percentage:", 3);
    Debug->DataFloat (mI.mNotUsedProportion, 0);
    Debug->DataChar ("%", 1);

    Debug->Header("Surface created", 6);

    return 1;
}
Example #21
0
void cServerDC::DoUserLogin(cConnDC *conn)
{
	// verify we didn't get here by chance
	if(eLS_LOGIN_DONE != conn->GetLSFlag(eLS_LOGIN_DONE)) {
		if(conn->ErrLog(2))
			conn->LogStream() << "User Login when not all done"<<endl;
		conn->CloseNow();
		return;
	}

	// check if same nick already exists
	if (!VerifyUniqueNick(conn))
		return;

	// he is not anymore in progress
	if (mInProgresUsers.ContainsNick(conn->mpUser->mNick)) {
		mInProgresUsers.FlushForUser(conn->mpUser);
		mInProgresUsers.Remove(conn->mpUser);
	}

	// anti login flood temp bans
	if (conn->GetTheoricalClass() <= mC.max_class_int_login) {
		mBanList->AddNickTempBan(conn->mpUser->mNick, mTime.Sec() + mC.int_login, "login later");
		mBanList->AddIPTempBan(conn->GetSockAddress(), mTime.Sec() + mC.int_login, "login later");
	}

	// users special rights and restrictions
	cPenaltyList::sPenalty pen;
	if (mPenList->LoadTo(pen, conn->mpUser->mNick) && (conn->mpUser->mClass != eUC_PINGER))
		conn->mpUser->ApplyRights(pen);

	// insert user to userlist
	if(!AddToList(conn->mpUser)) {
		conn->CloseNow();
		return;
	}

	// display user to others
	ShowUserToAll(conn->mpUser);

	if(mC.send_user_ip) {
		if(conn->mpUser->mClass >= eUC_OPERATOR) {
 			conn->Send(mUserList.GetIPList(),true);
		} else {
			string UserIP;
			cCompositeUserCollection::ufDoIpList DoUserIP(UserIP);
			DoUserIP.Clear();
			DoUserIP(conn->mpUser);
			mOpchatList.SendToAll(UserIP, true, true);
			conn->Send(UserIP);
		}
	}

	if (!mC.hub_topic.empty()) { // send hub name with topic
		static string omsg;
		cDCProto::Create_HubName(omsg, mC.hub_name, mC.hub_topic);

		#ifndef WITHOUT_PLUGINS
		if (mCallBacks.mOnHubName.CallAll(conn->mpUser->mNick, omsg))
		#endif
		{
			conn->Send(omsg);
		}
	}

	SendHeaders(conn, 1);
	AfterUserLogin(conn);
	conn->ClearTimeOut(eTO_LOGIN);
	conn->mpUser->mT.login.Get();
}
Example #22
0
BOOL
ReadInputFile(VOID)
{
INT     i;
CHAR    cbReadBuf[MAXCHARPERLINE];
CHAR    cbTmpBuf[16];
PCHAR   lpTmpPtr;
PCHAR   lpTokPtr;
FILE    *fpin;
LPMACHINEINFO lpMachineInfo;

   if((fpin = fopen(BROWTESTINFILE, "r")) == NULL){
      sprintf(PrintBuf,"\nError opening the input file %s!!\n", BROWTESTINFILE);
      PrintString(TOSCREENANDLOG, PrintBuf);
      return FALSE;
   }

   while(fgets(cbReadBuf, MAXCHARPERLINE, fpin)  != NULL){
      BOOL QUOTEFOUND = FALSE;

      //
      // Skip lines starting with the COMMENTCHAR sign
      //
      for(lpTmpPtr = cbReadBuf; (*lpTmpPtr) == SPACECHAR; lpTmpPtr++);
      if((*lpTmpPtr) == COMMENTCHAR || (*lpTmpPtr) == NEWLINECHAR){
          continue;
      }


//      printf("%s", cbReadBuf);
      //
      // Check if Machine name is given in quotes
      //
      for(lpTokPtr = lpTmpPtr; ((*lpTokPtr) != '\0') &&
                                    ((*lpTokPtr) != QUOTECHAR); lpTokPtr++);

      if((*lpTokPtr) == QUOTECHAR)
            QUOTEFOUND = TRUE;

      //
      // Get the domain name
      //
      if((lpTokPtr = strtok(lpTmpPtr, SPACETABSTR)) == NULL){
         printf("Error in parsing the Domain Name: %s", cbReadBuf);
         fclose(fpin);
         return FALSE;
      }

      //
      // Allocate the Machine Info Structure
      //
      if((lpMachineInfo =  (LPMACHINEINFO) calloc(1, sizeof(MACHINEINFO))) == NULL){
         printf("\nError.  Not enough memory for MachineInfo\n");
         fclose(fpin);
         return FALSE;
      }
      memset(lpMachineInfo, 0, sizeof(MACHINEINFO));

//      RemoveTabs(&lpTokPtr);
      MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, lpTokPtr, strlen(lpTokPtr)+1, lpMachineInfo->wcDomainName, sizeof(lpMachineInfo->wcDomainName));
//      printf("Domain: XXX%sXXX\n",  UnicodeToPrintfString(lpMachineInfo->wcDomainName));

		//
      // Get the machine name
      //

      if(QUOTEFOUND){
          //
          // Machine name given in quotes
          //
          if((lpTokPtr = strtok(NULL, QUOTESTR)) == NULL){
             printf("(1)Error in parsing the Machine Name: %s", cbReadBuf);
             free(lpMachineInfo);
             fclose(fpin);
             return FALSE;
           }

          if((lpTokPtr = strtok(NULL, QUOTESTR)) == NULL){
             printf("(2)Error in parsing the Machine Name: %s", cbReadBuf);
             free(lpMachineInfo);
             fclose(fpin);
             return FALSE;
           }

          MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, lpTokPtr, strlen(lpTokPtr)+1, lpMachineInfo->wcMachineName, sizeof(lpMachineInfo->wcMachineName));

      } else {

          //
          // Machine name not in quotes
          //
          if((lpTokPtr = strtok(NULL, SPACETABSTR)) == NULL){
             printf("(3)Error in parsing the Machine Name: %s", cbReadBuf);
             free(lpMachineInfo);
             fclose(fpin);
             return FALSE;
           }

//          RemoveTabs(&lpTokPtr);
          MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, lpTokPtr, strlen(lpTokPtr)+1, lpMachineInfo->wcMachineName, sizeof(lpMachineInfo->wcMachineName));
      }

//      printf("MachineName: XXX%sXXX\n",  UnicodeToPrintfString(lpMachineInfo->wcMachineName));

      //
      // Get the type (eg: AS3.5)
      //
      if((lpTokPtr = strtok(NULL, SPACETABSTR)) == NULL){
         printf("Error in parsing the Type. Machine: %s", UnicodeToPrintfString(lpMachineInfo->wcMachineName));
         free(lpMachineInfo);
         fclose(fpin);
         return FALSE;
      }

//      RemoveTabs(&lpTokPtr);
      for(i=0; i<MAXOSTYPES && _strnicmp(lpTokPtr, OSTYPES[i].Type, strlen(OSTYPES[i].Type)) != 0; i++);
      if(i < MAXOSTYPES){
         lpMachineInfo->iOsType = i;
         lpMachineInfo->iOsPreference = OSTYPES[i].iPreference;

//         printf("ZZZ%sZZZ  OSTYPE=%s\n", lpTokPtr, OSTYPES[i]);
      } else {
         printf("\nError unknown OsType: %s\n", lpTokPtr);
         free(lpMachineInfo);
         fclose(fpin);
         return FALSE;
      }

      //
      // Get the Subnet
      //
      if((lpTokPtr = strtok(NULL, SPACETABSTR)) == NULL){
         printf("Error in parsing the Subnet. Machine: %s", UnicodeToPrintfString(lpMachineInfo->wcMachineName));
         free(lpMachineInfo);
         fclose(fpin);
         return FALSE;
      }

//      RemoveTabs(&lpTokPtr);
      lpMachineInfo->iSubnet = atoi(lpTokPtr);
//      printf("Subnet: XXX%dXXX\n",  atoi(lpTokPtr));
      if(!(lpMachineInfo->iSubnet == SUBNET1 || lpMachineInfo->iSubnet == SUBNET2)){
         printf("\nUnknown Subnet specified: %d\n", lpMachineInfo->iSubnet);
         fclose(fpin);
         return FALSE;
      }

      //
      // Get the list of protocols
      //
      if((lpTokPtr = strtok(NULL, NEWLINESTR)) == NULL){
         printf("Error in parsing the Protocols. Machine: %s", UnicodeToPrintfString(lpMachineInfo->wcMachineName));
         free(lpMachineInfo);
         fclose(fpin);
         return FALSE;
      }


      RemoveTabs(&lpTokPtr);
      lpTmpPtr = lpTokPtr;
      if((lpTokPtr = strtok(lpTmpPtr, COMMASTR)) == NULL){
         printf("Error in parsing the first protocol. Machine: %s", UnicodeToPrintfString(lpMachineInfo->wcMachineName));
         free(lpMachineInfo);
         fclose(fpin);
         return FALSE;
      }
      for(lpTmpPtr = lpTokPtr; (*lpTmpPtr != '\0') && (*lpTmpPtr == SPACECHAR); lpTmpPtr++);
      RemoveTabs(&lpTmpPtr);
      for(i=0; i<MAXPROTOCOLS && _strnicmp(lpTmpPtr, PROTOCOLS[i], strlen(PROTOCOLS[i])) != 0; i++);
      if(i < MAXPROTOCOLS){
         lpMachineInfo->Protocols[i] = TRUE;
//         printf("ZZZ%sZZZ  PROTOCOL=%s\n", lpTmpPtr, PROTOCOLS[i]);
         }
      else {
         printf("\n(1)Error unknown Protocol: %s\n", lpTmpPtr);
         free(lpMachineInfo);
         fclose(fpin);
         return FALSE;
      }


      while((lpTokPtr = strtok(NULL, COMMASTR)) != NULL){
         for(lpTmpPtr = lpTokPtr; (*lpTmpPtr != '\0') && (*lpTmpPtr == SPACECHAR); lpTmpPtr++);
         RemoveTabs(&lpTmpPtr);
         for(i=0; i<MAXPROTOCOLS && _strnicmp(lpTmpPtr, PROTOCOLS[i], strlen(PROTOCOLS[i])) != 0; i++);
         if(i < MAXPROTOCOLS){
            lpMachineInfo->Protocols[i] = TRUE;
//            printf("ZZZ%sZZZ  PROTOCOL=%s\n", lpTmpPtr, PROTOCOLS[i]);
         } else {
            printf("\n(2)Error unknown Protocol: %s\n", lpTmpPtr);
            free(lpMachineInfo);
            fclose(fpin);
            return FALSE;
         }
      }

      AddToList(&HeadList1, lpMachineInfo);


   } // while(fgets)

fclose(fpin);
return TRUE;
}
Example #23
0
UnicodeString TConfiguration::GetProductVersionStr() const
{
  UnicodeString Result;
#ifndef __linux__
  TGuard Guard(FCriticalSection);
  try
  {
    TVSFixedFileInfo * Info = GetFixedApplicationInfo();
    /*return FMTLOAD(VERSION,
      HIWORD(Info->dwFileVersionMS),
      LOWORD(Info->dwFileVersionMS),
      HIWORD(Info->dwFileVersionLS),
      LOWORD(Info->dwFileVersionLS));*/
    UnicodeString BuildStr;
    if (!GetIsUnofficial())
    {
      BuildStr = LoadStr(VERSION_BUILD);
    }
    else
    {
      #ifdef _DEBUG
      BuildStr = LoadStr(VERSION_DEBUG_BUILD);
      #else
      BuildStr = LoadStr(VERSION_DEV_BUILD);
      #endif
    }

    int Build = LOWORD(Info->dwFileVersionLS);
    if (Build > 0)
    {
      BuildStr += L" " + ::IntToStr(Build);
    }

#if 0
    #ifndef BUILD_OFFICIAL
    UnicodeString BuildDate = __DATE__;
    UnicodeString MonthStr = CutToChar(BuildDate, L' ', true);
    int Month = ParseShortEngMonthName(MonthStr);
    int Day = StrToInt64(CutToChar(BuildDate, L' ', true));
    int Year = StrToInt64(Trim(BuildDate));
    UnicodeString DateStr = FORMAT("%d-%2.2d-%2.2d", Year, Month, Day);
    AddToList(BuildStr, DateStr, L" ");
    #endif
#endif

    UnicodeString FullVersion = GetProductVersion();

    UnicodeString AReleaseType = GetReleaseType();
    if (DebugAlwaysTrue(!AReleaseType.IsEmpty()) &&
        !SameText(AReleaseType, L"stable") &&
        !SameText(AReleaseType, L"development"))
    {
      FullVersion += L" " + AReleaseType;
    }

    Result = FMTLOAD(VERSION2, GetProductVersion().c_str(), Build);

#if 0
    #ifndef BUILD_OFFICIAL
    Result += L" " + LoadStr(VERSION_DONT_DISTRIBUTE);
    #endif
#endif
  }
  catch (Exception & E)
  {
    throw ExtException(&E, "Can't get application version");
  }
#endif
  return Result;
}
Example #24
0
/*!
\b Parameters:

\arg \b pNewFont				Pointer to a new object type 1 font.
\arg \b pImage					Pinter to an object ::IND_Image that contains a previously loaded font from a graphic file generated by \b MudFont (see \b tools section).
\arg \b pFile					Name of the configuration file of the font generated by \b MudFont (see \b tools section)
\arg \b pType					Font type (see ::IND_Type)
\arg \b pQuality				Font quality (see ::IND_Quality)

\b Operation:

This function returns 1 (true) if the font object type 1 passed as a parameter 
exists and is added successfully to the manager loading the font directly from
::IND_Image object and a configuration file, both generated with \b MudFont
(modified version for \b IndieLib can be found in the section \b tools).

The posibility of changing the font from an ::IND_Image object is offered in case 
that you want to change the original font with any modification or filter from 
::IND_ImageManager
*/
bool IND_FontManager::Add		(IND_Font		*pNewFont,
								IND_Image		*pImage,
								char			*pFile,
								IND_Type		pType,
								IND_Quality		pQuality)
{
	Debug->Header ("Parsing and loading font", 5);
	Debug->Header ("File name:", 3);
	Debug->DataChar (pFile, 1);

	if (!mOk)
	{	
		WriteMessage ();
		return 0;
	}
	
	// ----- Width and height of the bitmap font MUST be power of two -----

	IND_Math mMath;

	if (!mMath.IsPowerOfTwo (pImage->GetWidth ()) || 
		!mMath.IsPowerOfTwo (pImage->GetHeight ()))
	{
		Debug->Header ("This operation can not be done", 3);
		Debug->DataChar ("", 1);
		Debug->Header ("The height and width of the font must be power of 2", 2);
		return 0;
	}

	// ----- Bitmap (IND_Surface object) creation -----

	IND_Surface *mNewSurface = new IND_Surface;
	if (!mSurfaceManager->Add (mNewSurface, pImage, pType, pQuality)) 
		return 0;

	// IND_Surface object MUST have one block ONLY
	if (mNewSurface->GetNumBlocks() > 1)
	{
		mSurfaceManager->Delete (mNewSurface);
		return 0;
	}

	pNewFont->SetSurface (mNewSurface);

	// ----- XML font parsing -----

	if (!ParseFont (pNewFont, pFile))
	{
		Debug->Header ("Fatal error, cannot load the font xml file", 2);
		return 0;
	}

	pNewFont->SetFileName (pFile);

	// ----- Puts the object into the manager -----

	AddToList (pNewFont);
	
	// ----- Debug -----

	Debug->Header("Font parsed and loaded", 6);	
	
	return 1;
}
Example #25
0
BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	const int BUF_SIZE = 1024;
	TCHAR buf[BUF_SIZE] { 0 };

	int list_items(0);
	int index(0);

	switch (message)
	{
	case WM_INITDIALOG:
		// handlers
		hComboCat = GetDlgItem(hDlg, IDC_COMBO_CAT);
		hEditSum = GetDlgItem(hDlg, IDC_EDIT_SUM);
		hListGoods = GetDlgItem(hDlg, IDC_LIST_GOODS);
		hListBasket = GetDlgItem(hDlg, IDC_LIST_BASKET);
		hBtnAdd = GetDlgItem(hDlg, IDC_BTN_ADD);
		hBtnDel = GetDlgItem(hDlg, IDC_BTN_DEL);
		hBtnClear = GetDlgItem(hDlg, IDC_BTN_CLEAR);

		// disable windows
		EnableWindow(hEditSum, FALSE);

		// add test data
		AddToList(hComboCat, CAT1);
		AddToList(hComboCat, CAT2);
		AddToList(hComboCat, CAT3);
		SendMessage(hComboCat, CB_SETCURSEL, 0, 0);
		break;
	case WM_COMMAND:
		switch (wParam)
		{
		case IDC_BTN_ADD:
			list_items = SendMessage(hListGoods, LB_GETCOUNT, 0, 0);
			if (list_items)
			{
				index = SendMessage(hListGoods, LB_GETCURSEL, 0, 0);
				SendMessage(hListGoods, LB_GETTEXT, index, (LPARAM)buf);
				SendMessage(hListBasket, LB_ADDSTRING, 0, (LPARAM)buf);
			}
			else
			{
				MessageBox(hDlg, L"List is empty!", L"Error", MB_OK | MB_ICONERROR);
			}
			break;
		case IDC_BTN_DEL:
			break;
		case IDC_BTN_CLEAR:
			SendMessage(hListBasket, LB_RESETCONTENT, 0, 0);
			break;
		}

		if (LOWORD(wParam) == IDC_COMBO_CAT
			&& HIWORD(wParam) == CBN_SELCHANGE)
		{
			SendMessage(hListGoods, LB_RESETCONTENT, 0, 0);

			int category = SendMessage(hComboCat, CB_GETCURSEL, 0, 0);
			switch (category)
			{
			case Category::NOTEBOOKS:
				for (size_t i = 0; i < GOODS_NUM; ++i)
					SendMessage(hListGoods, LB_ADDSTRING, 0, (LPARAM)CAT_NOTEBOOKS[i]);
				break;
			}
		}
		break;
	case WM_CLOSE:
		EndDialog(hDlg, 0);
		return TRUE;
	}

	return FALSE;
}
	EndEnumSysDev

	BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker) {
		AddToList(pMoniker);
	}
Example #27
0
//---------------------------------------------------------------------------
void __fastcall OpenSessionInPutty(const UnicodeString PuttyPath,
  TSessionData * SessionData)
{
  UnicodeString Program, AParams, Dir;
  SplitCommand(PuttyPath, Program, AParams, Dir);
  Program = ExpandEnvironmentVariables(Program);
  if (FindFile(Program))
  {

    AParams = ExpandEnvironmentVariables(AParams);
    UnicodeString Password = GUIConfiguration->PuttyPassword ? SessionData->Password : UnicodeString();
    TCustomCommandData Data(SessionData, SessionData->UserName, Password);
    TRemoteCustomCommand RemoteCustomCommand(Data, SessionData->RemoteDirectory);
    TWinInteractiveCustomCommand InteractiveCustomCommand(
      &RemoteCustomCommand, L"PuTTY");

    UnicodeString Params =
      RemoteCustomCommand.Complete(InteractiveCustomCommand.Complete(AParams, false), true);

    if (!RemoteCustomCommand.IsSiteCommand(AParams))
    {
      UnicodeString SessionName;
      TRegistryStorage * Storage = NULL;
      TSessionData * ExportData = NULL;
      TRegistryStorage * SourceStorage = NULL;
      try
      {
        Storage = new TRegistryStorage(Configuration->PuttySessionsKey);
        Storage->AccessMode = smReadWrite;
        // make it compatible with putty
        Storage->MungeStringValues = false;
        Storage->ForceAnsi = true;
        if (Storage->OpenRootKey(true))
        {
          if (Storage->KeyExists(SessionData->StorageKey))
          {
            SessionName = SessionData->SessionName;
          }
          else
          {
            SourceStorage = new TRegistryStorage(Configuration->PuttySessionsKey);
            SourceStorage->MungeStringValues = false;
            SourceStorage->ForceAnsi = true;
            if (SourceStorage->OpenSubKey(StoredSessions->DefaultSettings->Name, false) &&
                Storage->OpenSubKey(GUIConfiguration->PuttySession, true))
            {
              Storage->Copy(SourceStorage);
              Storage->CloseSubKey();
            }

            ExportData = new TSessionData(L"");
            ExportData->Assign(SessionData);
            ExportData->Modified = true;
            ExportData->Name = GUIConfiguration->PuttySession;
            ExportData->Password = L"";

            if (SessionData->FSProtocol == fsFTP)
            {
              if (GUIConfiguration->TelnetForFtpInPutty)
              {
                ExportData->PuttyProtocol = PuttyTelnetProtocol;
                ExportData->PortNumber = TelnetPortNumber;
                // PuTTY  does not allow -pw for telnet
                Password = L"";
              }
              else
              {
                ExportData->PuttyProtocol = PuttySshProtocol;
                ExportData->PortNumber = SshPortNumber;
              }
            }

            ExportData->Save(Storage, true);
            SessionName = GUIConfiguration->PuttySession;
          }
        }
      }
      __finally
      {
        delete Storage;
        delete ExportData;
        delete SourceStorage;
      }

      AddToList(Params, FORMAT(L"-load %s", (EscapePuttyCommandParam(SessionName))), L" ");
    }

    if (!Password.IsEmpty() && !RemoteCustomCommand.IsPasswordCommand(AParams))
    {
      AddToList(Params, FORMAT(L"-pw %s", (EscapePuttyCommandParam(Password))), L" ");
    }

    if (!ExecuteShell(Program, Params))
    {
      throw Exception(FMTLOAD(EXECUTE_APP_ERROR, (Program)));
    }
  }
Example #28
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    LPNMTOOLBAR lPEvent;
    LPNMTBGETINFOTIP lptbgit;
    LPNMMOUSE lpnm;
    LPNMTBDISPINFO lptbdi;
    LPNMKEY lpnmk;
    HDESK a, b, z;
    DWORD tid;
    DWORD pid;


	//--------------------- Windows Hook Events--------------------

    if (message == WM_SHELLHOOKMESSAGE) {
	switch (LOWORD(wParam)) {
	case HSHELL_WINDOWCREATED:
	    AddToList(hWnd, lParam, "HSHELL_WINDOWCREATED");
	    break;
	case HSHELL_WINDOWDESTROYED:
	    RemoveFromList(hWnd, lParam, "HSHELL_WINDOWDESTROYED");
	    break;
	}
	return 0;
    }
	//---------------------------------------------------------------

    switch (message) {


    case WM_MYBUTTON:
    case WM_COMMAND:
	wmId = LOWORD(wParam);
	wmEvent = HIWORD(wParam);
	// Parse the menu selections:
	newhWnd = (HWND) lParam;
	lPEvent = (LPNMTOOLBAR) lParam;
	lptbgit = (LPNMTBGETINFOTIP) lParam;
	lptbdi = (LPNMTBDISPINFO) lParam;
	lpnm = (LPNMMOUSE) lParam;

	if (HIWORD(wParam) == EN_CHANGE) {
	    Search((HWND) lParam);
	}

	switch (wmId) {

	case ID_PORT_BUTTON:								// When Button Pressed
	    OutputDebugString(L"Button Pressed \n");

	    break;
	case IDM_ABOUT:
	    DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
	    break;
	case IDM_EXIT:
	    DestroyWindow(hWnd);
	    break;
	default:
	    return DefWindowProc(hWnd, message, wParam, lParam);
	}
	break;
    case WM_PAINT:
	GetClientRect(hWnd, &rect);
	hdc = BeginPaint(hWnd, &ps);
	// TODO: Add any drawing code here...
	OutputDebugStringW(L"In Paint");

	EndPaint(hWnd, &ps);
	break;
    case WM_DESTROY:
	freeList();
	ImageList_Remove(g_hImageList, -1);
	ImageList_Destroy(g_hImageList);
	DestroyWindow(hWndToolbar);
	UnSetShellHook(hWnd);
	PostQuitMessage(0);
	break;
    case WM_NOTIFY:											// Capture Notification Messages

	lptbgit = (LPNMTBGETINFOTIP) lParam;
	lPEvent = (LPNMTOOLBAR) lParam;
	lpnm = (LPNMMOUSE) lParam;
	lptbdi = (LPNMTBDISPINFO) lParam;
	newhWnd = (HWND) lParam;
	lpnmk = (LPNMKEY) lParam;



	TCHAR szText[0x1000];
	switch (lPEvent->hdr.code) {
	case TBN_DROPDOWN:										//When Dropdown Button Pressed
	    OutputDebugString(L"Dropdown Pressed \n");
	    {
		// Get the coordinates of the button.
		RECT rc;
		if (!SendMessage(lPEvent->hdr.hwndFrom, TB_GETRECT, (WPARAM) lPEvent->iItem, (LPARAM) & rc))
		    OutputDebugString(L"Error get rect");

		// Convert to screen coordinates.            
		MapWindowPoints(lPEvent->hdr.hwndFrom, HWND_DESKTOP, (LPPOINT) & rc, 2);

		// Get the menu.
		HMENU hMenuLoaded = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU2));

		HICON hIcon = (HICON) GetClassLong((HWND) lPEvent->tbButton.iBitmap, GCL_HICON);

		GetWindowText(((HWND) lPEvent->tbButton.dwData), szText, sizeof(szText));
		// Get the submenu for the first menu item.
		HMENU hPopupMenu = GetSubMenu(hMenuLoaded, 0);
		AppendMenu(hPopupMenu, MF_STRING, 0, szText);




		TPMPARAMS tpm;

		tpm.cbSize = sizeof(TPMPARAMS);
		tpm.rcExclude = rc;




		TrackPopupMenuEx(hPopupMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, rc.left, rc.bottom, hWnd, &tpm);



		return TRUE;

	    }
	    break;
	    //case TBN_GETINFOTIP : 


	default:
	    break;
	}
	switch (lptbgit->hdr.code) {
	case TBN_GETINFOTIP:
	    OutputDebugString(TEXT("ToolTip Info \n"));
	    break;
	default:
	    break;
	}
	switch (lPEvent->hdr.code) {
		 HDESK b;

	case NM_CLICK:											// When Taskbar Button Pressed
	    OutputDebugString(L"ButtonPressed ");
		 b = GetThreadDesktop(GetCurrentThreadId());
	   /* tid = GetWindowThreadProcessId((HWND) lPEvent->tbButton.iBitmap, &pid);
	    a = GetThreadDesktop(tid);
	    b = GetThreadDesktop(GetCurrentThreadId());
	    if (GetThreadDesktop(tid) != GetThreadDesktop(GetCurrentThreadId())) {
		SwitchDesktop((HDESK) a);
		ShowWindow(((HWND) lPEvent->tbButton.iBitmap), SW_RESTORE);
		SetForegroundWindow((HWND) lPEvent->tbButton.iBitmap);
		break;
	    }

	    if (IsIconic(((HWND) lPEvent->tbButton.iBitmap)))
		ShowWindow(((HWND) lPEvent->tbButton.iBitmap), SW_RESTORE);
	    else
		ShowWindow(((HWND) lPEvent->tbButton.iBitmap), SW_MINIMIZE);

		*/
		if(GetParent((HWND) lPEvent->tbButton.iBitmap) != hWnd)
		SetParent((HWND) lPEvent->tbButton.iBitmap,hWnd);
		else
			SetParent((HWND) lPEvent->tbButton.iBitmap,NULL);
	    break;


	default:
	    break;
	}
	


	break;


    case WM_CREATE:
	break;




    default:

	return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Example #29
0
/* Spreads from each nonzero point in points map.
 * First all cells that have a point value > 0, are
 * put in a list. These cells are the points from which is spread.
 * Returns 1 if an error occurs, 0 otherwise.
 */
int SpreadMax(
     MAP_REAL8 *outCost,		/* read-write output map  */
     MAP_INT4 *outId,			/* read-write output map  */
     const MAP_INT4 *points,		/* points to be spread */
     const MAP_REAL8 *cost,		/* initial costs */
     const MAP_REAL8 *friction,		/* friction of each cell */
     const MAP_REAL8 *maxCost)          /* maximum cost before cell is read */
{
     	NODE 	*coordList = NULL;	/* list with cells to be checked */
     	INT4 	pointVal;		/* value in points map of cell */
     	REAL8 	costVal,s, f;	/* s = initial cost, f = friction of cell */
     	int 	r, nrRows = points->NrRows(points);
     	int 	c, nrCols = points->NrCols(points);
     	inList = NewBitMatrix((size_t)nrRows,(size_t)nrCols);

     	if (inList == NULL)
     		return 1;
     	SetAllBitMatrix(inList,nrRows, nrCols, 0); /* not in list */

	/* Fill outCostBuf with MV, this is the initial value */
	outCost->PutAllMV(outCost);

	/* Fill outIdBuf with 0, this is the initial value */
	for (r = 0; r < nrRows; r++)
	 for (c = 0; c < nrCols; c++)
		outId->Put(0, r, c, outId);

	/* algorithm wants points->Get() and all others to
 	* return FALSE if a value is a missing value
 	*/
	points->SetGetTest(GET_MV_TEST, points);
	friction->SetGetTest(GET_MV_TEST, friction);
	cost->SetGetTest(GET_MV_TEST, cost);
	outId->SetGetTest(GET_MV_TEST, outId);
	outCost->SetGetTest(GET_MV_TEST, outCost);
	maxCost->SetGetTest(GET_MV_TEST, maxCost);

	/* breadth - first */
	for(r = 0; r < nrRows; r++)
	{
	 for(c = 0; c < nrCols; c++)
	 {
	 	if(points->Get(&pointVal, r, c, points) &&
	 	(friction->Get(&f, r, c, friction)))
	 	{	
	 		if (f < 0) 
			 return	RetError(1,"spread: Domain error on parameters");
	 		if(pointVal != 0)
	 		{  /* put spread points in coordlist */	
	 	            if(! cost->Get(&s, r, c, cost)) 
	 	                goto putMv;

	 		    outCost->Put(s, r, c, outCost);
	 		    outId->Put(pointVal, r, c, outId);
	 		    coordList = AddToList(coordList, r, c);
	 			if(coordList == NULL)
	 				return 1;
	 		}		
	 	}	
	 	else
		{	
putMv:
			outId->PutMV(r, c, outId);	
			outCost->PutMV(r, c, outCost);	
		}	
	 }
	 AppDynamicProgress();
	}	
	if(PerformSpread(outCost, outId, coordList, friction,maxCost))
		return 1;
	/* cost is not computed for ouside maxCost rangge set to 0  */
	for (r = 0; r < nrRows; r++)
	 for (c = 0; c < nrCols; c++)
	  if(points->Get(&pointVal, r, c, points) &&
	 	(friction->Get(&f, r, c, friction)))
	  { /* under above condition we dis spread so now 
	     * test for these cells if cost is computed
	     */
	    if(!outCost->Get(&costVal, r, c, outCost))
	     outCost->Put(0.0, r, c, outCost);
	  }
	AppEndDynamicProgress();
	Free2d((void **)inList, (size_t)nrRows);
	return 0;		/* successful terminated */ 
}
//---------------------------------------------------------------------------------
// Purpose: Load maps into memory
//---------------------------------------------------------------------------------
void	LoadMaps(const char *map_being_loaded)
{	
	FileHandle_t file_handle;
	char	base_filename[512];
	char	map_name[128];
	bool	map_is_in_map_cycle;
	bool	found_match;

	// Don't call FreeMaps() !!!!
	FreeList((void **) &map_list, &map_list_size);
	FreeList((void **) &votemap_list, &votemap_list_size);
	FreeList((void **) &map_in_cycle_list, &map_in_cycle_list_size);
	FreeList((void **) &map_not_in_cycle_list, &map_not_in_cycle_list_size);

	FindMapCVars();

//	MMsg("************ LOADING MAP LISTS *************\n");
	override_changelevel = 0;

//	MMsg("Loading Map [%s]\n", map_being_loaded);
	Q_strcpy(current_map, map_being_loaded);

	// Update last maps list
	last_map_index ++;
	if (last_map_index == MAX_LAST_MAPS)
	{
		last_map_index = 0;
	}


	Q_strcpy(last_map_list[last_map_index].map_name, current_map);

	time_t current_time;
	time(&current_time);
	last_map_list[last_map_index].start_time = current_time;

	SetChangeLevelReason("");

	Q_strcpy(last_map_list[last_map_index].end_reason, "");

	// Reset force map stuff, mani_map_cycle_mode will set these if necessary
	// when server.cfg is run
	Q_strcpy(forced_nextmap,"");
	override_changelevel = 0;
	override_setnextmap = false;

	// Get nextmap on level change
	file_handle = filesystem->Open (mapcyclefile->GetString(),"rt",NULL);
	if (file_handle == NULL)
	{
//		MMsg("Failed to load %s\n", mapcyclefile->GetString());
		Q_strcpy(next_map, map_being_loaded);
		mani_nextmap.SetValue(next_map);
		AddToList((void **) &map_in_cycle_list, sizeof(map_t), &map_in_cycle_list_size);
		Q_strcpy(map_in_cycle_list[map_in_cycle_list_size - 1].map_name, map_being_loaded);
	}
	else
	{
//		MMsg("Mapcycle list [%s]\n", mapcyclefile->GetString());

		while (filesystem->ReadLine (map_name, sizeof(map_name), file_handle) != NULL)
		{
			if (!ParseLine(map_name, true, false))
			{
				continue;
			}

			if (engine->IsMapValid(map_name) == 0) 
			{
//				MMsg("\n*** Map [%s] is not a valid map !!! *****\n", map_name);
				continue;
			}

			AddToList((void **) &map_in_cycle_list, sizeof(map_t), &map_in_cycle_list_size);
			Q_strcpy(map_in_cycle_list[map_in_cycle_list_size - 1].map_name, map_name);
			map_in_cycle_list[map_in_cycle_list_size - 1].selected_for_vote = false;

//			MMsg("[%s] ", map_name);
		}

//		MMsg("\n");
		filesystem->Close(file_handle);
	}
	
	// Check if this map is in the map cycle
	map_is_in_map_cycle = false;
	for (int i = 0; i < map_in_cycle_list_size; i ++)
	{
		if (FStrEq(map_in_cycle_list[i].map_name, current_map))
		{
			map_is_in_map_cycle = true;
			break;
		}
	}

	if (!map_is_in_map_cycle)
	{
		// Map loaded is not in the map cycle list
		// so hl2 will default the next map to 
		// be the first on the map cycle list
		if (map_in_cycle_list_size != 0)
		{
			Q_strcpy(next_map, map_in_cycle_list[0].map_name);
			mani_nextmap.SetValue(next_map);
		}
	}
	else
	{
		// Search map cycle list for nextmap
		for (int i = 0; i < map_in_cycle_list_size; i ++)
		{
			if (FStrEq( map_in_cycle_list[i].map_name, current_map))
			{
				if (i == (map_in_cycle_list_size - 1))
				{
					// End of map list so we must use the first
					// in the list
					Q_strcpy(next_map, map_in_cycle_list[0].map_name);
					mani_nextmap.SetValue(next_map);
				}
				else
				{
					// Set next map
					Q_strcpy(next_map, map_in_cycle_list[i+1].map_name);
					mani_nextmap.SetValue(next_map);
				}

				Q_strcpy(last_map_in_cycle, current_map);

				break;
			}
		}
	}

	//Get Map list
	
       //Default to loading the new location
       if(filesystem->FileExists("cfg/mapcycle.txt",NULL)) { file_handle = filesystem->Open ("cfg/mapcycle.txt","rt",NULL); }
       //If that failed, load the default file from the new location
       else if(filesystem->FileExists("cfg/mapcycle_default.txt",NULL)) { file_handle = filesystem->Open ("cfg/mapcycle_default.txt","rt",NULL); }
       //fall back to the old location
       else { file_handle = filesystem->Open ("maplist.txt","rt",NULL); }
	
	if (file_handle == NULL)
	{
		MMsg("Failed to load maplist.txt/mapcycle.txt YOU MUST HAVE A MAPLIST.TXT FILE!\n");
	}
	else
	{
//		MMsg("Map list\n");

		while (filesystem->ReadLine (map_name, 128, file_handle) != NULL)
		{
			if (!ParseLine(map_name, true, false))
			{
				// String is empty after parsing
				continue;
			}


			if ((!FStrEq( map_name, "test_speakers"))
				&& (!FStrEq( map_name, "test_hardware")))
			{
				if (engine->IsMapValid(map_name) == 0) 
				{
					MMsg("\n*** Map [%s] is not a valid map !!! *****\n", map_name);
					continue;
				}

				AddToList((void **) &map_list, sizeof(map_t), &map_list_size);
				Q_strcpy(map_list[map_list_size-1].map_name, map_name);
				map_list[map_list_size - 1].selected_for_vote = false;
//				MMsg("[%s] ", map_name);
			}
		}

//		MMsg("\n");
		filesystem->Close(file_handle);
	}

//	MMsg("Maps not in [%s]\n", mapcyclefile->GetString());
	// Calculate maps not in mapcycle

	for (int i = 0; i < map_list_size; i ++)
	{
		found_match = false;
		for (int j = 0; j < map_in_cycle_list_size; j++)
		{
			if (FStrEq(map_list[i].map_name, map_in_cycle_list[j].map_name))
			{
				found_match = true;
				break;
			}
		}

		if (!found_match)
		{
			AddToList((void **) &map_not_in_cycle_list, sizeof(map_t), &map_not_in_cycle_list_size);
			Q_strcpy(map_not_in_cycle_list[map_not_in_cycle_list_size - 1].map_name, map_list[i].map_name);
//			MMsg("[%s] ", map_not_in_cycle_list[map_not_in_cycle_list_size - 1].map_name);
		}
	}			

//	MMsg("\n");

	// Check if votemaplist.txt exists, create a new one if it doesn't
	snprintf(base_filename, sizeof (base_filename), "./cfg/%s/votemaplist.txt", mani_path.GetString());
	file_handle = filesystem->Open (base_filename,"rt",NULL);
	if (file_handle == NULL)
	{
		MMsg("Failed to load votemaplist.txt\n");
		MMsg("Attempting to write a new votemaplist.txt file based on maplist.txt\n");

		file_handle = filesystem->Open(base_filename,"wt",NULL);
		if (file_handle == NULL)
		{
//			MMsg("Failed to open votemaplist.txt for writing\n");
		}
		else
		{
			// Write votemaplist.txt in human readable text format
			for (int i = 0; i < map_list_size; i ++)
			{
				char	temp_string[512];
				int		temp_length = snprintf(temp_string, sizeof(temp_string), "%s\n", map_list[i].map_name);

				if (filesystem->Write((void *) temp_string, temp_length, file_handle) == 0)											
				{
					MMsg("Failed to write map [%s] to votemaplist.txt!!\n", map_list[i].map_name);
					filesystem->Close(file_handle);
					break;
				}
			}

			MMsg("Wrote %i maps to votemaplist.txt\n", map_list_size);
			filesystem->Close(file_handle);
		}
	}
	else
	{
		filesystem->Close(file_handle);
	}

	// Read in votemaplist.txt
	file_handle = filesystem->Open (base_filename,"rt",NULL);
	if (file_handle == NULL)
	{
//		MMsg("Failed to load votemaplist.txt\n");
	}
	else
	{
//		MMsg("Votemap list\n");
		while (filesystem->ReadLine (map_name, sizeof(map_name), file_handle) != NULL)
		{
			if (!ParseLine(map_name, true, false))
			{
				// String is empty after parsing
				continue;
			}

			if (engine->IsMapValid(map_name) == 0) 
			{
				MMsg("\n*** Map [%s] is not a valid map !!! *****\n", map_name);
				continue;
			}

			AddToList((void **) &votemap_list, sizeof(map_t), &votemap_list_size);
			Q_strcpy(votemap_list[votemap_list_size - 1].map_name, map_name);
			votemap_list[votemap_list_size - 1].selected_for_vote = false;
//			MMsg("[%s] ", map_name);
		}

//		MMsg("\n");
		filesystem->Close(file_handle);
	}

	// Check if loaded map cycle file is different than
	// the persistent one
	bool	rebuild_proper_map_cycle = false;

	if (map_in_cycle_list_size != proper_map_cycle_mode_list_size)
	{
		rebuild_proper_map_cycle = true;
	}
	else
	{
		// Both cycles the same size so check maps are in same
		// order
		for (int i = 0; i < map_in_cycle_list_size; i ++)
		{
			if (!FStrEq(map_in_cycle_list[i].map_name, 
						proper_map_cycle_mode_list[i].map_name))
			{
				rebuild_proper_map_cycle = true;
				break;
			}
		}
	}

	if (rebuild_proper_map_cycle)
	{
		// Free persistance map cycle and rebuild
		FreeList((void **) &proper_map_cycle_mode_list, &proper_map_cycle_mode_list_size);
		for (int i = 0; i < map_in_cycle_list_size; i++)
		{
			AddToList((void **) &proper_map_cycle_mode_list, sizeof(track_map_t), &proper_map_cycle_mode_list_size);
			Q_strcpy(proper_map_cycle_mode_list[i].map_name, map_in_cycle_list[i].map_name);
			proper_map_cycle_mode_list[i].played = false;
			if (FStrEq(proper_map_cycle_mode_list[i].map_name, current_map))
			{
				proper_map_cycle_mode_list[i].played = true;
			}
		}
	}

//	MMsg("Persistant Map Cycle\n");
	for (int i = 0; i < proper_map_cycle_mode_list_size; i++)
	{
		if (FStrEq(proper_map_cycle_mode_list[i].map_name, current_map))
		{
			proper_map_cycle_mode_list[i].played = true;
		}

		if (proper_map_cycle_mode_list[i].played)
		{
//			MMsg("*[%s] ", proper_map_cycle_mode_list[i].map_name);
		}
		else
		{
//			MMsg("[%s] ", proper_map_cycle_mode_list[i].map_name);
		}
	}

//	MMsg("\n");
//	MMsg("************ MAP LISTS LOADED *************\n");
}