Esempio n. 1
0
File: ugView.c Progetto: rolk/ug
static void PICTCommand (void)
{
  OSErr error ;
  SFReply reply ;
  Point wher ;
  char buffer1[32],buffer2[128];
  char *s;

  if (globalState!=OPENED) return;

  /* get file name */
  wher.v = 40 ;
  wher.h = 40 ;
  strcpy(buffer1,"Name of Pict-File :");
  strcpy(buffer2,fileName);
  if ((s=strstr(buffer2,".meta"))!=NULL)
    *s = '\0';
  strcat(buffer2,".pict");
  SFPutFile ( wher, c2pstr(buffer1), c2pstr(buffer2), NULL, &reply ) ;
  if (!reply.good) return;

  error = Create ( reply.fName, reply.vRefNum, *((OSType *)"DAD2"), *((OSType *)"PICT") ) ;
  if ((error!=noErr) && (error!=dupFNErr))
  {
    OneButtonBox("Could not create file","OK");
    return;
  }

  SaveToPICT(&reply);
  return;
}
Esempio n. 2
0
void mac_cleanup_tmpf(void)
{
	int i,err;
    HFileParam pb;
    char fname[256];
	for (i = 0; i < MAXTMPF; ++i)
		if (tmpf[i].flags)
	       {
	        strcpy(fname,tmpf[i].path);
	        pb.ioCompletion=nil;
	        c2pstr(fname);
	        pb.ioNamePtr=(uchar *)fname;
	        pb.ioVRefNum=0;
	        pb.ioFDirIndex=0;
	        pb.ioFRefNum=0;
	        pb.ioDirID=0;
	        err=PBHGetFInfo((HParmBlkPtr)&pb,false);
	        if (pb.ioFRefNum!=0){
	            strcpy(fname,tmpf[i].path);
	            pb.ioCompletion=nil;
	            c2pstr(fname);
	            pb.ioNamePtr=(uchar *)fname;
	            pb.ioVRefNum=0;
	            pb.ioDirID=0;
	            err=PBClose((ParmBlkPtr)&pb,false);
	            }
			rmtemp(tmpf[i].path);
			}
}	/* mac_cleanup_tmpf */
Esempio n. 3
0
File: ugView.c Progetto: rolk/ug
static int OneButtonBox (char *text, char *button1)
{
  DialogPtr theDialog;
  short itemHit,itemType;
  Handle item;
  Rect box;
  char buffer[256];

  theDialog = GetNewDialog(oneButtonDialog,NULL,(WindowPtr) -1);

  /* draw OK Button */
  GetDialogItem(theDialog,OKButton,&itemType,&item,&box);
  SetPort((GrafPtr) theDialog);
  PenSize(3,3);
  InsetRect(&box,-4,-4);
  FrameRoundRect(&box,16,16);

  /* change text of button 1 */
  strcpy(buffer,button1);
  SetControlTitle((ControlHandle) item,c2pstr(buffer));

  GetDialogItem(theDialog,2,&itemType,&item,&box);
  strcpy(buffer,text);
  SetDialogItemText(item,c2pstr(buffer));
  itemHit=0;
  while (itemHit!=OKButton)
  {
    ModalDialog(NULL,&itemHit);
  }
  DisposeDialog(theDialog);
  return(itemHit);
}
Esempio n. 4
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. 5
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. 6
0
void *wxDynamicLibrary::DoGetSymbol(const wxString &name, bool *success) const
{
    wxCHECK_MSG( IsLoaded(), NULL,
                 _T("Can't load symbol from unloaded library") );

    void    *symbol = 0;

    wxUnusedVar(symbol);
#if defined(__WXMAC__) && !defined(__DARWIN__)
    Ptr                 symAddress;
    CFragSymbolClass    symClass;
    Str255              symName;
#if TARGET_CARBON
    c2pstrcpy( (StringPtr) symName, name.fn_str() );
#else
    strcpy( (char *)symName, name.fn_str() );
    c2pstr( (char *)symName );
#endif
    if( FindSymbol( m_handle, symName, &symAddress, &symClass ) == noErr )
        symbol = (void *)symAddress;
#elif defined(__WXPM__) || defined(__EMX__)
    DosQueryProcAddr( m_handle, 1L, (PSZ)name.c_str(), (PFN*)symbol );
#else
    symbol = RawGetSymbol(m_handle, name);
#endif

    if ( success )
        *success = symbol != NULL;

    return symbol;
}
Esempio n. 7
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. 8
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. 9
0
short PGFAlert(char *inCStr, short allowCancel)
{
#ifdef	PGP_MACINTOSH
	DialogPtr pfAlert;
	GrafPtr savePort;
	short result=0, i;
	Str255 s;
	
	GetPort(&savePort);
	strcpy((char *)s, inCStr);
	c2pstr((char *)s);
	if((pfAlert = GetNewDialog(130,nil,(WindowPtr)-1L)) != NULL)
	{
		SetPort(pfAlert);
		ParamText((uchar *)s,"\p","\p","\p");
		if(!allowCancel)
			HideDialogItem(pfAlert,2);
		SetDialogCancelItem(pfAlert, 2);
		SetDialogDefaultItem(pfAlert, 1);
		ShowWindow(pfAlert);
		SysBeep(30);
		ModalDialog(nil, &i);
		DisposeDialog(pfAlert);
		result = (i==1);
	}
Esempio n. 10
0
//#  include <stldebug.h>
void STLPORT::__stl_debug_message(const char * format_str, ...)
{
  std::va_list args;
  va_start( args, format_str );
  char msg[256];
  std::vsnprintf(msg, sizeof(msg)/sizeof(*msg) - 1, format_str, args );
  DebugStr( c2pstr(msg) );
}
Esempio n. 11
0
ImportFileHandle *QTImportPlugin::Open(wxString Filename)
{
   FSSpec inFile;
   FInfo fileInfo;
   Movie theMovie = 0;
   Media theMedia;

   // Make sure QuickTime is initialized
   //::EnterMovies();

#ifdef WIN32
   char* specFilename = strdup(Filename.GetData());
   if (FSMakeFSSpec(0,0,c2pstr(specFilename), &inFile) != noErr)
   {
       free(specFilename);
       return false;
   }
   free(specFilename);
#else
   wxMacFilename2FSSpec(Filename, &inFile);
#endif

   OSErr err = FSpGetFInfo(&inFile, &fileInfo);

   if(err != noErr)
      return NULL;

   if (kQTFileTypeSystemSevenSound == fileInfo.fdType)
   {
      // TODO: handle this case.  it is special because system seven sounds cannot
      // be opened in place
   }
   else
   {
      short theRefNum;
      short theResID = 0;  // we want the first movie
      Boolean wasChanged;

      // open the movie file
      err = OpenMovieFile(&inFile, &theRefNum, fsRdPerm);
      if(err != noErr)
         return NULL;

      // instantiate the movie
      err = NewMovieFromFile(&theMovie, theRefNum, &theResID, NULL, newMovieActive, &wasChanged);
      CloseMovieFile(theRefNum);
      if(err != noErr)
         return NULL;
   }


   // get and return the sound track media
   theMedia = GetMediaFromMovie(theMovie);
   if(theMedia == NULL)
      return NULL;

   return new QTImportFileHandle(theMovie, theMedia);
}
Esempio n. 12
0
const char *autotype_via_mactype(const char *file) 
{
    OSErr err;
    CInfoPBRec CPB;
    HFileParam hfp;
    char *d, kind[10], buf[MAXPATHLEN];
    short vRef = 0;
    long dirID = 0;
    

    if (!file) return nil;
    strcpy(buf, file);	/* thou shalt not poke thy caller's buffer */
    err = GetPathRef(buf, &vRef, &dirID); /* GetPathRef does c2p */
    c2pstr(buf);
    CPB.hFileInfo.ioNamePtr = buf;
    CPB.hFileInfo.ioDirID = 0;
    CPB.hFileInfo.ioVRefNum = 0;
    CPB.hFileInfo.ioFDirIndex = 0;
    switch (PBGetCatInfo (&CPB, 0)) {
	case noErr: break;
	case fnfErr:
	    CPB.hFileInfo.ioDirID = 0;
	    CPB.hFileInfo.ioVRefNum = vRef; 
	    err = PBGetCatInfo (&CPB, 0);
	    break;
	default:
	    return nil;
    }
    hfp.ioCompletion = nil;
    hfp.ioNamePtr = buf;
    hfp.ioVRefNum = CPB.hFileInfo.ioVRefNum;
    hfp.ioFDirIndex = 0;
    hfp.ioDirID = CPB.hFileInfo.ioDirID;
    if (err = PBHGetFInfo((HParmBlkPtr) &hfp, FALSE)) {
	print(catgets(catalog, CAT_MSGS, 1013, "autotyper:  couldn't read attachment file information"));
	return nil;
    }

    /* creator default is Z-Mail sig */
    d = (char *) kind;
    *((long *)(d)) =  CPB.hFileInfo.ioFlFndrInfo.fdType;
    kind[4] = '/';
    d += 5;
    *((long *)(d)) = CPB.hFileInfo.ioFlFndrInfo.fdCreator;
    kind[9] = 0;
    if (!type_mactypes)
        (void) get_attach_keys(0, (Attach *)0, NULL);
    d = get_type_from_mactype((char *)kind);    
    if (!strcmp(d, kind))
    	d = nil;
    if (!d && hfp.ioFlRLgLen)
	d = "application/mac-binhex40";

    return d;

} /* autotype_via_mactype */
Esempio n. 13
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. 14
0
static void CreateAMovie (void)
{
	Point where = {100,100};
	SFReply theSFReply;

	Movie theMovie = nil;
	FSSpec mySpec;
	short resRefNum = 0;
	short resId = movieInDataForkResID;
	OSErr err = noErr;

		SFPutFile (where, c2pstr(kPrompt), 
					c2pstr(kMovieFileName), nil, &theSFReply);
		if (!theSFReply.good) return; 

		FSMakeFSSpec(theSFReply.vRefNum, 0, theSFReply.fName, &mySpec);


		err = CreateMovieFile (&mySpec, 
							kMyCreatorType,
							smCurrentScript, 
							createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
							&resRefNum, 
							&theMovie );
		CheckError(err, "CreateMovieFile error");

		QTVideo_CreateMyVideoTrack (theMovie);
		QTSound_CreateMySoundTrack (theMovie);


		err = AddMovieResource (theMovie, resRefNum, &resId,
		 						theSFReply.fName);
		CheckError(err, "AddMovieResource error");

		if (resRefNum)

		{

			CloseMovieFile (resRefNum);

		}
		DisposeMovie (theMovie);
} 
Esempio n. 15
0
void main(
	int argc,
	char **argv)
{
	if (argc<=1)
	{
		fprintf(stderr, "Usage: %s <original> <new> <patchname>\n", argv[0]);
		exit(1);
	}
	else
	{
		FSSpec original, new, delta;
		OSErr error;
		
		strcpy(temporary, argv[1]);
		c2pstr(temporary);
		/* Boot drive, desktop.. */
		error= FSMakeFSSpec(0, 0, temporary, &original);
		if(!error)
		{
			strcpy(temporary, argv[2]);
			c2pstr(temporary);
			
			/* Boot drive, desktop.. */
			error= FSMakeFSSpec(0, 0, temporary, &new);
			if(!error)
			{
				strcpy(temporary, argv[3]);
				c2pstr(temporary);
				
				/* Boot drive, desktop.. */
				error= FSMakeFSSpec(0, 0, temporary, &delta);
				if(!error || error==fnfErr)
				{
					if(!create_delta_wad_file((FileDesc *)&original, (FileDesc *)&new, (FileDesc *)&delta, PATCH_FILE_TYPE))
					{
						fprintf(stderr, "Unable to create delta wad.", argv[0], argv[1], error);
						exit(1);
					}
				}
			}
			else
			{
Esempio n. 16
0
File: ugView.c Progetto: rolk/ug
static int CreateApplicationWindow (AWindowRecord *wr, char *fname, short h, short v, short dh, short dv)
{
  Rect r;
  GrafPtr myPort;
  PaletteHandle myPalette;
  char name[80];

  /* init AWindowRecord */
  wr->theWindow = (WindowPtr) wr;

  /* read in resources */
  if (GetNewCWindow(appWinId,(Ptr)wr,(WindowPtr) -1)==NULL)
  {
    return(1);
  }
  myPalette = GetNewPalette(defaultPaletteId);
  SetPalette(wr->theWindow,myPalette,false);

  /* move and size window */
  myPort = (GrafPtr) wr->theWindow;
  SetPort(myPort);
  MoveWindow(wr->theWindow,h,v,false);
  SizeWindow(wr->theWindow,dh+15,dv+15,false);
  strcpy(name,fname);
  SetWTitle(wr->theWindow,c2pstr(name));
  ShowWindow(wr->theWindow);
  SelectWindow(wr->theWindow);
  DrawGrowIcon(wr->theWindow);
  r = myPort->portRect;

  TextFont(kFontIDMonaco);

  /* get the scroll bars */
  wr->vScrollBar = GetNewControl(vScrollBarId,wr->theWindow);
  wr->hScrollBar = GetNewControl(hScrollBarId,wr->theWindow);

  /* set correct size of the scroll bars */
  MoveControl(wr->vScrollBar,r.right-15,-1);
  SizeControl(wr->vScrollBar,16,r.bottom-13);
  SetControlMinimum(wr->vScrollBar,0);
  SetControlMaximum(wr->vScrollBar,0);
  SetControlValue(wr->vScrollBar,0);
  ShowControl(wr->vScrollBar);
  MoveControl(wr->hScrollBar,-1,r.bottom-15);
  SizeControl(wr->hScrollBar,r.right-13,16);
  SetControlMinimum(wr->hScrollBar,0);
  SetControlMaximum(wr->hScrollBar,0);
  SetControlValue(wr->hScrollBar,0);
  ShowControl(wr->hScrollBar);
  DrawControls(wr->theWindow);

  SetRect(&(wr->usableRect),0,0,dh,dv);

  return(0);
}
Esempio n. 17
0
OSErr TotalHack(CFragConnectionID connID)
{
	Handle				theStrings;
	CMBufferSizes		bufSizes;
	short					procID;
	Str255				toolName;
	OSErr					error;
	FSSpec				where;
	short					ref;
	char*					end;
	Ptr					tempString;
	char*					here;
	short					baud;
	Boolean				prefsChanged = false;
	THz					myZone;
	ser_t*				storage;
	gConnection = nil;

	// get a Connection Tool name
	strcpy((char *)toolName, "Apple Modem Tool");						// so try to use the Apple modem tool
	c2pstr((char *)toolName);
	end = (char *)(toolName + toolName[0] + 1);
	memset(end, '\0', 255 - toolName[0]);
	// init the CMBufferSizes variable so that Tool will init with defaults

	bufSizes[cmDataIn] = 0;
	bufSizes[cmDataOut] = 0;
	bufSizes[cmCntlIn] = 0;
	bufSizes[cmCntlOut] = 0;
	bufSizes[cmAttnIn] = 0;
	bufSizes[cmAttnOut] = 0;
	bufSizes[cmRsrvIn] = 0;
	bufSizes[cmRsrvOut] = 0;

	error = noErr;
	myZone = GetZone();
	SetZone(SystemZone());
	// get a process ID for the tool
	procID = CMGetProcID(toolName);
	if (procID == -1) {
		error = -2;
	}

	// now get a conn record set up
	if (error == noErr) {
		gConnection = CMNew(procID, cmData|cmNoMenus|cmQuiet, bufSizes, 0, 0);
		if (gConnection != nil) {
			storage = (ser_t*)NewPtrClear(sizeof(ser_t));
			storage->sConnection = gConnection;
			error = SetData(connID, (unsigned long)storage);
		}
	}

	return error;
}
Esempio n. 18
0
 void __assertion_failed(char *condition, char *testfilename, int lineno)
 {
     char msg[256];
     std::strncpy( msg, condition, 255 );
     std::strncat( msg, ": ", 255 );
     std::strncat(  msg, testfilename, 255 );
     std::strncat( msg, ", ", 255 );
     char line[20];
     std::sprintf( line, "%d", lineno );
     std::strncat(  msg, line, 255 );
     DebugStr( c2pstr( msg ) );
 }
Esempio n. 19
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. 20
0
short ModalMacros(NewMacroInfo *macrost)
{
	DialogPtr dtemp;
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	SetUpMovableModalMenus();
	dtemp=GetNewMyDialog( MacroDLOG + 2, NULL, kInFront, (void *)ThirdCenterDialog);
	SetDialogDefaultItem(dtemp, 1);
	SetDialogCancelItem(dtemp, 2);
	SetDialogTracksCursor(dtemp, 1);
	HideDialogItem(dtemp, 25); // no save default in session macros dialog

	dialogPane = 0; // start with Command-[0-9]

	// RAB BetterTelnet 2.0b5 - fix cancel button so it works again
	oldMacros = macrost->handle;
	HandToHand(&oldMacros);
	oldMacroIndexes = *macrost;

	// 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, (char *) &temp, 256); /* BYU LSC */
		c2pstr((char *)temp);								/* BYU LSC */
		GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
		SetDialogItemText( MacString[i], temp );
		}

	TelInfo->macrosModeless = dtemp;

	dItem = 0;
	while ((dItem != 1) && (dItem != 2)) {
		movableModalDialog(0, &dItem);
		MacroDialog(macrost, dtemp, 0, dItem);
	}

	if (dItem == 2) CancelMacros(macrost, dtemp);
	else CloseMacros(macrost, dtemp);
	ResetMenus();
	return dItem;
}
Esempio n. 21
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. 22
0
uint1 MCScreenDC::fontnametocharset(const char *oldfontname)
{
	// MW-2006-06-09: [[ Bug 3670 ]] Fixed length buffer can cause a crash
	char fname[256];
	strncpy(fname, oldfontname, 255);
	fname[255] = '\0';
	
	char *sptr = fname;
	if ((sptr = strchr(fname, ',')) != NULL)
		*sptr = '\0';
	short ffamilyid;		    //font family ID
	StringPtr reqnamePascal = c2pstr(fname);
	GetFNum(reqnamePascal, &ffamilyid);
	return MCS_langidtocharset(FontToScript(ffamilyid));
}
Esempio n. 23
0
File: chdir.c Progetto: aosm/emacs
int chdir(const char *path)
{
  WDPBRec wdpb;

  Str255 mypath;
  OSErr error;

  strcpy(mypath, path);
  c2pstr(mypath);

  wdpb.ioNamePtr = mypath;
  wdpb.ioVRefNum = 0;
  wdpb.ioWDDirID = 0;
  error = PBHSetVolSync(&wdpb);

  return error == noErr ? 0 : -1;
}
Esempio n. 24
0
void	Macros( void)
{
	DialogPtr dtemp;
	short dItem;
	short i;
	Rect dBox;
	Str255 temp;
	Handle MacString[10], rubbish;

	setLastCursor(theCursors[normcurs]);

	if (TelInfo->macrosModeless) {
		SelectWindow(TelInfo->macrosModeless);
		return;
	}

	dtemp=GetNewMyDialog( MacroDLOG, NULL, kInFront, (void *)ThirdCenterDialog);
	SetDialogDefaultItem(dtemp, 1);
	SetDialogCancelItem(dtemp, 2);
	SetDialogTracksCursor(dtemp, 1);

	dialogPane = 0; // start with Command-[0-9]

	// RAB BetterTelnet 2.0b5 - fix cancel button so it works again
	oldMacros = TelInfo->newMacros.handle;
	HandToHand(&oldMacros);
	oldMacroIndexes = TelInfo->newMacros;

	// 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(&TelInfo->newMacros, i, (char *) &temp, 256); /* BYU LSC */
		c2pstr((char *)temp);								/* BYU LSC */
		GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
		SetDialogItemText( MacString[i], temp );
		}
	TelInfo->macrosModeless = dtemp;
}
Esempio n. 25
0
void attach_new_endpoint_to_application(
	struct endpoint_data *endpoint,
	char *title,
	NMBoolean system_time)
{
	static long startLeft = 100;
	static long startTop = 100;
	
	WindowPtr wp;
	char window_title[128];
	
	if(system_time)
	{
		Rect boundsRect;
		boundsRect.left = startLeft;
		startLeft += 32;
		boundsRect.right = boundsRect.left + 500;
		boundsRect.top = startTop;
		startTop += 32;
		boundsRect.bottom = boundsRect.top + 300;
		wp = NewCWindow(nil,&boundsRect,"\pWindow", true, noGrowDocProc,(WindowPtr)-1,false,0);
		//wp = NewCWind(
		//wp= GetNewWindow(winDOCUMENT, NULL, (WindowPtr) -1l);
		op_assert(wp);
		
		//add a close box
		//FIXME: i forgot how to do this on classic =)
#ifdef OP_PLATFORM_MAC_CARBON_FLAG
			ChangeWindowAttributes(wp,kWindowCloseBoxAttribute,0);
		#endif
		
		if(wp)
		{
			SetWRefCon(wp, (long) endpoint);

			strcpy(window_title, title);
			c2pstr(window_title);
			SetWTitle(wp, (const unsigned char *) window_title);
			ShowWindow(wp);
		
			new_log(wp);
		}
	} else {
/*
	DoGraphicsImport
*/
BOOL DoGraphicsImport(PINFO pInfo)
{
	long	err;

	// Get the graphics importer component
	c2pstr(pInfo->spec.name);
	err = GetGraphicsImporterForFile(&pInfo->spec, &pInfo->gi);
	
	if (err) 
		goto bail;

	// Get the pixel bounds of this image
	err = GraphicsImportGetNaturalBounds(pInfo->gi, &pInfo->imageRect);

bail:
	if (err)
		return FALSE;
	else
		return TRUE;
}
Esempio n. 27
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. 28
0
/* showNetNumbers	- Show the current network numbers. */
void showNetNumbers( void)
{
	char		tmpout[256];			/* IP Number */

	DialogPtr	dptr;				/* dialog box pointer */
	short		scratchshort;
	int			tmp[4];				/* Integer copy of IP Number */
	unsigned char tmp2[4];

	if (TelInfo->ipModeless) {
		SelectWindow(TelInfo->ipModeless);
		return;
	}

	Mnetinit();						// RAB BetterTelnet 1.0fc4
	netgetip(tmp2);
	for(scratchshort=0; scratchshort<4; scratchshort++)
			tmp[scratchshort] = (int)tmp2[scratchshort];		/* Get integer numbers */

	sprintf(&tmpout[0],"IP Address:\r%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]);
										/* create Human-readable numbers */


	c2pstr(tmpout);									/* BYU LSC */

//	RAB BetterTelnet 1.2 - we can't use ParamText() for modeless dialogs
//	ParamText(0L, (StringPtr)tmpout,0L,0L);				/* BYU LSC - Put Parms in Dlog */

	dptr = GetNewDialog(MyIPDLOG, NULL, kInFront);
	SetTEText(dptr, 1, (unsigned char *)tmpout);
	DrawDialog(dptr);							/* Display Dialog */
	TelInfo->ipModeless = dptr;

//	ModalDialog(NULL, &scratchshort);			/* Wait for a click */

//	DisposeDialog(dptr);
//	Alert(MyIPDLOG, 0L);
	AdjustMenus();
	DoTheMenuChecks();
}
Esempio n. 29
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. 30
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 */
				}
		}

}