T.R | Title | User | Personal Name | Date | Lines |
---|
627.1 | devs/system-configuration a struct preferences? | Z::TENNY | Dave Tenny | DTN 225-6089 | Sun Aug 02 1987 20:22 | 10 |
| Thanks for the (misplaced?) reply in 591.19,
the documentation for the SetPrefs call.
Can I just read the devs/system-configuration file into
a preferences structure and use that for the call?
I have several versions of preferences that I use,
in particular, my wife likes her own colors...
(what's wrong with brown,white/violet/black :-)
Dave
|
627.2 | Works on Tuesdays | Z::TENNY | Dave Tenny | DTN 225-6089 | Sun Aug 02 1987 23:25 | 15 |
|
Never mind .-1; I figured it out. The program works when compiled
with +p, linked with -lcl32. I couldn't figure out how to suppress
these warnings, after much casting etc. I suspect they are the problem.
Any ideas??? Source code (which works when compeled as above) follows
in next note. I would like to know why it won't work with 16bit ints.
Aztec C68K 3.4a 2-3-87 (C) 1982-1987 by Manx Software Systems, Inc.
OpenLibrary("intuition.library", 31L)))
^
prefs.c:35: WARNING 121: ptr/int conversion:
F_CHIP) ;
^
prefs.c:46: WARNING 121: ptr/int conversion:
Aztec 68000 Assembler 3.4a 2-3-87
|
627.3 | A preference setting program, sometimes. | Z::TENNY | Dave Tenny | DTN 225-6089 | Sun Aug 02 1987 23:26 | 69 |
| /* This program takes a system-configuration file and makes it the
current preferences.
Compile this with +p, link with -lcl32.
What have I missed that it won't work with 16bit ints?
*/
#include <stdio.h>
#include <fcntl.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
struct IntuitionBase *IntuitionBase ;
#define PREFSIZE sizeof(struct Preferences)
#define go(s) {puts(s);fflush(stdout);}
main(argc, argv)
int argc;
char **argv ;
{ /* main */
struct Preferences *p ;
int fd ;
/* Text */
if (argc < 2)
{
puts("Usage: prefs preferences-file (e.g. devs/system-configuration)") ;
exit(0) ;
}
if (!(IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library", 31L)))
exit(16) ;
fd = open(argv[1], O_RDONLY) ;
if (fd < 0)
{
puts("Error opening file.") ;
CloseLibrary(IntuitionBase) ;
exit(8) ;
}
p = (struct Preferences *) AllocMem((long) PREFSIZE, (long) MEMF_CHIP) ;
if (!p)
{
puts("Error allocating memory.") ;
close(fd) ;
CloseLibrary(IntuitionBase) ;
exit(8) ;
}
if (read(fd, p, PREFSIZE) < PREFSIZE)
{
puts("Not enough bytes in file, or error reading.") ;
close(fd) ;
FreeMem(p, (long) PREFSIZE) ;
CloseLibrary(IntuitionBase) ;
exit(8) ;
}
SetPrefs(p, (long) PREFSIZE, (long) TRUE) ;
FreeMem(p, (long) PREFSIZE) ;
close(fd) ;
CloseLibrary(IntuitionBase) ;
exit(0) ;
} /* main */
|
627.4 | Declare Functions | TLE::RMEYERS | Randy Meyers | Mon Aug 03 1987 14:04 | 10 |
| Re: .3
It appears you didn't declare all of the functions you are using.
For example, OpenLibrary returns a pointer. You didn't declare
it, so the Manx compiler thinks it returns a 16 bit int. Since you
then cast the int to a pointer, the compiler just zero extends the
16 bit quantity to 32 bits. Since the intuition.library is in Kickstart,
its start vector isn't within the first 64k of the machine, so the
result is garbage.
|
627.5 | the answer | Z::TENNY | Dave Tenny | DTN 225-6089 | Mon Aug 03 1987 18:44 | 10 |
|
re: .4
Give the man a cigar. That was the problem.
The 16bit version links at 4700 bytes, about 2000 bytes less than
using the +p option.
Thanks,
Dave
|
627.6 | There is a header file | NOVA::RAVAN | | Tue Aug 18 1987 14:27 | 5 |
| If I recall correctly, there is a Manx header file that declares
all the Amiga functions. I think it is called ... functions.h ?
Maybe. '#include'ing it should get rid of most problems like this.
-jim
|
627.7 | stdlib.h | NULL::TORNHEIM | | Tue Aug 18 1987 16:19 | 7 |
| or maybe
# include <stdlib.h>
I recently had a problem because I didn't include this file in
a VAXC program.
|
627.8 | I hope not | TLE::RMEYERS | Randy Meyers | Tue Aug 18 1987 17:16 | 5 |
| Re: .7
Personally, I hope the Amiga functions are not declared in stdlib.h.
The file's contents is specified by the draft ANSI C standard. Putting
lots of OS specific stuff in there is in somewhat bad taste.
|