Advertisement

06.21.2007 at 09:26PM PDT, ID: 22650498 | Points: 250
[x]
Attachment Details

GetProcAddress returning null - not the correct address!

Asked by n1875621 in C++ Programming Language, C++ Builder

Tags: getprocaddress

GetProcAddress is returning null...

I am using the latest C++ Builder from CodeGear.

There is an API.h and file1.cpp - then I show my output...  no compiling problems - just keep getting null!

-------------------file1.cpp---------------------
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma argsused
#pragma package(smart_init)

#include "api.h"
#include <vcl.h>
#include <iostream>

/*
 *  The handle for the cdbdapi Libray
 */
      HMODULE hm = NULL;

/*
 * Holders for DLL Imported functions
 */
TInitAPI InitAPI;
TCloseAPI CloseAPI;
TGetMeet GetMeet;
TGetTime GetTime;
TGetRace GetRace;
TResult Result;
TGetID GetID;
TLoadShadow LoadShadow;
TEngineFromSysTray EngineFromSysTray;
TEngineToSysTray EngineToSysTray;
TGetQuinella GetQuinella;
TGetExacta GetExacta;
TGetTrifecta GetTrifecta;
 

using namespace std;

void exit_application ( void );

//---------------------------------------------------------------------------

void exit_application ( void )
{
      int t;
      cin >> t;
      exit (0);
}

int main(int argc, char* argv[])
{
      //try to load the library, return to console if not found
      if( ( hm = LoadLibrary( "C:\\Users\\Yiannis\\Desktop\\HR2\\cdbdapi.dll" ) ) == NULL )
      {
            cout << "LoadLibrary: DLL Could Not Be Loaded." << endl;
            exit_application ();
      }
      else
      {
            cout << "LoadLibrary: DLL Loaded Fine." << endl;
      }

      /*
       *  Get the addresses for the functions being used.
       */
      if((InitAPI=(TInitAPI)GetProcAddress(hm,"InitAPI"))==NULL)
            cout << "InitAPI(): Address Not Found!" << endl;

    if((CloseAPI=(TCloseAPI)GetProcAddress(hm,"CloseAPI"))==NULL)
            cout << "CloseAPI(): Address Not Found!" << endl;

      if((GetMeet=(TGetMeet)GetProcAddress(hm,"GetMeet"))==NULL)
            cout << "GetMeet(): Address Not Found!" << endl;

      //if((GetTime=(TGetTime)GetProcAddress(hm,"GetTime"))==NULL)
      //      cout << "GetTime(): Address Not Found!" << endl;

      if((GetRace=(TGetRace)GetProcAddress(hm,"GetRace"))==NULL)
            cout << "GetRace(): Address Not Found!" << endl;

      if((Result=(TResult)GetProcAddress(hm,"Result"))==NULL)
            cout << "Result(): Address Not Found!" << endl;

      if((GetID=(TGetID)GetProcAddress(hm,"GetID"))==NULL)
            cout << "GetID(): Address Not Found!" << endl;

      if((LoadShadow=(TLoadShadow)GetProcAddress(hm,"LoadShadow"))==NULL)
            cout << "LoadShadow(): Address Not Found!" << endl;

      if((EngineFromSysTray=(TEngineFromSysTray)GetProcAddress(hm,"EngineFromSysTray"))==NULL)
            cout << "EngineFromSysTray(): Address Not Found!" << endl;

      if((EngineToSysTray=(TEngineToSysTray)GetProcAddress(hm,"EngineToSysTray"))==NULL)
            cout << "EngineToSysTray(): Address Not Found!" << endl;

      if((GetQuinella=(TGetQuinella)GetProcAddress(hm,"GetQuinella"))==NULL)
            cout << "GetQuinella(): Address Not Found!" << endl;

      if((GetExacta=(TGetExacta)GetProcAddress(hm,"GetExacta"))==NULL)
            cout << "GetExacta(): Address Not Found!" << endl;

      if((GetTrifecta=(TGetTrifecta)GetProcAddress(hm,"GetTrifecta"))==NULL)
            cout << "GetTrifecta(): Address Not Found!" << endl;


      if ( !FreeLibrary ( hm ) ) {
            cout << "FreeLibrary(): Could not unload DLL" << endl;
      }
      
      exit_application ();

      return 1;
}
//---------------------------------------------------------------------------

-----------api.h--------
//A few defines not show...

typedef int _stdcall (*TInitAPI)( void );
typedef void _stdcall (*TCloseAPI)( void );
typedef int _stdcall (*TGetMeet)(char *, int *); //buf, len
typedef int _stdcall (*TGetTime)(char *, int *); //buf, len
typedef int _stdcall (*TGetRace)(char *, int *, int, char *, char *, int, int, int, int); //buf, len, refstate, meet, race, state, pool, updates, summary
typedef int _stdcall (*TGetQuinella)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TGetExacta)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TGetTrifecta)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TResult)(char *, int *, int, char *, char *, int); //buf, len, refstate, meet, race, state
typedef int _stdcall (*TGetID)(char *, int *); //buf, len
typedef int _stdcall (*TLoadShadow)(char *); //filename
typedef int _stdcall (*TEngineToSysTray)( void );
typedef int _stdcall (*TEngineFromSysTray)( void );

------end api.h-----------

My output!

LoadLibrary: DLL Loaded Fine.
InitAPI(): Address Not Found!
CloseAPI(): Address Not Found!
GetMeet(): Address Not Found!
GetRace(): Address Not Found!
Result(): Address Not Found!
GetID(): Address Not Found!
LoadShadow(): Address Not Found!
EngineFromSysTray(): Address Not Found!
EngineToSysTray(): Address Not Found!
GetQuinella(): Address Not Found!
GetExacta(): Address Not Found!
GetTrifecta(): Address Not Found!




Start Free Trial
 
Loading Advertisement...
 
[+][-]06.21.2007 at 10:49PM PDT, ID: 19339210

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.21.2007 at 11:46PM PDT, ID: 19339370

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.22.2007 at 06:22AM PDT, ID: 19341013

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.22.2007 at 09:31AM PDT, ID: 19342726

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.22.2007 at 09:34AM PDT, ID: 19342745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.22.2007 at 11:50AM PDT, ID: 19343837

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 05:15AM PDT, ID: 19354939

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 05:18AM PDT, ID: 19354950

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 05:24AM PDT, ID: 19354986

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 05:29AM PDT, ID: 19355022

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 06:27AM PDT, ID: 19355353

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 06:31AM PDT, ID: 19355384

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 06:40AM PDT, ID: 19355462

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 06:44AM PDT, ID: 19355500

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 06:50AM PDT, ID: 19355553

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 06:55AM PDT, ID: 19355599

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.25.2007 at 09:17PM PDT, ID: 19360906

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.02.2007 at 08:44PM PDT, ID: 19408568

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.18.2007 at 11:28AM PDT, ID: 19915387

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
06.21.2007 at 10:49PM PDT, ID: 19339210
Using dumpbin or Dependency Walker check actual function names exported from cdbdapi.dll. If this is C++ Dll, function names can be decorated, this prevents them to be called by this way.
 
06.21.2007 at 11:46PM PDT, ID: 19339370
sorry - my fault - i had a crucial part of the api.h commented out! sorry guys!

BUT - I can give you the points for something else...

I have just downloaded libcurl - but have no idea on how to link that into my project....

I've added

 #include "libcurl/include/curl/curl.h"
 #include "libcurl/include/curl/types.h"
 #include "libcurl/include/curl/easy.h"
 

into my code - but how to i get the linker to see the dlls?

I am using code gear - but there is no way to include a .DLL into my project - only.libs etc.
 
06.22.2007 at 06:22AM PDT, ID: 19341013
Make sure to export your functions as e.g.

__declspec(dllexport)
extern "C" int InitAPI( void );

to avoid C++ name mangling. Using '__stdcall' will cause an underscore being pretended to your function's name and the name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list, that is the reason why 'GetProcAddress()' fails in the above since the name is different from what you are passing in. See also http://msdn2.microsoft.com/en-us/library/zxk0tw93(VS.80).aspx ("__stdcall (C++)")
 
06.22.2007 at 09:31AM PDT, ID: 19342726
>>I am using code gear - but there is no way to include a .DLL into my project - only.libs etc.

If you include .lib files to your project then you are using the STATIC linking method...
That means YOU DON'T need to use the GetProcAddress() method.
BUT...
The dll HAS to be present at one of the followin directories:
1. Application's directory.
2. The Windows directory...
3. The Windows\System (for win9x) or Windows\System32, because for the time Codegear does not support 64bit.

Also what is that libcurl? Looks like it has to do with internet (url)...
Isn't there any other VCL component you can use and using this library?

George Tokas.

BTW: Ellinas?

 
06.22.2007 at 09:34AM PDT, ID: 19342745
>>Also what is that libcurl?
Just verified what it is...
If the reason you are using this library is download using HTTP the you can use TAction component...

George Tokas.
 
06.22.2007 at 11:50AM PDT, ID: 19343837
Addition:
>>I am using code gear - but there is no way to include a .DLL into my project - only.libs etc.
If you want to "include" the dll to the project here is a trick:
Create a res file containing the dll.
This can be done as follows:
1. open notepad.
2. add the line: MYDLL    DLL   "THE_DLL_I_WANT_TO_IMPORT.DLL". (the space characters is a tab)
3. save the file as something.rc
4. open a command line window, browse to the directory the .rc file is locared, make sure that the dll is alo there along with brcc32.exe (from the bin directory of BCB).
5. type "brcc32 -32 something.rc"

If all goes well and there is no error a file named something.res is created. The size of the file is a bit bigger than the dll.
Add the res file to your project.
To extract and save it:
Because the dll is used with static linking method AT THE FIRST LINE OF WinMain AND BEFORE Application->Initialize() add:
HRSRC   ResHandle;
        HGLOBAL MemHandle;
        void *ResPtr;
        int   ResSize;
        char  *lpName;
        TMemoryStream    *Stream;

        ResHandle = FindResource(HInstance, "MYDLL", "DLL");
        MemHandle = LoadResource(HInstance, Re-sHandle);
        ResPtr = LockResource(MemHandle);
        ResSize = SizeofResource(HInstance, ResHandle);
        Stream = new TMemoryStream;
        Stream->SetSize(ResSize);
        Stream->Seek(0,0);
        Stream->Write(ResPtr, ResSize);
        Stream->Seek(0,0);
                  Stream->SaveToFile("THE_DLL_I_WANT_TO_IMPORT.dll);
                 delete Stream;

Now the dll is extracted and saved at the applications directory.

George Tokas.
       
 
06.25.2007 at 05:15AM PDT, ID: 19354939
Thanks - but its a console application... so I dont want any of the windows stuff if I don't have too - I've gotten the Address of the functions I want now, but I just can't figure out how to "call" that function - i.e. I have a void pointer with the address of the function - how do i call that address with whatever params...

so - (void*)GetProcAddress(cl,"curl_global_init"); actually works - i get a valid address (seemingly) back from that - but how do i then call that address as a function?  Considering the HEADER file is in a file I dont want to touch (part of the distribution).

 
06.25.2007 at 05:18AM PDT, ID: 19354950
I am so unfamilar with windows components, libcurl is something i've used on linux and works well (its actually for remote "posting" to an IP address. The client has specifically requested libcurl as well (not that that means much :)

It seems I am so close by having a valid pointer - just cant figure out how to bleeding well call the darn thing!
 
06.25.2007 at 05:24AM PDT, ID: 19354986
>>It seems I am so close by having a valid pointer - just cant figure out how to bleeding well call the darn thing!
Post the headers and we will find out how you will do it...

As for the rest is some tricks you can use eigther in windows or console application...

George Tokas.
 
06.25.2007 at 05:29AM PDT, ID: 19355022
The header is below, but the only funcs i'll need are:

curl_global_init
curl_formadd
curl_easy_init
curl_slist_append
curl_easy_setopt
curl_easy_perform
curl_easy_cleanup
curl_formfree
curl_slist_free_all

ok, here is the H file...

#ifndef __CURL_CURL_H
#define __CURL_CURL_H
/***************************************************************************
 *                                  _   _ ____  _
 *  Project                     ___| | | |  _ \| |
 *                             / __| | | | |_) | |
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * are also available at http://curl.haxx.se/docs/copyright.html.
 *
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
 * copies of the Software, and permit persons to whom the Software is
 * furnished to do so, under the terms of the COPYING file.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 * $Id: curl.h,v 1.316 2007-02-20 22:02:11 linus Exp $
 ***************************************************************************/

/* If you have problems, all libcurl docs and details are found here:
   http://curl.haxx.se/libcurl/
*/

#include "curlver.h" /* the libcurl version defines */

#include <stdio.h>
#include <limits.h>

/* The include stuff here below is mainly for time_t! */
#ifdef vms
# include <types.h>
# include <time.h>
#else
# include <sys/types.h>
# include <time.h>
#endif /* defined (vms) */

typedef void CURL;

#ifdef  __cplusplus
extern "C" {
#endif

/*
 * Decorate exportable functions for Win32 DLL linking.
 * This avoids using a .def file for building libcurl.dll.
 */
#if (defined(WIN32) || defined(_WIN32)) && !defined(CURL_STATICLIB)
#if defined(BUILDING_LIBCURL)
#define CURL_EXTERN  __declspec(dllexport)
#else
#define CURL_EXTERN  __declspec(dllimport)
#endif
#else

#ifdef CURL_HIDDEN_SYMBOLS
/*
 * This definition is used to make external definitions visibile in the
 * shared library when symbols are hidden by default.  It makes no
 * difference when compiling applications whether this is set or not,
 * only when compiling the library.
 */
#define CURL_EXTERN CURL_EXTERN_SYMBOL
#else
#define CURL_EXTERN
#endif
#endif

/*
 * We want the typedef curl_off_t setup for large file support on all
 * platforms. We also provide a CURL_FORMAT_OFF_T define to use in *printf
 * format strings when outputting a variable of type curl_off_t.
 *
 * Note: "pocc -Ze" is MSVC compatibily mode and this sets _MSC_VER!
 */

#if (defined(_MSC_VER) && !defined(__POCC__)) || (defined(__LCC__) && defined(WIN32))
/* MSVC */
#ifdef _WIN32_WCE
  typedef long curl_off_t;
#define CURL_FORMAT_OFF_T "%ld"
#else
  typedef signed __int64 curl_off_t;
#define CURL_FORMAT_OFF_T "%I64d"
#endif
#else /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */
#if (defined(__GNUC__) && defined(WIN32)) || defined(__WATCOMC__)
/* gcc on windows or Watcom */
  typedef long long curl_off_t;
#define CURL_FORMAT_OFF_T "%I64d"
#else /* GCC or Watcom on Windows  */

/* "normal" POSIX approach, do note that this does not necessarily mean that
   the type is >32 bits, see the SIZEOF_CURL_OFF_T define for that! */
  typedef off_t curl_off_t;

/* Check a range of defines to detect large file support. On Linux it seems
   none of these are set by default, so if you don't explicitly switches on
   large file support, this define will be made for "small file" support. */
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 0 /* to prevent warnings in the check below */
#define UNDEF_FILE_OFFSET_BITS
#endif
#ifndef FILESIZEBITS
#define FILESIZEBITS 0 /* to prevent warnings in the check below */
#define UNDEF_FILESIZEBITS
#endif

#if defined(_LARGE_FILES) || (_FILE_OFFSET_BITS > 32) || (FILESIZEBITS > 32) \
   || defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)
  /* For now, we assume at least one of these to be set for large files to
     work! */
#define CURL_FORMAT_OFF_T "%lld"
#else /* LARGE_FILE support */
#define CURL_FORMAT_OFF_T "%ld"
#endif
#endif /* GCC or Watcom on Windows */
#endif /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */

#ifdef UNDEF_FILE_OFFSET_BITS
/* this was defined above for our checks, undefine it again */
#undef _FILE_OFFSET_BITS
#endif

#ifdef UNDEF_FILESIZEBITS
/* this was defined above for our checks, undefine it again */
#undef FILESIZEBITS
#endif

#if defined(_WIN32) && !defined(WIN32)
/* Chris Lewis mentioned that he doesn't get WIN32 defined, only _WIN32 so we
   make this adjustment to catch this. */
#define WIN32 1
#endif

#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
  !defined(__CYGWIN__) || defined(__MINGW32__)
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
/* The check above prevents the winsock2 inclusion if winsock.h already was
   included, since they can't co-exist without problems */
#include <winsock2.h>
#endif
#else

/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
   libc5-based Linux systems. Only include it on system that are known to
   require it! */
#if defined(_AIX) || defined(NETWARE) || defined(__NetBSD__) || defined(__minix)
#include <sys/select.h>
#endif

#ifndef _WIN32_WCE
#include <sys/socket.h>
#endif
#ifndef __WATCOMC__
#include <sys/time.h>
#endif
#include <sys/types.h>
#endif

#ifndef curl_socket_typedef
/* socket typedef */
#ifdef WIN32
typedef SOCKET curl_socket_t;
#define CURL_SOCKET_BAD INVALID_SOCKET
#else
typedef int curl_socket_t;
#define CURL_SOCKET_BAD -1
#endif
#define curl_socket_typedef
#endif /* curl_socket_typedef */

struct curl_httppost {
  struct curl_httppost *next;       /* next entry in the list */
  char *name;                       /* pointer to allocated name */
  long namelength;                  /* length of name length */
  char *contents;                   /* pointer to allocated data contents */
  long contentslength;              /* length of contents field */
  char *buffer;                     /* pointer to allocated buffer contents */
  long bufferlength;                /* length of buffer field */
  char *contenttype;                /* Content-Type */
  struct curl_slist* contentheader; /* list of extra headers for this form */
  struct curl_httppost *more;       /* if one field name has more than one
                                       file, this link should link to following
                                       files */
  long flags;                       /* as defined below */
#define HTTPPOST_FILENAME (1<<0)    /* specified content is a file name */
#define HTTPPOST_READFILE (1<<1)    /* specified content is a file name */
#define HTTPPOST_PTRNAME (1<<2)     /* name is only stored pointer
                                       do not free in formfree */
#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer
                                       do not free in formfree */
#define HTTPPOST_BUFFER (1<<4)      /* upload file from buffer */
#define HTTPPOST_PTRBUFFER (1<<5)   /* upload file from pointer contents */

  char *showfilename;               /* The file name to show. If not set, the
                                       actual file name will be used (if this
                                       is a file part) */
};

typedef int (*curl_progress_callback)(void *clientp,
                                      double dltotal,
                                      double dlnow,
                                      double ultotal,
                                      double ulnow);

  /* Tests have proven that 20K is a very bad buffer size for uploads on
     Windows, while 16K for some odd reason performed a lot better. */
#define CURL_MAX_WRITE_SIZE 16384

typedef size_t (*curl_write_callback)(char *buffer,
                                      size_t size,
                                      size_t nitems,
                                      void *outstream);

/* This is a return code for the read callback that, when returned, will
   signal libcurl to immediately abort the current transfer. */
#define CURL_READFUNC_ABORT 0x10000000
typedef size_t (*curl_read_callback)(char *buffer,
                                      size_t size,
                                      size_t nitems,
                                      void *instream);

typedef enum  {
  CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */
  CURLSOCKTYPE_LAST   /* never use */
} curlsocktype;

typedef int (*curl_sockopt_callback)(void *clientp,
                                     curl_socket_t curlfd,
                                     curlsocktype purpose);

#ifndef CURL_NO_OLDIES
  /* not used since 7.10.8, will be removed in a future release */
typedef int (*curl_passwd_callback)(void *clientp,
                                    const char *prompt,
                                    char *buffer,
                                    int buflen);
#endif

typedef enum {
  CURLIOE_OK,            /* I/O operation successful */
  CURLIOE_UNKNOWNCMD,    /* command was unknown to callback */
  CURLIOE_FAILRESTART,   /* failed to restart the read */
  CURLIOE_LAST           /* never use */
} curlioerr;

typedef enum  {
  CURLIOCMD_NOP,         /* no operation */
  CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
  CURLIOCMD_LAST         /* never use */
} curliocmd;

typedef curlioerr (*curl_ioctl_callback)(CURL *handle,
                                         int cmd,
                                         void *clientp);

/*
 * The following typedef's are signatures of malloc, free, realloc, strdup and
 * calloc respectively.  Function pointers of these types can be passed to the
 * curl_global_init_mem() function to set user defined memory management
 * callback routines.
 */
typedef void *(*curl_malloc_callback)(size_t size);
typedef void (*curl_free_callback)(void *ptr);
typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
typedef char *(*curl_strdup_callback)(const char *str);
typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);

/* the kind of data that is passed to information_callback*/
typedef enum {
  CURLINFO_TEXT = 0,
  CURLINFO_HEADER_IN,    /* 1 */
  CURLINFO_HEADER_OUT,   /* 2 */
  CURLINFO_DATA_IN,      /* 3 */
  CURLINFO_DATA_OUT,     /* 4 */
  CURLINFO_SSL_DATA_IN,  /* 5 */
  CURLINFO_SSL_DATA_OUT, /* 6 */
  CURLINFO_END
} curl_infotype;

typedef int (*curl_debug_callback)
       (CURL *handle,      /* the handle/transfer this concerns */
        curl_infotype type, /* what kind of data */
        char *data,        /* points to the data */
        size_t size,       /* size of the data pointed to */
        void *userptr);    /* whatever the user please */

/* All possible error codes from all sorts of curl functions. Future versions
   may return other values, stay prepared.

   Always add new return codes last. Never *EVER* remove any. The return
   codes must remain the same!
 */

typedef enum {
  CURLE_OK = 0,
  CURLE_UNSUPPORTED_PROTOCOL,    /* 1 */
  CURLE_FAILED_INIT,             /* 2 */
  CURLE_URL_MALFORMAT,           /* 3 */
  CURLE_URL_MALFORMAT_USER,      /* 4 - NOT USED */
  CURLE_COULDNT_RESOLVE_PROXY,   /* 5 */
  CURLE_COULDNT_RESOLVE_HOST,    /* 6 */
  CURLE_COULDNT_CONNECT,         /* 7 */
  CURLE_FTP_WEIRD_SERVER_REPLY,  /* 8 */
  CURLE_FTP_ACCESS_DENIED,       /* 9 a service was denied by the FTP server
                                    due to lack of access - when login fails
                                    this is not returned. */
  CURLE_FTP_USER_PASSWORD_INCORRECT, /* 10 - NOT USED */
  CURLE_FTP_WEIRD_PASS_REPLY,    /* 11 */
  CURLE_FTP_WEIRD_USER_REPLY,    /* 12 */
  CURLE_FTP_WEIRD_PASV_REPLY,    /* 13 */
  CURLE_FTP_WEIRD_227_FORMAT,    /* 14 */
  CURLE_FTP_CANT_GET_HOST,       /* 15 */
  CURLE_FTP_CANT_RECONNECT,      /* 16 */
  CURLE_FTP_COULDNT_SET_BINARY,  /* 17 */
  CURLE_PARTIAL_FILE,            /* 18 */
  CURLE_FTP_COULDNT_RETR_FILE,   /* 19 */
  CURLE_FTP_WRITE_ERROR,         /* 20 */
  CURLE_FTP_QUOTE_ERROR,         /* 21 */
  CURLE_HTTP_RETURNED_ERROR,     /* 22 */
  CURLE_WRITE_ERROR,             /* 23 */
  CURLE_MALFORMAT_USER,          /* 24 - NOT USED */
  CURLE_FTP_COULDNT_STOR_FILE,   /* 25 - failed FTP upload */
  CURLE_READ_ERROR,              /* 26 - could open/read from file */
  CURLE_OUT_OF_MEMORY,           /* 27 */
  /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error
           instead of a memory allocation error if CURL_DOES_CONVERSIONS
           is defined
  */
  CURLE_OPERATION_TIMEOUTED,     /* 28 - the timeout time was reached */
  CURLE_FTP_COULDNT_SET_ASCII,   /* 29 - TYPE A failed */
  CURLE_FTP_PORT_FAILED,         /* 30 - FTP PORT operation failed */
  CURLE_FTP_COULDNT_USE_REST,    /* 31 - the REST command failed */
  CURLE_FTP_COULDNT_GET_SIZE,    /* 32 - the SIZE command failed */
  CURLE_HTTP_RANGE_ERROR,        /* 33 - RANGE "command" didn't work */
  CURLE_HTTP_POST_ERROR,         /* 34 */
  CURLE_SSL_CONNECT_ERROR,       /* 35 - wrong when connecting with SSL */
  CURLE_BAD_DOWNLOAD_RESUME,     /* 36 - couldn't resume download */
  CURLE_FILE_COULDNT_READ_FILE,  /* 37 */
  CURLE_LDAP_CANNOT_BIND,        /* 38 */
  CURLE_LDAP_SEARCH_FAILED,      /* 39 */
  CURLE_LIBRARY_NOT_FOUND,       /* 40 */
  CURLE_FUNCTION_NOT_FOUND,      /* 41 */
  CURLE_ABORTED_BY_CALLBACK,     /* 42 */
  CURLE_BAD_FUNCTION_ARGUMENT,   /* 43 */
  CURLE_BAD_CALLING_ORDER,       /* 44 - NOT USED */
  CURLE_INTERFACE_FAILED,        /* 45 - CURLOPT_INTERFACE failed */
  CURLE_BAD_PASSWORD_ENTERED,    /* 46 - NOT USED */
  CURLE_TOO_MANY_REDIRECTS ,     /* 47 - catch endless re-direct loops */
  CURLE_UNKNOWN_TELNET_OPTION,   /* 48 - User specified an unknown option */
  CURLE_TELNET_OPTION_SYNTAX ,   /* 49 - Malformed telnet option */
  CURLE_OBSOLETE,                /* 50 - NOT USED */
  CURLE_SSL_PEER_CERTIFICATE,    /* 51 - peer's certificate wasn't ok */
  CURLE_GOT_NOTHING,             /* 52 - when this is a specific error */
  CURLE_SSL_ENGINE_NOTFOUND,     /* 53 - SSL crypto engine not found */
  CURLE_SSL_ENGINE_SETFAILED,    /* 54 - can not set SSL crypto engine as
                                    default */
  CURLE_SEND_ERROR,              /* 55 - failed sending network data */
  CURLE_RECV_ERROR,              /* 56 - failure in receiving network data */
  CURLE_SHARE_IN_USE,            /* 57 - share is in use */
  CURLE_SSL_CERTPROBLEM,         /* 58 - problem with the local certificate */
  CURLE_SSL_CIPHER,              /* 59 - couldn't use specified cipher */
  CURLE_SSL_CACERT,              /* 60 - problem with the CA cert (path?) */
  CURLE_BAD_CONTENT_ENCODING,    /* 61 - Unrecognized transfer encoding */
  CURLE_LDAP_INVALID_URL,        /* 62 - Invalid LDAP URL */
  CURLE_FILESIZE_EXCEEDED,       /* 63 - Maximum file size exceeded */
  CURLE_FTP_SSL_FAILED,          /* 64 - Requested FTP SSL level failed */
  CURLE_SEND_FAIL_REWIND,        /* 65 - Sending the data requires a rewind
                                    that failed */
  CURLE_SSL_ENGINE_INITFAILED,   /* 66 - failed to initialise ENGINE */
  CURLE_LOGIN_DENIED,            /* 67 - user, password or similar was not
                                    accepted and we failed to login */
  CURLE_TFTP_NOTFOUND,           /* 68 - file not found on server */
  CURLE_TFTP_PERM,               /* 69 - permission problem on server */
  CURLE_TFTP_DISKFULL,           /* 70 - out of disk space on server */
  CURLE_TFTP_ILLEGAL,            /* 71 - Illegal TFTP operation */
  CURLE_TFTP_UNKNOWNID,          /* 72 - Unknown transfer ID */
  CURLE_TFTP_EXISTS,             /* 73 - File already exists */
  CURLE_TFTP_NOSUCHUSER,         /* 74 - No such user */
  CURLE_CONV_FAILED,             /* 75 - conversion failed */
  CURLE_CONV_REQD,               /* 76 - caller must register conversion
                                    callbacks using curl_easy_setopt options
                                    CURLOPT_CONV_FROM_NETWORK_FUNCTION,
                                    CURLOPT_CONV_TO_NETWORK_FUNCTION, and
                                    CURLOPT_CONV_FROM_UTF8_FUNCTION */
  CURLE_SSL_CACERT_BADFILE,      /* 77 - could not load CACERT file, missing
                                    or wrong format */
  CURLE_REMOTE_FILE_NOT_FOUND,   /* 78 - remote file not found */
  CURLE_SSH,                     /* 79 - error from the SSH layer, somewhat
                                    generic so the error message will be of
                                    interest when this has happened */

  CURLE_SSL_SHUTDOWN_FAILED,     /* 80 - Failed to shut down the SSL
                                    connection */
  CURL_LAST /* never use! */
} CURLcode;

/* This prototype applies to all conversion callbacks */
typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length);

typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl,    /* easy handle */
                                          void *ssl_ctx, /* actually an
                                                            OpenSSL SSL_CTX */
                                          void *userptr);

/* Make a spelling correction for the operation timed-out define */
#define CURLE_OPERATION_TIMEDOUT CURLE_OPERATION_TIMEOUTED

#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
                          the obsolete stuff removed! */
/* backwards compatibility with older names */
#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR
#define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED
#endif

typedef enum {
  CURLPROXY_HTTP = 0,
  CURLPROXY_SOCKS4 = 4,
  CURLPROXY_SOCKS5 = 5
} curl_proxytype;

#define CURLAUTH_NONE         0       /* nothing */
#define CURLAUTH_BASIC        (1<<0)  /* Basic (default) */
#define CURLAUTH_DIGEST       (1<<1)  /* Digest */
#define CURLAUTH_GSSNEGOTIATE (1<<2)  /* GSS-Negotiate */
#define CURLAUTH_NTLM         (1<<3)  /* NTLM */
#define CURLAUTH_ANY ~0               /* all types set */
#define CURLAUTH_ANYSAFE (~CURLAUTH_BASIC)

#define CURLSSH_AUTH_ANY       ~0     /* all types supported by the server */
#define CURLSSH_AUTH_NONE      0      /* none allowed, silly but complete */
#define CURLSSH_AUTH_PUBLICKEY (1<<0) /* public/private key files */
#define CURLSSH_AUTH_PASSWORD  (1<<1) /* password */
#define CURLSSH_AUTH_HOST      (1<<2) /* host key files */
#define CURLSSH_AUTH_KEYBOARD  (1<<3) /* keyboard interactive */
#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY

#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
                          the obsolete stuff removed! */
/* this was the error code 50 in 7.7.3 and a few earlier versions, this
   is no longer used by libcurl but is instead #defined here only to not
   make programs break */
#define CURLE_ALREADY_COMPLETE 99999

/* These are just to make older programs not break: */
#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE
#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME
#endif

#define CURL_ERROR_SIZE 256

/* parameter for the CURLOPT_FTP_SSL option */
typedef enum {
  CURLFTPSSL_NONE,    /* do not attempt to use SSL */
  CURLFTPSSL_TRY,     /* try using SSL, proceed anyway otherwise */
  CURLFTPSSL_CONTROL, /* SSL for the control connection or fail */
  CURLFTPSSL_ALL,     /* SSL for all communication or fail */
  CURLFTPSSL_LAST     /* not an option, never use */
} curl_ftpssl;

/* parameter for the CURLOPT_FTP_SSL_CCC option */
typedef enum {
  CURLFTPSSL_CCC_NONE,    /* do not send CCC */
  CURLFTPSSL_CCC_PASSIVE, /* Let the server initiate the shutdown */
  CURLFTPSSL_CCC_ACTIVE,  /* Initiate the shutdown */
  CURLFTPSSL_CCC_LAST     /* not an option, never use */
} curl_ftpccc;

/* parameter for the CURLOPT_FTPSSLAUTH option */
typedef enum {
  CURLFTPAUTH_DEFAULT, /* let libcurl decide */
  CURLFTPAUTH_SSL,     /* use "AUTH SSL" */
  CURLFTPAUTH_TLS,     /* use "AUTH TLS" */
  CURLFTPAUTH_LAST /* not an option, never use */
} curl_ftpauth;

/* parameter for the CURLOPT_FTP_FILEMETHOD option */
typedef enum {
  CURLFTPMETHOD_DEFAULT,   /* let libcurl pick */
  CURLFTPMETHOD_MULTICWD,  /* single CWD operation for each path part */
  CURLFTPMETHOD_NOCWD,     /* no CWD at all */
  CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */
  CURLFTPMETHOD_LAST       /* not an option, never use */
} curl_ftpmethod;

/* long may be 32 or 64 bits, but we should never depend on anything else
   but 32 */
#define CURLOPTTYPE_LONG          0
#define CURLOPTTYPE_OBJECTPOINT   10000
#define CURLOPTTYPE_FUNCTIONPOINT 20000
#define CURLOPTTYPE_OFF_T         30000

/* name is uppercase CURLOPT_<name>,
   type is one of the defined CURLOPTTYPE_<type>
   number is unique identifier */
#ifdef CINIT
#undef CINIT
#endif
/*
 * Figure out if we can use the ## operator, which is supported by ISO/ANSI C
 * and C++. Some compilers support it without setting __STDC__ or __cplusplus
 * so we need to carefully check for them too. We don't use configure-checks
 * for these since we want these headers to remain generic and working for all
 * platforms.
 */
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
  defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
  defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__)
  /* This compiler is believed to have an ISO compatible preprocessor */
#define CURL_ISOCPP
#else
&nbs