callbacks: fix segmentation fault

Performing a request defining custom callbacks, then performing another
request without callbacks (i.e. using libcurl default callbacks) causes
a segmentation fault:
    -- assume the easy handle is properly set up
    easy:perform{writefunction = function(chunk) io.write(chunk) end}
    -- the answer is written to stdout --
    easy:perform()
    -- segmentation fault (in fwrite () from libc)

The above segmentation fault happens because the data pointer, set with
CURLOPT_WRITEDATA (CURLOPT_FILE) in curl_easy_setopt, for the write
function (fwrite for default callbacks) is not properly cleaned up and
the lua_State from the previous callback is passed.

Similar faults will show up with CURLOPT_WRITEHEADER and
CURLOPT_READDATA (CURLOPT_INFILE).

In order to properly restore the default callback behaviours:
    - the "write function" data pointer must be set back to stdout;
    - the "header function" data pointer must be set to NULL;
    - the "read function" data pointer must be set to stdin;
About the values for data pointers: despite the libcurl documentation
says nothing about their default values, reading libcurl source code
leads to stdout, stdin and NULL (actually 0x0).

Signed-off-by: Davide "FunkyAss" Del Zompo <davide.delzompo@gmail.com>
callbacks: fix attempt to call a nil value

Performing a request with custom callbacks that returns anything but
CURLE_OK, then performing a request with default callbacks causes lua to
call a nil value:
    -- assume the easy handle is properly set up
    easy:setopt_url("http://mispelled-domain/")
    -- curl_perform will return CURLE_COULDNT_RESOLVE_HOST
    pcall(easy.perform, easy,
        {writefunction = function(chunk) return end}
    )
    -- a totally legit url
    easy:setopt_url("http://example.com")
    easy:perform()
    -- lua: attempt to call a nil value

When curl_easy_perform returns anything but CURLE_OK, l_easy_perform
calls luaL_error, which ends doing a longjump. The callbacks cleanup
never happens, leaving the lua-curl "callback handlers"
(l_easy_writefunction, readfuntion, headerfunction) registered.
The subsequent request doesn't register any callback, so an empty table
is pushed on the stack and the callback handler will call a nil value.

Signed-off-by: Davide "FunkyAss" Del Zompo <davide.delzompo@gmail.com>
Merge pull request #10 from FunkyAss/fix-callback

Fix segmentation fault and attempt to call nil in callbacks