Esempio n. 1
0
OSErr	FindPrefs(FSSpec* where)
{
	OSErr		error = noErr;
	Str255	theString;
	Str255	name;
	FSSpec	spec;
	short		foundVRefNum;
	long		foundDirID;
	// Look for the prefs in the folder
	GetIndString(theString, kTransportPath, 1);
	p2cstr(theString);
	strncpy(name, theString, 63);
	strncat(name, "Modem prefs", 63);
	c2pstr(name);
	error = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &foundVRefNum, &foundDirID);
	if (error == noErr) {
		error = FSMakeFSSpec(foundVRefNum, foundDirID, name, where);
		if (error == fnfErr) {		// May need to create the file
			FSpCreateResFile(where, 'mwNT', 'pref', smSystemScript);
			error = ResError();
		}
	}

	return error;
}
Esempio n. 2
0
File: ugView.c Progetto: rolk/ug
static void HDFCommand (void)
{
  SFReply reply;
  Point where;
  char prompt[128];
  OSErr error;
  char buffer[80];
  char *s;

  if (globalState!=OPENED) return;

  /* get file name */
  strcpy(buffer,"Save HDF image as:");
  strcpy(prompt,fileName);
  if ((s=strstr(prompt,".meta"))!=NULL)
    *s = '\0';
  strcat(prompt,".hdf");
  where.h = 20; where.v = 40;
  SFPutFile(where,c2pstr(buffer),c2pstr(prompt),NULL,&reply);
  if (!reply.good) return;

  /* set volume */
  error = SetVol(NULL,reply.vRefNum);
  if (((int)error)!=0)
  {
    OneButtonBox("Could not set volume","OK");
    return;
  }
  /* change pascal string to C string */
  p2cstr(reply.fName);

  RefreshCommand();
  SaveToHDF(reply.fName);
  return;
}
Esempio n. 3
0
int
TclMacChmod(
    char *path, 
    int mode)
{
    HParamBlockRec hpb;
    OSErr err;
    
    c2pstr(path);
    hpb.fileParam.ioNamePtr = (unsigned char *) path;
    hpb.fileParam.ioVRefNum = 0;
    hpb.fileParam.ioDirID = 0;
    
    if (mode & 0200) {
        err = PBHRstFLockSync(&hpb);
    } else {
        err = PBHSetFLockSync(&hpb);
    }
    p2cstr((unsigned char *) path);
    
    if (err != noErr) {
        errno = TclMacOSErrorToPosixError(err);
        return -1;
    }
    
    return 0;
}
Esempio n. 4
0
void SetBasePath(void)
{
	OSErr			error;
	FSSpec		where;
	//Handle		theString;
	Str255		name;
	short			vRef;
	long			dirID;
	long			nDirID;
	error = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &vRef, &dirID);
	GetIndString(name, kTransportPath, 1);
	if (name[0] != '0') {
		error = FSMakeFSSpec(vRef, dirID, name, &where);	// First, check to see if the directory exists
		if (error != noErr) {
			// Create it
			error = FSpDirCreate(&where, smSystemScript, &nDirID);
		}
		p2cstr(name);
		strncat((char *)name, "Serial", 63);	// It won't matter if this exists or not; we'll get the parent directory ID this way
		c2pstr((char *)name);
		error = FSMakeFSSpec(vRef, dirID, name, &where);
		gvRef = where.vRefNum;
		gparID = where.parID;
	}
}
Esempio n. 5
0
void CloseMacros(NewMacroInfo *macrost, DialogPtr dtemp)
{
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10];

	if ( TelInfo->macrosModeless == dtemp ) {
		for (i=0; i<10; i++) {
			GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
			GetDialogItemText( MacString[i], temp);
			p2cstr(temp);
			setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}

		DisposeHandle(oldMacros);
		DisposeDialog(dtemp);
		
		//if ( TelInfo->macrosModeless ) {
			TelInfo->macrosModeless = 0;
			AdjustMenus();
			DoTheMenuChecks();
		//}
	}
}
Esempio n. 6
0
static
PGPError pgpGetProxyServer(PGPContextRef context, PGPProxyServerType type,
                           char **proxyAddress, PGPUInt16 *proxyPort)
{
    PGPMemoryMgrRef	mgr = PGPGetContextMemoryMgr(context);
    PGPError			err = kPGPError_NoErr;
    ICError				icErr;
    ICInstance			icInstance;
    Str255				proxy;
    SInt32				bufSize;
    ICAttr				icAttr;
    Boolean				useProxy;
    static PGPUInt32	kDefaultPort = 80;
    char *				host = (char *) proxy;
    char *				port = NULL;

    if (type != kPGPProxyServerType_HTTP) {
        return kPGPError_BadParams;
    }
    if (ICStart != (void *) kUnresolvedCFragSymbolAddress) {
        icErr = ICStart(&icInstance, '????');
        if (icErr == noErr) {
            icErr = ICFindConfigFile(icInstance, 0, NULL);
            if (icErr == noErr) {
                bufSize = sizeof(Boolean);
                icErr = ICGetPref(icInstance, kICUseHTTPProxy, &icAttr, (Ptr) &useProxy, &bufSize);
                if ((icErr == noErr) && useProxy) {
                    bufSize = sizeof(Str255);
                    icErr = ICGetPref(icInstance, kICHTTPProxyHost, &icAttr, (Ptr) proxy, &bufSize);
                    if (icErr == noErr) {
                        p2cstr(proxy);
                        port = strchr(host, ':');
                        if (port == NULL) {
                            port = strchr(host, ' ');
                        }
                        if (port == NULL) {
                            *proxyPort = kDefaultPort;
                        } else {
                            *port++ = 0;
                            *proxyPort = atoi(port);
                        }
                        *proxyAddress = (char *) PGPNewData(mgr, strlen(host) + 1,
                                                            kPGPMemoryMgrFlags_None);
                        if (*proxyAddress == NULL) {
                            err = kPGPError_OutOfMemory;
                            *proxyPort = 0;
                        } else {
                            strcpy(*proxyAddress, host);
                        }
                    }
                }
            }
            ICStop(icInstance);
        }
    }

    return err;
}
int prFile_PutFile(struct VMGlobals *g, int numArgsPushed)
{

	PyrSlot *a = g->sp - 2;
	PyrSlot *b = g->sp - 1;
	PyrSlot *c = g->sp;

	NavDialogOptions options;

	int err = NavGetDefaultDialogOptions(&options);
	if (err) return errFailed;

	options.dialogOptionFlags |= kNavNoTypePopup;
	options.dialogOptionFlags |= kNavDontAutoTranslate;
	options.dialogOptionFlags |= kNavDontAddTranslateItems;
	options.dialogOptionFlags |= kNavSelectDefaultLocation;
	options.dialogOptionFlags &= ~kNavAllowPreviews;
	options.dialogOptionFlags &= ~kNavAllowMultipleFiles;

	if (isKindOfSlot(b, class_string)) {
		pstringFromPyrString((PyrString*)slotRawObject(b), options.message, 256);
	}

	if (isKindOfSlot(c, class_string)) {
		pstringFromPyrString((PyrString*)slotRawObject(c), options.savedFileName, 256);
	} else {
		//pstrncpy(options.savedFileName, "\pUntitled", 255);
	}

	NavReplyRecord reply;
	err = NavPutFile(0, &reply, &options, 0, 'TEXT', 'SCjm', 0);

	if (err == noErr && reply.validRecord) {
		AEKeyword keyword;
		DescType actualType;
		Size actualSize;
		FSSpec fsspec;

		err = AEGetNthPtr(&reply.selection, 1, typeFSS, &keyword, &actualType,
							&fsspec, sizeof(FSSpec), &actualSize);

		if (err == noErr) {
			Str255 pathname;
			GetFullPathname(&fsspec, pathname);
			p2cstr(pathname);
			PyrString *string = newPyrString(g->gc, (char*)pathname, 0, true);
			SetObject(a, string);

			err = NavCompleteSave(&reply, kNavTranslateInPlace);
		} else {
			SetNil(a);
		}
		err = NavDisposeReply(&reply);
	} else {
		SetNil(a);
	}
	return errNone;
}
Esempio n. 8
0
void screenOpen(char *Title) {
    FontInfo fontInfo;
    int n;

    theWindow = GetNewWindow(screenWindow, nil, (WindowPtr)(-1));

    if ((Title != NULL) && (*Title != '\0')) {
        c2pstr(Title);
        SetWTitle(theWindow, Title);
        p2cstr(Title);
    }

    ShowWindow(theWindow);

    SetPort(theWindow);
    TextFont(monaco);
    TextSize(9);

    GetFontInfo(&fontInfo);
    fontHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
    fontWidth = fontInfo.widMax;

    scrollRgn = NewRgn();

    screenWidth = (theWindow->portRect.right - theWindow->portRect.left - 10) /
        fontWidth;
    screenHeight = (theWindow->portRect.bottom - theWindow->portRect.top) /
        fontHeight;
    maxPosition = screenHeight * fontHeight;
    pausePosition = maxPosition - (currentPosition = fontHeight);

    SetRect(&scrollRect, theWindow->portRect.left, theWindow->portRect.top + fontInfo.descent,
        theWindow->portRect.right, theWindow->portRect.bottom);
    SetRect(&pauseRect, theWindow->portRect.left, pausePosition + fontInfo.descent,
        theWindow->portRect.right, theWindow->portRect.bottom);

    MoveTo(5, currentPosition);

    n = (sizeof(char *) + sizeof(short) + screenWidth) * screenHeight;

    screenLine = (char **)NewPtr(n);

    screenLength = (short *)&screenLine[screenHeight];
    screenImage = (char *)&screenLength[screenHeight];

    for (n = 0; n < screenHeight; n++) {
        screenLine[n] = &screenImage[n * screenWidth];
        screenLength[n] = 0;
    }

    startLine = endLine = 0;

    screenOptions = 0;

    return;
}
Esempio n. 9
0
char *getcstr(
	char *buffer,
	short resource_number,
	short string_number)
{
	getpstr(buffer, resource_number, string_number);
	p2cstr((unsigned char *)buffer);
	
	return buffer;
}
Esempio n. 10
0
char *
getbootvol()
{
	short vrefnum;
	static unsigned char name[32];
	
	(void) GetVol(name, &vrefnum);
	p2cstr(name);
		/* Shouldn't fail; return ":" if it does */
	strcat((char *)name, ":");
	return (char *)name;
}
Esempio n. 11
0
static OSErr 
OpenLibraryResource(
    struct CFragInitBlock* initBlkPtr)
{
    /*
     * The 3.0 version of the Universal headers changed CFragInitBlock
     * to an opaque pointer type.  CFragSystem7InitBlock is now the
     * real pointer.
     */
     
#if !defined(UNIVERSAL_INTERFACES_VERSION) || (UNIVERSAL_INTERFACES_VERSION < 0x0300)
    struct CFragInitBlock *realInitBlkPtr = initBlkPtr;
#else 
    CFragSystem7InitBlock *realInitBlkPtr = (CFragSystem7InitBlock *) initBlkPtr;
#endif
    FSSpec* fileSpec = NULL;
    OSErr err = noErr;
    

    if (realInitBlkPtr->fragLocator.where == kDataForkCFragLocator) {
    	fileSpec = realInitBlkPtr->fragLocator.u.onDisk.fileSpec;
    } else if (realInitBlkPtr->fragLocator.where == kResourceCFragLocator) {
    	fileSpec = realInitBlkPtr->fragLocator.u.inSegs.fileSpec;
    } else {
    	err = resFNotFound;
    }

    /*
     * Open the resource fork for this library in read-only mode.  
     * This will make it the current res file, ahead of the 
     * application's own resources.
     */
    
    if (fileSpec != NULL) {
	ourResFile = FSpOpenResFile(fileSpec, fsRdPerm);
	if (ourResFile == kResFileNotOpened) {
	    err = ResError();
	} else {
#ifdef TCL_REGISTER_LIBRARY
	    ourResToken = Tcl_NewObj();
	    Tcl_IncrRefCount(ourResToken);
	    p2cstr(realInitBlkPtr->libName);
	    Tcl_SetStringObj(ourResToken, (char *) realInitBlkPtr->libName, -1);
	    c2pstr((char *) realInitBlkPtr->libName);
	    TclMacRegisterResourceFork(ourResFile, ourResToken,
	            TCL_RESOURCE_DONT_CLOSE);
#endif
            SetResFileAttrs(ourResFile, mapReadOnly);
	}
    }
    
    return err;
}
Esempio n. 12
0
boolean getyesno(char default_answer)
{ 
  extern FILE *logfile;
  short  alertid,i,large,err;
  char dfault[8], ndfault[8];
  ProcessSerialNumber psn;
  if (batchmode)
  	return(default_answer == 'y' ? TRUE : FALSE);
  if (strlen(Yes_No_Message)<72) large=0;
  else large=100;
  strcpy(dfault,default_answer == 'y' ? LANG("y") : LANG("n"));
  strcpy(ndfault,default_answer == 'n' ? LANG("y") : LANG("n"));
  for(i=0;i<strlen(Yes_No_Message);i++)
  if (Yes_No_Message[i]<' ' && Yes_No_Message[i]>=0) Yes_No_Message[i]=' ';	/* It's a signed char! */
  InitCursor();
  alertid=(default_answer == 'n' ? 211+large : 212+large);
  c2pstr(Yes_No_Message);
  ParamText((uchar *)Yes_No_Message,(uchar *)"", \
  		(uchar *)"",(uchar *)"");
  if (AEProcessing) {
  	if (gHasProcessManager)
  		GetFrontProcess(&psn);
  	if(MyInteractWithUser())
  		return default_answer;
  	if (gHasProcessManager)
    	SetFrontProcess(&psn);
  }
  if (CautionAlert(alertid,nil)==1){
   p2cstr((uchar *)Yes_No_Message);
   fputs(strcat(Yes_No_Message,dfault),stderr);
   fputc('\n',stderr);
   fflush(stderr);
   return(default_answer == 'y' ? TRUE : FALSE);
   }
  p2cstr((uchar *)Yes_No_Message);
  fputs(strcat(Yes_No_Message,ndfault),stderr);
  fputc('\n',stderr);
  fflush(stderr);
  return(default_answer == 'n' ? TRUE : FALSE);
  } 
Esempio n. 13
0
NMBoolean
NMTeardownDialog(
    NMDialogPtr	dialog,
    NMBoolean	inUpdateConfig,
    NMConfigRef	ioConfig)
{
    DEBUG_ENTRY_EXIT("NMTeardownDialog");

    NMIPConfigPriv	*theConfig = (NMIPConfigPriv *) ioConfig;
    NMErr		status;
    InetAddress		addr;
    Str255			hostText;
    Str255			portText;

    NMSInt16		kind;
    Rect 			r;
    Handle 			h;
    NMSInt32		theVal;
    SetTempPort		port(dialog);

    op_vassert_return((theConfig != NULL),"Config ref is NULL!",true);
    op_vassert_return((dialog != NULL),"Dialog ptr is NULL!",true);

    if (inUpdateConfig)
    {
        // 	Get the host text
        GetDialogItem(dialog, gBaseItem + kHostText, &kind, &h, &r);
        GetDialogItemText(h, hostText);

        p2cstr(hostText);

        //	resolve it into a host addr
        status = OTUtils::MakeInetAddressFromString((const char *)hostText, &addr);
        op_warn(status == kNMNoError);

        if (status != kNMNoError)
            return false;

        theConfig->address = addr;

        //	Get the port text
        GetDialogItem(dialog, gBaseItem + kPortText, &kind, &h, &r);
        GetDialogItemText(h, portText);
        StringToNum(portText, &theVal);

        if (theVal != 0)
            theConfig->address.fPort = theVal;
    }

    return true;
}
Esempio n. 14
0
File: ugView.c Progetto: rolk/ug
static void OpenCommand (void)
{
  int error;
  FILE *stream;
  SFReply reply;
  Point where;
  char prompt[32];
  SFTypeList typeList;

  if (globalState==OPENED) return;

  /* get file name */
  strcpy(prompt,"choose metafile:");
  where.h = 20; where.v = 40;
  SFGetFile(where,c2pstr(prompt),NULL,-1,typeList,NULL,&reply);
  if (!reply.good)
  {
    return;
  }

  /* save name and path */
  vRefNum = reply.vRefNum;
  strcpy(fileName,p2cstr(reply.fName));

  /* set volume */
  error = SetVol(NULL,vRefNum);
  if (((int)error)!=0)
  {
    OneButtonBox("Could not set volume","OK");
    return;
  }

  stream = fopen(fileName,"rb");
  if (stream==NULL)
  {
    OneButtonBox("Could not open file","OK");
    return;
  }

  GetFileScreen(stream,&fx,&fy);

  /* open a window */
  error = CreateApplicationWindow(&myWindow,fileName,20,40,fx,fy);
  fclose(stream);
  SetState(OPENED);
  RefreshCommand();

  return;
}
Esempio n. 15
0
HFONT AFXAPI _AfxGetHelpFont()
{
	LONG nFondAndSize;
	LOGFONT logfont;

	nFondAndSize = GetScriptVariable(smSystemScript, smScriptHelpFondSize);

	memset(&logfont, 0, sizeof(logfont));
	logfont.lfWeight = FW_NORMAL;
	logfont.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
	logfont.lfHeight = -MulDiv(LOWORD(nFondAndSize), afxData.cyPixelsPerInch, 72);
	GetFontName(HIWORD(nFondAndSize), (StringPtr) logfont.lfFaceName);
	p2cstr((StringPtr) logfont.lfFaceName);
	return ::CreateFontIndirect(&logfont);
}
Esempio n. 16
0
void DOCUMENTFunction(Value *stack, int, CContainer *cells)
{
	CCellView *thePane;
	
	if (cells && (thePane = cells->GetOwner()) != NULL)
#if !__BEOS__ && !__HAIKU__ 
	{
		Str255 s;
		thePane->Doc()->GetDescriptor(s);
		stack[0] = p2cstr(s);
	}
#else
		stack[0] = thePane->Window()->Title();
#endif
	else
Esempio n. 17
0
static FILE *
OpenScript(StandardFileReply *reply)
{
	FILE *					stream;
	OSType					fileType = 'TEXT';
	Str255					buff;
	short					vRefNum;
	long					dirID;
		
	stream = nil;
	HGetVol( buff, &vRefNum, &dirID );
	HSetVol( nil, reply->sfFile.vRefNum, reply->sfFile.parID );
	
	p2cstr( (StringPtr) &reply->sfFile.name );
	stream = fopen( (char *) &reply->sfFile.name, "r" );
	fprintf(gLogFile, "\n%s\n",(char *) &reply->sfFile.name);
	if ( stream == nil )
		{
		DebugStr( "\punable to open script file." );
		}
Esempio n. 18
0
char *MCScreenDC::charsettofontname(uint1 charset, const char *oldfontname)
{
	char *fname = new char[255];
	strcpy(fname, oldfontname);
	char *sptr = fname;
	if ((sptr = strchr(fname, ',')) != NULL)
		*sptr = '\0';
	char *tmpname = strclone(fname);//make a copy of the font name
	short ffamilyid;		    //font family ID
	StringPtr reqnamePascal = c2pstr(tmpname);
	GetFNum(reqnamePascal, &ffamilyid);
	delete tmpname;
	if (FontToScript(ffamilyid) != MCS_charsettolangid(charset))
	{
		GetFontName(GetScriptVariable(MCS_charsettolangid(charset),
		                              smScriptAppFond), (unsigned char *)fname);
		p2cstr((unsigned char *)fname);
	}
	return fname;
}
Esempio n. 19
0
struct dirent *readdir(DIR *dPtr)
{
    struct dirent *dirPtr;
    CInfoPBRec cPB;
    char name[256];
    OSErr err;

    if (dPtr->flags) {
        return NULL;
    }

    /* Get information about file. */

    memset(&cPB, '\0', sizeof(cPB));

    cPB.hFileInfo.ioNamePtr = (StringPtr)name;
    cPB.hFileInfo.ioFDirIndex = dPtr->ioFDirIndex;
    cPB.hFileInfo.ioVRefNum = dPtr->ioVRefNum;
    cPB.hFileInfo.ioDirID = dPtr->ioDrDirID;

    err = PBGetCatInfoSync(&cPB);

    if (err != noErr) {
        dPtr->flags = 0xff;
        errno = (err == fnfErr) ? ENOENT : EIO;
        return NULL;
    }

    p2cstr((StringPtr)name);

    dirPtr = &dPtr->currEntry;

    dirPtr->d_fileno = dPtr->ioFDirIndex++;
    dirPtr->d_namlen = strlen(name);
    strcpy(dirPtr->d_name, name);
    dirPtr->d_reclen = sizeof(struct dirent) - sizeof(dirPtr->d_name) +
                       dirPtr->d_namlen;

    return dirPtr;
}
Esempio n. 20
0
static void Utils_Macintosh_DisplayMsg(char *msg)
{
	DialogPtr theDlog;
	Handle item = NULL;
	Rect box;

		theDlog = GetNewDialog(kMsgDialogRsrcID, NULL, (WindowPtr)-1);
		if (theDlog != NULL)
		{
			short itemType;
			
				GetDialogItem(theDlog, kMsgItemID, &itemType, &item, &box);
				if (item != NULL)
				{
					short itemHit;
					
						SetDialogItemText(item, c2pstr(msg));
						ModalDialog(NULL, &itemHit);
						DisposeDialog(theDlog);
						p2cstr((StringPtr)msg);	/* restore C-string */
				}
		}

}
Esempio n. 21
0
// NB: As of 2.0fc1, theEvent can be NULL! It isn't used anywhere, so don't _let_ it be
// used anywhere!
void MacroDialog(NewMacroInfo *macrost, DialogPtr dtemp, EventRecord *theEvent, short dItem)
{
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	switch (dItem) {
		case 27: // switch keyset (pane) - RAB BetterTelnet 2.0b5
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}
			dialogPane = GetCntlVal(dtemp, 27) - 1;
			// now fix the strings
			for (i=0; i<10; i++) {
				GetIndString(temp, 7100, i + (10 * dialogPane) + 1);
				GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox);
				if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); }
				else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); }
				SetDialogItemText(rubbish, temp);
			}
			for (i=0; i<10; i++) {
				getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256);		
				c2pstr((char *)temp);								
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );
			}
		break;

		case (MacroExport):
			// we _used_ to get all the macros out, but now only the current set of 10
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
								// RAB BetterTelnet 2.0b5 (revised)
			}
			saveMacros(macrost, (FSSpec *) NULL);
			break;
		case 25:
			for (i=0; i<10; i++) {
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				GetDialogItemText( MacString[i], temp);
				p2cstr(temp);
				setmacro(macrost, i + (10 * dialogPane), (char *) &temp);
			}
			SaveGlobalMacros(macrost);
			break;
		case (MacroImport):
			loadMacros(macrost, (FSSpec *) NULL);
			for (i=0; i<10; i++) {
				getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256);		
				c2pstr((char *)temp);								
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );
			}
			break;
		case 1:
		case 2:
			break;
		default:
			if (dItem >2 && dItem <13) 
			{
				i=dItem-3;
				getmacro(macrost, i + (dialogPane * 10), (char *) &temp, 256); /* BYU LSC */
				c2pstr((char *)temp);
				GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
				SetDialogItemText( MacString[i], temp );				/* BYU LSC - Revert the mother */
				SelectDialogItemText( dtemp, i+13, 0, 32767);				/* And select it... */
			}	
			break;
	}
}
Esempio n. 22
0
/*--------------------------------------------------------------------------
Determines if there's a stub and if there is, returns its serial number stubPSN.
Requires stub to be called anetstub.
--------------------------------------------------------------------------*/
dp_result_t getstub(ProcessSerialNumber *pstubPSN)
{
	static int havestub = -1;
	OSErr err;
	ProcessInfoRec proc;
	ProcessSerialNumber myPSN;
	static ProcessSerialNumber stubPSN;
	char processName[FILENAME_MAX];
	FSSpec launchFSSpec;
	char buf[FILENAME_MAX];		// p2cstr alters its arg so use buffer
	
	/* check if already have determined if stub exists and if so return it */
	switch (havestub) {
		case -2:
			return dp_RES_BAD;
			break;
		case -1:
			break;
		case 0:
			return dp_RES_EMPTY;
			break;
		case 1:
			*pstubPSN = stubPSN;
			return dp_RES_OK;
			break;
		default:
			DPRINT(("macapp: error got havestub = %d\n", havestub));
			return dp_RES_BUG;
	}			
	
	/* find launcher of current process */
	proc.processInfoLength = sizeof(ProcessInfoRec);
	proc.processName = nil;
	proc.processAppSpec = nil;
	err = GetCurrentProcess(&myPSN);
	if (err != noErr) {
		DPRINT(("macapp: get current process number error %d\n", err));
		havestub = -2;
		return dp_RES_BAD;
	}
	err = GetProcessInformation(&myPSN, &proc);
	if (err != noErr) {
		DPRINT(("macapp: get current process info error %d\n", err));
		havestub = -2;
		return dp_RES_BAD;
	}
	proc.processName = &processName[0];
	proc.processAppSpec = &launchFSSpec;
	stubPSN = proc.processLauncher;
	/* check if launcher of current process was anetstub */
	err = GetProcessInformation(&stubPSN, &proc);
	if (err != noErr) {
		DPRINT(("macapp: get launcher process info error %d\n", err));
		havestub = -2;
		return dp_RES_BAD;
	}
	memcpy(buf, proc.processName, *proc.processName + 1);
	p2cstr(buf);
	DPRINT(("launcher was %s\n", buf));
	if (strcmp(buf, STUB_NAME)) {
		DPRINT(("macapp: found no stub\n", err));
		havestub = 0;
		return dp_RES_EMPTY;
	}
	*pstubPSN = stubPSN;
	havestub = 1;
	return dp_RES_OK;
}
Esempio n. 23
0
static int DoDialogItem(DialogPtr dlog, short itemHit) {
		short type,okay=FALSE,keepGoing=TRUE,val;
		Handle hndl; Rect box; Point pt;
		unsigned char *p,str[256];

		if (itemHit<1 || itemHit>=LASTITEM)
			return(keepGoing);				/* Only legal items, please */

		GetDialogItem(dlog,itemHit,&type,&hndl,&box);
		switch(type) {
			case ctrlItem+btnCtrl:
				switch(itemHit) {
					case BUT1_OK:

						//	the default is that we're done

						keepGoing = FALSE; okay = TRUE;

						//	check to see if the name that has been entered can be resolved

						{
							extern InetSvcRef	gInetService;

							Str255				theString;
							InetHostInfo		theHost;
							short				aShort;
							OSStatus			err;

							GetDlgString(dlog, EDIT5, theString);		//	machine name
							ParamText(theString, "\p", "\p", "\p");		//	show the name in the dialog
							p2cstr(theString);

							OTSetSynchronous(gInetService);
							err = OTInetStringToAddress(gInetService, theString, &theHost);
							OTSetAsynchronous(gInetService);
							if (err != noErr) {

								//	the name cannot be looked up, ask the user if they want
								//	to add the entry anyway

								aShort = CautionAlert(1501, nil);		//	returns 1 if OK to add
								if (aShort != 1) {
									keepGoing = TRUE; okay = FALSE;
								}

							}

						}

						break;
					case BUT2_Cancel:
						keepGoing = FALSE;
						break;
					}
				break;
			case ctrlItem+chkCtrl:
				break;
			case ctrlItem+radCtrl:
				break;
			case ctrlItem+resCtrl:
				break;
			case statText:
				switch(itemHit) {
					case STXT3_Host:		/* NOT Enabled */
						break;
					case STXT4_Notes:		/* NOT Enabled */
						break;
					case STXT7_Enter:		/* NOT Enabled */
						break;
					}
				break;
			case editText:
				switch(itemHit) {
					case EDIT5:
						break;
					case EDIT6:
						break;
					}
				break;
			case iconItem:
				break;
			case picItem:
				break;
			case userItem:
				break;
			}

		if (okay) keepGoing = AnyBadValues(dlog);
		return(keepGoing);
	}
Esempio n. 24
0
/*
 * Like rename() but will try to copy the file if the rename fails.
 * This is because under OS's with multiple physical volumes if the
 * source and destination are on different volumes the rename will fail
 */
int rename2(char *srcFile, char *destFile)
{
    FILE *f, *g;
#ifdef MACTC5
	int copy=-1;
#endif
    int status = 0;
    long fileLength;

#ifdef MACTC5
	copy=MoveRename(srcFile,destFile);
if (copy)
#else
#if defined(VMS) || defined(C370)
    if (rename(srcFile, destFile) != 0)
#else
    if (rename(srcFile, destFile) == -1)
#endif
#endif
    {
	/* Rename failed, try a copy */
	if (((f = fopen(srcFile, FOPRBIN)) == NULL) ||
	    ((g = fopen(destFile, FOPWBIN)) == NULL))
	    /* Can't open files */
	    return -1;

#ifdef MACTC5
		{
		FInfo finderInfo;
		c2pstr(srcFile);
		c2pstr(destFile);
		if(GetFInfo((uchar *)srcFile,0,&finderInfo)==0)
			SetFInfo((uchar *)destFile,0,&finderInfo);
		p2cstr((uchar *)srcFile);
		p2cstr((uchar *)destFile);
		}
#endif

	/* Get file length and copy it */
	fseek(f, 0L, SEEK_END);
	fileLength = ftell(f);
	rewind(f);
	status = copyfile(f, g, fileLength);
	if (write_error(g))
	    status = -1;

	/* Zap source file if the copy went OK, otherwise zap the (possibly
	   incomplete) destination file */
	if (status >= 0) {
	    wipeout(f);		/* Zap source file */
	    fclose(f);
	    remove(srcFile);
	    fclose(g);
	} else {
	    if (is_regular_file(destFile)) {
		wipeout(g);	/* Zap destination file */
		fclose(g);
		remove(destFile);
	    } else {
		fclose(g);
	    }
	    fclose(f);
	}
    }
    return status;
}
Esempio n. 25
0
int
TclLoadFile(
    Tcl_Interp *interp,		/* Used for error reporting. */
    char *fileName,		/* Name of the file containing the desired
				 * code. */
    char *sym1, char *sym2,	/* Names of two procedures to look up in
				 * the file's symbol table. */
    Tcl_PackageInitProc **proc1Ptr,
    Tcl_PackageInitProc **proc2Ptr)
				/* Where to return the addresses corresponding
				 * to sym1 and sym2. */
{
    CFragConnectionID connID;
    Ptr dummy;
    OSErr err;
    CFragSymbolClass symClass;
    FSSpec fileSpec;
    short fragFileRef, saveFileRef;
    Handle fragResource;
    UInt32 offset = 0;
    UInt32 length = kCFragGoesToEOF;
    char packageName[255];
    Str255 errName;
    
    /*
     * First thing we must do is infer the package name from the sym1
     * variable.  This is kind of dumb since the caller actually knows
     * this value, it just doesn't give it to us.
     */
    strcpy(packageName, sym1);
    *packageName = (char) tolower(*packageName);
    packageName[strlen(packageName) - 5] = NULL;
    
    err = FSpLocationFromPath(strlen(fileName), fileName, &fileSpec);
    if (err != noErr) {
	interp->result = "could not locate shared library";
	return TCL_ERROR;
    }
    
    /*
     * See if this fragment has a 'cfrg' resource.  It will tell us were
     * to look for the fragment in the file.  If it doesn't exist we will
     * assume we have a ppc frag using the whole data fork.  If it does
     * exist we find the frag that matches the one we are looking for and
     * get the offset and size from the resource.
     */
    saveFileRef = CurResFile();
    SetResLoad(false);
    fragFileRef = FSpOpenResFile(&fileSpec, fsRdPerm);
    SetResLoad(true);
    if (fragFileRef != -1) {
	UseResFile(fragFileRef);
	fragResource = Get1Resource(kCFragResourceType, kCFragResourceID);
	HLock(fragResource);
	if (ResError() == noErr) {
	    CfrgItem* srcItem;
	    long itemCount, index;
	    Ptr itemStart;

	    itemCount = (*(CfrgHeaderPtrHand)fragResource)->itemCount;
	    itemStart = &(*(CfrgHeaderPtrHand)fragResource)->arrayStart;
	    for (index = 0; index < itemCount;
		 index++, itemStart += srcItem->itemSize) {
		srcItem = (CfrgItem*)itemStart;
		if (srcItem->archType != OUR_ARCH_TYPE) continue;
		if (!strncasecmp(packageName, (char *) srcItem->name + 1,
			srcItem->name[0])) {
		    offset = srcItem->codeOffset;
		    length = srcItem->codeLength;
		}
	    }
	}
	/*
	 * Close the resource file.  If the extension wants to reopen the
	 * resource fork it should use the tclMacLibrary.c file during it's
	 * construction.
	 */
	HUnlock(fragResource);
	ReleaseResource(fragResource);
	CloseResFile(fragFileRef);
	UseResFile(saveFileRef);
    }

    /*
     * Now we can attempt to load the fragement using the offset & length
     * obtained from the resource.  We don't worry about the main entry point
     * as we are going to search for specific entry points passed to us.
     */
    
    c2pstr(packageName);
    err = GetDiskFragment(&fileSpec, offset, length, (StringPtr) packageName,
	    kLoadCFrag, &connID, &dummy, errName);
    if (err != fragNoErr) {
	p2cstr(errName);
	Tcl_AppendResult(interp, "couldn't load file \"", fileName,
	    "\": ", errName, (char *) NULL);
	return TCL_ERROR;
    }
    
    c2pstr(sym1);
    err = FindSymbol(connID, (StringPtr) sym1, (Ptr *) proc1Ptr, &symClass);
    p2cstr((StringPtr) sym1);
    if (err != fragNoErr || symClass == kDataCFragSymbol) {
	interp->result =
	    "could not find Initialization routine in library";
	return TCL_ERROR;
    }

    c2pstr(sym2);
    err = FindSymbol(connID, (StringPtr) sym2, (Ptr *) proc2Ptr, &symClass);
    p2cstr((StringPtr) sym2);
    if (err != fragNoErr || symClass == kDataCFragSymbol) {
	*proc2Ptr = NULL;
    }
    
    return TCL_OK;
}
Esempio n. 26
0
//--------------------------------------------------------------------
void ofVideoGrabber::listDevices(){

	//---------------------------------
	#ifdef OF_VIDEO_CAPTURE_QUICKTIME
	//---------------------------------

		bool bNeedToInitGrabberFirst = false;

		if (!bSgInited) bNeedToInitGrabberFirst = true;

		//if we need to initialize the grabbing component then do it
		if( bNeedToInitGrabberFirst ){
			if( !qtInitSeqGrabber() ){
				return;
			}
		}

		printf("-------------------------------------");

		/*
			//input selection stuff (ie multiple webcams)
			//from http://developer.apple.com/samplecode/SGDevices/listing13.html
			//and originally http://lists.apple.com/archives/QuickTime-API/2008/Jan/msg00178.html
		*/

		SGDeviceList deviceList;
		SGGetChannelDeviceList (gVideoChannel, sgDeviceListIncludeInputs, &deviceList);
		unsigned char pascalName[256];
		unsigned char pascalNameInput[256];

		//this is our new way of enumerating devices
		//quicktime can have multiple capture 'inputs' on the same capture 'device'
		//ie the USB Video Class Video 'device' - can have multiple usb webcams attached on what QT calls 'inputs'
		//The isight for example will show up as:
		//USB Video Class Video - Built-in iSight ('input' 1 of the USB Video Class Video 'device')
		//Where as another webcam also plugged whill show up as
		//USB Video Class Video - Philips SPC 1000NC Webcam ('input' 2 of the USB Video Class Video 'device')

		//this means our the device ID we use for selection has to count both capture 'devices' and their 'inputs'
		//this needs to be the same in our init grabber method so that we select the device we ask for
		int deviceCount = 0;

		ofLog(OF_LOG_NOTICE, "listing available capture devices");
		for(int i = 0 ; i < (*deviceList)->count ; ++i)
		{
			SGDeviceName nameRec;
			nameRec = (*deviceList)->entry[i];
			SGDeviceInputList deviceInputList = nameRec.inputs;

			int numInputs = 0;
			if( deviceInputList ) numInputs = ((*deviceInputList)->count);

			memcpy(pascalName, (*deviceList)->entry[i].name, sizeof(char) * 256);

			//this means we can use the capture method
			if(nameRec.flags != sgDeviceNameFlagDeviceUnavailable){

				//if we have a capture 'device' (qt's word not mine - I would prefer 'system' ) that is ready to be used
				//we go through its inputs to list all physical devices - as there could be more than one!
				for(int j = 0; j < numInputs; j++){


					//if our 'device' has inputs we get their names here
					if( deviceInputList ){
						SGDeviceInputName inputNameRec  = (*deviceInputList)->entry[j];
						memcpy(pascalNameInput, inputNameRec.name, sizeof(char) * 256);
					}

					printf( "device[%i] %s - %s",  deviceCount, p2cstr(pascalName), p2cstr(pascalNameInput) );

					//we count this way as we need to be able to distinguish multiple inputs as devices
					deviceCount++;
				}

			}else{
				printf( "(unavailable) device[%i] %s",  deviceCount, p2cstr(pascalName) );
				deviceCount++;
			}
		}
		printf( "-------------------------------------");

		//if we initialized the grabbing component then close it
		if( bNeedToInitGrabberFirst ){
			qtCloseSeqGrabber();
		}

	//---------------------------------
	#endif
	//---------------------------------


	//---------------------------------
	#ifdef OF_VIDEO_CAPTURE_DIRECTSHOW
	//---------------------------------
		ofLog(OF_LOG_NOTICE, "---");
		VI.listDevices();
		ofLog(OF_LOG_NOTICE, "---");

	//---------------------------------
	#endif
	//---------------------------------


	//---------------------------------
	#ifdef OF_VIDEO_CAPTURE_UNICAP
	//--------------------------------


		ucGrabber.listUCDevices();

	//---------------------------------
	#endif
	//---------------------------------

	//---------------------------------
	#ifdef OF_VIDEO_CAPTURE_GSTREAMER
	//--------------------------------


		gstUtils.listDevices();

	//---------------------------------
	#endif
	//---------------------------------

	//---------------------------------
	#ifdef OF_VIDEO_CAPTURE_V4L
	//--------------------------------

	struct stat st;

	printf( "listing available capture devices");
	printf( "---");
	for (int i = 0; i < 8; i++)
	{
		sprintf(dev_name, "/dev/video%i", i);
		if (stat (dev_name, &st) == 0) {
			printf( "Video device %i = /dev/video%i",i,i);
		} else {

		}
	}
	printf( "---");

	//---------------------------------
	#endif
	//---------------------------------

}
Esempio n. 27
0
//--------------------------------------------------------------------
bool ofVideoGrabber::qtSelectDevice(int deviceNumber, bool didWeChooseADevice){

	//note - check for memory freeing possibly needed for the all SGGetChannelDeviceList mac stuff
	// also see notes in listDevices() regarding new enunemeration method.

	//Generate a device list and enumerate
	//all devices availble to the channel
	SGDeviceList deviceList;
	SGGetChannelDeviceList(gVideoChannel, sgDeviceListIncludeInputs, &deviceList);

	unsigned char pascalName[256];
	unsigned char pascalNameInput[256];

	int numDevices = (*deviceList)->count;
	if(numDevices == 0){
		ofLog(OF_LOG_ERROR, "error: No catpure devices found");
		return false;
	}

	int deviceCount = 0;
	for(int i = 0 ; i < numDevices; ++i)
	{
		SGDeviceName nameRec;
		nameRec = (*deviceList)->entry[i];
		SGDeviceInputList deviceInputList = nameRec.inputs;

		int numInputs = 0;
		if( deviceInputList ) numInputs = ((*deviceInputList)->count);

		memcpy(pascalName, (*deviceList)->entry[i].name, sizeof(char) * 256);
		memset(pascalNameInput, 0, sizeof(char)*256);

		//this means we can use the capture method
		if(nameRec.flags != sgDeviceNameFlagDeviceUnavailable){

			//if we have a capture 'device' (qt's word not mine - I would prefer 'system' ) that is ready to be used
			//we go through its inputs to list all physical devices - as there could be more than one!
			for(int j = 0; j < numInputs; j++){

				//if our 'device' has inputs we get their names here
				if( deviceInputList ){
					SGDeviceInputName inputNameRec  = (*deviceInputList)->entry[j];
					memcpy(pascalNameInput, inputNameRec.name, sizeof(char) * 256);
				}

				//if the device number matches we try and setup the device
				//if we didn't specifiy a device then we will try all devices till one works!
				if( deviceCount == deviceNumber || !didWeChooseADevice ){
					ofLog(OF_LOG_NOTICE, "attempting to open device[%i] %s   -   %s",  deviceCount, p2cstr(pascalName), p2cstr(pascalNameInput) );

					OSErr err1 = SGSetChannelDevice(gVideoChannel, pascalName);
					OSErr err2 = SGSetChannelDeviceInput(gVideoChannel, j);

					int successLevel = 0;

					//if there were no errors then we have opened the device without issue
					if ( err1 == noErr && err2 == noErr){
						successLevel = 2;
					}
						//parameter errors are not fatal so we will try and open but will caution the user
					else if ( (err1 == paramErr || err1 == noErr) && (err2 == noErr || err2 == paramErr) ){
						successLevel = 1;
					}

					//the device is opened!
					if ( successLevel > 0 ){

						deviceName = (char *)p2cstr(pascalName);
						deviceName  += "-";
						deviceName +=  (char *)p2cstr(pascalNameInput);

						if(successLevel == 2)ofLog(OF_LOG_NOTICE, "device opened successfully");
						else ofLog(OF_LOG_WARNING, "device opened with some paramater errors - should be fine though!");

						//no need to keep searching - return that we have opened a device!
						return true;

					}else{
						//if we selected a device in particular but failed we want to go through the whole list again - starting from 0 and try any device.
						//so we return false - and try one more time without a preference
						if( didWeChooseADevice ){
							ofLog(OF_LOG_WARNING, "problems setting device[%i] %s - %s *****", deviceNumber, p2cstr(pascalName), p2cstr(pascalNameInput));
							return false;
						}else{
							ofLog(OF_LOG_WARNING, "unable to open device, trying next device");
						}
					}

				}

				//we count this way as we need to be able to distinguish multiple inputs as devices
				deviceCount++;
			}
		}else{
			//ofLog(OF_LOG_ERROR, "(unavailable) device[%i] %s",  deviceCount, p2cstr(pascalName) );
			deviceCount++;
		}
	}

	return false;
}
Esempio n. 28
0
void setupkeys( void)
{
	DialogPtr dtemp;
	Rect dBox;
	short dItem,kItem,sItem,eItem;
	Handle kbox,sbox,ebox;
	
	char *tempspot;
	
	tempspot = (char *) myNewPtr(256);
	if (tempspot == NULL)
		return; //BUGG signal error here
		
	SetUpMovableModalMenus();
	dtemp=GetNewMyDialog( SetupDLOG, NULL, kInFront, (void *)ThirdCenterDialog);

	setLastCursor(theCursors[normcurs]);
	
	GetDialogItem( dtemp, killbox, &kItem, &kbox, &dBox);	
	GetDialogItem( dtemp, stopbox, &eItem, &ebox, &dBox);	
	GetDialogItem( dtemp, startbox, &sItem, &sbox, &dBox);	

	*tempspot = 0;
	if (screens[scrn].TELstop > 0) {
		sprintf(tempspot,"^%c",screens[scrn].TELstop^64);
		c2pstr(tempspot);									/* BYU LSC */
		SetDialogItemText( ebox , (StringPtr)tempspot);
		SelectDialogItemText( dtemp, stopbox, 0, 32767);
		}
	if (screens[scrn].TELgo > 0) {
		sprintf(tempspot,"^%c",screens[scrn].TELgo^64);
		c2pstr(tempspot);									/* BYU LSC */
		SetDialogItemText( sbox , (StringPtr)tempspot);
		SelectDialogItemText( dtemp, startbox, 0, 32767);
		}
	if (screens[scrn].TELip > 0) {
		sprintf(tempspot,"^%c",screens[scrn].TELip^64);
		c2pstr(tempspot);									/* BYU LSC */
		SetDialogItemText( kbox , (StringPtr)tempspot);
		SelectDialogItemText( dtemp, killbox, 0, 32767);
		}
	
		dItem=0;								/* initially no hits */
		while((dItem>3) || (dItem==0)) {		/* While we are in the loop */
			/*ModalDialog(DLOGwOK_CancelUPP,&dItem);*/
			movableModalDialog(DLOGwOK_CancelUPP,&dItem);

/*
*  intermediate check.  If they hit a key, put its number in the box.
*/
			GetDialogItemText( kbox, (StringPtr)tempspot);					/* BYU LSC - Get the string */
			p2cstr((StringPtr)tempspot);							/* BYU LSC */
			if (*tempspot < 32 && *tempspot > 0) {
				sprintf(tempspot,"^%c",*tempspot^64);
				c2pstr(tempspot);						/* BYU LSC */
				SetDialogItemText( kbox , (StringPtr)tempspot);				/* BYU LSC */
				SelectDialogItemText( dtemp, killbox, 0, 32767 );
				}
			GetDialogItemText( ebox, (StringPtr)tempspot);					/* BYU LSC - Get the string */
			p2cstr((StringPtr)tempspot);							/* BYU LSC */
			if (*tempspot < 32 && *tempspot > 0) {
				sprintf(tempspot,"^%c",*tempspot^64);
				c2pstr(tempspot);						/* BYU LSC */
				SetDialogItemText( ebox , (StringPtr)tempspot);				/* BYU LSC */
				SelectDialogItemText( dtemp, stopbox, 0, 32767);
				}
			GetDialogItemText( sbox, (StringPtr)tempspot);					/* BYU LSC - Get the string */
			p2cstr((StringPtr)tempspot);							/* BYU LSC */
			if (*tempspot < 32 && *tempspot > 0) {
				sprintf(tempspot,"^%c",*tempspot^64);
				c2pstr(tempspot);						/* BYU LSC */
				SetDialogItemText( sbox , (StringPtr)tempspot);				/* BYU LSC */
				SelectDialogItemText( dtemp, startbox, 0, 32767);
				}
				
			}
				
	
		if (dItem==DLOGCancel) {
			DisposeDialog( dtemp);
			ResetMenus();
			return;
			}
			
		GetDialogItemText( kbox, (StringPtr)tempspot);			/* BYU LSC - Get the string */
		p2cstr((StringPtr)tempspot);					/* BYU LSC */
		if (*tempspot != '^') 
			screens[scrn].TELip = -1;
		else
			screens[scrn].TELip = toupper(*(tempspot+1)) ^ 64;
			
		GetDialogItemText( ebox, (StringPtr)tempspot);			/* BYU LSC - Get the string */
		p2cstr((StringPtr)tempspot);					/* BYU LSC */
		if (*tempspot != '^') 
			screens[scrn].TELstop = -1;
		else
			screens[scrn].TELstop = toupper(*(tempspot+1)) ^ 64;

		GetDialogItemText( sbox, (StringPtr)tempspot);			/* BYU LSC - Get the string */
		p2cstr((StringPtr)tempspot);					/* BYU LSC */
		if (*tempspot != '^') 
			screens[scrn].TELgo = -1;
		else
			screens[scrn].TELgo = toupper(*(tempspot+1)) ^ 64;
			
	DisposeDialog( dtemp);
	ResetMenus();
	updateCursor(1);
}
//--------------------------------------------------------------------
vector<ofVideoDevice> ofQuickTimeGrabber::listDevices(){

    vector <ofVideoDevice> devices; 
    
	//---------------------------------
	#ifdef OF_VIDEO_CAPTURE_QUICKTIME
	//---------------------------------

		bool bNeedToInitGrabberFirst = false;

		if (!bSgInited) bNeedToInitGrabberFirst = true;

		//if we need to initialize the grabbing component then do it
		if( bNeedToInitGrabberFirst ){
			if( !qtInitSeqGrabber() ){
				return devices;
			}
		}

		ofLogNotice("ofQuickTimeGrabber") << "-------------------------------------";

		/*
			//input selection stuff (ie multiple webcams)
			//from http://developer.apple.com/samplecode/SGDevices/listing13.html
			//and originally http://lists.apple.com/archives/QuickTime-API/2008/Jan/msg00178.html
		*/

		SGDeviceList deviceList;
		SGGetChannelDeviceList (gVideoChannel, sgDeviceListIncludeInputs, &deviceList);
		unsigned char pascalName[64];
		unsigned char pascalNameInput[64];

		//this is our new way of enumerating devices
		//quicktime can have multiple capture 'inputs' on the same capture 'device'
		//ie the USB Video Class Video 'device' - can have multiple usb webcams attached on what QT calls 'inputs'
		//The isight for example will show up as:
		//USB Video Class Video - Built-in iSight ('input' 1 of the USB Video Class Video 'device')
		//Where as another webcam also plugged whill show up as
		//USB Video Class Video - Philips SPC 1000NC Webcam ('input' 2 of the USB Video Class Video 'device')

		//this means our the device ID we use for selection has to count both capture 'devices' and their 'inputs'
		//this needs to be the same in our init grabber method so that we select the device we ask for
		int deviceCount = 0;

		ofLogNotice("ofQuickTimeGrabber") << "listing available capture devices";
		for(int i = 0 ; i < (*deviceList)->count ; ++i)
		{
			SGDeviceName nameRec;
			nameRec = (*deviceList)->entry[i];
			SGDeviceInputList deviceInputList = nameRec.inputs;

			int numInputs = 0;
			if( deviceInputList ) numInputs = ((*deviceInputList)->count);

			memcpy(pascalName, (*deviceList)->entry[i].name, sizeof(char) * 64);

			//this means we can use the capture method
			if(nameRec.flags != sgDeviceNameFlagDeviceUnavailable){

				//if we have a capture 'device' (qt's word not mine - I would prefer 'system' ) that is ready to be used
				//we go through its inputs to list all physical devices - as there could be more than one!
				for(int j = 0; j < numInputs; j++){


					//if our 'device' has inputs we get their names here
					if( deviceInputList ){
						SGDeviceInputName inputNameRec  = (*deviceInputList)->entry[j];
						memcpy(pascalNameInput, inputNameRec.name, sizeof(char) * 64);
					}

					ofLogNotice() << "device [" << deviceCount << "] " << p2cstr(pascalName) << " - " << p2cstr(pascalNameInput);

                    ofVideoDevice vd; 
                    vd.id           = deviceCount; 
                    vd.deviceName   = p2cstr(pascalName);
                    vd.bAvailable   = true; 
                    devices.push_back(vd);
                    
					//we count this way as we need to be able to distinguish multiple inputs as devices
					deviceCount++;
				}

			}else{
				ofLogNotice("ofQuickTimeGrabber") << "(unavailable) device [" << deviceCount << "] " << p2cstr(pascalName);
                
                ofVideoDevice vd;
                vd.id           = deviceCount; 
                vd.deviceName   = p2cstr(pascalName);
                vd.bAvailable   = false; 
                devices.push_back(vd);

				deviceCount++;
			}
		}
		ofLogNotice("ofQuickTimeGrabber") << "-------------------------------------";

		//if we initialized the grabbing component then close it
		if( bNeedToInitGrabberFirst ){
			qtCloseSeqGrabber();
		}

	//---------------------------------
	#endif
	//---------------------------------

    return devices; 
}