core: Add gpgme_data_set_flag to add more meta data to data objects.
* src/gpgme.h.in (gpgme_data_set_flag): New public function. * src/data.c (gpgme_data_set_flag): New. (_gpgme_data_get_size_hint): New. * src/data.h (strucy gpgme_data): Add field 'size_hint'. * src/gpgme.def, src/libgpgme.vers: Add new function. * src/conversion.c (_gpgme_string_to_off): New. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
06e601ad1a
commit
293d173691
1
NEWS
1
NEWS
@ -12,6 +12,7 @@ Noteworthy changes in version 1.7.0 (unreleased) [C25/A14/R_]
|
||||
gpgme_pubkey_algo_string NEW.
|
||||
GPGME_PK_EDDSA NEW.
|
||||
gpgme_set_ctx_flag NEW.
|
||||
gpgme_data_set_flag NEW.
|
||||
gpgme_signature_t EXTENDED: New field tofu.
|
||||
gpgme_subkey_t EXTENDED: New field keygrip.
|
||||
gpgme_tofu_policy_t NEW.
|
||||
|
@ -364,6 +364,25 @@ _gpgme_strtoul_field (const char *string, unsigned long *result)
|
||||
}
|
||||
|
||||
|
||||
/* Convert STRING into an offset value. Note that this functions only
|
||||
* allows for a base-10 length. This function is similar to atoi()
|
||||
* and thus there is no error checking. */
|
||||
gpgme_off_t
|
||||
_gpgme_string_to_off (const char *string)
|
||||
{
|
||||
gpgme_off_t value = 0;
|
||||
|
||||
while (*string == ' ' || *string == '\t')
|
||||
string++;
|
||||
for (; *string >= '0' && *string <= '9'; string++)
|
||||
{
|
||||
value *= 10;
|
||||
value += atoi_1 (string);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
static time_t
|
||||
_gpgme_timegm (struct tm *tm)
|
||||
|
30
src/data.c
30
src/data.c
@ -243,6 +243,28 @@ gpgme_data_get_file_name (gpgme_data_t dh)
|
||||
return dh->file_name;
|
||||
}
|
||||
|
||||
|
||||
/* Set a flag for the data object DH. See the manual for details. */
|
||||
gpg_error_t
|
||||
gpgme_data_set_flag (gpgme_data_t dh, const char *name, const char *value)
|
||||
{
|
||||
TRACE_BEG2 (DEBUG_DATA, "gpgme_data_set_flag", dh,
|
||||
"%s=%s", name, value);
|
||||
|
||||
if (!dh)
|
||||
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
||||
|
||||
if (!strcmp (name, "size-hint"))
|
||||
{
|
||||
dh->size_hint= value? _gpgme_string_to_off (value) : 0;
|
||||
}
|
||||
else
|
||||
return gpg_error (GPG_ERR_UNKNOWN_NAME);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Functions to support the wait interface. */
|
||||
|
||||
@ -334,3 +356,11 @@ _gpgme_data_get_fd (gpgme_data_t dh)
|
||||
return -1;
|
||||
return (*dh->cbs->get_fd) (dh);
|
||||
}
|
||||
|
||||
|
||||
/* Get the size-hint value for DH or 0 if not available. */
|
||||
gpgme_off_t
|
||||
_gpgme_data_get_size_hint (gpgme_data_t dh)
|
||||
{
|
||||
return dh ? dh->size_hint : 0;
|
||||
}
|
||||
|
@ -89,6 +89,9 @@ struct gpgme_data
|
||||
/* File name of the data object. */
|
||||
char *file_name;
|
||||
|
||||
/* Hint on the to be expected toatl size of the data. */
|
||||
gpgme_off_t size_hint;
|
||||
|
||||
union
|
||||
{
|
||||
/* For gpgme_data_new_from_fd. */
|
||||
@ -134,4 +137,7 @@ void _gpgme_data_release (gpgme_data_t dh);
|
||||
return -1. */
|
||||
int _gpgme_data_get_fd (gpgme_data_t dh);
|
||||
|
||||
/* Get the size-hint value for DH or 0 if not available. */
|
||||
gpgme_off_t _gpgme_data_get_size_hint (gpgme_data_t dh);
|
||||
|
||||
#endif /* DATA_H */
|
||||
|
@ -226,5 +226,8 @@ EXPORTS
|
||||
|
||||
gpgme_pubkey_algo_string @169
|
||||
gpgme_set_ctx_flag @170
|
||||
|
||||
gpgme_data_set_flag @171
|
||||
|
||||
; END
|
||||
|
||||
|
@ -1282,6 +1282,10 @@ char *gpgme_data_get_file_name (gpgme_data_t dh);
|
||||
gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh,
|
||||
const char *file_name);
|
||||
|
||||
/* Set a flag for the data object DH. See the manual for details. */
|
||||
gpg_error_t gpgme_data_set_flag (gpgme_data_t dh,
|
||||
const char *name, const char *value);
|
||||
|
||||
/* Try to identify the type of the data in DH. */
|
||||
gpgme_data_type_t gpgme_data_identify (gpgme_data_t dh, int reserved);
|
||||
|
||||
|
@ -230,6 +230,8 @@ GPGME_1.0 {
|
||||
gpgme_err_code_from_syserror;
|
||||
gpgme_err_set_errno;
|
||||
|
||||
gpgme_data_set_flag;
|
||||
|
||||
local:
|
||||
*;
|
||||
|
||||
|
@ -134,6 +134,9 @@ int _gpgme_split_fields (char *string, char **array, int arraysize);
|
||||
* trailing garbage. */
|
||||
gpgme_error_t _gpgme_strtoul_field (const char *string, unsigned long *result);
|
||||
|
||||
/* Convert STRING into an offset value similar to atoi(). */
|
||||
gpgme_off_t _gpgme_string_to_off (const char *string);
|
||||
|
||||
/* Parse the string TIMESTAMP into a time_t. The string may either be
|
||||
seconds since Epoch or in the ISO 8601 format like
|
||||
"20390815T143012". Returns 0 for an empty string or seconds since
|
||||
|
Loading…
Reference in New Issue
Block a user