Back to index

opendkim  2.6.2
t-test116.c
Go to the documentation of this file.
00001 /*
00002 **  Copyright (c) 2005-2008 Sendmail, Inc. and its suppliers.
00003 **    All rights reserved.
00004 **
00005 **  Copyright (c) 2009, 2011, The OpenDKIM Project.  All rights reserved.
00006 */
00007 
00008 #ifndef lint
00009 static char t_test116_c_id[] = "@(#)$Id: t-test116.c,v 1.2 2009/12/08 19:14:27 cm-msk Exp $";
00010 #endif /* !lint */
00011 
00012 #include "build-config.h"
00013 
00014 /* system includes */
00015 #include <sys/types.h>
00016 #include <assert.h>
00017 #include <string.h>
00018 #include <stdio.h>
00019 
00020 #ifdef USE_GNUTLS
00021 # include <gnutls/gnutls.h>
00022 #endif /* USE_GNUTLS */
00023 
00024 /* libopendkim includes */
00025 #include "../dkim.h"
00026 #include "t-testdata.h"
00027 
00028 #define       MAXHEADER     4096
00029 
00030 /*
00031 **  MAIN -- program mainline
00032 **
00033 **  Parameters:
00034 **     The usual.
00035 **
00036 **  Return value:
00037 **     Exit status.
00038 */
00039 
00040 int
00041 main(int argc, char **argv)
00042 {
00043 #ifdef TEST_KEEP_FILES
00044        u_int flags;
00045 #endif /* TEST_KEEP_FILES */
00046        DKIM_STAT status;
00047        DKIM *dkim;
00048        DKIM_LIB *lib;
00049        dkim_query_t qtype = DKIM_QUERY_FILE;
00050 
00051        printf("*** verifying unsigned message\n");
00052 
00053 #ifdef USE_GNUTLS
00054        (void) gnutls_global_init();
00055 #endif /* USE_GNUTLS */
00056 
00057        /* instantiate the library */
00058        lib = dkim_init(NULL, NULL);
00059        assert(lib != NULL);
00060 
00061 #ifdef TEST_KEEP_FILES
00062        /* set flags */
00063        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
00064        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
00065                            sizeof flags);
00066 #endif /* TEST_KEEP_FILES */
00067 
00068        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
00069                            &qtype, sizeof qtype);
00070        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
00071                            KEYFILE, strlen(KEYFILE));
00072 
00073        dkim = dkim_verify(lib, JOBID, NULL, &status);
00074        assert(dkim != NULL);
00075 
00076        status = dkim_header(dkim, HEADER01, strlen(HEADER01));
00077        assert(status == DKIM_STAT_OK);
00078 
00079        status = dkim_header(dkim, HEADER02, strlen(HEADER02));
00080        assert(status == DKIM_STAT_OK);
00081 
00082        status = dkim_header(dkim, HEADER03, strlen(HEADER03));
00083        assert(status == DKIM_STAT_OK);
00084 
00085        status = dkim_header(dkim, HEADER04, strlen(HEADER04));
00086        assert(status == DKIM_STAT_OK);
00087 
00088        status = dkim_header(dkim, HEADER05, strlen(HEADER05));
00089        assert(status == DKIM_STAT_OK);
00090 
00091        status = dkim_header(dkim, HEADER06, strlen(HEADER06));
00092        assert(status == DKIM_STAT_OK);
00093 
00094        status = dkim_header(dkim, HEADER07, strlen(HEADER07));
00095        assert(status == DKIM_STAT_OK);
00096 
00097        status = dkim_header(dkim, HEADER08, strlen(HEADER08));
00098        assert(status == DKIM_STAT_OK);
00099 
00100        status = dkim_header(dkim, HEADER09, strlen(HEADER09));
00101        assert(status == DKIM_STAT_OK);
00102 
00103        status = dkim_eoh(dkim);
00104        assert(status == DKIM_STAT_NOSIG);
00105 
00106        status = dkim_eom(dkim, NULL);
00107        assert(status == DKIM_STAT_NOSIG);
00108 
00109        status = dkim_free(dkim);
00110        assert(status == DKIM_STAT_OK);
00111 
00112        dkim_close(lib);
00113 
00114        return 0;
00115 }