Ensured that the library also works in finalized mode. The issue is that in finalized mode
more than one copy of `eiffel_curl.h' could be present, meaning that multiple values of each static declared variables could be present at run-time and in one case, one was properly initialized, but not the other. Fixes bug#13671. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71399 8089f293-4706-0410-a29e-feb5c42a2edf
This commit is contained in:
67
Clib/Makefile-win.SH
Normal file
67
Clib/Makefile-win.SH
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
TOP = ..
|
||||||
|
DIR = $dir_sep
|
||||||
|
OUTDIR= .
|
||||||
|
INDIR= .
|
||||||
|
CC = $cc
|
||||||
|
OUTPUT_CMD = $output_cmd
|
||||||
|
CFLAGS = -I"$rt_include" -I..$(DIR)spec$(DIR)include -I. \
|
||||||
|
-I..$(DIR)..$(DIR)..$(DIR)C_library$(DIR)libpng -I..$(DIR)..$(DIR)..$(DIR)C_library$(DIR)zlib
|
||||||
|
JCFLAGS = $(CFLAGS) $ccflags $optimize
|
||||||
|
JMTCFLAGS = $(CFLAGS) $mtccflags $optimize
|
||||||
|
JILCFLAGS = $(CFLAGS) $mtccflags $optimize -DEIF_IL_DLL
|
||||||
|
LN = copy
|
||||||
|
MV = $mv
|
||||||
|
RM = $del
|
||||||
|
MKDIR_TARGET = $mkdir_target
|
||||||
|
LINK = $link32
|
||||||
|
DLL_FLAGS = $dll_flags
|
||||||
|
DLL_LIBS = $dll_libs
|
||||||
|
OBJECTS = eiffel_curl.$obj
|
||||||
|
MT_OBJECTS = MTeiffel_curl.$obj
|
||||||
|
IL_OBJECTS = ILeiffel_curl.$obj
|
||||||
|
|
||||||
|
.c.$obj:
|
||||||
|
$(CC) -c $(JCFLAGS) $<
|
||||||
|
|
||||||
|
all:: lib_dir $output_libraries clean
|
||||||
|
|
||||||
|
standard:: eiffel_curl.lib ileiffel_curl.lib
|
||||||
|
mtstandard:: mteiffel_curl.lib
|
||||||
|
|
||||||
|
..$(DIR)spec:
|
||||||
|
$(MKDIR_TARGET)
|
||||||
|
|
||||||
|
..$(DIR)spec$(DIR)$(ISE_C_COMPILER): ..$(DIR)spec
|
||||||
|
$(MKDIR_TARGET)
|
||||||
|
|
||||||
|
..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM): ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)
|
||||||
|
$(MKDIR_TARGET)
|
||||||
|
|
||||||
|
..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib: ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)
|
||||||
|
$(MKDIR_TARGET)
|
||||||
|
|
||||||
|
lib_dir: ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.$obj
|
||||||
|
$(RM) *.lib
|
||||||
|
|
||||||
|
eiffel_curl.lib: $(OBJECTS)
|
||||||
|
$alib_line
|
||||||
|
$(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@
|
||||||
|
|
||||||
|
mteiffel_curl.lib: $(MT_OBJECTS)
|
||||||
|
$alib_line
|
||||||
|
$(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@
|
||||||
|
|
||||||
|
ileiffel_curl.lib: $(IL_OBJECTS)
|
||||||
|
$alib_line
|
||||||
|
$(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@
|
||||||
|
|
||||||
|
#Multithreaded targets.
|
||||||
|
MTeiffel_curl.$obj: eiffel_curl.c
|
||||||
|
$(CC) $(JMTCFLAGS) $(OUTPUT_CMD)$@ -c $?
|
||||||
|
|
||||||
|
#.NET targets.
|
||||||
|
ILeiffel_curl.$obj: eiffel_curl.c
|
||||||
|
$(CC) $(JILCFLAGS) $(OUTPUT_CMD)$@ -c $?
|
||||||
94
Clib/Makefile.SH
Normal file
94
Clib/Makefile.SH
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
case $CONFIG in
|
||||||
|
'')
|
||||||
|
if test ! -f config.sh; then
|
||||||
|
(echo "Can't find config.sh."; exit 1)
|
||||||
|
fi 2>/dev/null
|
||||||
|
. ./config.sh
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case "$0" in
|
||||||
|
*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
|
||||||
|
esac
|
||||||
|
echo "Extracting "."/Makefile (with variable substitutions)"
|
||||||
|
$spitshell >Makefile <<!GROK!THIS!
|
||||||
|
########################################################################
|
||||||
|
# Makefile generated from Makefile.SH on $DATE
|
||||||
|
|
||||||
|
SHELL = /bin/sh
|
||||||
|
AR = ar rc
|
||||||
|
CC = $cc
|
||||||
|
CTAGS = ctags
|
||||||
|
INCLUDE = -I$rt_include -I../spec/include -I../../../C_library/libpng -I../../../C_library/zlib
|
||||||
|
CFLAGS = $optimize $ccflags $large -g \$(INCLUDE)
|
||||||
|
MTCFLAGS = $optimize $mtccflags $large -g \$(INCLUDE)
|
||||||
|
SHAREDLINK = $sharedlink
|
||||||
|
LDSHAREDFLAGS = $ldsharedflags
|
||||||
|
LN = $ln
|
||||||
|
MAKE = $make
|
||||||
|
MKDEP = $mkdep \$(DPFLAGS) --
|
||||||
|
RANLIB = $ranlib
|
||||||
|
RM = $rm -f
|
||||||
|
MV = $mv
|
||||||
|
MKDIR = $mkdir -p
|
||||||
|
PLATFORM = $ISE_PLATFORM
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# New suffixes and associated building rules -- edit with care
|
||||||
|
|
||||||
|
|
||||||
|
!GROK!THIS!
|
||||||
|
$spitshell >>Makefile <<'!NO!SUBS!'
|
||||||
|
|
||||||
|
MT_OBJECTS = MTeiffel_curl.o
|
||||||
|
OBJECTS = eiffel_curl.o
|
||||||
|
|
||||||
|
ALL_OBJECTS = $(OBJECTS) $(MT_OBJECTS)
|
||||||
|
|
||||||
|
all: $(ALL_OBJECTS)
|
||||||
|
$(MKDIR) ../spec/$(PLATFORM)/lib
|
||||||
|
$(MV) $? ../spec/$(PLATFORM)/lib
|
||||||
|
$(MAKE) clobber
|
||||||
|
|
||||||
|
MTeiffel_curl.o: eiffel_curl.c
|
||||||
|
$(CC) -c $(MTCFLAGS) $? -o $@
|
||||||
|
|
||||||
|
local_realclean::
|
||||||
|
$(RM) $(ALL_OBJECTS)
|
||||||
|
########################################################################
|
||||||
|
# Common rules for all Makefiles -- do not edit
|
||||||
|
|
||||||
|
emptyrule::
|
||||||
|
|
||||||
|
clean: local_clean
|
||||||
|
realclean: local_realclean
|
||||||
|
clobber: local_clobber
|
||||||
|
|
||||||
|
local_clean::
|
||||||
|
$(RM) core *~ *.o
|
||||||
|
|
||||||
|
local_realclean:: local_clean
|
||||||
|
|
||||||
|
local_clobber:: local_realclean
|
||||||
|
$(RM) Makefile config.sh
|
||||||
|
|
||||||
|
Makefile: Makefile.SH
|
||||||
|
/bin/sh Makefile.SH
|
||||||
|
|
||||||
|
tags::
|
||||||
|
$(CTAGS) -w *.[ch]
|
||||||
|
$(CTAGS) -xw *.[ch] > tags
|
||||||
|
|
||||||
|
local_clobber::
|
||||||
|
$(RM) tags
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Dependencies generated by make depend
|
||||||
|
# DO NOT DELETE THIS LINE -- make depend relies on it
|
||||||
|
|
||||||
|
# Put nothing here or make depend will gobble it up
|
||||||
|
.FORCE_DEPEND::
|
||||||
|
@echo "You must run 'make depend' in $(TOP) first."; exit 1
|
||||||
|
!NO!SUBS!
|
||||||
|
chmod 644 Makefile
|
||||||
|
$eunicefix Makefile
|
||||||
|
|
||||||
149
Clib/eiffel_curl.c
Normal file
149
Clib/eiffel_curl.c
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
indexing
|
||||||
|
description: "Functions used by the class CURL_FUNCTION."
|
||||||
|
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
source: "[
|
||||||
|
Eiffel Software
|
||||||
|
356 Storke Road, Goleta, CA 93117 USA
|
||||||
|
Telephone 805-685-1006, Fax 805-685-6869
|
||||||
|
Website http://www.eiffel.com
|
||||||
|
Customer support http://support.eiffel.com
|
||||||
|
]"
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "eiffel_curl.h"
|
||||||
|
|
||||||
|
typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) (
|
||||||
|
#ifndef EIF_IL_DLL
|
||||||
|
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
||||||
|
#endif
|
||||||
|
EIF_POINTER, /* a_user_pointer */
|
||||||
|
EIF_REAL_64, /* a_dltotal */
|
||||||
|
EIF_REAL_64, /* a_dlnow */
|
||||||
|
EIF_REAL_64, /* a_ultotal */
|
||||||
|
EIF_REAL_64 /* a_ulnow */
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) (
|
||||||
|
#ifndef EIF_IL_DLL
|
||||||
|
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
||||||
|
#endif
|
||||||
|
EIF_POINTER, /* a_data_pointer */
|
||||||
|
EIF_INTEGER, /* a_size */
|
||||||
|
EIF_INTEGER, /* a_nmemb */
|
||||||
|
EIF_POINTER /* a_write_pointer */
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) (
|
||||||
|
#ifndef EIF_IL_DLL
|
||||||
|
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
||||||
|
#endif
|
||||||
|
EIF_POINTER, /* a_curl_handle */
|
||||||
|
EIF_INTEGER, /* a_curl_infotype */
|
||||||
|
EIF_POINTER, /* a_char_pointer */
|
||||||
|
EIF_INTEGER, /* a_size */
|
||||||
|
EIF_POINTER /* a_user_pointer */
|
||||||
|
);
|
||||||
|
|
||||||
|
static EIF_OBJECT eiffel_function_object = NULL;
|
||||||
|
/* Address of Eiffel object CURL_FUNCTION */
|
||||||
|
|
||||||
|
static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL;
|
||||||
|
/* Address of Eiffel CURL_FUNCTION.progress_function */
|
||||||
|
|
||||||
|
static EIF_CURL_WRITE_PROC eiffel_write_function = NULL;
|
||||||
|
/* Address of Eiffel CURL_FUNCTION.write_function */
|
||||||
|
|
||||||
|
static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL;
|
||||||
|
/* Address of Eiffel CURL_FUNCTION.debug_function */
|
||||||
|
|
||||||
|
/* Set Eiffel CURL_FUNCTION object address */
|
||||||
|
void c_set_object(EIF_REFERENCE a_address)
|
||||||
|
{
|
||||||
|
if (a_address) {
|
||||||
|
eiffel_function_object = eif_protect (a_address);
|
||||||
|
} else {
|
||||||
|
eiffel_function_object = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release Eiffel CURL_FUNCTION object address */
|
||||||
|
void c_release_object()
|
||||||
|
{
|
||||||
|
eif_wean (eiffel_function_object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set CURL_FUNCTOIN.progress_function address */
|
||||||
|
void c_set_progress_function_address( EIF_POINTER a_address)
|
||||||
|
{
|
||||||
|
eiffel_progress_function = (EIF_CURL_PROGRESS_PROC) a_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set CURL_FUNCTOIN.write_function address */
|
||||||
|
void c_set_write_function_address( EIF_POINTER a_address)
|
||||||
|
{
|
||||||
|
eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set CURL_FUNCTOIN.debug_function address */
|
||||||
|
void c_set_debug_function_address (EIF_POINTER a_address)
|
||||||
|
{
|
||||||
|
eiffel_debug_function = (EIF_CURL_DEBUG_PROC) a_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Eiffel adapter function for CURLOPT_WRITEFUNCTION
|
||||||
|
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
||||||
|
size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data)
|
||||||
|
{
|
||||||
|
if (eiffel_function_object) {
|
||||||
|
return (size_t) ((eiffel_write_function) (
|
||||||
|
#ifndef EIF_IL_DLL
|
||||||
|
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
||||||
|
#endif
|
||||||
|
(EIF_POINTER) ptr,
|
||||||
|
(EIF_INTEGER) size,
|
||||||
|
(EIF_INTEGER) nmemb,
|
||||||
|
(EIF_POINTER) data));
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION
|
||||||
|
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
||||||
|
size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow)
|
||||||
|
{
|
||||||
|
if (eiffel_function_object) {
|
||||||
|
return (size_t) ((eiffel_progress_function) (
|
||||||
|
#ifndef EIF_IL_DLL
|
||||||
|
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
||||||
|
#endif
|
||||||
|
(EIF_POINTER) a_object_id,
|
||||||
|
(EIF_REAL_64) a_dltotal,
|
||||||
|
(EIF_REAL_64) a_dlnow,
|
||||||
|
(EIF_REAL_64) a_ultotal,
|
||||||
|
(EIF_REAL_64) a_ulnow));
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Eiffel adapter function for CURLOPT_DEBUGFUNCTION
|
||||||
|
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
||||||
|
size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id)
|
||||||
|
{
|
||||||
|
if (eiffel_function_object) {
|
||||||
|
return (size_t) ((eiffel_debug_function) (
|
||||||
|
#ifndef EIF_IL_DLL
|
||||||
|
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
||||||
|
#endif
|
||||||
|
(EIF_POINTER) a_curl_handle,
|
||||||
|
(EIF_INTEGER) a_curl_infotype,
|
||||||
|
(EIF_POINTER) a_char_pointer,
|
||||||
|
(EIF_INTEGER) a_size,
|
||||||
|
(EIF_POINTER) a_object_id));
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
cURL.ecf
32
cURL.ecf
@@ -23,6 +23,38 @@
|
|||||||
<platform excluded_value="windows"/>
|
<platform excluded_value="windows"/>
|
||||||
</condition>
|
</condition>
|
||||||
</external_include>
|
</external_include>
|
||||||
|
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/eiffel_curl.o">
|
||||||
|
<condition>
|
||||||
|
<platform excluded_value="windows"/>
|
||||||
|
<multithreaded value="false"/>
|
||||||
|
</condition>
|
||||||
|
</external_object>
|
||||||
|
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
|
||||||
|
<condition>
|
||||||
|
<platform excluded_value="windows"/>
|
||||||
|
<multithreaded value="true"/>
|
||||||
|
</condition>
|
||||||
|
</external_object>
|
||||||
|
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
|
||||||
|
<condition>
|
||||||
|
<platform value="windows"/>
|
||||||
|
<multithreaded value="false"/>
|
||||||
|
<dotnet value="false"/>
|
||||||
|
</condition>
|
||||||
|
</external_object>
|
||||||
|
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.lib">
|
||||||
|
<condition>
|
||||||
|
<platform value="windows"/>
|
||||||
|
<multithreaded value="true"/>
|
||||||
|
<dotnet value="false"/>
|
||||||
|
</condition>
|
||||||
|
</external_object>
|
||||||
|
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\ileiffel_curl.lib">
|
||||||
|
<condition>
|
||||||
|
<platform value="windows"/>
|
||||||
|
<dotnet value="true"/>
|
||||||
|
</condition>
|
||||||
|
</external_object>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||||
<library name="framework" location="$ISE_LIBRARY\framework\framework.ecf"/>
|
<library name="framework" location="$ISE_LIBRARY\framework\framework.ecf"/>
|
||||||
<cluster name="curl" location=".\" recursive="true"/>
|
<cluster name="curl" location=".\" recursive="true"/>
|
||||||
|
|||||||
@@ -12,146 +12,34 @@ indexing
|
|||||||
]"
|
]"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#ifndef _eiffel_curl_h_
|
||||||
#include <string.h>
|
#define _eiffel_curl_h_
|
||||||
|
|
||||||
|
#include "eif_eiffel.h"
|
||||||
|
|
||||||
/* unix-specific */
|
/* unix-specific */
|
||||||
#ifndef EIF_WINNT
|
#ifndef EIF_WINDOWS
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "eif_main.h"
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
#ifdef EIF_THREADS
|
|
||||||
#include "eif_threads.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef eiffel_curl
|
extern void c_set_object(EIF_REFERENCE a_address);
|
||||||
#define eiffel_curl
|
extern void c_release_object(void);
|
||||||
|
extern void c_set_progress_function_address( EIF_POINTER a_address);
|
||||||
typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) (
|
extern void c_set_write_function_address( EIF_POINTER a_address);
|
||||||
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
extern void c_set_debug_function_address (EIF_POINTER a_address);
|
||||||
EIF_POINTER, /* a_user_pointer */
|
extern size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data);
|
||||||
EIF_REAL_64, /* a_dltotal */
|
extern size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow);
|
||||||
EIF_REAL_64, /* a_dlnow */
|
extern size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id);
|
||||||
EIF_REAL_64, /* a_ultotal */
|
|
||||||
EIF_REAL_64 /* a_ulnow */
|
|
||||||
);
|
|
||||||
|
|
||||||
typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) (
|
|
||||||
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
|
||||||
EIF_POINTER, /* a_data_pointer */
|
|
||||||
EIF_INTEGER, /* a_size */
|
|
||||||
EIF_INTEGER, /* a_nmemb */
|
|
||||||
EIF_POINTER /* a_write_pointer */
|
|
||||||
);
|
|
||||||
|
|
||||||
typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) (
|
|
||||||
EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */
|
|
||||||
EIF_POINTER, /* a_curl_handle */
|
|
||||||
EIF_INTEGER, /* a_curl_infotype */
|
|
||||||
EIF_POINTER, /* a_char_pointer */
|
|
||||||
EIF_INTEGER, /* a_size */
|
|
||||||
EIF_POINTER /* a_user_pointer */
|
|
||||||
);
|
|
||||||
|
|
||||||
static EIF_OBJECT eiffel_function_object = NULL;
|
|
||||||
/* Address of Eiffel object CURL_FUNCTION */
|
|
||||||
|
|
||||||
static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL;
|
|
||||||
/* Address of Eiffel CURL_FUNCTION.progress_function */
|
|
||||||
|
|
||||||
static EIF_CURL_WRITE_PROC eiffel_write_function = NULL;
|
|
||||||
/* Address of Eiffel CURL_FUNCTION.write_function */
|
|
||||||
|
|
||||||
static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL;
|
|
||||||
/* Address of Eiffel CURL_FUNCTION.debug_function */
|
|
||||||
|
|
||||||
/* Set Eiffel CURL_FUNCTION object address */
|
|
||||||
static void c_set_object(EIF_REFERENCE a_address)
|
|
||||||
{
|
|
||||||
if (a_address) {
|
|
||||||
eiffel_function_object = eif_protect (a_address);
|
|
||||||
} else {
|
|
||||||
eiffel_function_object = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release Eiffel CURL_FUNCTION object address */
|
|
||||||
static void c_release_object()
|
|
||||||
{
|
|
||||||
eif_wean (eiffel_function_object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set CURL_FUNCTOIN.progress_function address */
|
|
||||||
static void c_set_progress_function_address( EIF_POINTER a_address)
|
|
||||||
{
|
|
||||||
eiffel_progress_function = (EIF_CURL_PROGRESS_PROC) a_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set CURL_FUNCTOIN.write_function address */
|
|
||||||
static void c_set_write_function_address( EIF_POINTER a_address)
|
|
||||||
{
|
|
||||||
eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set CURL_FUNCTOIN.debug_function address */
|
|
||||||
static void c_set_debug_function_address (EIF_POINTER a_address)
|
|
||||||
{
|
|
||||||
eiffel_debug_function = (EIF_CURL_DEBUG_PROC) a_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Eiffel adapter function for CURLOPT_WRITEFUNCTION
|
|
||||||
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
|
||||||
static size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data)
|
|
||||||
{
|
|
||||||
if (eiffel_function_object) {
|
|
||||||
return (size_t) ((eiffel_write_function) (
|
|
||||||
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
|
||||||
(EIF_POINTER) ptr,
|
|
||||||
(EIF_INTEGER) size,
|
|
||||||
(EIF_INTEGER) nmemb,
|
|
||||||
(EIF_POINTER) data));
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION
|
|
||||||
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
|
||||||
static size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow)
|
|
||||||
{
|
|
||||||
if (eiffel_function_object) {
|
|
||||||
return (size_t) ((eiffel_progress_function) (
|
|
||||||
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
|
||||||
(EIF_POINTER) a_object_id,
|
|
||||||
(EIF_REAL_64) a_dltotal,
|
|
||||||
(EIF_REAL_64) a_dlnow,
|
|
||||||
(EIF_REAL_64) a_ultotal,
|
|
||||||
(EIF_REAL_64) a_ulnow));
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Eiffel adapter function for CURLOPT_DEBUGFUNCTION
|
|
||||||
We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */
|
|
||||||
static size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id)
|
|
||||||
{
|
|
||||||
if (eiffel_function_object) {
|
|
||||||
return (size_t) ((eiffel_debug_function) (
|
|
||||||
(EIF_REFERENCE) eif_access (eiffel_function_object),
|
|
||||||
(EIF_POINTER) a_curl_handle,
|
|
||||||
(EIF_INTEGER) a_curl_infotype,
|
|
||||||
(EIF_POINTER) a_char_pointer,
|
|
||||||
(EIF_INTEGER) a_size,
|
|
||||||
(EIF_POINTER) a_object_id));
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user