~ben-kersten/mysql-proxy/packet-empty-set

« back to all changes in this revision

Viewing changes to lib/glib2.c

  • Committer: jan at mysql
  • Date: 2010-08-20 15:02:44 UTC
  • Revision ID: jan@mysql.com-20100820150244-0ay10u2769sar3fy
added get_current_time()

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        return 0;
34
34
}
35
35
 
 
36
static int lua_g_get_current_time (lua_State *L) {
 
37
        GTimeVal t;
 
38
 
 
39
        g_get_current_time(&t);
 
40
 
 
41
        lua_newtable(L);
 
42
        lua_pushinteger(L, t.tv_sec);
 
43
        lua_setfield(L, -2, "tv_sec");
 
44
        lua_pushinteger(L, t.tv_usec);
 
45
        lua_setfield(L, -2, "tv_usec");
 
46
 
 
47
        return 1;
 
48
}
 
49
 
36
50
static int lua_g_checksum_md5 (lua_State *L) {
37
51
        size_t str_len;
38
52
        const char *str = luaL_checklstring (L, 1, &str_len);
54
68
*/
55
69
static void set_info (lua_State *L) {
56
70
        lua_pushliteral (L, "_COPYRIGHT");
57
 
        lua_pushliteral (L, "Copyright (c) 2008 MySQL AB, 2008 Sun Microsystems, Inc.");
 
71
        lua_pushliteral (L, "Copyright (c) 2010 Oracle");
58
72
        lua_settable (L, -3);
59
73
        lua_pushliteral (L, "_DESCRIPTION");
60
74
        lua_pushliteral (L, "export glib2-functions as glib.*");
68
82
static const struct luaL_reg gliblib[] = {
69
83
        {"usleep", lua_g_usleep},
70
84
        {"md5", lua_g_checksum_md5},
 
85
        {"get_current_time", lua_g_get_current_time},
71
86
        {NULL, NULL},
72
87
};
73
88