home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
back2roots/padua
/
padua.7z
/
padua
/
ftp.vapor.com
/
microdot-1
/
md1_src_02.lzx
/
prefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
2014-05-19
|
28KB
|
1,173 lines
#include <prefs/font.h>
#include "microdot.h"
#include "ogre.h"
#include "ogre_protos.h"
#include "asyncio.h"
static ULONG rgb4to32( ULONG rgb )
{
ULONG result;
rgb &= 0xf;
result = rgb;
result = ( result << 4 ) | rgb;
result = ( result << 4 ) | rgb;
result = ( result << 4 ) | rgb;
result = ( result << 4 ) | rgb;
result = ( result << 4 ) | rgb;
result = ( result << 4 ) | rgb;
result = ( result << 4 ) | rgb;
return( result );
}
/* Read Font Prefs */
void getwbfonts( void )
{
struct FontPrefs fp;
BPTR f;
ULONG id = 0;
if( !isv37 )
return;
f = Open( "ENV:SYS/font.prefs", MODE_OLDFILE );
if( !f )
return;
for(;;)
{
if( FRead( f, ( APTR ) ( ( ( ULONG ) ( &id ) ) + 2 ), 2, 1 ) != 1 )
break;
if( id != ID_FONT )
{
id = id << 16;
continue;
}
memset( &fp, 0, sizeof( fp ) );
Seek( f, 4, OFFSET_CURRENT );
FRead( f, &fp, sizeof( fp ), 1 );
switch( fp.fp_Type )
{
case FP_SCREENFONT:
strncpy( prefs.screenfontname, fp.fp_Name, 29 );
prefs.screenfontheight = fp.fp_TextAttr.ta_YSize;
break;
case FP_SYSFONT:
strncpy( prefs.fontname, fp.fp_Name, 29 );
prefs.fontheight = fp.fp_TextAttr.ta_YSize;
break;
}
}
Close( f );
}
/* Get Colors into prefs */
void getcolors( struct Screen * scr )
{
int c, numcols = min( ( 1 << scr->RastPort.BitMap->Depth ), 8 );
UWORD rgb;
if( isv39 )
{
GetRGB32( scr->ViewPort.ColorMap, 0, numcols, prefs.colors32 );
return;
}
for( c = 0; c < numcols; c ++ )
{
rgb = GetRGB4( scr->ViewPort.ColorMap, c );
prefs.colors32[ ( c * 3 ) + 0 ] = rgb4to32( rgb >> 8 );
prefs.colors32[ ( c * 3 ) + 1 ] = rgb4to32( rgb >> 4 );
prefs.colors32[ ( c * 3 ) + 2 ] = rgb4to32( rgb );
}
}
/* Set prefs Colors */
void setcolors( struct Screen *scr )
{
ULONG table[ 8 * 3 + 2 ];
ULONG cols = min( 1 << scr->RastPort.BitMap->Depth, 8 );
int c;
if( isv39 )
{
table[ 0 ] = ( cols << 16 );
memcpy( &table[1], prefs.colors32, 8 * 3 * 4 );
table[ cols * 3 + 1 ] = 0;
LoadRGB32( &scr->ViewPort, table );
}
else
{
for( c = 0; c < cols; c++ )
{
SetRGB4( &scr->ViewPort, c,
prefs.colors32[ c * 3 ] >> 28,
prefs.colors32[ c * 3 + 1 ] >> 28,
prefs.colors32[ c * 3 + 2 ] >> 28
);
}
}
}
void term_getcolors( void )
{
int c, numcols = min( 1 << scr->RastPort.BitMap->Depth, 8 );
UWORD rgb;
if( isv39 )
{
GetRGB32( scr->ViewPort.ColorMap, 0, numcols, prefs.term_colors );
return;
}
for( c = 0; c < numcols; c ++ )
{
rgb = GetRGB4( scr->ViewPort.ColorMap, c );
prefs.term_colors[ ( c * 3 ) + 0 ] = rgb4to32( rgb >> 8 );
prefs.term_colors[ ( c * 3 ) + 1 ] = rgb4to32( rgb >> 4 );
prefs.term_colors[ ( c * 3 ) + 2 ] = rgb4to32( rgb );
}
}
/* Set prefs Colors */
extern struct mdtprefs mdtprefs;
void term_setcolors( void )
{
ULONG table[ 8 * 3 + 2 ];
ULONG cols = min( 1 << scr->RastPort.BitMap->Depth, 8 );
int c;
static UWORD ansicols[]á= {á0x000, 0xd00, 0x0d0, 0xdd0, 0x00d, 0xd0d, 0x0dd, 0xddd };
if( mdtprefs.whichcolors == 2 )
{
LoadRGB4( &scr->ViewPort, ansicols, cols );
return;
}
if( isv39 )
{
table[ 0 ] = ( cols << 16 );
memcpy( &table[1], prefs.term_colors, 8 * 3 * 4 );
table[ cols * 3 + 1 ] = 0;
LoadRGB32( &scr->ViewPort, table );
}
else
{
for( c = 0; c < cols; c++ )
{
SetRGB4( &scr->ViewPort, c,
prefs.term_colors[ c * 3 ] >> 28,
prefs.term_colors[ c * 3 + 1 ] >> 28,
prefs.term_colors[ c * 3 + 2 ] >> 28
);
}
}
}
void setwbcolors( struct Screen *scr )
{
ULONG table[ 8 * 3 ];
memcpy( table, prefs.colors32, 8 * 3 * 4 );
getwbcolors();
setcolors( scr );
memcpy( prefs.colors32, table, 8 * 3 * 4 );
}
/* Userliste konvertieren */
static void convuserlist( void )
{
struct AsyncFile *f1, *f2;
struct user new;
struct olduser old;
if( exists( "microdot.userdb" ) )
return;
if( !exists( "microdot.user" ) )
return;
f1 = OpenAsync( "microdot.user", MODE_READ, sizeof( struct olduser ) * 16 );
if( !f1 )
return;
f2 = OpenAsync( "microdot.userdb", MODE_WRITE, sizeof( struct user ) * 16 );
if( !f2 )
{
CloseAsync( f1 );
return;
}
while( ( ReadAsync( f1, &old, sizeof( old ) ) ) == sizeof( old ) )
{
memset( &new, 0, sizeof( new ) );
memcpy( &new, &old, sizeof( old ) - 4 );
WriteAsync( f2, &new, sizeof( new ) );
}
CloseAsync( f1 );
CloseAsync( f2 );
}
void getwbcolors( void )
{
struct Screen *cmpscr;
if( isv37 )
cmpscr = LockPubScreen( NULL );
else
cmpscr = (struct Screen *) OpenWorkBench();
getcolors( cmpscr );
if( isv37 )
UnlockPubScreen( NULL, cmpscr );
}
void doprefsnewinit(void)
{
int c;
ret:
c=askreq("Willkommen zu ╖ MicroDot ╖\n\nErstkonfiguration per 'microdot.cfg'\neingestelle Parameter:\n\nUsername....: %s (%s)\nPointname...: %s\nBoxname.....: %s%s\nTelefon.....: %s\nSeriell.....: %s, Unit %ld, %lD Baud\nModem-Init..: %s\nModem-Dial..: %s\nModem-Hangup: %s\nPacker......: %s\nEntpacker...: %s\nEditor......: %s\nDatadir.....: %s\nTransferdir.: %s",
"Akzeptieren|_Point Σndern|_Modem|E_xtern|_Hilfe|Abbruch",
prefs.username,prefs.userrealname,
prefs.pointname,
prefs.boxname,prefs.boxdomain,
prefs.phone,
prefs.modemdevice,prefs.modemunit,prefs.modembaud,
prefs.modeminit,prefs.modemdial,prefs.modemhangup,
prefs.packer,prefs.unpacker,prefs.editor,
prefs.datadir,prefs.transferdir);
switch( c )
{
case 0:
exit( 0 );
break;
case 2:
dopointcfg();
goto ret;
case 3:
doserialcfg();
goto ret;
case 4:
doexternprefs();
goto ret;
case 5:
showguide( "firstinstall" );
goto ret;
}
prefs.flags2 &=~ MDF2_NOPREFS;
}
static char *mmdf_name[] = {
"MAPS", "MAPS", "MAPS", "MAPS", "AREAFIX", "MAPS", "MAPS"
};
static char *mmdf_outname[] = {
"MAPS", "MAPS", "MAPS", "MAPS", "AREAFIX", "MAPS", "MAPS"
};
static char *mmdf_add[] = {
"ADD", "ADD", "ADD", "ADD", "ADD", "ADD", "ADD"
};
static char *mmdf_del[] = {
"DEL", "DEL", "DEL", "DEL", "DEL", "DEL", "DEL"
};
static char *mmdf_list[] = {
"LIST BRETTER", "LIST BRETTER", "LIST BRETTER *", "LIST BRETTER", "LIST BRETTER", "LIST", "LIST"
};
static char *mmdf_listv[] = {
"LIST BRETTER VERBOSE", "LIST BRETTER VERBOSE", "LIST VERBOSE BRETTER *", "LIST VERBOSE BRETTER", "LIST VERBOSE BRETTER", "LIST", "LIST"
};
static char *mmdf_help[] = {
"HILFE *", "HILFE", "HILFE *", "HILFE *", "HILFE *", "HELP", "HELP"
};
static char *mmdf_clearpm[] = {
"CLEARPM", "--", "PM LOESCHEN", "PM LOESCHEN", "PM LOESCHEN", "DELPM", "CLEARPM"
};
static char *mmdf_listid[] = {
"Re: LIST BRETTER VERBOSE", "BRETTER", "BRETTER", "BRETTER", "BRETTER", "Your LIST", "Your LIST"
};
static ULONG mmdf_listo[] = {á
44, 45, 37, 43, 43, 63, 0
};
static ULONG mmdf_listb[] = {á
0, 0, 2, 2, 0, 2, 2
};
static char *mmdf_addpf[] = {
"", "", "", "", "ADD ", "", ""
};
static char *mmdf_delpf[] = {
"", "", "", "", "DEL ", "", ""
};
void presetmapsprefs( UBYTE mapstyp )
{
if( mapstyp < 1 || mapstyp > 7 )
mapstyp = 1;
mapstyp--;
strcpy( prefs.mapsname, mmdf_name[ámapstyp ]á);
strcpy( prefs.mapsoutname, mmdf_outname[ámapstyp ]á);
strcpy( prefs.maps_add, mmdf_add[ámapstyp ] );
strcpy( prefs.maps_addprefix, mmdf_addpf[ámapstyp ] );
strcpy( prefs.maps_delprefix, mmdf_delpf[ámapstyp ] );
strcpy( prefs.maps_del, mmdf_del[ámapstyp ] );
strcpy( prefs.maps_list, mmdf_list[ámapstyp ] );
strcpy( prefs.maps_list_verbose, mmdf_listv[ámapstyp ] );
strcpy( prefs.maps_help, mmdf_help[ámapstyp ] );
strcpy( prefs.maps_clearpm, mmdf_clearpm[ámapstyp ] );
strcpy( prefs.maps_listid, mmdf_listid[ámapstyp ] );
prefs.maps_list_offs = mmdf_listo[ mapstyp ];
prefs.maps_list_boffs = mmdf_listb[ mapstyp ];
}
static void procitem(char *head,char *data)
{
if(!stricmp(head,"boxname")) strncpy(prefs.boxname,data,11);
else if(!stricmp(head,"hostname")) strncpy(prefs.boxname,data,11);
else if(!stricmp(head,"pointname")) strncpy(prefs.pointname,data,39);
else if(!stricmp(head,"sysname")) strncpy(prefs.pointname,data,39);
else if(!stricmp(head,"editor")) strncpy(prefs.editor,data,39);
else if(!stricmp(head,"username")) strncpy(prefs.username,data,39);
else if(!stricmp(head,"realname")) strncpy(prefs.userrealname,data,39);
else if(!stricmp(head,"password")) strncpy(prefs.password,data,39);
else if(!stricmp(head,"passwort")) strncpy(prefs.password,data,39);
else if(!stricmp(head,"boxdomain")) strncpy(prefs.boxdomain,data,38);
else if(!stricmp(head,"domain")) strncpy(prefs.boxdomain,data,38);
else if(!stricmp(head,"datadir")) strncpy(prefs.datadir,data,127);
else if(!stricmp(head,"brettdir")) strncpy(prefs.datadir,data,127);
else if(!stricmp(head,"transferdir")) strncpy(prefs.transferdir,data,127);
else if(!stricmp(head,"modemdevice")) strncpy(prefs.modemdevice,data,31);
else if(!stricmp(head,"modemunit")) prefs.modemunit=atoi(data);
else if(!stricmp(head,"modembaud")) prefs.modembaud=atoi(data);
else if(!stricmp(head,"dialretries")) prefs.dialretries=atoi(data);
else if(!stricmp(head,"dialtimeout")) prefs.dialtimeout=atoi(data);
else if(!stricmp(head,"dialretrydelay")) prefs.retrydelay=atoi(data);
else if(!stricmp(head,"dialpacktimeout")) prefs.packtimeout=atoi(data);
else if(!stricmp(head,"modemflags")) prefs.modemflags=atoi(data);
else if(!stricmp(head,"modeminit")) strncpy(prefs.modeminit,data,39);
else if(!stricmp(head,"modemdial")) strncpy(prefs.modemdial,data,39);
else if(!stricmp(head,"modemhangup")) strncpy(prefs.modemhangup,data,39);
else if(!stricmp(head,"packer")) strncpy(prefs.packer,data,39);
else if(!stricmp(head,"unpacker")) strncpy(prefs.unpacker,data,39);
else if(!stricmp(head,"organisation")) strncpy(prefs.organisation,data,79);
else if(!stricmp(head,"login")) strncpy(prefs.rfc_login,data,255);
else if(!stricmp(head,"screenmode")) {
if(!stricmp(data,"interlace")) prefs.flags|=MDF_INTERLACE;
else prefs.flags&=~MDF_INTERLACE;
}
else if(!stricmp(head,"telefon")) strncpy(prefs.phone,data,79);
else if(!stricmp(head,"phone")) strncpy(prefs.phone,data,79);
else if(!stricmp(head,"mapsname")) strncpy( prefs.mapsname, data, 39 );
else if(!stricmp(head,"mapsoutname")) strncpy( prefs.mapsname, data, 39 );
else if(!stricmp(head,"mapsname")) strncpy( prefs.mapsname, data, 39 );
else if(!stricmp(head,"mapsoutname")) strncpy( prefs.mapsoutname, data, 39 );
else if(!stricmp(head,"mapsadd")) strncpy( prefs.maps_add, data, 39 );
else if(!stricmp(head,"mapsdel")) strncpy( prefs.maps_del, data, 39 );
else if(!stricmp(head,"mapslist")) strncpy( prefs.maps_list, data, 39 );
else if(!stricmp(head,"mapslistverbose")) strncpy( prefs.maps_list_verbose, data, 39 );
else if(!stricmp(head,"mapsclearpm")) strncpy( prefs.maps_clearpm, data, 39 );
else if(!stricmp(head,"mapshelp")) strncpy( prefs.maps_help, data, 39 );
else if(!stricmp(head,"mapstype")) presetmapsprefs( atoi( data ) );
else if(!stricmp(head,"mapstyp")) presetmapsprefs( atoi( data ) );
else if(!stricmp(head,"mapslistid")) strncpy( prefs.maps_listid, data, 39 );
else if(!stricmp(head,"mapslistcol")) prefs.maps_list_offs = atoi( data );
else if(!stricmp(head,"mapslistsubjectcol")) prefs.maps_list_offs = atoi( data );
else if(!stricmp(head,"mapsliststartcol")) prefs.maps_list_boffs = atoi( data );
else if(!stricmp(head,"netcallmode"))
{
if( !stricmp( data, "n38" ) || !stricmp( data, "z38" ) )
prefs.mode = MDM_N38;
else if( !stricmp( data, "rfc" ) || !stricmp( data, "uucp" ) )
prefs.mode = MDM_RFC;
else if( !stricmp( data, "janus2" ) )
prefs.flags2 |= MDF2_JANUS2;
}
else {
char buf[80];
sprintf(buf,"Fehler in prefs: %s unbekannt\n",head);
Write(Output(),buf,strlen(buf));
}
makedospath( prefs.transferdir );
makedospath( prefs.datadir );
}
void freeprefs(void)
{
}
#define NEWPREFSID 0x8d0ac01d
void saveprefs(char *pf)
{
BPTR f;
struct mdprefs *p;
int prefspacksize = 0;
ULONG pid = NEWPREFSID;
if( prefs.flags2 & MDF2_NOPREFS )
return;
if( !( f = Open( pf, MODE_NEWFILE ) ) )
return;
p = myAllocVec( sizeof( prefs ) + 512, MEMF_CLEAR );
if( p )
prefspacksize = lzw_pack( &prefs, p, sizeof( prefs ), 10 );
if( !prefspacksize )
{
Write( f, &prefs, sizeof(struct mdprefs) );
}
else
{
Write( f, &pid, 4 );
Write( f, p, prefspacksize );
}
Close( f );
if( p )
myFreeVec( p );
}
void loadprefs( char *pf )
{
BPTR f2;
FILE *f;
char line[256];
char *p,*p2,ch;
int c;
convuserlist();
presetmapsprefs( 0 );
prefs.pens[ PEN_TEXT ]á= 1;
prefs.pens[ PEN_MARK ]á= 1;
prefs.pens[ PEN_MARKBOLD ]á= 1;
prefs.pens[ PEN_SEL ]á= 3;
prefs.pens[áPEN_SELBAK ] = 2;
prefs.pens[ PEN_MARKSEL ]á= 3;
prefs.pens[áPEN_MARKSELBAK ] = 2;
prefs.pens[ PEN_MARKSELBOLD ] = 1;
prefs.pens[ PEN_READ ] = 1;
prefs.pens[ PEN_QUOTEBOLD ] = 1;
prefs.pens[ PEN_HEAD ] = 3;
for( c = 0; c < 7; c++ )
prefs.quotepens[ác ]á= ( c % 3 ) + 1;
prefs.editor_stack = 8192;
prefs.viewer_stack = 8192;
prefs.auto_ixcreate = TRUE;
prefs.screendepth = 2;
prefs.reqpos = REQPOS_CENTERSCR;
prefs.showboardtree = TRUE;
prefs.zmodembuffer = 32;
strcpy( prefs.username, "Undefiniert" );
strcpy( prefs.userrealname, "Vorname Nachname" );
if( isv37 )
strcpy( prefs.console_window, "CON:////%t/CLOSE/AUTO" );
else
strcpy( prefs.console_window, "CON:////%t" );
strcpy( prefs.langnames, "Deutsch" );
strcpy( &prefs.langnames[ 30 ], "English" );
strcpy( prefs.rfc_cicocon, "CON://640/240/MicroDot-UUCP-Transfer/AUTO" );
f2 = Open( pf, MODE_OLDFILE );
if( f2 )
{
ULONG pid, coltest, c;
Read( f2, &pid, 4 );
if( pid == NEWPREFSID )
{
APTR b1, b2;
do {
b1 = AllocMem( sizeof( struct mdprefs ) * 2, MEMF_CLEAR );
} while( !b1 );
do {
b2 = AllocMem( sizeof( struct mdprefs ) * 2, MEMF_CLEAR );
} while( !b2 );
Read( f2, b1, sizeof( prefs ) * 2 );
lzw_unpack( b1, b2 );
memcpy( &prefs, b2, sizeof( prefs ) );
FreeMem( b1, sizeof( struct mdprefs ) * 2 );
FreeMem( b2, sizeof( struct mdprefs ) * 2 );
}
else
{
Seek( f2, 0, OFFSET_BEGINNING );
Read( f2, &prefs, sizeof(struct mdprefs) );
}
Close( f2 );
/* Umtragen */
if( !prefs.pointname[0] )
strcpy( prefs.pointname, prefs.oldpointname );
if( !prefs.boxname[0] )
strcpy( prefs.boxname, prefs.oldboxname );
if( !prefs.editor[á0 ]á)
strcpy( prefs.editor, prefs.oldeditor );
for( coltest = 0, c = 0; c < ( 1L << prefs.screendepth ); c++ )
{
if( prefs.colors32[ c ]á)
coltest |= 1;
if( prefs.term_colors[ c ]á)
coltest |= 2;
}
if( !prefs.reader_tabsize )
prefs.reader_tabsize = 8;
if( ! ( coltest & 1 ) )
{
getwbcolors();
}
if( ! ( coltest & 2 ) )
{
memcpy( prefs.term_colors, prefs.colors32, 3 * 8 * 4 );
}
if( !prefs.screendepth )
prefs.screendepth = 2;
if( !prefs.console_window[á0 ]á)
{
if( isv37 )
strcpy( prefs.console_window, "CON:////%t/CLOSE/AUTO/%p" );
else
strcpy( prefs.console_window, "CON:////%t" );
}
prefs.flags2 |= MDF2_PREFSLOADED;
//prefs.flags &= ~MDF_HIDEDEL;
if( prefs.std_maps_type )
presetmapsprefs( prefs.std_maps_type );
if( !strchr( prefs.transferdir, ':' ) )
{
askreq( "Warnung!\nDas MicroDot-Transferverzeichnis mu▀ absolut\n(d.h. mit Laufwerksangabe) angegeben werden.", "Weiter" );
if( isv37 )
strins( prefs.transferdir, "PROGDIR:" );
}
if( !strchr( prefs.datadir, ':' ) )
{
askreq( "Warnung!\nDas MicroDot-Dataverzeichnis mu▀ absolut\n(d.h. mit Laufwerksangabe) angegeben werden.", "Weiter" );
if( isv37 )
strins( prefs.datadir, "PROGDIR:" );
}
for( c = 0; c < 7; c++ )
if( prefs.quotepens[ác ]á)
break;
if( c == 7 )
{
for( c = 0; c < 7; c++ )
prefs.quotepens[ác ]á= ( c % 3 ) + 1;
}
makedospath( prefs.transferdir );
makedospath( prefs.datadir );
makexpkpw();
if( !registerinfo.serie )
prefs.do_packmsg = 0;
return;
}
getwbcolors();
getwbfonts();
strcpy( prefs.modemdevice, "serial.device" );
prefs.modembaud = 19200;
prefs.oscantype = 0;
prefs.displayid = HIRES_KEY;
strcpy( prefs.boxname, "Boxname" );
strcpy( prefs.boxdomain, ".box.do.main" );
strcpy( prefs.organisation, "MicroDot-Supportsystem" );
strcpy( prefs.phone, "1234567890" );
if( isv37 )
strcpy(prefs.datadir,"PROGDIR:DATA/");
else
strcpy(prefs.datadir,"DATA/");
if( isv37 )
strcpy(prefs.transferdir,"PROGDIR:TRANSFER/");
else
strcpy(prefs.transferdir,"TRANSFER/");
strcpy( prefs.packer, "lha -0 a %s PUFFER" );
strcpy( prefs.unpacker, "lha x %s" );
strcpy( prefs.modeminit, "ATZ|~~" );
strcpy( prefs.modemdial, "ATDP" );
strcpy( prefs.modemhangup, "~~~+++~~~ATH0|" );
strcpy( prefs.editor, "ed %s" );
if( isv37 )
{
GetVar( "EDITOR", prefs.editor, 127, 0 );
}
strcpy( prefs.pointname, "MDINFO" );
strcpy( prefs.password, "MDINFO" );
if( isv39 )
strcpy( prefs.binviewer, "Sys:Utilities/MULTIVIEW %s" );
else
strcpy( prefs.binviewer, "Sys:Utilities/Display %s" );
prefs.dialretries=42;
prefs.dialtimeout=90;
prefs.retrydelay=5;
prefs.packtimeout=1200;
prefs.flags |= MDF_SHOWREAL | MDF_TERM_IBM | MDF_TERM_LOG | MDF_TERM_AUTODL | MDF_TERM_AUTOUL | MDF_EB | MDF_GADGETS | MDF_SORTDATE;
prefs.flags2 |= MDF2_NOPREFS | MDF2_CRUNCH_DAT | MDF2_SCROLLJUMP | MDF2_TERM_AUTOLOGIN | MDF2_NEXTNEWBOARD | MDF2_NEXTNEWBOARDASK;
prefs.swidth = 640;
prefs.sheight = 256;
prefs.wz_fm = 9; prefs.wz_fd = 26;
prefs.sz_fm = 3; prefs.sz_fd = 28;
prefs.wz_offs = 1; prefs.sz_offs = 2;
time( &prefs.firstinstalltime );
f=fopen("microdot.cfg","r");
if( !f )
{
makexpkpw();
return;
}
for( ;; )
{
if(!fgets(line,256,f)) break;
clnl(line);
p=stpblk(line);
if(!p || !*p || *p==';' || *p=='#') continue;
if(p!=line) strcpy(line,p);
p=p2=strchr(line,'=');
if(!p) continue;
*p++; p=stpblk(p);
p2--;
while(*p2==' ')p2--;
p2++; *p2=0;
procitem(line,p);
}
fclose( f );
if(prefs.boxdomain[0]!='.') strins(prefs.boxdomain,".");
ch=prefs.datadir[strlen(prefs.datadir)-1];
if(ch!='/'&&ch!=':') strcat(prefs.datadir,"/");
ch=prefs.transferdir[strlen(prefs.transferdir)-1];
if(ch!='/'&&ch!=':') strcat(prefs.transferdir,"/");
makexpkpw();
}
static void dofontprefs1( char *fontname, int *fontheight )
{
int rc;
struct rtFontRequester *fontreq;
struct TextFont *tf;
fontreq = rtAllocRequest( RT_FONTREQ, NULL );
if( !fontreq )
return;
rtChangeReqAttr( fontreq,
RTFO_FontName, fontname,
RTFO_FontHeight, *fontheight,
TAG_DONE );
rc = rtFontRequest( fontreq,
"Bitte Text-Font auswΣhlen",
RTFO_Flags, FREQF_FIXEDWIDTH,
TAG_DONE );
if( !rc )
{
rtFreeRequest( fontreq );
return;
}
tf = OpenDiskFont( &fontreq->Attr );
if( !tf )
{
displaybeep();
rtFreeRequest( fontreq );
return;
}
strcpy( fontname, fontreq->Attr.ta_Name );
*fontheight = fontreq->Attr.ta_YSize;
rtFreeRequest( fontreq );
}
static void dofontprefs2( char *fontname, int *fontheight, char *title )
{
struct TextFont *tf;
struct rtFontRequester *fontreq;
int rc;
fontreq = rtAllocRequest( RT_FONTREQ, NULL );
if( !fontreq )
return;
rtChangeReqAttr( fontreq,
RTFO_FontName, fontname,
RTFO_FontHeight, *fontheight,
TAG_DONE );
rc = rtFontRequest( fontreq,
title,
TAG_DONE );
if( !rc )
{
rtFreeRequest( fontreq );
return;
}
tf = OpenDiskFont( &fontreq->Attr );
if( !tf )
{
displaybeep();
rtFreeRequest( fontreq );
return;
}
strcpy( fontname, fontreq->Attr.ta_Name );
*fontheight = fontreq->Attr.ta_YSize;
rtFreeRequest( fontreq );
}
#define FGI_F1 1
#define FGI_F2 2
#define FGI_S1 3
#define FGI_S2 4
#define FGI_OK 5
#define FGI_CANCEL 6
#define FGI_OWNSCREEN 7
/*#define FGI_PUBSCREEN 8*/
#define FGI_F3 9
#define FGI_S3 10
#define FGI_RES 11
#define FGI_RESSEL 12
#define FGI_COLACT 13
#define FGI_COLSEL 14
#define FGI_CLOCK 15
#define FGI_GADGET 16
static char *clock_options[] =
{
"HH:MM:SS",
"HH:MM",
"Keine",
NULL
};
void dofontprefs( void )
{
struct ogwin *ogw;
struct Window *iw;
char fn1[ 64 ],
fn2[ 64 ],
fn3[ 64 ];
char fp1[ 64 ], fp2[ 64 ], fp3[ 64 ];
char modebuffer[ 128 ], modestring[ 128 ];
int fs1 = prefs.fontheight, fs2 = prefs.gadfontheight, fs3 = prefs.screenfontheight;
struct IntuiMessage *im;
int rc;
struct rtScreenModeRequester *smr;
int Done = FALSE;
smr = rtAllocRequest( RT_SCREENMODEREQ, TAG_DONE );
if( !smr )
return;
rtChangeReqAttr( smr,
RTSC_OverscanType, prefs.oscantype,
RTSC_ModeFromScreen, scr,
RTSC_DisplayWidth, prefs.swidth,
RTSC_DisplayHeight, prefs.sheight,
RTSC_DisplayDepth, prefs.screendepth,
TAG_DONE
);
strcpy( fp1, prefs.fontname );
strcpy( fp2, prefs.gadfontname );
strcpy( fp3, prefs.screenfontname );
ogw = ogreInitWindow( scr, WFLG_RMBTRAP, NULL, "Bildschirm-Konfiguration" );
ogreAddGroup( ogw, 0, OGFRAME_OUTLINE, " Fonts " );
ogreAddText( ogw, 1, "_Text-Font:", FGI_F1, "", 40, TRUE );
ogreAddText( ogw, 0, "_Gadgetleisten-Font:", FGI_F2, "", 40, TRUE );
ogreAddButton( ogw, 1 | OGGP_KEEPSIZE, 't', "?", FGI_S1 );
ogreAddButton( ogw, 0 | OGGP_KEEPSIZE, 'g', "?", FGI_S2 );
ogreAddText( ogw, 2, "_Bildschirm-Font:", FGI_F3, "", 40, TRUE );
ogreAddButton( ogw, 2 | OGGP_KEEPSIZE, 'b', "?", FGI_S3 );
ogreAddGroup( ogw, 1, OGFRAME_OUTLINE, " Bildschirm " );
ogreAddCheckbox( ogw, 0, 'e', "_Eigener Bildschirm", FGI_OWNSCREEN, prefs.flags2 & MDF2_OWNSCREEN );
/* ogreAddCheckbox( ogw, 0, 'p', "Bildschirm _Public?", FGI_PUBSCREEN, prefs.flags2 & MDF2_PUBSCREEN );*/
/* ogreAddCheckbox( ogw, 1, 'w', "_Workbench-Farben?", FGI_COLACT, !prefs.usecustomcolors );
ogreAddButton( ogw, 1, 'f', "_Farben einstellen", FGI_COLSEL );*/
ogreAddCheckbox( ogw, 0, 'l', "Gadget-_Leiste", FGI_GADGET, prefs.flags & MDF_GADGETS );
ogreAddCycle( ogw, 0 , 'u', "_Uhr:", FGI_CLOCK, clock_options, 12, prefs.clockmode );
ogreAddText( ogw, 1, "Bildschirm-_Modus:", FGI_RES, "", 40, TRUE );
ogreAddButton( ogw, 1 | OGGP_KEEPSIZE, 'm', "?", FGI_RESSEL );
ogreAddGroup( ogw, 2, OGFRAME_NONE, NULL );
ogreAddButton( ogw, 0 | OGB_ONENTER, 'o', "_OK", FGI_OK );
ogreAddHelp( ogw, 0 );
ogreAddButton( ogw, 0 | OGB_ONESC, 'a', "_Abbruch", FGI_CANCEL );
ogreEnable( ogw, !wbwindow, FGI_COLSEL, 0 );
iw = ogreOpenWindow( ogw );
if( !iw)
return;
while( !Done )
{
rc = GetDisplayInfoData(
NULL,
modebuffer,
128,
DTAG_NAME,
smr->DisplayID
);
if( rc < 17 )
strcpy( &modebuffer[ 16 ], "unbenannt" );
else
{
//modebuffer[árc ] = 0;
}
sprintf( modestring, "%lD ╫ %lD, %ld Farben, %s",
smr->DisplayWidth,
smr->DisplayHeight,
1 << smr->DisplayDepth,
&modebuffer[á16 ]
);
sprintf( fn1, "%s / %ld", fp1, fs1 );
sprintf( fn2, "%s / %ld", fp2, fs2 );
sprintf( fn3, "%s / %ld", fp3, fs3 );
ogreSetStringValue( ogw, FGI_F1, fn1 );
ogreSetStringValue( ogw, FGI_F2, fn2 );
ogreSetStringValue( ogw, FGI_F3, fn3 );
ogreSetStringValue( ogw, FGI_RES, modestring );
ogreEnable( ogw, ogreValue( ogw, FGI_OWNSCREEN ) && !ogreValue( ogw, FGI_COLACT ), FGI_COLSEL, 0 );
ogreEnable( ogw, ogreValue( ogw, FGI_OWNSCREEN ), /*FGI_PUBSCREEN,*/ FGI_F3, FGI_S3, FGI_COLACT, FGI_RES, FGI_RESSEL, FGI_CLOCK, /*FGI_GADGET,*/ 0 );
im = ogreWaitIM( ogw );
if( im->Class == IDCMP_GADGETUP )
{
switch( im->Code )
{
case FGI_S1:
dofontprefs1( fp1, &fs1 );
break;
case FGI_S2:
dofontprefs2( fp2, &fs2, "Bitte Gadgetleisten-Font auswΣhlen:" );
break;
case FGI_S3:
dofontprefs2( fp3, &fs3, "Bitte Bildschirm-Font auswΣhlen:" );
break;
case FGI_RESSEL:
rtScreenModeRequest( smr, "Bildschirmmodus auswΣhlen...",
RT_Screen, scr,
RT_ReqPos, REQPOS_CENTERSCR,
RTSC_Flags, SCREQF_GUIMODES | SCREQF_OVERSCANGAD | SCREQF_SIZEGADS | SCREQF_DEPTHGAD,
RTSC_MinWidth, 640, RTSC_MinHeight, 256,
RTSC_MinDepth, 1, RTSC_MaxDepth, 3,
TAG_DONE
);
break;
/*
case FGI_COLSEL:
rtPaletteRequest( "Farben einstellen:", NULL, TAG_DONE );
break;*/
case FGI_OK:
Done = 1;
break;
case FGI_CANCEL:
Done = 2;
break;
}
}
else if( im->Class == IDCMP_GADGETHELP )
showguidenum( "fontprefs", im->Code );
ogreIMReply( ogw, im );
}
if( Done == 1 )
{
if( ogreValue( ogw, FGI_OWNSCREEN ) )
prefs.flags2 |= MDF2_OWNSCREEN;
else
prefs.flags2 &= ~MDF2_OWNSCREEN;
/* if( ogreValue( ogw, FGI_PUBSCREEN ) )
prefs.flags2 |= MDF2_PUBSCREEN;
else
prefs.flags2 &= ~MDF2_PUBSCREEN;*/
if( ogreValue( ogw, FGI_GADGET ) )
prefs.flags |= MDF_GADGETS;
else
prefs.flags &= ~MDF_GADGETS;
/* prefs.usecustomcolors = !ogreValue( ogw, FGI_COLACT );*/
prefs.clockmode = ogreValue( ogw, FGI_CLOCK );
/* if( prefs.usecustomcolors && !wbwindow )
getcolors();*/
}
ogreExitWindow( ogw );
if( Done == 1 )
{
strcpy( prefs.fontname, fp1 );
strcpy( prefs.gadfontname, fp2 );
strcpy( prefs.screenfontname, fp3 );
prefs.fontheight = fs1;
prefs.gadfontheight = fs2;
prefs.screenfontheight = fs3;
prefs.displayid = smr->DisplayID;
prefs.oscantype = smr->OverscanType;
prefs.swidth = smr->DisplayWidth;
prefs.sheight = smr->DisplayHeight;
prefs.screendepth = smr->DisplayDepth;
savemenustate( w->MenuStrip );
closegui();
opengui();
resetmenustate( w->MenuStrip );
}
rtFreeRequest( smr );
}
void dofontprefs13( void )
{
struct ogwin *ogw;
struct Window *w;
struct IntuiMessage *im;
int Done = FALSE;
if( isv37 )
return;
ogw = ogreInitWindow( scr, WFLG_RMBTRAP, NULL, "Bildschirm-Konfiguration" );
ogreAddGroup( ogw, 0, OGFRAME_OUTLINE, " Allgemeines " );
ogreAddCheckbox( ogw, 0, 'i', "_Interlace?", FGI_OWNSCREEN, prefs.flags & MDF_INTERLACE );
ogreAddCheckbox( ogw, 1, 'l', "Gadget-_Leiste", FGI_GADGET, prefs.flags & MDF_GADGETS );
ogreAddCycle( ogw, 2 , 'u', "_Uhr:", FGI_CLOCK, clock_options, 12, prefs.clockmode );
ogreAddGroup( ogw, 1, OGFRAME_NONE, NULL );
ogreAddButton( ogw, 0 | OGB_ONENTER, 'o', "_OK", FGI_OK );
ogreAddHelp( ogw, 0 );
ogreAddButton( ogw, 0 | OGB_ONESC, 'a', "_Abbruch", FGI_CANCEL );
w = ogreOpenWindow( ogw );
if( !w)
{
displaybeep();
return;
}
while( !Done )
{
im = ogreWaitIM( ogw );
if( im->Class == IDCMP_GADGETUP )
{
switch( im->Code )
{
case FGI_OK:
Done = 1;
break;
case FGI_CANCEL:
Done = 2;
break;
}
}
else if( im->Class == IDCMP_GADGETHELP )
showguidenum( "fontprefs13", im->Code );
ogreIMReply( ogw, im );
}
if( Done == 1 )
{
if( ogreValue( ogw, FGI_OWNSCREEN ) )
prefs.flags |= MDF_INTERLACE;
else
prefs.flags &= ~MDF_INTERLACE;
if( ogreValue( ogw, FGI_GADGET ) )
prefs.flags |= MDF_GADGETS;
else
prefs.flags &= ~MDF_GADGETS;
prefs.clockmode = ogreValue( ogw, FGI_CLOCK );
}
ogreExitWindow( ogw );
if( Done == 1 )
{
savemenustate( w->MenuStrip );
closegui();
opengui();
resetmenustate( w->MenuStrip );
}
}
static ULONG rtgetpw( char *title )
{
UBYTE pwbuf[ 32 ];
pwbuf[0]á= 0;
if( !rtGetString( pwbuf, 31, NULL, rinfo,
RTGS_Invisible, TRUE,
RTGS_TextFmt, title,
TAG_DONE ) )
return( 0 );
if( !pwbuf[0] )
return( 0 );
strlwr( pwbuf );
return( crc32( pwbuf, strlen( pwbuf ) ) );
}
void docheckpassword( void )
{
ULONG pwcrc;
if( !prefs.passwordcrc )
return;
pwcrc = rtgetpw( "Passwortgeschⁿtzt! Bitte Passwort eingeben:" );
if( pwcrc != prefs.passwordcrc )
{
openlogmsg( "!!! Fehler bei der Passworteingabe !!!" );
printlog( "Es erfolgte ein Zugriffsversuch mit falschem Passwort.\n" );
closelogmsg();
askreq( "Zugang verweigert!", "Beenden" );
exit( 10 );
}
}
/* Change internal Password */
void dochangepassword( void )
{
ULONG pwcrc;
if( prefs.passwordcrc )
{
pwcrc = rtgetpw( "PASSWORT ─NDERN - Bitte altes Passwort eingeben:" );
if( pwcrc != prefs.passwordcrc )
{
if( pwcrc ) askreq( "Falsches Passwort!", "Abbruch" );
return;
}
}
for( ;; )
{
pwcrc = rtgetpw ( "PASSWORT ─NDERN - Bitte neues Passwort eingeben:" );
prefs.passwordcrc = pwcrc;
saveprefs( currentprefsname );
if( !pwcrc )
{
makexpkpw();
askreq( "Passwort gel÷scht!", "OK" );
return;
}
pwcrc = rtgetpw( "PASSWORT ─NDERN - Bitte neues Passwort bestΣtigen:" );
if( pwcrc == prefs.passwordcrc )
{
makexpkpw();
askreq( "Passwort gesetzt.", "OK" );
return;
}
askreq( "Die eingegebenen Passw÷rter\nstimmen nicht ⁿberein!", "Nochmal" );
}
}