aboutsummaryrefslogtreecommitdiff
path: root/dep/ACE_wrappers/ace/Capabilities.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:35:07 -0700
committermaximius <none@none>2009-10-17 15:35:07 -0700
commit26b5e033ffde3d161382fc9addbfa99738379641 (patch)
treea344f369ca32945f787a02dee35c3dbe342bed7e /dep/ACE_wrappers/ace/Capabilities.cpp
parentf21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff)
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
Diffstat (limited to 'dep/ACE_wrappers/ace/Capabilities.cpp')
-rw-r--r--dep/ACE_wrappers/ace/Capabilities.cpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/dep/ACE_wrappers/ace/Capabilities.cpp b/dep/ACE_wrappers/ace/Capabilities.cpp
index 4f8151d1bc6..c64417095f7 100644
--- a/dep/ACE_wrappers/ace/Capabilities.cpp
+++ b/dep/ACE_wrappers/ace/Capabilities.cpp
@@ -2,36 +2,27 @@
#include "ace/OS_NS_ctype.h"
#include "ace/OS_Memory.h"
#include "ace/OS_NS_string.h"
-
#if !defined (__ACE_INLINE__)
#include "ace/Capabilities.inl"
#endif /* !__ACE_INLINE__ */
-
#include "ace/OS_NS_stdio.h"
-
ACE_RCSID (ace,
Capabilities,
"$Id: Capabilities.cpp 80826 2008-03-04 14:51:23Z wotte $")
-
#define ACE_ESC ((ACE_TCHAR)0x1b)
-
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
ACE_CapEntry::~ACE_CapEntry (void)
{
}
-
ACE_Capabilities::ACE_Capabilities (void)
: caps_ ()
{
}
-
ACE_Capabilities::~ACE_Capabilities (void)
{
this->resetcaps ();
}
-
const ACE_TCHAR *
ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap)
{
@@ -77,7 +68,6 @@ ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap)
i < 3 && *buf && ACE_OS::ace_isdigit (*buf);
i++)
oc = oc * 8 + (*buf++ - ACE_TEXT ('0'));
-
cap += (ACE_TCHAR) oc;
continue;
}
@@ -86,20 +76,15 @@ ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap)
}
return buf;
}
-
const ACE_TCHAR *
ACE_Capabilities::parse (const ACE_TCHAR *buf, int &cap)
{
int n = 0;
-
while (*buf && ACE_OS::ace_isdigit (*buf))
n = n * 10 + (*buf++ - ACE_TEXT ('0'));
-
cap = n;
-
return buf;
}
-
void
ACE_Capabilities::resetcaps (void)
{
@@ -111,11 +96,9 @@ ACE_Capabilities::resetcaps (void)
iter.next (entry);
delete entry->int_id_;
}
-
this->caps_.close ();
this->caps_.open ();
}
-
int
ACE_Capabilities::fillent (const ACE_TCHAR *buf)
{
@@ -126,14 +109,11 @@ ACE_Capabilities::fillent (const ACE_TCHAR *buf)
int n;
ACE_TString name;
ACE_CapEntry *ce;
-
// Skip blanks
while (*buf && ACE_OS::ace_isspace(*buf)) buf++;
// If we get end of line return
-
if (*buf == ACE_TEXT ('\0'))
break;
-
if (*buf == ACE_TEXT ('#'))
{
while (*buf && *buf != ACE_TEXT ('\n'))
@@ -146,7 +126,6 @@ ACE_Capabilities::fillent (const ACE_TCHAR *buf)
&& *buf!= ACE_TEXT ('#')
&& *buf != ACE_TEXT (','))
name += *buf++;
-
// If name is null.
switch (*buf)
{
@@ -188,14 +167,11 @@ ACE_Capabilities::fillent (const ACE_TCHAR *buf)
default:
return 0;
}
-
if (*buf++ != ACE_TEXT (','))
return -1;
}
-
return 0;
}
-
int
ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line)
{
@@ -204,20 +180,16 @@ ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line)
// Skip blanks or irrelevant characters
while (*line && ACE_OS::ace_isspace(*line))
++line;
-
// End of line reached
if (*line == ACE_TEXT ('\0'))
break;
-
// Build the entry name
ACE_TString nextname;
while (*line && *line != ACE_TEXT ('|') && *line != ACE_TEXT (','))
nextname += *line++;
-
// We have found the required entry?
if (ACE_OS::strcmp (nextname.c_str (), name) == 0)
return 1;
-
// Skip puntuaction char if neccesary.
if (*line == ACE_TEXT ('|') || *line == ACE_TEXT (','))
++line;
@@ -230,46 +202,37 @@ ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line)
}
return 0;
}
-
int
ACE_Capabilities::getline (FILE *fp, ACE_TString &line)
{
int ch;
-
line.set (0, 0);
-
while ((ch = ACE_OS::fgetc (fp)) != EOF && ch != ACE_TEXT ('\n'))
line += (ACE_TCHAR) ch;
-
if (ch == EOF && line.length () == 0)
return -1;
else
return 0;
}
-
int
ACE_Capabilities::getval (const ACE_TCHAR *keyname, ACE_TString &val)
{
ACE_CapEntry* cap = 0;
if (this->caps_.find (keyname, cap) == -1)
return -1;
-
ACE_StringCapEntry *scap =
dynamic_cast<ACE_StringCapEntry *> (cap);
if (scap == 0)
return -1;
-
val = scap->getval ();
return 0;
}
-
int
ACE_Capabilities::getval (const ACE_TCHAR *keyname, int &val)
{
ACE_CapEntry *cap = 0;
if (this->caps_.find (keyname, cap) == -1)
return -1;
-
ACE_IntCapEntry *icap =
dynamic_cast<ACE_IntCapEntry *> (cap);
if (icap != 0)
@@ -277,80 +240,63 @@ ACE_Capabilities::getval (const ACE_TCHAR *keyname, int &val)
val = icap->getval ();
return 0;
}
-
ACE_BoolCapEntry *bcap =
dynamic_cast<ACE_BoolCapEntry *> (cap);
-
if (bcap == 0)
return -1;
-
val = bcap->getval ();
return 0;
}
-
#if !defined (ACE_IS_SPLITTING)
static int
is_empty (const ACE_TCHAR *line)
{
while (*line && ACE_OS::ace_isspace (*line))
++line;
-
return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#');
}
-
static int
is_line (const ACE_TCHAR *line)
{
while (*line && ACE_OS::ace_isspace (*line))
++line;
-
return *line != ACE_TEXT ('\0');
}
#endif /* !ACE_IS_SPLITTING */
-
int
ACE_Capabilities::getent (const ACE_TCHAR *fname, const ACE_TCHAR *name)
{
FILE *fp = ACE_OS::fopen (fname, ACE_TEXT ("r"));
-
if (fp == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Can't open %s file\n"),
fname),
-1);
-
int done;
ACE_TString line;
-
while (0 == (done = (this->getline (fp, line) == -1))
&& is_empty (line.c_str ()))
continue;
-
while (!done)
{
ACE_TString newline;
ACE_TString description;
-
while (0 == (done = (this->getline (fp, newline) == -1)))
if (is_line (newline.c_str ()))
description += newline;
else
break;
-
if (this->is_entry (name, line.c_str()))
{
ACE_OS::fclose (fp);
return this->fillent (description.c_str ());
}
-
line = newline;
while (!done && is_empty (line.c_str ()))
done = this->getline (fp, line) == -1;
}
-
ACE_OS::fclose (fp);
return -1;
}
-
ACE_END_VERSIONED_NAMESPACE_DECL