~ubuntu-branches/ubuntu/saucy/juju-core/saucy-proposed

« back to all changes in this revision

Viewing changes to src/github.com/andelf/go-curl/c-callback.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-11 17:18:27 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130711171827-vjqkg40r0dlf7ys2
Tags: 1.11.2-0ubuntu1
* New upstream release.
* Make juju-core the default juju (LP: #1190634):
  - d/control: Add virtual package juju -> juju-core.
  - d/juju-core.postinst.in: Bump priority of alternatives over that of
    python juju packages.
* Enable for all architectures (LP: #1172505):
  - d/control: Version BD on golang-go to >= 2:1.1.1 to ensure CGO
    support for non-x86 archs, make juju-core Arch: any.
  - d/README.source: Dropped - no longer required.
* d/watch: Updated for new upstream tarball naming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <string.h>
 
3
#include "callback.h"
 
4
#include "_cgo_export.h"
 
5
 
 
6
/* for OPT_HEADERFUNCTION */
 
7
size_t header_function( char *ptr, size_t size, size_t nmemb, void *ctx) {
 
8
    void *go_header_func = (void *)goGetCurlField((GoUintptr)ctx, "headerFunction");
 
9
    GoInterface *userdata = (GoInterface *)goGetCurlField((GoUintptr)ctx, "headerData");
 
10
 
 
11
    if (userdata == NULL) {
 
12
        return goCallWriteFunctionCallback(go_header_func, ptr, size*nmemb, goNilInterface());
 
13
    }
 
14
    return goCallWriteFunctionCallback(go_header_func, ptr, size*nmemb, *userdata);
 
15
}
 
16
 
 
17
void *return_header_function() {
 
18
    return (void *)&header_function;
 
19
}
 
20
 
 
21
 
 
22
/* for OPT_WRITEFUNCTION */
 
23
size_t write_function( char *ptr, size_t size, size_t nmemb, void *ctx) {
 
24
    void *go_write_func = (void *)goGetCurlField((GoUintptr)ctx, "writeFunction");
 
25
    GoInterface *userdata = (GoInterface *)goGetCurlField((GoUintptr)ctx, "writeData");
 
26
 
 
27
    if (userdata == NULL) {
 
28
        return goCallWriteFunctionCallback(go_write_func, ptr, size*nmemb, goNilInterface());
 
29
    }
 
30
    return goCallWriteFunctionCallback(go_write_func, ptr, size*nmemb, *userdata);
 
31
}
 
32
 
 
33
void *return_write_function() {
 
34
    return (void *)&write_function;
 
35
}
 
36
 
 
37
/* for OPT_READFUNCTION */
 
38
size_t read_function( char *ptr, size_t size, size_t nmemb, void *ctx) {
 
39
    void *go_read_func = (void *)goGetCurlField((GoUintptr)ctx, "readFunction");
 
40
    GoInterface *userdata = (GoInterface *)goGetCurlField((GoUintptr)ctx, "readData");
 
41
 
 
42
    if (userdata == NULL) {
 
43
        return goCallReadFunctionCallback(go_read_func, ptr, size*nmemb, goNilInterface());
 
44
    }
 
45
    return goCallReadFunctionCallback(go_read_func, ptr, size*nmemb, *userdata);
 
46
}
 
47
 
 
48
void *return_read_function() {
 
49
    return (void *)&read_function;
 
50
}
 
51
 
 
52
 
 
53
/* for OPT_PROGRESSFUNCTION */
 
54
int progress_function(void *ctx, double dltotal, double dlnow, double ultotal, double ulnow) {
 
55
    void *go_progress_func = (void *)goGetCurlField((GoUintptr)ctx, "progressFunction");
 
56
    GoInterface *clientp = (GoInterface *)goGetCurlField((GoUintptr)ctx, "progressData");
 
57
 
 
58
    if (clientp == NULL) {
 
59
        return goCallProgressCallback(go_progress_func, goNilInterface(),
 
60
                                    dltotal, dlnow, ultotal, ulnow);
 
61
    }
 
62
    return goCallProgressCallback(go_progress_func, *clientp,
 
63
                                dltotal, dlnow, ultotal, ulnow);
 
64
}
 
65
 
 
66
void *return_progress_function() {
 
67
    return (void *)progress_function;
 
68
}