rpms/crypto-utils/devel certwatch.c,1.15,1.16
Elio Maldonado
emaldonado at fedoraproject.org
Mon Dec 29 00:52:55 UTC 2008
Author: emaldonado
Update of /cvs/extras/rpms/crypto-utils/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv10838
Modified Files:
certwatch.c
Log Message:
code cleanup
Index: certwatch.c
===================================================================
RCS file: /cvs/extras/rpms/crypto-utils/devel/certwatch.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- certwatch.c 24 Dec 2008 22:19:24 -0000 1.15
+++ certwatch.c 29 Dec 2008 00:52:25 -0000 1.16
@@ -149,8 +149,7 @@
return buf;
}
-
-/* A year is leap iff is divisible by 4 but not by 100 or is divisible by 400 */
+/* A leap year is divisible by 4 but not by 100 or divisible by 400 */
static int leap_year(int year) {
return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) ? 1 : 0;
}
@@ -165,21 +164,21 @@
LL_I2L(one, 1);
do {
- PR_ExplodeTime(aT, PR_GMTParameters, &a);
- PR_ExplodeTime(bT, PR_GMTParameters, &b);
+ PR_ExplodeTime(aT, PR_GMTParameters, &a);
+ PR_ExplodeTime(bT, PR_GMTParameters, &b);
- years = a.tm_year - b.tm_year;
- if (years < 0) break;
+ years = a.tm_year - b.tm_year;
+ if (years < 0)
+ break;
- if (years == 0) {
+ if (years == 0) {
days += (a.tm_yday - b.tm_yday);
- } else if (a.tm_year == b.tm_year + 1) {
+ } else if (a.tm_year == b.tm_year + 1) {
days += (365 + leap_year(b.tm_year) - b.tm_yday + a.tm_yday);
- } else {
+ } else {
LL_SUB(am1, aT, one);
aT = am1;
- }
-
+ }
} while (0);
return days;
@@ -192,7 +191,7 @@
PRTime start, PRTime end, PRTime now, int quiet)
{
/* Note that filename can be the cert nickname. */
- int renew = 1;
+ int renew = 1, int days; /* days till expiry */
char subj[50];
switch (validity) {
@@ -204,20 +203,17 @@
sprintf(subj, "has expired");
break;
case secCertTimeValid:
- {
- /* days till expiry */
- int days = diff_time_days(end, now);
- if (days == 0) {
- strcpy(subj, "will expire today");
- } else if (days == 1) {
- sprintf(subj, "will expire tomorrow");
- } else if (days < warn_period) {
- sprintf(subj, "will expire in %d days", days);
- } else {
- return 0; /* nothing to warn about. */
- }
- }
- break;
+ days = diff_time_days(end, now);
+ if (days == 0) {
+ strcpy(subj, "will expire today");
+ } else if (days == 1) {
+ sprintf(subj, "will expire tomorrow");
+ } else if (days < warn_period) {
+ sprintf(subj, "will expire in %d days", days);
+ } else {
+ return 0; /* nothing to warn about. */
+ }
+ break;
case secCertTimeUndetermined:
default:
/* it will never get here if caller checks validity */
@@ -338,7 +334,8 @@
int main(int argc, char **argv)
{
int optc, quiet = 0;
- static const struct option options[] = {
+ const char *shortopts = "qp:a:d:w:c:k:";
+ static const struct option longopts[] = {
{ "quiet", no_argument, NULL, 'q' },
{ "period", required_argument, NULL, 'p' },
{ "address", required_argument, NULL, 'a' },
@@ -348,10 +345,8 @@
{ "keydbprexix", required_argument, NULL, 'k' },
{ NULL }
};
- const char *opts = "qp:a:d:w:c:k:";
char *certDBPrefix = "";
char *keyDBPrefix = "";
-
char *configdir = NULL; /* contains the cert database */
char *passwordfile = NULL; /* module password file */
int byNickname = 0; /* whether to search by nickname */
@@ -360,7 +355,7 @@
* mktime() back to UTC: */
tzset();
- while ((optc = getopt_long(argc, argv, opts, options, NULL)) != -1) {
+ while ((optc = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (optc) {
case 'q':
quiet = 1;
More information about the fedora-extras-commits
mailing list