/* conversion.c - String conversion helper functions.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH
-
+
This file is part of GPGME.
GPGME is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
GPGME is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
/* A binary zero is not representable in a C
string. */
*(dest++) = '\\';
- *(dest++) = '0';
+ *(dest++) = '0';
}
- else
+ else
*((unsigned char *) dest++) = val;
src += 4;
}
*(dest++) = *(src++);
*(dest++) = *(src++);
}
- }
+ }
}
*(dest++) = 0;
else
{
int val = _gpgme_hextobyte (&src[1]);
-
+
if (val == -1)
{
/* Should not happen. */
/* A binary zero is not representable in a C
string. */
*(dest++) = '\\';
- *(dest++) = '0';
+ *(dest++) = '0';
}
- else
+ else
*((unsigned char *) dest++) = val;
src += 3;
}
the special plus format. */
while (*str)
{
- if (*str == '+' || *str == '\"' || *str == '%'
+ if (*str == '+' || *str == '\"' || *str == '%'
|| *(const unsigned char *)str <= 0x20)
destlen += 3;
else
/* Convert the string. */
while (*src)
{
- if (*src == '+' || *src == '\"' || *src == '%'
+ if (*src == '+' || *src == '\"' || *src == '%'
|| *(const unsigned char *)src <= 0x20)
{
snprintf (dest, 4, "%%%02X", *(unsigned char *)src);
SYSTEMTIME st;
FILETIME ft;
unsigned long long cnsecs;
-
+
st.wYear = tm->tm_year + 1900;
st.wMonth = tm->tm_mon + 1;
st.wDay = tm->tm_mday;
gpg_err_set_errno (EINVAL);
return (time_t)(-1);
}
-
+
cnsecs = (((unsigned long long)ft.dwHighDateTime << 32)
| ft.dwLowDateTime);
cnsecs -= 116444736000000000ULL; /* The filetime epoch is 1601-01-01. */
memset (&buf, 0, sizeof buf);
buf.tm_year = year - 1900;
- buf.tm_mon = atoi_2 (timestamp+4) - 1;
+ buf.tm_mon = atoi_2 (timestamp+4) - 1;
buf.tm_mday = atoi_2 (timestamp+6);
buf.tm_hour = atoi_2 (timestamp+9);
buf.tm_min = atoi_2 (timestamp+11);
#else
{
time_t tim;
-
+
putenv ("TZ=UTC");
tim = mktime (&buf);
#ifdef __GNUC__
Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH
This file is part of GPGME.
-
+
GPGME is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
GPGME is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
if (sig->notations)
{
TRACE_LOG1 ("sig[%i] = has notations (not shown)", i);
- }
+ }
sig = sig->next;
i++;
}
calc_sig_summary (gpgme_signature_t sig)
{
unsigned long sum = 0;
-
+
/* Calculate the red/green flag. */
if (sig->validity == GPGME_VALIDITY_FULL
|| sig->validity == GPGME_VALIDITY_ULTIMATE)
sum |= GPGME_SIGSUM_SYS_ERROR;
break;
}
-
+
/* Now look at the certain reason codes. */
switch (gpg_err_code (sig->validity_reason))
{
if (sig->validity == GPGME_VALIDITY_UNKNOWN)
sum |= GPGME_SIGSUM_CRL_TOO_OLD;
break;
-
+
case GPG_ERR_CERT_REVOKED:
sum |= GPGME_SIGSUM_KEY_REVOKED;
break;
/* Check other flags. */
if (sig->wrong_key_usage)
sum |= GPGME_SIGSUM_BAD_POLICY;
-
+
/* Set the valid flag when the signature is unquestionable
valid. (The test is identical to if(sum == GPGME_SIGSUM_GREEN)). */
if ((sum & GPGME_SIGSUM_GREEN) && !(sum & ~GPGME_SIGSUM_GREEN))
sum |= GPGME_SIGSUM_VALID;
-
+
sig->summary = sum;
}
-
+
static gpgme_error_t
prepare_new_sig (op_data_t opd)
end = tail;
while (*end == ' ')
end++;
-
+
/* Parse the hash algo. */
if (!*end)
goto parse_err_sig_fail;
end = tail;
while (*end == ' ')
end++;
-
+
/* Parse the return code. */
if (end[0] && (!end[1] || end[1] == ' '))
{
case '4':
sig->status = gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
break;
-
+
case '9':
sig->status = gpg_error (GPG_ERR_NO_PUBKEY);
break;
-
+
default:
sig->status = gpg_error (GPG_ERR_GENERAL);
}
goto parse_err_sig_fail;
goto parse_err_sig_ok;
-
+
parse_err_sig_fail:
sig->status = gpg_error (GPG_ERR_GENERAL);
parse_err_sig_ok:
break;
-
+
default:
return gpg_error (GPG_ERR_GENERAL);
}
if (sig->timestamp == -1 || end == tail || (*tail && *tail != ' '))
return gpg_error (GPG_ERR_INV_ENGINE);
end = tail;
-
+
sig->exp_timestamp = _gpgme_parse_timestamp (end, &tail);
if (sig->exp_timestamp == -1 || end == tail || (*tail && *tail != ' '))
return gpg_error (GPG_ERR_INV_ENGINE);
/* There is notation data without a previous notation
name. The crypto backend misbehaves. */
return gpg_error (GPG_ERR_INV_ENGINE);
-
+
if (!notation->value)
{
dest = notation->value = malloc (len);
notation->value = dest;
dest += cur_len;
}
-
+
err = _gpgme_decode_percent_string (args, &dest, len, 0);
if (err)
return err;
if (where)
*where = '\0';
- where = args;
+ where = args;
}
else
return gpg_error (GPG_ERR_INV_ENGINE);
gpgme_error_t
_gpgme_op_verify_init_result (gpgme_ctx_t ctx)
-{
+{
void *hook;
op_data_t opd;
case GPG_ERR_NO_ERROR:
*r_stat = GPGME_SIG_STAT_GOOD;
break;
-
+
case GPG_ERR_BAD_SIGNATURE:
*r_stat = GPGME_SIG_STAT_BAD;
break;
-
+
case GPG_ERR_NO_PUBKEY:
*r_stat = GPGME_SIG_STAT_NOKEY;
break;
-
+
case GPG_ERR_NO_DATA:
*r_stat = GPGME_SIG_STAT_NOSIG;
break;
-
+
case GPG_ERR_SIG_EXPIRED:
*r_stat = GPGME_SIG_STAT_GOOD_EXP;
break;
-
+
case GPG_ERR_KEY_EXPIRED:
*r_stat = GPGME_SIG_STAT_GOOD_EXPKEY;
break;
-
+
default:
*r_stat = GPGME_SIG_STAT_ERROR;
break;
number of the signature after a successful verify operation. WHAT
is an attribute where GPGME_ATTR_EXPIRE is probably the most useful
one. WHATIDX is to be passed as 0 for most attributes . */
-unsigned long
+unsigned long
gpgme_get_sig_ulong_attr (gpgme_ctx_t ctx, int idx,
_gpgme_attr_t what, int whatidx)
{
{
case GPG_ERR_NO_ERROR:
return GPGME_SIG_STAT_GOOD;
-
+
case GPG_ERR_BAD_SIGNATURE:
return GPGME_SIG_STAT_BAD;
-
+
case GPG_ERR_NO_PUBKEY:
return GPGME_SIG_STAT_NOKEY;
-
+
case GPG_ERR_NO_DATA:
return GPGME_SIG_STAT_NOSIG;
-
+
case GPG_ERR_SIG_EXPIRED:
return GPGME_SIG_STAT_GOOD_EXP;
-
+
case GPG_ERR_KEY_EXPIRED:
return GPGME_SIG_STAT_GOOD_EXPKEY;
-
+
default:
return GPGME_SIG_STAT_ERROR;
}