Skip to content

Commit

Permalink
fixup provide a flags field with ALIAS info etc
Browse files Browse the repository at this point in the history
- curl_easy_option_by_id() returns the non-alias version

- PROGRESSDATA is now an alias to CURLOPT_XFERINFODATA instead of the other
  way around
  • Loading branch information
bagder committed May 18, 2020
1 parent f0c2ac5 commit a12d16b
Show file tree
Hide file tree
Showing 7 changed files with 328 additions and 319 deletions.
4 changes: 3 additions & 1 deletion docs/libcurl/curl_easy_option_by_id.3
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const struct curl_easyoption *curl_easy_option_by_id(CURLoption id);
Given a CURLoption \fBid\fP, this function returns a pointer to the
curl_easyoption struct, holding information about the
\fIcurl_easy_setopt(3)\fP option using that id. The option id is the CURLOPT_
prefix ones provided in the standard curl/curl.h header file.
prefix ones provided in the standard curl/curl.h header file. This function
will return the non-aliases version for the cases where there is an alias
function as well.

If libcurl has no option with the given id, this function returns NULL.
.SH AVAILABILITY
Expand Down
8 changes: 6 additions & 2 deletions docs/libcurl/curl_easy_option_next.3
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,26 @@ struct curl_easyoption {
const char *name;
CURLoption id;
curl_easytype type;
unsigned int flags;
};

const struct curl_easyoption *
curl_easy_option_next(const struct curl_easyoption *prev);
.fi
.SH DESCRIPTION
This function returns a pointer to the first or the next curl_easyoption
struct, providing an ability to iterate over all known optiosn for
struct, providing an ability to iterate over all known options for
\fIcurl_easy_setopt(3)\fP in this instance of libcurl.

Pass a \fBNULL\fP argument as \fBprev\fP to get the first option returned, or
pass in the current option to get the next one returned. If there is no more
options to return, \fIcurl_easy_option_next(3)\fP returns NULL.
option to return, \fIcurl_easy_option_next(3)\fP returns NULL.

The options returned by this functions are the ones known to this libcurl and
information about what argument type they want.

If the \fBCURLOT_FLAG_ALIAS\fP bit is set in the flags field, it means the
name is provided for backwards compatibility as an alias.
.SH AVAILABILITY
This function was added in libcurl 7.71.0
.SH RETURN VALUE
Expand Down
4 changes: 2 additions & 2 deletions include/curl/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,8 @@ typedef enum {

/* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION
callbacks */
CURLOPT(CURLOPT_PROGRESSDATA, CURLOPTTYPE_CBPOINT, 57),
#define CURLOPT_XFERINFODATA CURLOPT_PROGRESSDATA
CURLOPT(CURLOPT_XFERINFODATA, CURLOPTTYPE_CBPOINT, 57),
#define CURLOPT_PROGRESSDATA CURLOPT_XFERINFODATA

/* We want the referrer field set automatically when following locations */
CURLOPT(CURLOPT_AUTOREFERER, CURLOPTTYPE_LONG, 58),
Expand Down
8 changes: 7 additions & 1 deletion include/curl/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ typedef enum {
CURLOT_FUNCTION /* function pointer */
} curl_easytype;

/* Flag bits */

/* "alias" means it is provided for old programs to remain functional,
we prefer another name */
#define CURLOT_FLAG_ALIAS (1<<0)

/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size
to use for curl_easy_setopt() for the given id */
struct curl_easyoption {
const char *name;
CURLoption id;
curl_easytype type;
unsigned int flags;
};

CURL_EXTERN const struct curl_easyoption *
Expand All @@ -59,4 +66,3 @@ curl_easy_option_next(const struct curl_easyoption *prev);
} /* end of extern "C" */
#endif
#endif /* CURLINC_OPTIONS_H */

5 changes: 3 additions & 2 deletions lib/easygetopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ static struct curl_easyoption *lookup(const char *name, CURLoption id)
return o;
}
else {
if(o->id == id)
if((o->id == id) && !(o->flags & CURLOT_FLAG_ALIAS))
/* don't match alias options */
return o;
}
o++;
Expand All @@ -53,7 +54,7 @@ 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)
const struct curl_easyoption *curl_easy_option_by_id(CURLoption id)
{
return lookup(NULL, id);
}
Expand Down
Loading

0 comments on commit a12d16b

Please sign in to comment.