FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Atlas/lib/crc32-lua.c at master · JavaDevelopRep/Atlas · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
JavaDevelopRep
/
Atlas
Public
forked from
Qihoo360/Atlas
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Atlas
/
lib
/
crc32-lua.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (47 loc) · 1.22 KB
Breadcrumbs
Atlas
/
lib
/
crc32-lua.c
Copy path
File metadata and controls
56 lines (47 loc) · 1.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* $%BEGINLICENSE%$
Copyright (c) 2011, Qihoo 360 - Chancey, wangchao3@360.cn
$%ENDLICENSE%$ */
#include
<lua.h>
#include
<glib.h>
#include
"lua-env.h"
#include
"crc32.h"
#include
"glib-ext.h"
int
crc32_string
(
lua_State
*
L
) {
size_t
str_len
;
const
char
*
str
=
luaL_checklstring
(
L
,
1
,
&
str_len
);
g_debug
(
"string:%s, length:%d"
,
str
,
str_len
);
// crc32 hash
unsigned
int
key
=
crc32
(
str
,
str_len
);
g_debug
(
"crc key:%ld"
,
key
);
// push crc number
lua_pushnumber
(
L
,
key
);
return
1
;
}
/*
** Assumes the table is on top of the stack.
*/
static
void
set_info
(
lua_State
*
L
) {
lua_pushliteral
(
L
,
"_COPYRIGHT"
);
lua_pushliteral
(
L
,
"Copyright (C) 2011 Qihoo 360 - wangchao3"
);
lua_settable
(
L
,
-3
);
lua_pushliteral
(
L
,
"_DESCRIPTION"
);
lua_pushliteral
(
L
,
"CRC32 String for Proxy.*"
);
lua_settable
(
L
,
-3
);
lua_pushliteral
(
L
,
"_VERSION"
);
lua_pushliteral
(
L
,
"LuaCRC32string 0.1"
);
lua_settable
(
L
,
-3
);
}
static
const
struct
luaL_reg
crc32_m
[]
=
{
{
"crc32"
,
crc32_string
},
{
NULL
,
NULL
},
};
#if
defined(
_WIN32
)
# define
LUAEXT_API
__declspec(dllexport)
#else
# define
LUAEXT_API
extern
#endif
LUAEXT_API
int
luaopen_crc32_string
(
lua_State
*
L
) {
luaL_register
(
L
,
"crc32"
,
crc32_m
);
set_info
(
L
);
return
1
;
}
Back
|
FazBrowse Home
|
New Git URL