AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   String extension module (https://forums.alliedmods.net/showthread.php?t=3926)

Wiper 07-18-2004 14:58

String extension module
 
1 Attachment(s)
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.

PM 07-18-2004 15:08

you can make stocks to change the functions name to the traditional names (which i also like more :D ).
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? :)

Wiper 07-18-2004 16:44

Sure thing - its free for editing/modifying whatever.
The main idea of posting was that maybe somebody will find some use for it.

BAILOPAN 07-18-2004 19:19

What Regex library did you use?

Wiper 07-19-2004 03:34

Re-lib from
http://www.geocities.com/SiliconVall...78/pubdom.html

OverlordQ 07-19-2004 17:47

Might look at The GNU regex library or TRE, both being pretty good.

devicenull 07-23-2004 21:58

Instead of getaccessfromfile, why not write a program to convert it all for you?
That would be easier to use then...

Havoc 07-24-2004 09:06

is this mudule avilable for Windows?


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

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