kruger@16bits.dec.com (Bear with me) (04/06/88)
I am just starting to get involved with machine specifics of the Amiga, and also suffer from extreme lack of time. However, the system is screaming for a program that will set preferences from a file. ie: setpref mypreferences setpref yourpreferences would allow me to quickly load my own setup, and then change back to yours, all without messing with the default. The only way of doing this currently is to rename the system-configuration, copy in your own, run preferences, click load, delete yours, and rename the default back. This is ugly and (I think) unnecessary. Anyone feel kind? For that matter, is the format of system-config even documented anywhere? If not, could anyone from CATS post it? Thanks! dov
avery@puff.cs.wisc.edu (Aaron Avery) (04/06/88)
In article <8804051628.AA27845@decwrl.dec.com> kruger@16bits.dec.com (Bear with me) writes: >unnecessary. Anyone feel kind? For that matter, is the format of system-config >even documented anywhere? If not, could anyone from CATS post it? The format of system-configuration is exactly the Preferences structure documented in the intuition header. This program would be quite trivial to write. You merely need to read the file with the supplied name into a buffer (it should be 232 bytes long, which is sizeof(struct Preferences)), then use the 1.2 SetPrefs() function. Let me know if you need more info, or want me to write one. -- Aaron Avery (avery@puff.cs.wisc.edu) ({seismo,caip,allegra,harvard,rutgers,ihnp4}!uwvax!puff!avery)
rss@ece-csc.UUCP (Ralph Scherp) (04/07/88)
In article <8804051628.AA27845@decwrl.dec.com> kruger@16bits.dec.comh writes: >I am just starting to get involved with machine specifics of the Amiga, and >also suffer from extreme lack of time. However, the system is screaming for >a program that will set preferences from a file. ie: > >setpref mypreferences >setpref yourpreferences > > ... For that matter, is the format of system-config >even documented anywhere? If not, could anyone from CATS post it? > >Thanks! >dov Sure, I've done this. It's quite simple. I wanted the same capability to reset preferences because I have a hard drive, but the preferences which show up on the system are those sitting in df0: rather than on dh0: (after I've reassigned DEVS: to DH0); so I put together a simple (really!) program which loads in the preferences from the disk file (which is devs:system-configuration) and makes them the current preferences. The file "devs:system-configuration" is just an exact copy of the "Preferences" structure defined in intuition/intuition.h (I think) so all you have to do to reset preferences is: open the intuition library IntuitionBase = OpenLibrary("intuition.library",0); open the disk file devs:system-configuration (or your substitute file) fd = open("Devs:System-configuration",O_RDONLY,0); read the data into a struct Preferences read(fd,&pref,sizeof(pref)); (where "pref" is "struct Preference pref") issue a SetPrefs call (this is what makes it all work) SetPrefs(&pref,sizeof(pref),TRUE); close the library & file & exit. The program I wrote is very simple at present since I only intended it to fix preferences to reflect my hard drive configuration rather than that on my floppy, but it works. If you'd like, I'll mail you a copy or if there's enough interest I'll post it. I was thinking of enhancing the program to allow you to actually modify current preferences settings; i.e., I was considering writing a CLI equivalent to the existing Preferences program. How about it folks? Is there any interest in this? If so, I'll do it; else I'm not gonna bother. Maybe someone out there already has one? Hope this helps, Mark Lanzo (posting thru a friend's account)
papa@pollux.usc.edu (Marco Papa) (04/07/88)
In article <3482@ece-csc.UUCP| rss@ece-csc.UUCP (Ralph Scherp) writes: |In article <8804051628.AA27845@decwrl.dec.com| kruger@16bits.dec.comh writes: ||I am just starting to get involved with machine specifics of the Amiga, and ||also suffer from extreme lack of time. However, the system is screaming for ||a program that will set preferences from a file. ie: || ||setpref mypreferences ||setpref yourpreferences |Sure, I've done this. It's quite simple. I wanted the same capability [..deleted stuff] |The file "devs:system-configuration" is just an exact copy of the |"Preferences" structure defined in intuition/intuition.h (I think) |so all you have to do to reset preferences is: | | open the intuition library | IntuitionBase = OpenLibrary("intuition.library",0); | open the disk file devs:system-configuration (or your substitute file) | fd = open("Devs:System-configuration",O_RDONLY,0); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | read the data into a struct Preferences | read(fd,&pref,sizeof(pref)); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | (where "pref" is "struct Preference pref") | issue a SetPrefs call (this is what makes it all work) | SetPrefs(&pref,sizeof(pref),TRUE); | close the library & file & exit. Please don't do that! What if C-A decides to change the filename or its location in a future release? There is an Intuition call that allows you to do just that in a portable way. It is called GetPrefs: GetPrefs(&pref, sizeof(pref)); Everything else is OK. -- Marco -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= uucp:...!pollux!papa BIX:papa ARPAnet:pollux!papa@oberon.usc.edu "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
page@swan.ulowell.edu (Bob Page) (04/07/88)
papa@pollux.usc.edu (Marco Papa) wrote: >| fd = open("Devs:System-configuration",O_RDONLY,0); >| read(fd,&pref,sizeof(pref)); > >[instead, use] GetPrefs(&pref, sizeof(pref)); These aren't equivalent. The first actually sets preferences based on what's in a particular file. The second just gets the preferences already in the system (in intuitionbase) and puts it into a structure. You have to open a disk-based file and use SetPrefs() to set the preferences from a file. ..Bob -- Bob Page, U of Lowell CS Dept. page@swan.ulowell.edu ulowell!page
rss@ece-csc.UUCP (Ralph Scherp) (04/08/88)
In article <8190@oberon.USC.EDU> papa@pollux.usc.edu (Marco Papa) writes: ]In article <3482@ece-csc.UUCP| rss@ece-csc.UUCP (Ralph Scherp) writes: ]|In article <8804051628.AA27845@decwrl.dec.com| kruger@16bits.dec.comh writes: ]||I am just starting to get involved with machine specifics of the Amiga, and ]||also suffer from extreme lack of time. However, the system is screaming for ]||a program that will set preferences from a file. ie: ]|| ]||setpref mypreferences ]||setpref yourpreferences ]|Sure, I've done this. It's quite simple. I wanted the same capability ][..deleted stuff] ]|The file "devs:system-configuration" is just an exact copy of the ]|"Preferences" structure defined in intuition/intuition.h (I think) [more deleted stuff] ]| fd = open("Devs:System-configuration",O_RDONLY,0); ] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]| read the data into a struct Preferences ]| read(fd,&pref,sizeof(pref)); ] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]| (where "pref" is "struct Preference pref") ]Please don't do that! What if C-A decides to change the filename or its ]location in a future release? There is an Intuition call that allows you ]to do just that in a portable way. It is called GetPrefs: ] ]GetPrefs(&pref, sizeof(pref)); > >Everything else is OK. > >-- Marco NO! Not if I read my intuition manual correctly. GetPrefs is documented as returning the CURRENT setting of preferences; which is not necessarily the same thing as that stored in the disk file devs:system-configuration. As I also stated, my program was a quick and dirty hack; a more sophisticated version would probably accept a filename as opposed to assuming DEVS:System-configuration; but regardless, fetching a permanent copy from disk is not the same as fetching something out of a RAM structure somewhere. Correct me if I'm wrong.... Mark Lanzo
papa@pollux.usc.edu (Marco Papa) (04/08/88)
In article <3484@ece-csc.UUCP| rss@ece-csc.UUCP (Ralph Scherp) writes: |In article <8190@oberon.USC.EDU| papa@pollux.usc.edu (Marco Papa) writes: |]In article <3482@ece-csc.UUCP| rss@ece-csc.UUCP (Ralph Scherp) writes: |]|In article <8804051628.AA27845@decwrl.dec.com| kruger@16bits.dec.comh writes: |]||I am just starting to get involved with machine specifics of the Amiga, and |]||also suffer from extreme lack of time. However, the system is screaming for |]||a program that will set preferences from a file. ie: |]|| |]||setpref mypreferences |]||setpref yourpreferences |]|Sure, I've done this. It's quite simple. I wanted the same capability |][..deleted stuff] |]|The file "devs:system-configuration" is just an exact copy of the |]|"Preferences" structure defined in intuition/intuition.h (I think) |[more deleted stuff] |]| fd = open("Devs:System-configuration",O_RDONLY,0); |] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |]| read the data into a struct Preferences |]| read(fd,&pref,sizeof(pref)); |] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |]| (where "pref" is "struct Preference pref") |]Please don't do that! What if C-A decides to change the filename or its |]location in a future release? There is an Intuition call that allows you |]to do just that in a portable way. It is called GetPrefs: |] |]GetPrefs(&pref, sizeof(pref)); |NO! Not if I read my intuition manual correctly. GetPrefs is documented |as returning the CURRENT setting of preferences; which is not necessarily |the same thing as that stored in the disk file devs:system-configuration. |version would probably accept a filename as opposed to assuming |DEVS:System-configuration; but regardless, fetching a permanent copy from |disk is not the same as fetching something out of a RAM structure somewhere. Correct. I misunderstood your problem, since you were using the "standard" configuration file. If what you want is read the "preferences" from a "user" file you'll need a requester that asks for the filename. Your problem will be that if the file does NOT contain preferences data, but other stuff, you'll definitely GURU the machine. You'll have to do a lot of checking to ensure that ALL values are within appropriate ranges, BEFORE you do the SetPrefs. This will require a little more work than what you described. -- Marco -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= uucp:...!pollux!papa BIX:papa ARPAnet:pollux!papa@oberon.usc.edu "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
joe@cbmvax.UUCP (Joe O'Hara) (04/09/88)
>Sure, I've done this. It's quite simple. I wanted the same capability >to reset preferences because I have a hard drive, but the preferences which >show up on the system are those sitting in df0: rather than on dh0: >(after I've reassigned DEVS: to DH0); so I put together a simple (really!) >program which loads in the preferences from the disk file (which is >devs:system-configuration) and makes them the current preferences. You could accomplish this by: copy dh0:devs/system-configuration df0:devs This would make the change permanent. -- ======================================================================== Joe O'Hara || Comments represent my own opinions, Commodore Electronics Ltd || not my employers. Any similarity to Software QA || to any other opinions, living or dead, || is purely coincidental. ========================================================================
cjp@antique.UUCP (Charles Poirier) (04/09/88)
In article <8214@oberon.USC.EDU> papa@pollux.usc.edu (Marco Papa) writes: ||]In article <3482@ece-csc.UUCP| rss@ece-csc.UUCP (Ralph Scherp) writes: ||]| fd = open("Devs:System-configuration",O_RDONLY,0); ||] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ||]| read the data into a struct Preferences ||]| read(fd,&pref,sizeof(pref)); ||] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ||]| (where "pref" is "struct Preference pref") |... You'll have to do a lot |of checking to ensure that ALL values are within appropriate ranges, BEFORE |you do the SetPrefs. This will require a little more work than what you |described. An easy hack would be to just check that the length of the file looks right. The chances of specifying a garbage file with the proper length are small enough. -- Charles Poirier (decvax,ihnp4,attmail)!vax135!cjp "Docking complete... Docking complete... Docking complete..."
doug@eris (Doug Merritt) (04/14/88)
In article <2161@antique.UUCP> cjp@vax135.UUCP (Charles Poirier) writes: >In article <8214@oberon.USC.EDU> papa@pollux.usc.edu (Marco Papa) writes: >|... You'll have to do a lot >|of checking to ensure that ALL values are within appropriate ranges, BEFORE >|you do the SetPrefs. This will require a little more work than what you >|described. > >An easy hack would be to just check that the length of the file looks right. >The chances of specifying a garbage file with the proper length are small >enough. No! Remember that we're about to be blessed with 1.3, which is known to have extensions to Preferences. They'll probably extend the length of the file to store this new stuff. Everyone doing something with sizeof(Preferences) or whatever will be ok. Anyone *depending* on the old length remaining forever the same will be out of luck...broken software under 1.3. Sigh...history repeats itself. Doug Merritt doug@mica.berkeley.edu (ucbvax!mica!doug) or ucbvax!unisoft!certes!doug
cjp@antique.UUCP (Charles Poirier) (04/15/88)
In article <8725@agate.BERKELEY.EDU> doug@eris.UUCP (Doug Merritt) writes: >In article <2161@antique.UUCP> cjp@vax135.UUCP (Charles Poirier) writes: >>In article <8214@oberon.USC.EDU> papa@pollux.usc.edu (Marco Papa) writes: >>|... You'll have to do a lot of checking... >> >>An easy hack would be to just check that the length of the file looks right. > >No! Remember that we're about to be blessed with 1.3, which is known to >have extensions to Preferences. They'll probably extend the length of the >file to store this new stuff. Everyone doing something with >sizeof(Preferences) or whatever will be ok. Anyone *depending* on the >old length remaining forever the same will be out of luck...broken >software under 1.3. Sigh...history repeats itself. I was deliberately vague about what length would "look right". Your guess, "sizeof(struct Preferences)", is wrong: that sizeof() would be compiled into your code as a constant which would NOT track changes to the Preferences struct. Wouldn't it be okay to assume "devs:system-configuration" as a permanent filename containing a valid Preferences? Then just stat that file and stat the one you want to SetPrefs from and compare their lengths. If unequal, either refuse to do it (my choice) or maybe give a requestor to proceed (in case devs:system-configuration is invalid for some reason). -- Charles Poirier (decvax,ihnp4,attmail)!vax135!cjp "Docking complete... Docking complete... Docking complete..."
eric@cbmvax.UUCP (Eric Cotton) (04/15/88)
In article <8725@agate.BERKELEY.EDU> doug@eris.UUCP (Doug Merritt) writes: >In article <2161@antique.UUCP> cjp@vax135.UUCP (Charles Poirier) writes: >>In article <8214@oberon.USC.EDU> papa@pollux.usc.edu (Marco Papa) writes: >>|... You'll have to do a lot >>|of checking to ensure that ALL values are within appropriate ranges, BEFORE >>|you do the SetPrefs. This will require a little more work than what you >>|described. >> >>An easy hack would be to just check that the length of the file looks right. >>The chances of specifying a garbage file with the proper length are small >>enough. > >No! Remember that we're about to be blessed with 1.3, which is known to >have extensions to Preferences. They'll probably extend the length of the >file to store this new stuff. Everyone doing something with >sizeof(Preferences) or whatever will be ok. Anyone *depending* on the >old length remaining forever the same will be out of luck...broken >software under 1.3. Sigh...history repeats itself. This is not correct. V1.3 sizeof(struct Preferences) = V1.2 sizeof(struct Preferences) Likewise the length of system-configuration is unchanged. The new printer stuff was put in the padding bytes at the end of the existing Preferences structure. ** This is subject to change for future releases! ** -- Eric Cotton Commodore-Amiga *======================================================================* *===== UUCP: {rutgers|ihnp4|allegra}!cbmvax!eric =====* *===== FONE: (215) 431-9100 =====* *===== MAIL: 1200 Wilson Drive / West Chester, PA 19380 =====* *===== PAUL: "I don't find this stuff amusing anymore." =====* *======================================================================*
cjp@antique.UUCP (Charles Poirier) (04/16/88)
In article <3635@cbmvax.UUCP> eric@cbmvax.UUCP (Eric Cotton) writes: > V1.3 sizeof(struct Preferences) = V1.2 sizeof(struct Preferences) >Likewise the length of system-configuration is unchanged. The new >printer stuff was put in the padding bytes at the end of the existing >Preferences structure. Oops! So my idea of checking the length won't work. So, then what would happen if someone ran SetPrefs under 1.3 from a 1.2 system-configuration? Presumably something awful? Though I suppose the reverse might be innocuous, setting 1.2 prefs from a 1.3 system-configuration? -- Charles Poirier (decvax,ihnp4,attmail)!vax135!cjp "Docking complete... Docking complete... Docking complete..."
doug@eris (Doug Merritt) (04/17/88)
>In article <8725@agate.BERKELEY.EDU> doug@eris.UUCP (Doug Merritt) writes: >>In article <2161@antique.UUCP> cjp@vax135.UUCP (Charles Poirier) writes: >>> >>>An easy hack would be to just check that the length of the file looks right. >>No! Remember that we're about to be blessed with 1.3, which is known to >>have extensions to Preferences. They'll probably extend the length of the >>file to store this new stuff. Eric Cotton's commented that in 1.3 the length is the same due to earlier reserved space was interesting, but it could still change length in 1.4 (as Eric pointed out). >Wouldn't it be okay to assume "devs:system-configuration" as >a permanent filename containing a valid Preferences? Then just stat that >file and stat the one you want to SetPrefs from and compare their lengths. >If unequal, either refuse to do it (my choice) or maybe give a requestor to >proceed (in case devs:system-configuration is invalid for some reason). Well, it's probably the best you can do in regard to length. But that's still not desirable. Consider that it might force a disk-swap just for data validation of uncertain veracity. Of course, this might be ok as long as you turn off requesters before looking for "devs:system-configuration", and skip the check if the "devs:" directory is unmounted. Better yet would be to actually do validity checking on the fields themselves, as originally suggested. Remember the only reason that this troublesome point came up was to avoid the "trouble" of checking fields. It appears to me that it's actually *less* trouble! To digress: By far the *best* solution would be if *all* file types had recognizable markings, like magic numbers. I have some heuristics in "filetype" for recognizing Preference config files (including but not limited to length [sigh] ), and I've been disturbed for a long time by the necessity for heuristic kludges for this kind of thing. And developers are *constantly* inventing new kinds of binary files (e.g. AMnews gadgets, menus, etc) and numeric script files (e.g. graphic objects), but people almost never bother to give them identifying characteristics. Hey, would one little magic number hurt that much? Keith Doyle's Director is a notable exception; the binary film shows are marked by the magic number 'FILM' (uh-oh; DaSilva constants strike again!) BTW I tried out some heuristics for recognizing ARP commands, and it's difficult (doable but hard to avoid false positives). My older heuristic for BCPL commands is pretty effective, with a small false positive rate. This is in regard to a previous posting about REZ's mistakes on this subject. Doug Merritt doug@mica.berkeley.edu (ucbvax!mica!doug) or ucbvax!unisoft!certes!doug
peter@sugar.UUCP (Peter da Silva) (04/18/88)
In article <8814@agate.BERKELEY.EDU>, doug@eris.UUCP writes: > marked by the magic number 'FILM' (uh-oh; DaSilva constants strike again!) I'm flattered, but I have to defer to Electronic Arts for the idea of using 4 characters handled as a long integer as a magic number. -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter -- Disclaimer: These aren't mere opinions, these are *values*.
eric@cbmvax.UUCP (Eric Cotton) (04/19/88)
In article <2178@antique.UUCP> cjp@vax135.UUCP (Charles Poirier) writes: >In article <3635@cbmvax.UUCP> eric@cbmvax.UUCP (Eric Cotton) writes: >> V1.3 sizeof(struct Preferences) = V1.2 sizeof(struct Preferences) >>Likewise the length of system-configuration is unchanged. The new >>printer stuff was put in the padding bytes at the end of the existing >>Preferences structure. > >Oops! So my idea of checking the length won't work. So, then what would >happen if someone ran SetPrefs under 1.3 from a 1.2 system-configuration? >Presumably something awful? Though I suppose the reverse might be innocuous, >setting 1.2 prefs from a 1.3 system-configuration? If you have an AMIGA running under V1.3, and used the SetPrefs program (as I understand it) from a 1.2 system-configuration (or simply copied a 1.2 system-configuration file to your V1.3 disk, then booted) there would be no problem. Or vice versa. All the new printer fields default to zeros. Going the other way, V1.2 would simply ignore the new printer stuff if fed a V1.3 sys-config file. -- Eric Cotton Commodore-Amiga *======================================================================* *===== UUCP: {rutgers|ihnp4|allegra}!cbmvax!eric =====* *===== FONE: (215) 431-9100 =====* *===== MAIL: 1200 Wilson Drive / West Chester, PA 19380 =====* *===== PAUL: "I don't find this stuff amusing anymore." =====* *======================================================================*
farren@gethen.UUCP (Michael J. Farren) (04/20/88)
In article <1855@sugar.UUCP> peter@sugar.UUCP (Peter da Silva) writes: >I'm flattered, but I have to defer to Electronic Arts for the idea of >using 4 characters handled as a long integer as a magic number. Funny. I would have thought that you'd defer to FORTRAN, instead. -- Michael J. Farren | "INVESTIGATE your point of view, don't just {ucbvax, uunet, hoptoad}! | dogmatize it! Reflect on it and re-evaluate unisoft!gethen!farren | it. You may want to change your mind someday." gethen!farren@lll-winken.llnl.gov ----- Tom Reingold, from alt.flame