## tests/pa/test.c

/* [<][>][^][v][top][bottom][index][help] */

## FUNCTIONS

This source file includes following functions.

1. ShowPAResults
2. main

       1 #include <stdio.h>
       2
       3 #include "ca_configFns.h"
       4 #include "ca_dictSyms.h"
       5 #include "ca_macros.h"
       6 #include "ca_srcAttribs.h"
       7 #include "gpg.h"
       8
       9
      10 void ShowPAResults(struct VerifySignObject *vSO) {
         /* [<][>][^][v][top][bottom][index][help] */
      11   if (vSO != NULL) {
      12     if (vSO->inner == NULL) {
      13       printf("isValid: %d\n", vSO->isValid);
      14       printf("key ID: %x\n",  vSO->keyID);
      15       printf("type: %s\n", (vSO->type == vSO_Type_PlainText ?
      16                             "PlainText" :
      17                             (vSO->type == vSO_Type_Signed ? "Signed" :
      18                              "ToBeGPGVerified")));
      19       printf("iDocSigFilename: %s\n", vSO->iDocSigFilename);
      20       printf("oStream: %s\n\n\n", vSO->oStream);
      21     } else {
      22       ShowPAResults(vSO->inner);
      23     }
      24     if (vSO->next != NULL) ShowPAResults(vSO->next);
      25   }
      26 }
      27
      28 int main(int argc, char **argv)
         /* [<][>][^][v][top][bottom][index][help] */
      29 {
      30
      31   char iSignedFilename[100] = "foo.asc";
      32   char iSignatureFilename[100] = "";
      33   char iImportKeyFilename[100] = "goo";
      34   char iKeyRing[100] = "/home/filippo/.gnupg/pubring.gpg";
      35   struct VerifySignObject vSO, *pvSO;
      36   struct ImportKeyObject iKO;
      37
      38
      39   /* config stuff */
      40   ca_populateDictionary(dictionary, VARS);
      41   /* if -c flag is given, use the named file as config file, otherwise use
      42      default filename */
      43   ca_readConfig("filippo.conf", confVars, VARS);
      44
      45   if ((argv[1] != NULL) &&  (!strcmp(argv[1], "-i"))) {
      46
      47     strcpy(iKO.iFilename, iImportKeyFilename);
      48     strcpy(iKO.keyRing, iKeyRing);
      49
      50     PA_ImportKey(&iKO);
      51
      52     printf("importKeyObj status:\n");
      53
      54     printf("isValid: %d\n", iKO.rc);
      55     printf("keyID: %08lX\n", iKO.keyID);
      56     printf("fingerPrint: %s\n", iKO.fingerPrint);
      57   } else
      58     if ((argv[1] != NULL) &&  (!strcmp(argv[1], "-r"))) {
      59       strcpy(iKO.iFilename, iImportKeyFilename);
      60       strcpy(iKO.keyRing, iKeyRing);
      61
      62       PA_RemoveKey(&iKO);
      63
      64       printf("importKeyObj status:\n");
      65
      66       printf("isValid: %d\n", iKO.rc);
      67     } else
      68       if ((argv[1] != NULL) &&  (!strcmp(argv[1], "-d"))) {
      69         strcpy(vSO.outputPath, "/tmp");
      70         strcpy(vSO.iDocSigFilename, "foo");
      71         strcpy(vSO.iSigFilename, "foo.sig");
      72         strcpy(vSO.keyRing, iKeyRing);
      73
      74         PA_ParseMessage(&vSO);
      75
      76         ShowPAResults(&vSO);
      77       }else {
      78         /*    strcpy(vSO.outputPath, ca_get_tmpdir+1); */
      79         g_strstrip(ca_get_tmpdir);
      80
      81         strcpy(vSO.outputPath, "/tmp");
      82         strcpy(vSO.iDocSigFilename, iSignedFilename);
      83         strcpy(vSO.iSigFilename, "");
      84         strcpy(vSO.keyRing, iKeyRing);
      85
      86         PA_ParseMessage(&vSO);
      87
      88         ShowPAResults(&vSO);
      89       }
      90
      91   return 0;
      92 }

/* [<][>][^][v][top][bottom][index][help] */