Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!hao!gatech!udel!princeton!phoenix!kenchiu From: kenchiu@phoenix.Princeton.EDU (Kenneth Chiu) Newsgroups: comp.sys.amiga Subject: Re: Help needed with finding ConUnit structure Message-ID: <1949@phoenix.Princeton.EDU> Date: 4 Mar 88 16:55:29 GMT References: <261@tolsun.oulu.fi> Reply-To: kenchiu@phoenix.Princeton.EDU (Kenneth Chiu) Organization: Princeton University, NJ Lines: 50 Keywords: ConUnit Summary: here's some code Someone wanted an example of using the ConUnit structure from Manx C. Here's some code that does it. It seems to work properly, if anyone knows otherwise, please let me know. It is part of an ls program that adjusts to different window widths and does "maximally compressed columnation." If you have no idea what that means, you probably don't care. :-) Success winsize(x, y) int *x, *y; { struct InfoData *id; struct Process *process; struct ConUnit *conunit; if ((id = malloc(sizeof(struct InfoData))) == NULL) return FAIL; /* find myself */ process = (struct Process *) FindTask(0L); /* make sure we have a console task */ if (process->pr_ConsoleTask == NULL) return FAIL; /* send the packet, id is filled in by the console task, also note that AmigaDOS wants a BPTR. In practice, you can leave out 2L, 3L, etc. They are just dummy arguments that are not used. I think if you want to be ultra proper, though, you should include them, because otherwise, in theory, you could have illegal memory reads, I think. */ if (!dos_packet(process->pr_ConsoleTask, ACTION_DISK_INFO, CP2BP(id)), 2L, 3L, 4L, 5L, 6L, 7L) return FAIL; /* here's the conunit, got to dig deep don't you */ conunit = (struct ConUnit *) ((struct IOStdReq *) id->id_InUse)->io_Unit; /* here are the window limits in no. of columns and no. of rows */ *x = conunit->cu_XMax + 1; *y = conunit->cu_YMax + 1; free(id); return SUCCESS; } Ken Chiu