FpresCompareNode::FpresCompareNode(FGLnode *aSupervisor, FTTpres *oldTTpres,FTTpres *newTTpres) :FGLnode(aSupervisor){ this->oldTTpres=oldTTpres; this->newTTpres=newTTpres; rNode=ZERO; gNode=ZERO; itsGLink= new FGLink; // rTree initialization FGLvarInitInfo *info= new FrTreeInitInfo(oldTTpres->f->numItems); rTree= new FrTree(itsGLink,oldTTpres->f,(FrTreeInitInfo*)info); // rTree clone initialization rClone=new FrTree(itsGLink,oldTTpres->f,(FrTreeInitInfo*)info); delete info;info=0; Str255 str; sprintf((char*)str,"rClone"); CtoPstr((char*)str); BlockMove((Ptr)str,(Ptr)rClone->itsName,7); // gTree initialization info= new FgTreeInitInfo(oldTTpres->g->numItems); gTree= new FgTree(itsGLink,oldTTpres->gCount,(FgTreeInitInfo*)info); delete info;info=0; mailPerson=rTreeMail; func=presCompareFunc; }
LVAL xsopen_resfile() { char *name; int fn; name = (char *) getstring(xlgastring()); xllastarg(); CtoPstr(name); fn = OpenResFile(name); PtoCstr(name); return((fn >= 0) ? cvfixnum((FIXTYPE) fn) : NIL); }
/* ARGSUSED */ char * get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) { static short authman_refnum = 0; char *cred, ticket[ MAX_KTXT_LEN ]; short version, ticketlen, err; Str255 svcps, instps; /* * make sure RJC's Authentication Manager 2.0 or better is available */ if ( authman_refnum == 0 && (( err = openAuthMan( &authman_refnum, &version )) != noErr || version < 2 )) { authman_refnum = 0; ld->ld_errno = LDAP_AUTH_UNKNOWN; return( NULL ); } strcpy( (char *)svcps, service ); CtoPstr( (char *)svcps ); strcpy( (char *)instps, ld->ld_defconn->lconn_krbinstance ); CtoPstr( (char *)instps ); if (( err = getV4Ticket( authman_refnum, &ticket, &ticketlen, &svcps, &instps, NULL, INFINITE_LIFETIME, 1 )) != noErr ) { ld->ld_errno = ( err == userCanceledErr ) ? LDAP_USER_CANCELLED : LDAP_INVALID_CREDENTIALS; return( NULL ); } if (( cred = malloc( ticketlen )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( NULL ); } *len = ticketlen; memcpy( cred, (char *)ticket, ticketlen ); return( cred ); }
void macSetInfo(Integer vRefNum,char * fName,OSType type,OSType creator) { FInfo finder_stuff; Str63 fileName; strncpy((char *) fileName, fName, 63); fileName[63] = '\0'; CtoPstr((char *) fileName); GetFInfo(fileName, vRefNum, &finder_stuff); finder_stuff.fdType = type; finder_stuff.fdCreator = creator; SetFInfo(fileName, vRefNum, &finder_stuff); } /*macSetInfo()*/
/* * Open a TIFF file for read/writing. */ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; Str255 pname; FInfo finfo; short fref; OSErr err; strcpy((char*) pname, name); CtoPstr((char*) pname); switch (_TIFFgetMode(mode, module)) { default: return ((TIFF*) 0); case O_RDWR | O_CREAT | O_TRUNC: if (GetFInfo(pname, 0, &finfo) == noErr) FSDelete(pname, 0); /* fall through */ case O_RDWR | O_CREAT: if ((err = GetFInfo(pname, 0, &finfo)) == fnfErr) { if (Create(pname, 0, ' ', 'TIFF') != noErr) goto badCreate; if (FSOpen(pname, 0, &fref) != noErr) goto badOpen; } else if (err == noErr) { if (FSOpen(pname, 0, &fref) != noErr) goto badOpen; } else goto badOpen; break; case O_RDONLY: case O_RDWR: if (FSOpen(pname, 0, &fref) != noErr) goto badOpen; break; } return (TIFFFdOpen((int) fref, name, mode)); badCreate: TIFFError(module, "%s: Cannot create", name); return ((TIFF*) 0); badOpen: TIFFError(module, "%s: Cannot open", name); return ((TIFF*) 0); }
static int SFReadHdr(FILE *file, SFSTRUCT *snd, int infoBmax) /* utility to sample the header of an opened file, at most infoBmax info byts */ { int chans,dsize,infoSize; long len; float srate; char *info; char *fname; int err,i; if(infoBmax < SFDFLTBYTS) infoBmax = SFDFLTBYTS; infoBmax = infoBmax&-4; /* round down to multiple of four */ infoSize = infoBmax; if( (fname = FindFname(file)) == NULL) return(SFerror = SFE_NOPEN); /* couldn't find a pathname for this */ CtoPstr(fname); err = MacReadHeader(fname,0,&chans,&srate,&dsize,&info,&infoSize); /* will only read into info for infoSize byts, updates infoSize to avai bts */ /* len = MacFileLen(fname,0); if(len < 0) /* couldn't read file length */ /* printf("SFRdHdr: len read failed\n"); */ len = file->len; /* cheat by using THINK_C's internal record... */ PtoCstr(fname); if(err&7) /* just bottom 3 bits critical - optional info */ return(SFerror = SFE_NSF); /* reading mac header failed */ if(infoSize < SFDFLTBYTS) infoSize = SFDFLTBYTS; /* don't rock the boat */ if(infoBmax > infoSize) infoBmax = infoSize; /* actual bts in buf */ snd->magic = SFMAGIC; snd->headBsize = sizeof(SFSTRUCT) + infoSize - SFDFLTBYTS; snd->dataBsize = len; snd->channels = chans; snd->samplingRate = srate; if(dsize == 1) snd->format = SFMT_CHAR; else if(dsize == 4) snd->format = SFMT_FLOAT; else snd->format = SFMT_SHORT; for(i=0; i<infoBmax; ++i) snd->info[i] = info[i]; return(SFerror = SFE_OK); }
void LCD_doreadpict(Lcd *x) /*read in a 'PICT' selected by the user*/ { Point wher; SFReply reply; SFTypeList myFileTypes; short numFileTypes; OSErr err; QDProcsPtr savedProcs; long longCount,myEOF,filePos; short vol,refNum; long length; Atom a; short i; GrafPort *thePort; Symbol *file; EnterCallback(); wher.h = 20; wher.v = 20; numFileTypes = 1; /*display 'PICT's*/ myFileTypes[0] = 'PICT'; if (!x->fn[0]) { SFGetFile(wher,"\p",0L,numFileTypes,myFileTypes,0L,&reply); vol=reply.vRefNum; if (reply.good) { for (i=0;i<=reply.fName[0];i++) x->fn[i]=reply.fName[i]; PtoCstr((Byte *)x->fn); file=gensym(x->fn); SETSYM(&a,file); outlet_anything (x->file_outlet,ps_pictname,1,&a); CtoPstr(x->fn); } }
static int SFWriteHdr(FILE *file, SFSTRUCT *snd, int infoBmax) /* Utility to write out header to open file infoBmax optionally limits the number of info chars to write. infoBmax = 0 => write out all bytes implied by .headBsize field infoBmax >= SFDFLTBYS => write out only infoBmax infobytes */ { int chans,dsize,infoSize; float srate; char *info; char *fname; int err,i; if(snd->magic != SFMAGIC) return(SFerror = SFE_NSF); if(infoBmax >= SFDFLTBYTS && infoBmax < SFInfoSize(snd) ) infoSize = infoBmax; else infoSize = SFInfoSize(snd); chans = snd->channels; srate = snd->samplingRate; if(snd->format == SFMT_CHAR || snd->format == SFMT_ALAW || snd->format == SFMT_ULAW) dsize = 1; else if(snd->format == SFMT_LONG || snd->format == SFMT_FLOAT) dsize = 4; else dsize = 2; /* default short */ info = snd->info; if( (fname = FindFname(file)) == NULL) return(SFerror = SFE_NOPEN); /* couldn't find a pathname for this */ CtoPstr(fname); err=MacAddHeader(fname,0/*vref*/,chans,srate,dsize,info,infoSize); MacSetCreator(fname,0/*vref*/); /* make an Sd2 file */ PtoCstr(fname); if(err) return(SFerror = SFE_WRERR); else return(SFerror = SFE_OK); }
int SFRdXInfo(FILE *file, SFSTRUCT *psnd, int done) /* fetch any extra info bytes needed in view of read header Passes open file handle, existing sound struct already read 'done' bytes; rest inferred from structure */ { int chans,dsize,infoSize; long len; float srate; char *info; char *fname; int err,i; int rem; if( (fname = FindFname(file)) == NULL) return(SFerror = SFE_NOPEN); /* couldn't find a pathname for this */ CtoPstr(fname); infoSize = SFInfoSize(psnd); /* reread whole of info */ err = MacReadHeader(fname,0,&chans,&srate,&dsize,psnd->info,&infoSize); PtoCstr(fname); if(err) return(SFerror = SFE_NOPEN); /* reading mac header failed */ else return(SFerror = SFE_OK); }
void ctopcpy(register char *p1, char *p2) { strcpy(p1, p2); CtoPstr(p1); }
char *macFindFile(char *fileName, Str255 message, Str255 defaultname, Integer readWrite, Integer ntypes, OSType * types, Integer * volume) { SFTypeList myTypes; Point p; Integer numTypes; Integer vRefNum = (volume != (Integer *) 0) ? *volume : 0; LongInt dirID; int i; WHERE("macFindFile"); if (fileName[0] == '\0') { /* Use standard file dialog box */ SetPt(&p, 82, 90); DeactivateWindow(); /*unhighlight front window*/ if (readWrite == WRITEIT) { /* write */ DialogEdit = true; NDialogButtons = 2; ButtonChars[0] = 's'; ButtonChars[1] = 'n'; SFPPutFile(p, message, defaultname, NullDialogHookPtr, &Reply, putDlgID, MyDialogFilterPtr); } /*if (readWrite == WRITEIT)*/ else {/* read */ if(ntypes == 0) { numTypes = 0; myTypes[numTypes++] = 'TEXT'; myTypes[numTypes++] = 'ttro'; if(types != (OSType *) 0) { myTypes[numTypes++] = types[0]; } } else { numTypes = (ntypes <= 4) ? ntypes : 4; /*play it safe*/ for(i = 0;i < numTypes; i++) { myTypes[i] = types[i]; } } DialogEdit = false; NDialogButtons = 2; ButtonChars[0] = 'o'; /* Open */ ButtonChars[1] = 'n'; /* Cancel */ SFPGetFile(p, message, NullFileFilterPtr, numTypes, myTypes, NullDialogHookPtr, &Reply, getDlgID, MyDialogFilterPtr); } /*if (readWrite == WRITEIT){}else{}*/ macUpdate((WindowPtr) 0); if (!Reply.good) { /* cancelled */ return (0); } vRefNum = Reply.vRefNum; if (volume != (Integer *) 0) { *volume = vRefNum; } PtoCstr((unsigned char *) Reply.fName); strcpy(FileName, (char *) Reply.fName); CtoPstr((char *) Reply.fName); fileName = FileName; } /*if (fileName[0] == '\0')*/ else if (volume != (Integer *) 0 && vRefNum == 0 && HGetVol((StringPtr) 0, &vRefNum, &dirID) == noErr) { *volume = vRefNum; } if (vRefNum != 0) { SetVol(0L, vRefNum); } return (fileName); } /*macFindFile()*/
FTT1pSubnode::FTT1pSubnode(FGLnode *aSupervisor,FTTpres *currentPres, long distinguishedRel,long timeRemaining) :FGLnode(aSupervisor){ this->currentPres=currentPres; this->distinguishedRel=distinguishedRel; this->timeRemaining=timeRemaining; // zero the member objects for proper destruction in case // of initialization failure newPres=ZERO; newPresDispose=FALSE; wordsToGLvar=ZERO; fold=ZERO; reducedFold=ZERO; grow=ZERO; CcloneGen=ZERO; presGen=ZERO; renumber=ZERO; itsGLink=ZERO; Cayley=ZERO; CayleyClone=ZERO; // the requirement that presentations locally number the free // generators from g->numItems+1 to globalSymbols->numItems // means that we don't need to search words whose generators // are in this range. Obviously no reduced word containing a // free generator can be a consequence. lettersNo=currentPres->g->numItems; if(!lettersNo){ xErr(59); } // control relatorIsConsequence=FALSE; wordsNo=0; verticesNo=-1; edgesNo=-1; foldEntryLocation=FGLink::NA; // construct Cayley, CayleyClone and their GLink itsGLink=new FGLink; // Cayley FGLvarInitInfo* info= new FCayleyInitInfo; info->rNoEntries=lettersNo; info->iNoEntries=1; Cayley= new FCayley(this,itsGLink,(FCayleyInitInfo*)info); // CayleyClone CayleyClone=new FGLvar(itsGLink,info); Str255 str; sprintf((char*)str,"CayleyClone"); CtoPstr((char*)str); BlockMove((Ptr)str,(Ptr)CayleyClone->itsName,12); delete info;info=0; // startup function mailPerson=wordsToGLvarMail; func=TT1pSubfunc; // control reentryFunc=ZERO; }
int main(int argc, Char *argv[]) { boolean canbeplotted; boolean wasplotted = false; #ifdef MAC OSErr retcode; FInfo fndrinfo; #ifdef OSX_CARBON FSRef fileRef; FSSpec fileSpec; #endif #ifdef __MWERKS__ SIOUXSetTitle("\pPHYLIP: Drawtree"); #endif argv[0] = "Drawgram"; #endif grbg = NULL; progname = argv[0]; #ifndef X_DISPLAY_MISSING nargc=1; nargv=argv; #endif init(argc, argv); emboss_getoptions("fdrawgram",argc,argv); setup_environment(argv, &canbeplotted); user_loop(&canbeplotted); if (!((previewer == winpreview || previewer == xpreview || previewer == mac) && (winaction == quitnow))) { previewing = false; initplotter(spp,fontname); numlines = dotmatrix ? ((long)floor(yunitspercm * ysize + 0.5)/strpdeep) : 1; if (plotter != ibm) printf("\nWriting plot file ...\n"); drawit(fontname,&xoffset,&yoffset,numlines,root); finishplotter(); FClose(plotfile); wasplotted = true; printf("\nPlot written to file \"%s\"\n\n", pltfilename); } FClose(intree); #ifdef MAC if (plotter == pict && wasplotted){ #ifdef OSX_CARBON FSPathMakeRef((unsigned char *)pltfilename, &fileRef, NULL); FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL); FSpGetFInfo(&fileSpec, &fndrinfo); fndrinfo.fdType='PICT'; fndrinfo.fdCreator='MDRW'; FSpSetFInfo(&fileSpec, &fndrinfo); #else retcode=GetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); fndrinfo.fdType='PICT'; fndrinfo.fdCreator='MDRW'; retcode=SetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); #endif } if (plotter == lw && wasplotted){ #ifdef OSX_CARBON FSPathMakeRef((unsigned char *)pltfilename, &fileRef, NULL); FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, NULL); FSpGetFInfo(&fileSpec, &fndrinfo); fndrinfo.fdType='TEXT'; FSpSetFInfo(&fileSpec, &fndrinfo); #else retcode=GetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); fndrinfo.fdType='TEXT'; retcode=SetFInfo(CtoPstr(PLOTFILE),0,&fndrinfo); #endif } #endif printf("Done.\n\n"); #ifdef WIN32 phyRestoreConsoleAttributes(); #endif embExit(); return 0; }