Mac OS 9
SegLoad.h File Reference

Segment Loader Interfaces. More...

#include <MacTypes.h>

Go to the source code of this file.

Data Structures

struct  AppFile
 

Macros

#define UnloadSeg(x)
 

Typedefs

typedef struct AppFile AppFile
 

Enumerations

enum  { appOpen = 0 , appPrint = 1 }
 

Functions

void GetAppFiles (short index, AppFile *theFile)
 Get information about files selected in the Finder. More...
 
void ClrAppFiles (short index)
 Let the Finder know have processed a file. More...
 
void GetAppParms (Str255 apName, short *apRefNum, Handle *apParam)
 Get application name, resource file reference, et.al. More...
 
void getappparms (char *apName, short *apRefNum, Handle *apParam)
 

Variables

</pre > *par Copyright
 Count selected files; determine Open or Print. More...
 
</pre > *par short * count
 

Detailed Description

Segment Loader Interfaces.

Introduced In: Mac OS 8
Avaliable From: Universal Interfaces 3.4.1
Copyright: © 1985-2001 by Apple Computer, Inc., all rights reserved

For bug reports, consult the following page on the World Wide Web:

http://developer.apple.com/bugreporter/

Macro Definition Documentation

◆ UnloadSeg

#define UnloadSeg (   x)

Because PowerPC applications don©t have segments. But, in order to allow applications to not have conditionalized source code, UnloadSeg is macro'ed away for PowerPC.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

CountAppFiles, GetAppFiles, ClrAppFiles, GetAppParms, getappparms, and the AppFile data structure and enums are obsolete. They are still supported for writing old style 68K apps, but they are not supported for CFM-based apps. Use AppleEvents to determine which files are to be opened or printed from the Finder.

Function Documentation

◆ ClrAppFiles()

void ClrAppFiles ( short  index)

Let the Finder know have processed a file.

via GetAppFiles , call ClrAppFiles to mark it as having been processed.
indexspecifies which file you want to "clear". It should range from 1 to
the fileCnt value obtained through a previous call to
CountAppFiles .
Returns
none
Note
ClrAppFiles simply clears (sets to 0) the ftype field of the index-th
AppFile structure. See CountAppFiles for an example of usage.
This function seems to have no effect whatsoever on how the Finder or
Segment Loader calls respond. However, you could use this function to help
make multiple passes at the file list. For instance, you could process all
'TEXT' files, followed by all files of a second type, and so forth. Once
cleared, the file's type won't match with any subsequently-compared type.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: not available
Carbon Lib: not available
Mac OS X: not available

◆ GetAppFiles()

void GetAppFiles ( short  index,
AppFile theFile 
)

Get information about files selected in the Finder.

GetAppFiles obtains the filename, type, and volume of one of the files
selected by the user when the Finder started your application.
indexspecifies which file you want to query. It should range from 1 to the
fileCnt value obtained through a previous call to CountAppFiles .
fileStuff is the address of a 264-byte AppFile structure. Upon return, it
contains information about the index-th file selected when the Finder
started your application.
Returns
none
Note
When a user double-clicks a document whose FInfo.fdCreator field (see
GetFInfo ) contains your signature, your application will begin executing.
At that time, you should call CountAppFiles and use GetAppFiles to
obtain the information needed to open that document.
In the event that the user selected two or more of your documents, and then
selected Open from the Finder's File menu, you should call GetAppFiles
several times and open each of the selected documents. See CountAppFiles
for an example.
Note: The files are indexed in the order the user selected them.
See AppFile for a description of the information returned by this call.
GetAppParms returns a handle to a block of data that contains this same
application file information - in a slightly different form.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: not available
Carbon Lib: not available
Mac OS X: not available

◆ getappparms()

void getappparms ( char *  apName,
short *  apRefNum,
Handle *  apParam 
)

getappparms()

Non-Carbon CFM: not available
Carbon Lib: not available
Mac OS X: not available

◆ GetAppParms()

void GetAppParms ( Str255  apName,
short *  apRefNum,
Handle *  apParam 
)

Get application name, resource file reference, et.al.

You can use GetAppParms to obtain your application's filename, your
resource fork's file reference number, and a handle. The handle leads to the list
of Finder file information about documents that were selected when your
program was launched.
apName is the address of a 32-byte buffer. Upon return, it is filled with a
length-prefixed pascal-style string containing the name of the
currently executing application.
resRefNum is the file reference number of the application resource file(fork).
You could use this to CloseResFile , UseResFile , FSRead, etc.
hParms is the address of a 4-byte Handle. Upon return, it will contain a
Handle leading to information about the files selected in the Finder
when your application was opened. The format of this data is
described in the AppFile topic.
Returns
none
Note
There are other ways to get information besides GetAppParms :
•You can get the fRefNum of your open resource file by calling
CurResFile early on.
•Use CountAppFiles and GetAppFiles to index easily through the Finder
information about documents you're supposed to process.
Furthermore, you can examine the global variables CurApName (at
0x0910), CurApRefNum (at 0x0900), and AppParmHandle (at 0x0AEC).
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: not available
Carbon Lib: not available
Mac OS X: not available

Variable Documentation

◆ Copyright

</ pre> * par Copyright

Count selected files; determine Open or Print.

Call CountAppFiles to determine how many files the user had selected in the
Finder. This is the first step in determining which file or files the user wants
you to process and what the user wants you to do with it (them).
doWhatis the address of a short. Upon return, it contains one of the
following action codes (defined in SegmentLdr.h):
appOpen 0Open the file(s)
appPrint 1Print the file(s)
fileCntis the address of a short. Upon return, it contains the number of
files the user selected in the Finder before selecting Open or Print.
If the user double-clicked a document, fileCnt will return containing
a 1.
Returns
none
Note
After initializing the various managers, most applications will want to
follow these steps to determine what files the user wishes to open or print:
•Call CountAppFiles . If fileCnt =0, open a blank, untitled document.
Otherwise...
•Call GetAppFiles indexing from 1 through fileCnt. Use the returned
information to open or print each file. If you can't or don't want to process
the file, issue a CautionAlert .
•After opening or printing the file, call ClrAppFiles with the same index.
This system lets a user open one or more documents automatically.
Example
#include < SegLoad.h >
#include <stdio.h>
shortfileCnt, doWhat, index;
AppFile fileStuff;
char*cp = (char *)&fileStuff.ftype;  // ease handling of file type
CountAppFiles(&doWhat, &fileCnt);
  for (index = 1; index <= fileCnt; index++)
  {
    GetAppFiles(index, &fileStuff);
    /* — normally you'd open or print the file here —