Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
options: API for meta-data about easy options
const struct curl_easyoption *curl_easy_option_by_name(const char *name); const struct curl_easyoption *curl_easy_option_by_id (CURLoption id); const struct curl_easyoption * curl_easy_option_next(const struct curl_easyoption *prev); The purpose is to provide detailed enough information to allow for example libcurl bindings to get option information at run-time about what easy options that exist and what arguments they expect. THIS IS WORK IN PROGRESS, MEANT AS A DISCUSSION STARTING POINT. Not the final version.
- Loading branch information
Showing
9 changed files
with
890 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef CURLINC_OPTIONS_H | ||
#define CURLINC_OPTIONS_H | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) 2018 - 2020, 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 https://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. | ||
* | ||
***************************************************************************/ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef enum { | ||
CURLOT_LONG, /* long (a range of values) */ | ||
CURLOT_VALUES, /* long (a defined set or bitmask) */ | ||
CURLOT_OFF_T, /* curl_off_t */ | ||
CURLOT_OBJECT, /* void * */ | ||
CURLOT_STRING, /* char * */ | ||
CURLOT_SLIST, /* struct curl_slist * */ | ||
CURLOT_FUNCTION /* function pointer */ | ||
} curl_easytype; | ||
|
||
struct curl_easyoption { | ||
const char *name; | ||
CURLoption id; | ||
curl_easytype type; | ||
}; | ||
|
||
const struct curl_easyoption *curl_easy_option_by_name(const char *name); | ||
const struct curl_easyoption *curl_easy_option_by_id (CURLoption id); | ||
const struct curl_easyoption * | ||
curl_easy_option_next(const struct curl_easyoption *prev); | ||
|
||
#ifdef __cplusplus | ||
} /* end of extern "C" */ | ||
#endif | ||
#endif /* CURLINC_OPTIONS_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ | | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* ___|___/|_| ______| | ||
* | ||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel.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 https://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. | ||
* | ||
***************************************************************************/ | ||
|
||
#include "curl_setup.h" | ||
#include "strcase.h" | ||
#include "easyoptions.h" | ||
|
||
/* Lookups easy options at runtime */ | ||
static struct curl_easyoption *lookup(const char *name, CURLoption id) | ||
{ | ||
DEBUGASSERT(name || id); | ||
if(name || id) { | ||
struct curl_easyoption *o = &Curl_easyopts[0]; | ||
do { | ||
if(name) { | ||
if(strcasecompare(o->name, name)) | ||
return o; | ||
} | ||
else { | ||
if(o->id == id) | ||
return o; | ||
} | ||
o++; | ||
} while(o->name); | ||
} | ||
return NULL; | ||
} | ||
|
||
const struct curl_easyoption *curl_easy_option_by_name(const char *name) | ||
{ | ||
return lookup(name, 0); | ||
} | ||
|
||
const struct curl_easyoption *curl_easy_option_by_id (CURLoption id) | ||
{ | ||
return lookup(NULL, id); | ||
} | ||
|
||
/* Iterates over available options */ | ||
const struct curl_easyoption * | ||
curl_easy_option_next(const struct curl_easyoption *prev) | ||
{ | ||
if(prev && prev->name) { | ||
prev++; | ||
return prev; | ||
} | ||
else if(!prev) | ||
return &Curl_easyopts[0]; | ||
return NULL; | ||
} | ||
|
Oops, something went wrong.