mirror of
https://github.com/znc/znc.git
synced 2026-08-07 01:13:25 +02:00
make perl hash map, update to use new getpermstr
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@290 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+43
-12
@@ -65,6 +65,43 @@ private:
|
||||
EType m_eType;
|
||||
};
|
||||
|
||||
|
||||
#define CSTR( a ) a.c_str(), a.length()
|
||||
|
||||
class CPerlHash : public map< CString, PString >
|
||||
{
|
||||
public:
|
||||
|
||||
HV *GetHash()
|
||||
{
|
||||
HV *pHash = newHV();
|
||||
for( CPerlHash::iterator it = this->begin(); it != this->end(); it++ )
|
||||
{
|
||||
SV *pSV = NULL;
|
||||
switch( it->second.GetType() )
|
||||
{
|
||||
case PString::NUM:
|
||||
pSV = newSVnv( it->second.ToDouble() );
|
||||
break;
|
||||
case PString::INT:
|
||||
pSV = newSViv( it->second.ToLongLong() );
|
||||
break;
|
||||
case PString::UINT:
|
||||
case PString::BOOL:
|
||||
pSV = newSVuv( it->second.ToULongLong() );
|
||||
break;
|
||||
case PString::STRING:
|
||||
default:
|
||||
pSV = newSVpv( CSTR( it->second ) );
|
||||
break;
|
||||
}
|
||||
hv_store( pHash, CSTR( it->first ), pSV, 0);
|
||||
}
|
||||
|
||||
return( pHash );
|
||||
}
|
||||
};
|
||||
|
||||
typedef vector< PString > VPString;
|
||||
|
||||
class CModPerl;
|
||||
@@ -496,8 +533,6 @@ XS(XS_ZNC_PutModNotice)
|
||||
}
|
||||
}
|
||||
|
||||
#define STR( a ) a, strlen( a )
|
||||
#define CSTR( a ) a.c_str(), a.length()
|
||||
|
||||
XS(XS_ZNC_GetNicks)
|
||||
{
|
||||
@@ -520,17 +555,13 @@ XS(XS_ZNC_GetNicks)
|
||||
|
||||
for( map< CString,CNick* >::const_iterator it = mscNicks.begin(); it != mscNicks.end(); it++ )
|
||||
{
|
||||
HV *Hash = newHV();
|
||||
CNick & cNick = *(it->second);
|
||||
hv_store( Hash, STR( "Nick" ), newSVpv( CSTR( cNick.GetNick() ) ), 0);
|
||||
hv_store( Hash, STR( "Ident" ), newSVpv( CSTR( cNick.GetIdent() ) ), 0);
|
||||
hv_store( Hash, STR( "Host" ), newSVpv( CSTR( cNick.GetHost() ) ), 0);
|
||||
if ( cNick.IsOp() )
|
||||
hv_store( Hash, STR( "IsOp" ), newSVpv( STR( "1" ) ), 0);
|
||||
if( cNick.IsVoice() )
|
||||
hv_store( Hash, STR( "IsVoice" ), newSVpv( STR( "1" ) ), 0);
|
||||
|
||||
XPUSHs( sv_2mortal( newRV( (SV *)Hash ) ) );
|
||||
CPerlHash cHash;
|
||||
cHash["Nick"] = cNick.GetNick();
|
||||
cHash["Ident"] = cNick.GetIdent();
|
||||
cHash["Host"] = cNick.GetHost();
|
||||
cHash["Perms"] = cNick.GetPermStr();
|
||||
XPUSHs( sv_2mortal( newRV( (SV *)cHash.GetHash() ) ) );
|
||||
}
|
||||
}
|
||||
PUTBACK;
|
||||
|
||||
Reference in New Issue
Block a user