Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Archive for September, 2012

Mac os 9 Vs. Mac os X

I am porting some windows software to mac os 9. My client has only mac
os 9. I would like to use the URLAccessLib for my development. I find
no documentation of it on Apple websites as if mac os 9 has fallen off
the earth for them.

The apple site says One can develop on mac os x and it is backward
compatible. What does this mean ? When I install my code on mac os 9
will I need all the mac os x libraries ?

can someone throw somelight ?

Thanks

.
posted by admin in Uncategorized and have Comments (6)

application duality?

Hi,

what would be the bet way to make an application startable from both
terminal and Finder (and behave differently)?

Basically I have an old unix tool ported to osx but wanted to add a
cocoa gui for it. I want to retain the command line behavior and have a
gui on wish. This calls for a different behavior on those launch methods.

any directions?

posted by admin in Uncategorized and have Comments (9)

ASynch read questions?

Hello,

Is there any important difference between PBReadForkAsync and
PBReadAsync, other than the fact you’re addressing the fork directly.
I’m not sure why you would use one over the other?
I’m using PBReadForkAsync to load sound file data, but just wondered if
I was missing something.
Is there any way, with either, to find out how much of the data has been
read before it completes?
I’m loading long tracks off a CD which takes about 15 sec, and wanted to
gradually draw the waveform as portions of the data have become read.
At the moment I’m just re-drawing the whole buffer every couple of
seconds. Which begs another question; is it safe to use this buffer data
while the async read is still in progress.

Failing that, how do various apps manage to draw data as it is being
read. Any suggestions welcome.

Finally, although I can’t change tack in the middle of this project, is
there a more modern OSX way to be doing asynchronous file access that I
should study?

Thanks

Steve

CW 8.3
OS 10.2.8

posted by admin in Uncategorized and have Comments (7)

Need some OT (Open Transport, not Off Topic) help, please?

OK, I know I’mlgging behind the curve (and probably dating myself
horribly besides) but here’s the deal –

I’m working under 9.1, trying to write some networking code to replace
GUSI in a specific application . Nothing against the author, but GUSI is
just plain unstable, IMO. (or at least seems to be – nothing I can
"prove" at this point, just a bunch of rather vague "this kind of thing
*ONLY* happens when a program that relys on GUSI for its networking is,
or has recently been, running" incidents that make up what seems like a
rather suspicious pattern)

Regardless of my motivation, I’m trying to redo a progam that used GUSI
for networking, in "full native" OpenTransport. If nothing else, it
should be at least slightly more efficient without all the overhead GUSI
imposes, and MAYBE it’ll even cure a problem that, to date, has eluded
all my efforts to track it down.

The reason I used GUSI in the first place was that it was there, and I
was lazy – trying to network from the Mac seems like an exercise in
overkill as far as "general-purpose the interface to the point where it
isn’t usable for any specific task", and there was GUSI, all set to go.
So I never climbed the learning curve to adopt OT.

Time to change that.

So the first step is figuring out how to work with OT. Got all the docs
I can locate, and though they’re pretty darn good, nicely detailed, etc.
etc, I’m hitting a wall when I try to do a DNS query.

What follows is the current state of the code that’s giving me trouble.

begin paste (pardon any poorly done wrapping… Honest, it’s not my
fault!)

#include <Memory.h>
#include "InitOT.h"
#include "DNSLookup.h"
#include <Stdio.h>

extern int OTInitialized;

struct hostent *gethostbyname(const char *Name)
   {

      OSStatus Result = kOTNoError;
      OTConfiguration *TheConfiguration;
      OSStatus QueryGood = kOTNoError;
      struct hostent *TheHostEnt;
      InetSvcRef TheReference;
      InetHostInfo TheHInfo;    

      TheHostEnt = (struct hostent *)NewPtrClear(sizeof(struct hostent));
      if (TheHostEnt)
         {
//       All good… memory was allocated, can proceed.
            if (!OTInitialized)
               {
//          Hmmm… We’re the first routine to use OT this run? OK…
Fire it up.              
                  FireUpOT();
               }
            else
               {
//             OT is already initialized.
               }
//      Make sure that the FireUpOT call above worked if OT wasn’t
already initialized
            if (OTInitialized)
               {
//             Create a configuration doohickey. We’re going to need it
when we try to
//             do the OTOpenInternetServices() call.
                  Result = CreateConfiguration(&TheConfiguration);
//          Do whatever is needed to open/setup/whatever the "provider"
that’s going to do DNS lookups.
//          Duhhhhhhhh… still not certain on the "how-to" of that.
Gotta do some more reading…

//             Put it here when you figure it out, stupid.
            TheReference = OTOpenInternetServices(TheConfiguration, 0,
&Result);

            if (Result == kOTNoError)
               {
//                   It’s all good. We can proceed

//                Make the actual query
                        QueryGood = OTInetStringToAddress(TheReference,
(char *) Name, &TheHInfo);
                        if (QueryGood)
                           {
//                         Good to go
//                    Massage the result into *nix form
                           }
                        else
                           {
//                         Query failed, for whatever reason
                              printf("DNS Query failed (Result Code
%d)\n", QueryGood);
                           }
                     }
                  else
                     {
//                   Something whent wrong when trying to open the
service
                        printf("Error %d while attempting to
OTOpenInternetServices()\n", Result);
                     }
               }
            else
               {
//             unable to init OT
                  printf("OT is not/could not be initialized\n");
               }
         }
      else
         {
//       Couldn’t allocate memory for the result
            printf("Unable to allocate memory for hostent struct\n");
         }
     return TheHostEnt;
   }

end paste

So, going at it from the top down, here’s what I *THINK* you probably
need to know that isn’t visible in the code itself:

"FireUpOT()" is wrapped around the "InitOT()" routine. It does some
version and availability checking to find out what, if any, version of
OT is installed on the machine, issues the InitOT() call, then sets up
the global "OTInitialized" to reflect its success or failure at getting
OT fired up.

Here’s the CreateConfiguration call:
OSStatus CreateConfiguration(OTConfiguration **TheResult)

   {
      OSStatus ReturnValue = 0;
      OTConfiguration *TheConfiguration;

      TheConfiguration = OTCreateConfiguration("tcp");

      if ((TheConfiguration != kOTInvalidConfigurationPtr) &&
              (TheConfiguration != kOTNoMemoryConfigurationPtr))
         {
            /* It’s all good */
            ReturnValue = 0;
         }
      else
         {
            /* Signal an error */
            printf("Error in CreateConfiguration: %d\n",
TheConfiguration);
            ReturnValue = -1;
         }
      if (ReturnValue == 0)
         *TheResult = TheConfiguration;
      else
         *TheResult = 0;
      return ReturnValue;
   }

Pretty routine stuff to be doing, it would seem – create a
configuration, error check the attempt, and return it. Which seems to
work just fine.

Where I’m hitting real trouble is in the "almost silent" way that the
call to "OTInternetServices()" is failing. All attempts, regardless of
conditions during the attempt, fail with a -3170 result code, which
apparently translates to "kOTBadNameErr", which OpenTransport.h has
commented as /* -3170 A bad endpoint name was supplied       */

Ummm… OK, a bad endpoint name… Errr… What name???? And why is it
"bad"? And perhaps just as importantly, what endpoint??? … Or perhaps
"what endpoint???" is a part of the problem? As in "Nobody told us about
an endpoint to be used, so we’re gonna barf and say that you gave us a
bad name"

That doesn’t seem to make any sense, though, since I can find no
reference to endpoints in connection with trying to do a name lookup.

As far as I can tell from the docs, doing a DNS query should be as
simple as making sure InitOT has been called, a tcp configuration is
created, and a call to OTOpenInternetServices() is done. Once that’s all
been done, calling one of the 2-3 available lookup routines (in this
particular case, "OTInetStringToAddress") should be handing back the IP
numbers that go with a DNS name.

I’m apparently missing something here…

Can anyone give me a clue what the "something" is? Nothing in the 900+
pages worth of OT docs I have seems to apply, and I’m currently sitting
here pretty well stumped.


Don Bruder –  dak…@sonic.net <— Preferred Email – SpamAssassinated.
Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
I will choose a path that’s clear: I will choose Free Will! – N. Peart
Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>

posted by admin in Uncategorized and have Comments (2)

G4 & G5 Assembler programming intro

Where can I find information for doing assembler programming for the
G4 and G5 processors under Darwin?  I would also like to know about
the executable (binary) file format and linker/loader.

Thanks


   One Emacs to rule them all.  One Emacs to find them,
   One Emacs to take commands and to the keystrokes bind them,

All other programming languages wish they were Lisp.

posted by admin in Uncategorized and have Comments (10)

some man pages are not available

Hello.

I’m using MacOSX 10.3 (upgraded from 10.2) with Developer Tools and fink
installed.

I cannot find man pages for some standard library functions. for
example, printf(3) and getopt(3) are not available. I think those are
too standard to be missing in my machine. Is this normal or my maching
having a problem?

And how can i get those man pages installed if they are missing by
default?

Thanks.

posted by admin in Uncategorized and have Comments (6)

Clashing callback parameters in PBReadForkAsync? (was ASync read questions)

PBReadForkAsync takes an FSForkIOParam.
FSForkIOParam has an IOCompletionUPP.
The IOCompletionUPP takes a ParmBlkPtr.

Apple’s Inside Carbon describes this ParmBlkPtr:
"A pointer to the parameter block that was passed to the asynchronous
File Manager function."

Hmmm. We don’t pass a ParmBlkPtr to the IO function, we pass an
FSForkIOParam!

OK, they share some fields. But is it safe to just hand it my
FSForkIOParam typecast as a  ParmBlkPtr?

Even if this resolves, then it means the FSForkIOParam has a parameter,
which in turn has a parameter back to FSForkIOParam. It seems to be what
Douglas Adam’s described as a ‘self-eating watermelon’.

BTW, it seems I can do everything I need by simply examining the
ioResult parameter directly, and set NULL callback. But it’s bugging me
anyway.

Thanks

Steve

posted by admin in Uncategorized and have Comment (1)

Converting CFM Carbon to Mach-O Carbon Application Package

To make my application eassier to maintain, I changed the linker
settings from CFM to Mach-O and built an "Application Package". The
application uses Carbon.

I encountered some problems. Is there an FAQ for that?

1. Function pointers are no longer indirect, so I have to omit one
indirection when called from inline assembler.
2. Static variables from inline assembler is accessed no longer via
rtoc and and a 16 bit offset, but with a mysterious RPIC register and
a 32 bit offset. I did not find information about that register. Is it
also gpr2?
3. The function GetProcessInformation() gives me the path of the
executable in MyPkg/contents/MacOS. Does that make any sense? I
thought the bundle structure should not be visible.
4. The current path also is MyPkg/contents/MacOS. In order to find
files in the same directory of my application, I had to go three
levels upwards. Is that documented somewhere?
5. My application lost its icon, only a generic one is displayed in
both the Dock and the Finder. I added the line
"CFBundleIconFile=MyPkg.icns" to the plist and put the MyPkg.icns file
to the Resources folder inside the package. Seems to be ignored. But
the ececutable in MyPkg/contents/MacOS shows the correct icon in the
Finder. Strange.
6. Unfortunately the example project that came with CW (8.3) does not
contain an icon, only a generic one is displayed. Is there a better
example?

posted by admin in Uncategorized and have Comments (17)

_program_name not found: dynamic libraries in Panther's Python

I’m trying to compile pybliographer, a python program for bibtex
databases. Previously I had it working with fink’s 2.2 python. Then I
got the hair brained scheme to make use of the Python built into Panther (
10.3). After some fudging with LDFLAGS (-framework Python) I can get the
compiled python modules to compile and load.

However, this is the output:

[piglet:~/Development/pybliographer-1.0.11/compiled] geoff%
pybliographer
This is pybliographer, version 1.0.11
Copyright (C) 1998-2000 Frederic GOBRY
This is free software with ABSOLUTELY NO WARRANTY.
For details, type `warranty’.
Useful commands:
        help     to get some help
        quit     to quit

dyld: python Undefined symbols:
_program_name
Trace/BPT trap

program_name is defined in libSystem.B.dylib which does exist on the
system.  So what’s up?

Thanks,

Geoff Ghose

posted by admin in Uncategorized and have No Comments

Re: Britney Spears dude

In article <Ifwwb.40381$Ek.11…@twister.austin.rr.com>, joe

<j…@news-upload.com> wrote:
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude
> Britney Spears dude

What?  You say Britney Spears is a _dude?_  Holy crap!


Jerry Kindall, Seattle, WA                <http://www.jerrykindall.com/>

        Send only plain text messages under 32K to the Reply-To address.
        This mailbox is filtered aggressively to thwart spam and viruses.

posted by admin in Uncategorized and have Comment (1)