- OS.1.5.12-dev.zip
- OS.1.5.12-dev.codeproject.com
- bin
- curllib.dll
- libeay32.dll
- libsasl.dll
- openldap.dll
- os.exe
- ssleay32.dll
- CMakeLists.txt
- doc-os
- string_double_quoted.os
- string_raw_heredoc.os
- string_single_quoted.os
- examples-os
- add_user_module.os
- bind.os
- core.os
- curl
- test_callbacks.os
- test_clone.os
- test_getinfo.os
- test_setopt.os
- test_version.os
- md2html.os
- run_os_prog.os
- std.os
- test.cmd
- test.db
- test.os
- test-new.os
- Makefile
- proj.win32
- README.md
- source
- OS.1.5.12-dev-noexe.zip
|
#include "stdafx.h"
#include "../../source/objectscript.h"
using namespace ObjectScript;
#include <ctype.h>
static int my_isdigit(OS * os, int params, int, int, void*)
{
OS::String str = os->toString(-params);
int len = str.getLen();
for(int i = 0; i < len; i++){
if(!isdigit(str[i])){
os->pushBool(false);
return 1;
}
}
os->pushBool(len > 0);
return 1;
}
static int my_hash(OS * os, int params, int, int, void*)
{
OS::String str = os->toString(-params);
int i, len = str.getLen(), hash = 5381;
for(i = 0; i < len; i++){
hash = ((hash << 5) + hash) + str[i];
}
hash &= 0x7fffffff;
char buf[16];
for(i = 0; hash > 0; hash >>= 4){
buf[i++] = "0123456789abcdef"[hash & 0xf];
}
buf[i] = 0;
os->pushString(buf);
return 1;
}
void initMyModule(OS * os)
{
OS::FuncDef funcs[] = {
{"isdigit", my_isdigit},
{"hash", my_hash},
{}
};
os->getModule("my");
os->setFuncs(funcs);
os->pop();
}
int _tmain(int argc, _TCHAR* argv[])
{
// craete ObjectScript instance
OS * os = OS::create();
// init ctype module
initMyModule(os);
// run program
os->require("../../examples-os/add_user_module.os");
// release the ObjectScript instance
os->release();
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.