home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
ixemul-45.0-src.tgz
/
tar.out
/
contrib
/
ixemul
/
utils
/
functions.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-01
|
8KB
|
324 lines
/*
Ixprefs v.2.4--ixemul.library configuration program
Copyright © 1995,1996 Kriton Kyrimis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <string.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include "ixprefs.h"
#include "ixemul.h"
#include "version.h"
#define IXPREFS_VERSION "2.4"
#define RUNNING 1
#define NOT_RUNNING 0
#define CONFIGFILE "ENVARC:" IX_ENV_SETTINGS
#define ENVFILE "ENV:" IX_ENV_SETTINGS
/* These strings are long enough to have a high probability of being typed
incorrectly, especially as they are used more than once. Using these
definitions, we can detect typing errors at compile time */
#define IX_NO_INSERT_DISK_REQUESTER "ix_no_insert_disk_requester"
#define IX_UNIX_PATTERN_MATCHING_CASE_SENSITIVE "ix_unix_pattern_matching_case_sensitive"
#define IX_TRANSLATE_SLASH "ix_translate_slash"
#define IX_MEMBUF_LIMIT "ix_membuf_limit"
#define IX_FS_BUF_FACTOR "ix_fs_buf_factor"
#define IX_ALLOW_AMIGA_WILDCARD "ix_allow_amiga_wildcard"
extern void showrequester(struct Window*, char *, char *);
extern struct ixemul_base *ixemulbase;
extern int translateslash, membuf, blocks, cases, suppress,
amigawildcard, noflush, ignoreenv, networking, enforcerhit,
profilemethod;
struct ix_settings settings;
extern void displayprefs(void);
void
use(void)
{
FILE *f;
unsigned long new_flags;
membufClicked();
blocksClicked();
new_flags =
(translateslash ? ix_translate_slash : 0)
| (cases ? ix_unix_pattern_matching_case_sensitive : 0)
| (suppress ? ix_no_insert_disk_requester : 0)
| (amigawildcard ? ix_allow_amiga_wildcard : 0)
| (noflush ? ix_do_not_flush_library : 0)
| (ignoreenv ? ix_ignore_global_env : 0)
| (enforcerhit ? ix_create_enforcer_hit : 0)
| (profilemethod << 14);
settings.version = IX_VERSION;
settings.revision = IX_REVISION;
settings.flags = new_flags;
settings.membuf_limit = membuf;
settings.fs_buf_factor = blocks;
settings.network_type = networking;
ix_set_settings(&settings);
f = fopen(ENVFILE, "w");
if (f) {
fwrite(&settings, sizeof(settings), 1, f);
fclose(f);
} else {
showrequester(ixprefsWnd, "Can't open " ENVFILE, "OK");
}
}
void
save(void)
{
FILE *f;
use();
f = fopen(CONFIGFILE, "w");
if (f) {
fwrite(&settings, sizeof(settings), 1, f);
fclose(f);
}else{
showrequester(ixprefsWnd, "Can't open " CONFIGFILE, "OK");
}
}
int
selected(int which)
{
if (ixprefsGadgets[which]->Flags & GFLG_SELECTED) {
return 1;
}else{
return 0;
}
}
int savegadClicked( void )
{
/* routine when gadget "Save" is clicked. */
save();
return NOT_RUNNING;
}
int usegadClicked( void )
{
/* routine when gadget "Use" is clicked. */
use();
return NOT_RUNNING;
}
int cancelgadClicked( void )
{
/* routine when gadget "Cancel" is clicked. */
return NOT_RUNNING;
}
int translateslashClicked( void )
{
/* routine when gadget "translate /" is clicked. */
translateslash = selected(GDX_translateslash);
return RUNNING;
}
int membufClicked( void )
{
/* routine when gadget "membuf size" is clicked. */
membuf = GetNumber(ixprefsGadgets[GDX_membuf]);
return RUNNING;
}
int blocksClicked( void )
{
/* routine when gadget "physical blocks to build one logical block (for stdio)" is clicked. */
blocks = GetNumber(ixprefsGadgets[GDX_blocks]);
return RUNNING;
}
int caseClicked( void )
{
/* routine when gadget "case sensitive)" is clicked. */
cases = selected(GDX_case);
return RUNNING;
}
int suppressClicked( void )
{
/* routine when gadget "suppress the \"Insert volume in drive\" requester" is clicked. */
suppress = selected(GDX_suppress);
return RUNNING;
}
int networkingClicked( void )
{
/* routine when cycle gadget "Networking support" is clicked. */
networking = ixprefsMsg.Code;
return RUNNING;
}
int profilemethodClicked( void )
{
/* routine when cycle gadget "Profile method" is clicked. */
profilemethod = ixprefsMsg.Code;
return RUNNING;
}
int amigawildcardClicked( void )
{
/* routine when gadget "allow Amiga wildcards" is clicked. */
amigawildcard = selected(GDX_amigawildcard);
return RUNNING;
}
int noflushClicked( void )
{
/* routine when gadget "do not flush library" is clicked. */
noflush = selected(GDX_noflush);
return RUNNING;
}
int ignoreenvClicked( void )
{
/* routine when gadget "ignore global environment (ENV:)" is clicked. */
ignoreenv = selected(GDX_ignoreenv);
return RUNNING;
}
int enforcerhitClicked( void )
{
/* routine when gadget "Create Enforcerhit on trap" is clicked. */
enforcerhit = selected(GDX_enforcerhit);
return RUNNING;
}
int ixprefssave( void )
{
/* routine when (sub)item "Save" is selected. */
save();
return NOT_RUNNING;
}
int ixprefsuse( void )
{
/* routine when (sub)item "Use" is selected. */
use();
return NOT_RUNNING;
}
int ixprefsabout( void )
{
/* routine when (sub)item "About" is selected. */
showrequester(ixprefsWnd,
"Ixprefs v." IXPREFS_VERSION "--ixemul.library configuration program\n"
"Copyright \251 1995,1996 Kriton Kyrimis\n\n"
"This program is free software; you can redistribute it\n"
"and/or modify it under the terms of the GNU General\n"
"Public License as published by the Free Software Foundation;\n"
"either version 2 of the License, or (at your option)\n"
"any later version.\n\n"
"GUI designed using GadToolsBox 2.0c by Jan van den Baard",
"OK");
return RUNNING;
}
int ixprefsquit( void )
{
/* routine when (sub)item "Quit" is selected. */
return NOT_RUNNING;
}
void read_from_settings(struct ix_settings *settings)
{
translateslash = (settings->flags & ix_translate_slash) != 0;
cases = (settings->flags & ix_unix_pattern_matching_case_sensitive) != 0;
suppress = (settings->flags & ix_no_insert_disk_requester) != 0;
amigawildcard = (settings->flags & ix_allow_amiga_wildcard) != 0;
noflush = (settings->flags & ix_do_not_flush_library) != 0;
ignoreenv = (settings->flags & ix_ignore_global_env) != 0;
enforcerhit = (settings->flags & ix_create_enforcer_hit) != 0;
membuf = settings->membuf_limit;
blocks = settings->fs_buf_factor;
networking = settings->network_type;
profilemethod = (settings->flags >> 14) & 3;
}
void defaults(void)
{
read_from_settings(ix_get_default_settings());
}
int ixprefsreset(void)
{
/* routine when (sub)item "Reset to defaults" is selected. */
defaults();
displayprefs();
return RUNNING;
}
int
last_saved(void)
{
FILE *f;
int status;
f = fopen(CONFIGFILE, "r");
if (f) {
fread(&settings, sizeof(settings), 1, f);
fclose(f);
read_from_settings(&settings);
status = 0;
}else{
showrequester(ixprefsWnd, "Can't open " CONFIGFILE, "OK");
status = 1;
}
return status;
}
int ixprefslast( void )
{
/* routine when (sub)item "Last Saved" is selected. */
if (last_saved() == 0) {
displayprefs();
}
return RUNNING;
}
int ixprefsrestore( void )
{
struct ix_settings *settings;
/* routine when (sub)item "Restore" is selected. */
settings = ix_get_settings();
read_from_settings(settings);
displayprefs();
return RUNNING;
}
int ixprefsCloseWindow( void )
{
/* routine for "IDCMP_CLOSEWINDOW". */
return NOT_RUNNING;
}