home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
s1
/
secure307
/
InHere
/
!Secure3
/
c
/
!SecureSrc
/
Secure
< prev
Wrap
Text File
|
1994-01-05
|
23KB
|
812 lines
/***************************************************************************/
/***************************************************************************/
/** **/
/** Name : Secure3. **/
/** Purpose : Desktop password protection. **/
/** Author : Anthony Brion, 1993,94. **/
/** Version : 3.05 (05 Jan 1993) **/
/** **/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/** **/
/** Library #includes. **/
/** **/
/***************************************************************************/
/***************************************************************************/
#include "res.h" /* Resources */
#include "resspr.h" /* Sprite resources */
#include "msgs.h" /* Provide support for message resource file */
#include "event.h" /* Central processing for window system events */
#include "win.h" /* Centraql management of RiscOS windows */
#include "werr.h" /* Wimp error reporting */
#include "dbox.h" /* Creation/deletion/manipulation of dialogue boxes */
#include "baricon.h" /* Support placing of an icon on the icon bar */
#include "menu.h" /* Menu creation/deletion/manipulation */
#include "os.h" /* Low-level RiscOS routines */
#include "wimpt.h" /* Low-level wimp functionality */
#include "kernel.h" /* Machine-level RiscOS routines */
#include "template.h" /* Template file management */
#include "wimp.h" /* C interface to RiscOS wimp routines */
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
/***************************************************************************/
/***************************************************************************/
/** **/
/** Macros. **/
/** **/
/***************************************************************************/
/***************************************************************************/
#define UNUSED(x) x = x
#define BEEP printf("\a")
#define VERSION "Secure version 3.05"
#define RETURN_key 13
#define PASSWORD_max 17
#define RESET_TYPE 253
#define POWER_ON 1
/* Iconbar menu options */
#define bar_info 1
#define bar_setup 2
#define bar_chgcode 3
#define bar_quit 4
/* Password dialogue box fields */
#define VERSION_field 22
#define SVERSION_field 2
#define NAME_field 19
#define ADDRESS1_field 20
#define ADDRESS2_field 18
#define PHONE_field 3
#define MODEL_field 4
#define SERIAL_field 5
#define PASSWORD_field 6
#define STEXT_field 3
/***************************************************************************/
/***************************************************************************/
/** **/
/** Global data. **/
/** **/
/***************************************************************************/
/***************************************************************************/
/* Task handle */
static wimp_t taskhandle;
/* Version string */
static char secure_version[] = "3.05 (05 Jan 1994)";
/* Iconbar menu handle */
static menu secure_menu;
/* Iconbar text */
static char Iconbar_text[] = "Secure3";
/* Password dialogue box handle */
static dbox secure;
/* Input password from dialogue box */
static char input_password[PASSWORD_max + 1];
/* Break key status */
static int break_status;
/* Setup file handle */
static FILE *setup;
/* ID A */
static char ida[10];
/* ID B */
static char idb[10];
/* Setup file data */
static char startup;
static char ibar;
static char poweron;
static char password[PASSWORD_max + 1];
static char name[36];
static char add1[36];
static char add2[36];
static char tel[36];
static char model[36];
static char serial[36];
static char text[28];
/***************************************************************************/
/***************************************************************************/
/** **/
/** Functions. **/
/** **/
/***************************************************************************/
/***************************************************************************/
/*************************************************************************-*/
/* Encode/Decode data. */
/*************************************************************************-*/
static void eor_data(char *string)
{
int count;
for (count=0;count < 35;count++)
{
if (string[count] == NULL)
break;
string[count] ^= '\001' + count;
}
return;
}
/***************************************************************************/
/* Encode/Decode password. */
/***************************************************************************/
static void eor_password(void)
{
int count;
for (count=0;count < PASSWORD_max;count++)
{
if (password[count] == NULL)
break;
password[count] ^= '\001' + count;
}
return;
}
/***************************************************************************/
/* Read a string (including spaces) from a file. */
/***************************************************************************/
static void freadstring(char *string)
{
int count = 0;
char c;
do
{
c = fgetc(setup);
*(string + count++) = c;
}
while (c != NULL);
return;
}
/***************************************************************************/
/* Load setup file. */
/***************************************************************************/
static void load_setup(void)
{
int error;
setup = fopen("<Secure3$dir>.setup","r");
startup = fgetc(setup);
ibar = fgetc(setup);
poweron = fgetc(setup);
freadstring(password); eor_password(); /* Decode password */
freadstring(name); eor_data(name); /* Decode name */
freadstring(add1); eor_data(add1); /* Decode address line one */
freadstring(add2); eor_data(add2); /* Decode address line two */
freadstring(tel); eor_data(tel); /* Decode telephone number */
freadstring(model); eor_data(model); /* Decode modeel number */
freadstring(serial); eor_data(serial); /* Decode serial number */
freadstring(text);
error = fclose(setup);
return;
}
/***************************************************************************/
/* Save setup file. */
/********************************************