Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!adobe!hawley From: hawley@adobe.COM (Steve Hawley) Newsgroups: comp.sys.mac.programmer Subject: Re: Is there a defacto standard for 'drop ins'? Message-ID: <13094@adobe.UUCP> Date: 22 Mar 91 18:14:17 GMT References: <1CE00001.aolmdnz@tbomb.ice.com> Reply-To: hawley@adobe.UUCP (Steve Hawley) Organization: Adobe Systems Incorporated, Mountain View Lines: 60 In article <1CE00001.aolmdnz@tbomb.ice.com> time@ice.com writes: > >In article <1991Mar21.223638.4346@ssd.kodak.com>, ph@ssd.kodak.com (Pete Hoch) writes: >> So I was wondering, do they all do it the same way? Should >> Apple step in and provide a filter manager? Is this hard to >> do today without Apples help? Also, is this a good idea? > >Most of these mechanisms use a very similar technique. > >However, all differ in content and calling conventions, and it is >very doubtful that a universal solution would be easily decided upon. >However, I am certain some could be standardized. For instance, there >could be a common interface for operations that work on text selections. >Of course, even then, some cases will still not fit... Since Pete was interested in a general way of doing filters, why not have the following (off the top of my head) for byte oriented streams: typedef struct { /* stream operations. These would probably follow Pascal calling conventions */ boolean (*EndOfStreamFunc)(); char (*GetCharFunc)(); OSErr (*PutCharFunc)(); OSErr (*UngetCharFunc)(); /* maybe Seek, and Length too */ } StreamOps, *StreamOpsPtr; /* prototype function to do filtering */ pascal void main(SOps) StreamOpsPtr SOps; { /* your code to do filtering */ } The idea is that the parent program passes in pointer to functions to do all operations one would need for a stream. The main could then use the ops on the stream to transform the data as needed: pascal void main(SOps) register StreamOpsPtr SOps; { /* convert an uppercase bytes stream to lowercase */ register char *c; while (! (SOps->EndOfStreamFunc)()) { c = (SOps->GetCharFunc)(); if (isupper(c)) c = tolower(c); /* whatever the syntax is for CallPascal -- I forget */ CallPascal1(SOps->PutCharFunc, c); } } Of course, this will not be particularly speedy because of the overhead added by the function calling, but you wanted generality, right? Steve Hawley hawley@adobe.com -- "Did you know that a cow was *MURDERED* to make that jacket?" "Yes. I didn't think there were any witnesses, so I guess I'll have to kill you too." -Jake Johansen