Move push_cb function to utils.

This commit is contained in:
Alexey Melnichuk 2014-08-26 14:30:58 +05:00
parent 3a2c8b9f81
commit 898d2859b4
3 changed files with 18 additions and 18 deletions

View File

@ -9,17 +9,11 @@ static const char *LCURL_ERROR_TAG = "LCURL_ERROR_TAG";
#define LCURL_EASY_NAME LCURL_PREFIX" Easy"
static const char *LCURL_EASY = LCURL_EASY_NAME;
typedef struct lcurl_callback_tag{
int cb_ref;
int ud_ref;
}lcurl_callback_t;
typedef struct lcurl_read_buffer_tag{
int ref;
int off;
}lcurl_read_buffer_t;
#define LCURL_LST_INDEX(N) LCURL_##N##_LIST,
#define LCURL_STR_INDEX(N)
#define LCURL_LNG_INDEX(N)
@ -367,16 +361,6 @@ static int lcurl_info_get_slist_(lua_State *L, int opt){
//{ CallBack
static int lcurl_util_push_cb(lua_State *L, lcurl_callback_t *c){
assert(c->cb_ref != LUA_NOREF);
lua_rawgeti(L, LCURL_LUA_REGISTRY, c->cb_ref);
if(c->ud_ref != LUA_NOREF){
lua_rawgeti(L, LCURL_LUA_REGISTRY, c->ud_ref);
return 2;
}
return 1;
}
static int lcurl_easy_set_callback(lua_State *L,
lcurl_easy_t *p, lcurl_callback_t *c,
int OPT_CB, int OPT_UD,

View File

@ -15,7 +15,6 @@ void lcurl_storage_preserve_value(lua_State *L, int storage, int i){
lua_pop(L, 1);
}
int lcurl_storage_preserve_slist(lua_State *L, int storage, struct curl_slist * list){
int r;
lua_rawgeti(L, LCURL_LUA_REGISTRY, storage);
@ -45,7 +44,6 @@ struct curl_slist* lcurl_storage_remove_slist(lua_State *L, int storage, int idx
return list;
}
void lcurl_storage_free(lua_State *L, int storage){
lua_rawgeti(L, LCURL_LUA_REGISTRY, storage);
lua_rawgeti(L, -1, 1); // list storage
@ -106,3 +104,14 @@ void lcurl_util_set_const(lua_State *L, const lcurl_const_t *reg){
lua_settable(L, -3);
}
}
int lcurl_util_push_cb(lua_State *L, lcurl_callback_t *c){
assert(c->cb_ref != LUA_NOREF);
lua_rawgeti(L, LCURL_LUA_REGISTRY, c->cb_ref);
if(c->ud_ref != LUA_NOREF){
lua_rawgeti(L, LCURL_LUA_REGISTRY, c->ud_ref);
return 2;
}
return 1;
}

View File

@ -11,6 +11,11 @@ typedef struct lcurl_const_tag{
int value;
}lcurl_const_t;
typedef struct lcurl_callback_tag{
int cb_ref;
int ud_ref;
}lcurl_callback_t;
int lcurl_storage_init(lua_State *L);
void lcurl_storage_preserve_value(lua_State *L, int storage, int i);
@ -31,4 +36,6 @@ void lcurl_util_slist_to_table(lua_State *L, struct curl_slist* list);
void lcurl_util_set_const(lua_State *L, const lcurl_const_t *reg);
int lcurl_util_push_cb(lua_State *L, lcurl_callback_t *c);
#endif