/*
 *      $Filename: system.c $
 *      $Revision: 1.2 $
 *      $Date: 1993/09/24 23:12:19 $
 *
 *      This file contains all routines accessing the AmigaOS. This is
 *      the file you should look into when porting PGPSendMail.
 *
 *      © Copyright 1993 Peter Simons, Germany
 *        All Rights Reserved
 *
 *      $Id: system.c,v 1.2 1993/09/24 23:12:19 simons Stab simons $
 *
 * ------------------------------ log history ----------------------------
 * $Log: system.c,v $
 * Revision 1.2  1993/09/24  23:12:19  simons
 * Added ConfirmEncryption().
 *
 * Revision 1.1  1993/09/24  22:47:13  simons
 * Initial revision
 *
 */


/**************************************************************************
 *                                                                        *
 * Sektion: Macros, Definitions, Includes, Structures                     *
 *                                                                        *
 **************************************************************************/

/************************************* Includes ***********/
#include <proto/dos.h>
#include <dos/dos.h>
#include <proto/intuition.h>
#include <intuition/intuition.h>

/************************************* Defines ************/

/************************************* Prototypes *********/

/************************************* global Variables ***/


        static const char __RCSId[] = "$Id: system.c,v 1.2 1993/09/24 23:12:19 simons Stab simons $";


/**************************************************************************
 *                                                                        *
 * Sektion: Subroutines                                                   *
 *                                                                        *
 **************************************************************************/

int TruncFile(char *filename, int pos)
        /*
         * Function: This routine truncates a file at a given positition.
         * Comment : AmigaDOS v2.04+ is required.
         */
{
        BPTR fh;

        if ((fh = Open(filename, MODE_OLDFILE)) == NULL)
                return 0;

        pos = SetFileSize(fh, pos, OFFSET_BEGINNING);
        Close(fh);
        return (pos == -1) ? 0 : 1;
}


int ConfirmEncryption(void)
{
        struct EasyStruct es = {
                sizeof(struct EasyStruct),
                0L,
                "PGPSendMail",
                "A public key for all receipients of this mail is\n" \
                        "available. Shall I encrypt it, using PGP?",
                "yes|no"
        };

        return EasyRequestArgs(0L, &es, 0L, 0L);
}
