Raised This Month: $12 Target: $400
 3% 

String extension module


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wiper
New Member
Join Date: Jul 2004
Old 07-18-2004 , 14:58   String extension module
Reply With Quote #1

Basically i wanted to switch to amxx from adminmod (because i had to use amx anyway because of war3 and other plugins).

One feature that i needed in amxx - it was regular expression matching. So i decided to make a module that will include regular expressions along with some basic string functionality (many of them match already existing functions, but honestly i cant stand their naming - copy, equal etc.. So i opted to create own functions with the good old names like strcpy, strcmp.... )

Because i'm a newbie at amxx module programming - i used string.cpp from amxx as example. For regular expression functionality i used the first free regxp library that i found - i'm not sure how good/fast it is, but looks like it does the job.

So i'm posting sources of this module (linux only) - maybe somebody will find it usefull. (Its still not heavily tested - the plugin that uses this module is still in development).

Module export descriptions:

str* functions don't need explanations, i believe

regmatch(const sRegexp[], const sString[], nSize, ...)
Uses regular expression sRegexp to parse string sString. Return 1 + parsed valu count if matches, 0 if doesn't.
nSize - size of string buffers where returning values will be stored
Maximum 9 values can be parsed.
Example:
new sLeft[10], sRight[10];
regmatch("([0-9]+):([0-9]+)", "10:5", 10, sLeft, sRight);
Return value will be 3, "10" will be stored into sLeft, "5" will be stored into sRight.

GetAccessFromFile(const sFilename[], const sUsername[], const sPassword[], nPwdsize);
Used to parse adminmod user file (users.ini). The file format:
<regexp>:<password>:<access level>
regexp - regular expression that matches player name
password - player password
access level - user access level mask (integer)
This function will look into sFilename for record that matches sUsername. If record found the return value will be the access mask, and user password will be stored into sPassword.
Attached Files
File Type: gz stringxt.tar.gz (15.2 KB, 224 views)
Wiper is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 07-18-2004 , 15:08  
Reply With Quote #2

you can make stocks to change the functions name to the traditional names (which i also like more ).
Anyway, i will look at the module source; maybe there will be something we will want to grab into the core. Would you give us a permission?
__________________
hello, i am pm
PM is offline
Wiper
New Member
Join Date: Jul 2004
Old 07-18-2004 , 16:44  
Reply With Quote #3

Sure thing - its free for editing/modifying whatever.
The main idea of posting was that maybe somebody will find some use for it.
Wiper is offline
BAILOPAN
Join Date: Jan 2004
Old 07-18-2004 , 19:19  
Reply With Quote #4

What Regex library did you use?
__________________
egg
BAILOPAN is offline
Wiper
New Member
Join Date: Jul 2004
Old 07-19-2004 , 03:34  
Reply With Quote #5

Re-lib from
http://www.geocities.com/SiliconVall...78/pubdom.html
Wiper is offline
OverlordQ
Junior Member
Join Date: Jul 2004
Old 07-19-2004 , 17:47  
Reply With Quote #6

Might look at The GNU regex library or TRE, both being pretty good.
OverlordQ is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 07-23-2004 , 21:58  
Reply With Quote #7

Instead of getaccessfromfile, why not write a program to convert it all for you?
That would be easier to use then...
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
Havoc
Member
Join Date: Jul 2004
Old 07-24-2004 , 09:06  
Reply With Quote #8

is this mudule avilable for Windows?
Havoc is offline
Send a message via ICQ to Havoc Send a message via MSN to Havoc
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode