more fixes for coverity, now fixed what i have done in previous build :)
This commit is contained in:
parent
95c121ef43
commit
ff51914ea6
10 changed files with 75 additions and 54 deletions
|
|
@ -4075,3 +4075,8 @@ public:
|
||||||
#define FOR_EACH_AE(arrayName, iteratorName) \
|
#define FOR_EACH_AE(arrayName, iteratorName) \
|
||||||
for (int iteratorName = 0; iteratorName != arrayName.GetElementNumber (); iteratorName++)
|
for (int iteratorName = 0; iteratorName != arrayName.GetElementNumber (); iteratorName++)
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Sizeof bounds
|
||||||
|
//
|
||||||
|
#define SIZEOF_CHAR(in) sizeof (in) - 1
|
||||||
|
|
|
||||||
|
|
@ -5123,14 +5123,14 @@ void Bot::BotAI (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char enemyName[80], weaponName[80], aimFlags[32], botType[32];
|
char enemyName[80], weaponName[80], aimFlags[64], botType[32];
|
||||||
|
|
||||||
if (!IsEntityNull (m_enemy))
|
if (!IsEntityNull (m_enemy))
|
||||||
strcpy (enemyName, STRING (m_enemy->v.netname));
|
strncpy (enemyName, STRING (m_enemy->v.netname), SIZEOF_CHAR (enemyName));
|
||||||
else if (!IsEntityNull (m_lastEnemy))
|
else if (!IsEntityNull (m_lastEnemy))
|
||||||
{
|
{
|
||||||
strcpy (enemyName, " (L)");
|
strcpy (enemyName, " (L)");
|
||||||
strcat (enemyName, STRING (m_lastEnemy->v.netname));
|
strncat (enemyName, STRING (m_lastEnemy->v.netname), SIZEOF_CHAR (enemyName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcpy (enemyName, " (null)");
|
strcpy (enemyName, " (null)");
|
||||||
|
|
@ -5139,7 +5139,7 @@ void Bot::BotAI (void)
|
||||||
memset (pickupName, 0, sizeof (pickupName));
|
memset (pickupName, 0, sizeof (pickupName));
|
||||||
|
|
||||||
if (!IsEntityNull (m_pickupItem))
|
if (!IsEntityNull (m_pickupItem))
|
||||||
strcpy (pickupName, STRING (m_pickupItem->v.classname));
|
strncpy (pickupName, STRING (m_pickupItem->v.classname), SIZEOF_CHAR (pickupName));
|
||||||
else
|
else
|
||||||
strcpy (pickupName, " (null)");
|
strcpy (pickupName, " (null)");
|
||||||
|
|
||||||
|
|
@ -5195,7 +5195,7 @@ void Bot::BotAI (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strncpy (weaponName, selectTab->weaponName, sizeof (weaponName));
|
strncpy (weaponName, selectTab->weaponName, SIZEOF_CHAR (weaponName));
|
||||||
|
|
||||||
char outputBuffer[512];
|
char outputBuffer[512];
|
||||||
memset (outputBuffer, 0, sizeof (outputBuffer));
|
memset (outputBuffer, 0, sizeof (outputBuffer));
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ char *HumanizeName (char *name)
|
||||||
// this function humanize player name (i.e. trim clan and switch to lower case (sometimes))
|
// this function humanize player name (i.e. trim clan and switch to lower case (sometimes))
|
||||||
|
|
||||||
static char outputName[64]; // create return name buffer
|
static char outputName[64]; // create return name buffer
|
||||||
strncpy (outputName, name, sizeof (outputName)); // copy name to new buffer
|
strncpy (outputName, name, SIZEOF_CHAR (outputName)); // copy name to new buffer
|
||||||
|
|
||||||
// drop tag marks, 80 percent of time
|
// drop tag marks, 80 percent of time
|
||||||
if (Random.Long (1, 100) < 80)
|
if (Random.Long (1, 100) < 80)
|
||||||
|
|
@ -156,6 +156,8 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
if (!yb_chat.GetBool () || IsNullString (text))
|
if (!yb_chat.GetBool () || IsNullString (text))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#define ASSIGN_TALK_ENTITY() if (!IsEntityNull (talkEntity)) strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), SIZEOF_CHAR (m_tempStrings))
|
||||||
|
|
||||||
memset (&m_tempStrings, 0, sizeof (m_tempStrings));
|
memset (&m_tempStrings, 0, sizeof (m_tempStrings));
|
||||||
|
|
||||||
char *textStart = text;
|
char *textStart = text;
|
||||||
|
|
@ -198,12 +200,11 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
}
|
}
|
||||||
talkEntity = g_clients[index].ent;
|
talkEntity = g_clients[index].ent;
|
||||||
|
|
||||||
if (!IsEntityNull (talkEntity))
|
ASSIGN_TALK_ENTITY ();
|
||||||
strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), sizeof (m_tempStrings));
|
|
||||||
}
|
}
|
||||||
// mapname?
|
// mapname?
|
||||||
else if (*pattern == 'm')
|
else if (*pattern == 'm')
|
||||||
strcat (m_tempStrings, GetMapName ());
|
strncat (m_tempStrings, GetMapName (), SIZEOF_CHAR (m_tempStrings));
|
||||||
// roundtime?
|
// roundtime?
|
||||||
else if (*pattern == 'r')
|
else if (*pattern == 'r')
|
||||||
{
|
{
|
||||||
|
|
@ -214,9 +215,7 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
else if (*pattern == 's')
|
else if (*pattern == 's')
|
||||||
{
|
{
|
||||||
talkEntity = EntityOfIndex (m_sayTextBuffer.entityIndex);
|
talkEntity = EntityOfIndex (m_sayTextBuffer.entityIndex);
|
||||||
|
ASSIGN_TALK_ENTITY ();
|
||||||
if (!IsEntityNull (talkEntity))
|
|
||||||
strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), sizeof (m_tempStrings));
|
|
||||||
}
|
}
|
||||||
// teammate alive?
|
// teammate alive?
|
||||||
else if (*pattern == 't')
|
else if (*pattern == 't')
|
||||||
|
|
@ -238,8 +237,7 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
else
|
else
|
||||||
talkEntity = g_clients[i].ent;
|
talkEntity = g_clients[i].ent;
|
||||||
|
|
||||||
if (!IsEntityNull (talkEntity))
|
ASSIGN_TALK_ENTITY ();
|
||||||
strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), sizeof (m_tempStrings));
|
|
||||||
}
|
}
|
||||||
else // no teammates alive...
|
else // no teammates alive...
|
||||||
{
|
{
|
||||||
|
|
@ -255,8 +253,7 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
{
|
{
|
||||||
talkEntity = g_clients[i].ent;
|
talkEntity = g_clients[i].ent;
|
||||||
|
|
||||||
if (!IsEntityNull (talkEntity))
|
ASSIGN_TALK_ENTITY ();
|
||||||
strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), sizeof (m_tempStrings));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -274,9 +271,7 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
if (i < GetMaxClients ())
|
if (i < GetMaxClients ())
|
||||||
{
|
{
|
||||||
talkEntity = g_clients[i].ent;
|
talkEntity = g_clients[i].ent;
|
||||||
|
ASSIGN_TALK_ENTITY ();
|
||||||
if (!IsEntityNull (talkEntity))
|
|
||||||
strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), sizeof (m_tempStrings));
|
|
||||||
}
|
}
|
||||||
else // no teammates alive...
|
else // no teammates alive...
|
||||||
{
|
{
|
||||||
|
|
@ -289,9 +284,7 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
if (i < GetMaxClients ())
|
if (i < GetMaxClients ())
|
||||||
{
|
{
|
||||||
talkEntity = g_clients[i].ent;
|
talkEntity = g_clients[i].ent;
|
||||||
|
ASSIGN_TALK_ENTITY ();
|
||||||
if (!IsEntityNull (talkEntity))
|
|
||||||
strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), sizeof (m_tempStrings));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -315,9 +308,7 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
else if (*pattern == 'v')
|
else if (*pattern == 'v')
|
||||||
{
|
{
|
||||||
talkEntity = m_lastVictim;
|
talkEntity = m_lastVictim;
|
||||||
|
ASSIGN_TALK_ENTITY ();
|
||||||
if (!IsEntityNull (talkEntity))
|
|
||||||
strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), sizeof (m_tempStrings));
|
|
||||||
}
|
}
|
||||||
pattern++;
|
pattern++;
|
||||||
textStart = pattern;
|
textStart = pattern;
|
||||||
|
|
@ -328,7 +319,7 @@ void Bot::PrepareChatMessage (char *text)
|
||||||
{
|
{
|
||||||
// let the bots make some mistakes...
|
// let the bots make some mistakes...
|
||||||
char tempString[160];
|
char tempString[160];
|
||||||
strncpy (tempString, textStart, 159);
|
strncpy (tempString, textStart, SIZEOF_CHAR (tempString));
|
||||||
|
|
||||||
HumanizeChat (tempString);
|
HumanizeChat (tempString);
|
||||||
strcat (m_tempStrings, tempString);
|
strcat (m_tempStrings, tempString);
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ bool Bot::IsEnemyHiddenByRendering (edict_t *enemy)
|
||||||
|
|
||||||
entvars_t &v = enemy->v;
|
entvars_t &v = enemy->v;
|
||||||
|
|
||||||
bool enemyHasGun = (v.weapons & WEAPON_SECONDARY) || (v.weapons & WEAPON_SECONDARY);
|
bool enemyHasGun = (v.weapons & WEAPON_PRIMARY) || (v.weapons & WEAPON_SECONDARY);
|
||||||
bool enemyGunfire = (v.button & IN_ATTACK) || (v.oldbuttons & IN_ATTACK);
|
bool enemyGunfire = (v.button & IN_ATTACK) || (v.oldbuttons & IN_ATTACK);
|
||||||
|
|
||||||
if ((v.renderfx == kRenderFxExplode || (v.effects & EF_NODRAW)) && (!enemyGunfire || !enemyHasGun))
|
if ((v.renderfx == kRenderFxExplode || (v.effects & EF_NODRAW)) && (!enemyGunfire || !enemyHasGun))
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ void InitConfig (void)
|
||||||
Array <String> pair = String (line).Split ("\t\t");
|
Array <String> pair = String (line).Split ("\t\t");
|
||||||
|
|
||||||
if (pair.GetElementNumber () > 1)
|
if (pair.GetElementNumber () > 1)
|
||||||
strcpy (line, pair[0].Trim ().GetBuffer ());
|
strncpy (line, pair[0].Trim ().GetBuffer (), SIZEOF_CHAR (line));
|
||||||
|
|
||||||
strtrim (line);
|
strtrim (line);
|
||||||
line[32] = 0;
|
line[32] = 0;
|
||||||
|
|
@ -516,7 +516,7 @@ void InitConfig (void)
|
||||||
while (fp.GetBuffer (line, 255))
|
while (fp.GetBuffer (line, 255))
|
||||||
{
|
{
|
||||||
SKIP_COMMENTS ();
|
SKIP_COMMENTS ();
|
||||||
strncpy (section, GetField (line, 0, 1), sizeof (section));
|
strncpy (section, GetField (line, 0, 1), SIZEOF_CHAR (section));
|
||||||
|
|
||||||
if (strcmp (section, "[KILLED]") == 0)
|
if (strcmp (section, "[KILLED]") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1993,7 +1993,7 @@ void ClientCommand (edict_t *ent)
|
||||||
if (IsNullString (CMD_ARGS ()))
|
if (IsNullString (CMD_ARGS ()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
strncpy (target->m_sayTextBuffer.sayText, CMD_ARGS (), sizeof (target->m_sayTextBuffer.sayText));
|
strncpy (target->m_sayTextBuffer.sayText, CMD_ARGS (), SIZEOF_CHAR (target->m_sayTextBuffer.sayText));
|
||||||
target->m_sayTextBuffer.timeNextChat = GetWorldTime () + target->m_sayTextBuffer.chatDelay;
|
target->m_sayTextBuffer.timeNextChat = GetWorldTime () + target->m_sayTextBuffer.chatDelay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pickedName->used = nameFound = true;
|
pickedName->used = nameFound = true;
|
||||||
strncpy (outputName, pickedName->name, sizeof (outputName));
|
strncpy (outputName, pickedName->name, SIZEOF_CHAR (outputName));
|
||||||
|
|
||||||
steamId = pickedName->steamId;
|
steamId = pickedName->steamId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -549,14 +549,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
||||||
if (blockedRight)
|
if (blockedRight)
|
||||||
state[i] -= 5;
|
state[i] -= 5;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
state[i] = 0;
|
|
||||||
i++;
|
|
||||||
state[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// weighted all possible moves, now sort them to start with most probable
|
// weighted all possible moves, now sort them to start with most probable
|
||||||
bool isSorting = false;
|
bool isSorting = false;
|
||||||
|
|
||||||
|
|
@ -1254,6 +1247,7 @@ private:
|
||||||
float pri;
|
float pri;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int m_allocCount;
|
||||||
int m_size;
|
int m_size;
|
||||||
int m_heapSize;
|
int m_heapSize;
|
||||||
Node *m_heap;
|
Node *m_heap;
|
||||||
|
|
@ -1269,7 +1263,9 @@ public:
|
||||||
{
|
{
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
m_heapSize = initialSize;
|
m_heapSize = initialSize;
|
||||||
m_heap = new Node[m_heapSize];
|
m_allocCount = 0;
|
||||||
|
|
||||||
|
m_heap = static_cast <Node *> (malloc (sizeof (Node) * m_heapSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ~PriorityQueue (void)
|
inline ~PriorityQueue (void)
|
||||||
|
|
@ -1281,20 +1277,24 @@ public:
|
||||||
// inserts a value into the priority queue
|
// inserts a value into the priority queue
|
||||||
inline void Push (int value, float pri)
|
inline void Push (int value, float pri)
|
||||||
{
|
{
|
||||||
|
if (m_allocCount > 20)
|
||||||
|
{
|
||||||
|
AddLogEntry (false, LL_FATAL, "Tried to re-allocate heap too many times in pathfinder. This usually indicates corrupted waypoint file. Please obtain new copy of waypoint.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_heap == NULL)
|
if (m_heap == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_size >= m_heapSize)
|
if (m_size >= m_heapSize)
|
||||||
{
|
{
|
||||||
|
m_allocCount++;
|
||||||
m_heapSize += 100;
|
m_heapSize += 100;
|
||||||
|
|
||||||
Node *newHeap = static_cast <Node *> (realloc (m_heap, sizeof (Node) * m_heapSize));
|
Node *newHeap = static_cast <Node *> (realloc (m_heap, sizeof (Node) * m_heapSize));
|
||||||
|
|
||||||
if (newHeap != NULL)
|
if (newHeap != NULL)
|
||||||
{
|
|
||||||
m_heap = newHeap;
|
m_heap = newHeap;
|
||||||
free (newHeap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_heap[m_size].pri = pri;
|
m_heap[m_size].pri = pri;
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ void NetworkMsg::Execute (void *p)
|
||||||
switch (m_state)
|
switch (m_state)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
strncpy (weaponProp.className, PTR_TO_STR (p), sizeof (weaponProp.className));
|
strncpy (weaponProp.className, PTR_TO_STR (p), SIZEOF_CHAR (weaponProp.className));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
||||||
|
|
@ -941,7 +941,7 @@ const char *GetMapName (void)
|
||||||
// this function gets the map name and store it in the map_name global string variable.
|
// this function gets the map name and store it in the map_name global string variable.
|
||||||
|
|
||||||
static char mapName[256];
|
static char mapName[256];
|
||||||
strncpy (mapName, const_cast <const char *> (g_pGlobals->pStringBase + static_cast <int> (g_pGlobals->mapname)), sizeof (mapName));
|
strncpy (mapName, const_cast <const char *> (g_pGlobals->pStringBase + static_cast <int> (g_pGlobals->mapname)), SIZEOF_CHAR (mapName));
|
||||||
|
|
||||||
return &mapName[0]; // and return a pointer to it
|
return &mapName[0]; // and return a pointer to it
|
||||||
}
|
}
|
||||||
|
|
@ -1222,7 +1222,7 @@ char *Localizer::TranslateInput (const char *input)
|
||||||
if (ptr != input)
|
if (ptr != input)
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
strncpy (string, input, 1024);
|
strncpy (string, input, ARRAYSIZE_HLSDK (string));
|
||||||
strtrim (string);
|
strtrim (string);
|
||||||
|
|
||||||
FOR_EACH_AE (m_langTab, i)
|
FOR_EACH_AE (m_langTab, i)
|
||||||
|
|
|
||||||
|
|
@ -1075,13 +1075,20 @@ bool Waypoint::Load (void)
|
||||||
|
|
||||||
if (fp.IsValid ())
|
if (fp.IsValid ())
|
||||||
{
|
{
|
||||||
fp.Read (&header, sizeof (header));
|
if (fp.Read (&header, sizeof (WaypointHeader)) == 0)
|
||||||
|
{
|
||||||
|
sprintf (m_infoBuffer, "%s.pwf - damaged waypoint file (unable to read header)", GetMapName ());
|
||||||
|
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||||
|
|
||||||
|
fp.Close ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (strncmp (header.header, FH_WAYPOINT, strlen (FH_WAYPOINT)) == 0)
|
if (strncmp (header.header, FH_WAYPOINT, strlen (FH_WAYPOINT)) == 0)
|
||||||
{
|
{
|
||||||
if (header.fileVersion != FV_WAYPOINT)
|
if (header.fileVersion != FV_WAYPOINT)
|
||||||
{
|
{
|
||||||
sprintf (m_infoBuffer, "%s.pwf - incorrect waypoint file version (expected '%d' found '%d')", GetMapName (), FV_WAYPOINT, static_cast <int> (header.fileVersion));
|
sprintf (m_infoBuffer, "%s.pwf - incorrect waypoint file version (expected '%d' found '%d')", GetMapName (), FV_WAYPOINT, header.fileVersion);
|
||||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||||
|
|
||||||
fp.Close ();
|
fp.Close ();
|
||||||
|
|
@ -1097,7 +1104,7 @@ bool Waypoint::Load (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (header.pointNumber == 0 || header.pointNumber >= MAX_WAYPOINTS)
|
if (header.pointNumber == 0 || header.pointNumber > MAX_WAYPOINTS)
|
||||||
{
|
{
|
||||||
sprintf (m_infoBuffer, "%s.pwf - waypoint file contains illegal number of waypoints (mapname: '%s', header: '%s')", GetMapName (), GetMapName (), header.mapName);
|
sprintf (m_infoBuffer, "%s.pwf - waypoint file contains illegal number of waypoints (mapname: '%s', header: '%s')", GetMapName (), GetMapName (), header.mapName);
|
||||||
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
AddLogEntry (true, LL_ERROR, m_infoBuffer);
|
||||||
|
|
@ -1221,8 +1228,8 @@ void Waypoint::Save (void)
|
||||||
memset (header.header, 0, sizeof (header.header));
|
memset (header.header, 0, sizeof (header.header));
|
||||||
|
|
||||||
strcpy (header.header, FH_WAYPOINT);
|
strcpy (header.header, FH_WAYPOINT);
|
||||||
strncpy (header.author, STRING (g_hostEntity->v.netname), sizeof (header.author));
|
strncpy (header.author, STRING (g_hostEntity->v.netname), SIZEOF_CHAR (header.author));
|
||||||
strncpy (header.mapName, GetMapName (), sizeof (header.mapName));
|
strncpy (header.mapName, GetMapName (), SIZEOF_CHAR (header.mapName));
|
||||||
|
|
||||||
header.mapName[31] = 0;
|
header.mapName[31] = 0;
|
||||||
header.fileVersion = FV_WAYPOINT;
|
header.fileVersion = FV_WAYPOINT;
|
||||||
|
|
@ -2146,7 +2153,11 @@ bool Waypoint::LoadPathMatrix (void)
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
// read number of waypoints
|
// read number of waypoints
|
||||||
fp.Read (&num, sizeof (int));
|
if (fp.Read (&num, sizeof (int)) == 0)
|
||||||
|
{
|
||||||
|
fp.Close ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (num != g_numWaypoints)
|
if (num != g_numWaypoints)
|
||||||
{
|
{
|
||||||
|
|
@ -2572,10 +2583,24 @@ WaypointDownloadError WaypointDownloader::DoDownload (void)
|
||||||
timeout.tv_sec = 5;
|
timeout.tv_sec = 5;
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
setsockopt (socketHandle, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof (timeout));
|
int result = 0;
|
||||||
setsockopt (socketHandle, SOL_SOCKET, SO_SNDTIMEO, (char *) &timeout, sizeof (timeout));
|
|
||||||
|
|
||||||
|
result = setsockopt (socketHandle, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof (timeout));
|
||||||
|
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
FreeSocket (socketHandle);
|
||||||
|
return WDE_SOCKET_ERROR;
|
||||||
|
}
|
||||||
|
result = setsockopt (socketHandle, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof (timeout));
|
||||||
|
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
FreeSocket (socketHandle);
|
||||||
|
return WDE_SOCKET_ERROR;
|
||||||
|
}
|
||||||
memset (&dest, 0, sizeof (dest));
|
memset (&dest, 0, sizeof (dest));
|
||||||
|
|
||||||
dest.sin_family = AF_INET;
|
dest.sin_family = AF_INET;
|
||||||
dest.sin_port = htons (80);
|
dest.sin_port = htons (80);
|
||||||
dest.sin_addr.s_addr = inet_addr (inet_ntoa (*((struct in_addr *) host->h_addr)));
|
dest.sin_addr.s_addr = inet_addr (inet_ntoa (*((struct in_addr *) host->h_addr)));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue