Пример #1
0
void loadMacros(NewMacroInfo *macrost, FSSpec *theFile)
{
	SFReply		sfr;
	long		junk;
	SFTypeList	typesok = {'TEXT'};
	Point		where;
	FSSpec		macros;
	OSErr 		err;
	short 		fileRef;
	where.h=100;where.v=100;
	if (theFile == 0L)
	{
		SFGetFile( where, NULL, 0L, 1, typesok, 0L, &sfr);
		if (!sfr.good) return;
		BlockMoveData(&sfr.fName, macros.name, (*sfr.fName)+1); 
		GetWDInfo(sfr.vRefNum, &macros.vRefNum, &macros.parID, &junk);
		err = HOpenDF(macros.vRefNum, macros.parID, macros.name, fsRdPerm, &fileRef);
	}
	else
		err = HOpenDF(theFile->vRefNum, theFile->parID, theFile->name, fsRdPerm, &fileRef);
	
	if (err != noErr)
		return;
	parseMacroFile(macrost, fileRef);
	FSClose(fileRef);
}
Пример #2
0
void oldsaveMacros(FSSpec *theFile)
{
	SFReply		whereReply;
	short 		refNum,exist;
	FSSpec		macroFile;
	long		junk;
	short 		i;
	char		temp[256], temp2[256];
	Point		where;
	OSErr		err;
	Str255		tempString,tempString2;

	where.h = 100; where.v = 100;

	GetIndString(tempString,MISC_STRINGS,SAVE_MACROS_STRING);
	GetIndString(tempString2,MISC_STRINGS,DEFAULT_MACRO_SET_NAME);

	if (theFile == 0) {
		SFPutFile( where, tempString, tempString2, 0L, &whereReply);

		if (!whereReply.good)
			return;

		BlockMoveData(&whereReply.fName, macroFile.name, (*whereReply.fName)+1); 
		GetWDInfo(whereReply.vRefNum, &macroFile.vRefNum, &macroFile.parID, &junk);
	}
	else
		macroFile = *theFile;

	if ((err = HCreate(macroFile.vRefNum, macroFile.parID, 
			macroFile.name, kNCSACreatorSignature, 'TEXT')) == dupFNErr)
		exist = 1;
	
	err = HOpenDF(macroFile.vRefNum, macroFile.parID, macroFile.name, fsWrPerm, &refNum);

	if (exist) 
		SetEOF(refNum, 0L);

	
	for (i = 0; i < 10; i++)
	{
		oldgetmacro(i, temp, sizeof(temp), 1);
		sprintf(temp2, "key%d = \"", i);
		CStringToFile(refNum,(unsigned char *) temp2);
		if (*temp)
		{
			CStringToFile(refNum,(unsigned char *) temp);
		}
		strcpy(temp2,"\"\015");
		CStringToFile(refNum,(unsigned char *) temp2);

	}
	FSClose(refNum);

}
Пример #3
0
FILE *
fopen_mac ( short vRefNum , long parID , char * fileName , char * mode,
                                                char action )
{
        short oldVol ;
        short aVol ;
        long aDir , aProc ;
        FILE * ret = NULL ;

        /* change to the proper disk and directory */
  if ( GetVol ( NULL , & oldVol ) ) {
     return NULL ;
  }
  if ( GetWDInfo ( oldVol , & aVol , & aDir , & aProc ) ) {
     return NULL  ;
  }
  if ( HSetVol ( NULL , vRefNum , parID ) ) {
     return NULL ;
  }
                if( action == MAC_FOPEN_OPEN_CD || action == MAC_FOPEN_OPEN_NOCD ){
            ret = fopen ( fileName , mode ) ;
           } else{
            ret = 0;
           }

                /* this doesn't seem to work the way I want it to... */
    if( action == MAC_FOPEN_OPEN_NOCD || action == MAC_FOPEN_NOOPEN_NOCD ){
             if ( HSetVol ( NULL, aVol , aDir ) ) {
                /* an error we can't currently handle */
            }
            if ( SetVol ( NULL, oldVol ) ) {
        /* an error we can't currently handle */
            }
    }
    return ret ;
}
Пример #4
0
void saveMacros(NewMacroInfo *macrost, FSSpec *theFile)
{
	SFReply		whereReply;
	short 		refNum,exist;
	FSSpec		macroFile;
	long		junk, len, len2;
	short 		i;
	Point		where;
	OSErr		err;
	Str255		tempString,tempString2;
	Handle		macroHandle;
	Ptr			pos;

	if (!macrost->handle) return; // sanity check

	where.h = 100; where.v = 100;

	GetIndString(tempString,MISC_STRINGS,SAVE_MACROS_STRING);
	GetIndString(tempString2,MISC_STRINGS,DEFAULT_MACRO_SET_NAME);

	if (theFile == 0) {
		SFPutFile( where, tempString, tempString2, 0L, &whereReply);

		if (!whereReply.good)
			return;

		BlockMoveData(&whereReply.fName, macroFile.name, (*whereReply.fName)+1); 
		GetWDInfo(whereReply.vRefNum, &macroFile.vRefNum, &macroFile.parID, &junk);
	}
	else
		macroFile = *theFile;

	if ((err = HCreate(macroFile.vRefNum, macroFile.parID, 
			macroFile.name, kNCSACreatorSignature, 'TEXT')) == dupFNErr)
		exist = 1;
	
	err = HOpenDF(macroFile.vRefNum, macroFile.parID, macroFile.name, fsWrPerm, &refNum);

	if (exist) 
		SetEOF(refNum, 0L);

// the new code - RAB BetterTelnet 2.0b5
	macroHandle = macrost->handle;
	HandToHand(&macroHandle);
	HLock(macroHandle);
	pos = *macroHandle;
	len = len2 = GetHandleSize(macroHandle);
	while (len) {
		if (*pos == 0) *pos = 13;
		pos++;
		len--;
	}

	pos = *macroHandle;
	junk = 2;
	FSWrite(refNum, &junk, "!\015");
	FSWrite(refNum, &len2, pos);
	DisposeHandle(macroHandle); // it's a copy anyway, get rid of it!

	FSClose(refNum);
}