Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:44:54 UTC

view on githubraw file Latest commit ec6cf3b0 on 2003-08-26 20:45:25 UTC
ec6cf3b09d Ed H*0001 /* macnfile.c -- standard file operations for nifty application library
                0002  */
                0003 /* (C) Copyright 1995 by Carnegie Mellon University
                0004  * All Rights Reserved.
                0005  *
                0006  * Permission to use, copy, modify, distribute, and sell this software
                0007  * and its documentation for any purpose is hereby granted without
                0008  * fee, provided that the above copyright notice appear in all copies
                0009  * and that both that copyright notice and this permission notice
                0010  * appear in supporting documentation, and that the name of Carnegie
                0011  * Mellon University not be used in advertising or publicity
                0012  * pertaining to distribution of the software without specific,
                0013  * written prior permission.  Carnegie Mellon University makes no
                0014  * representations about the suitability of this software for any
                0015  * purpose.  It is provided "as is" without express or implied
                0016  * warranty.
                0017  *
                0018  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
                0019  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
                0020  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
                0021  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                0022  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
                0023  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
                0024  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
                0025  * SOFTWARE.
                0026  */
                0027 /* (C) Copyright 1990-1995 by Christopher J. Newman
                0028  * All Rights Reserved.
                0029  *
                0030  * Permission to use, copy, modify, distribute, and sell this software and its
                0031  * documentation for any purpose is hereby granted without fee, provided that
                0032  * the above copyright notice appear in all copies and that both that
                0033  * copyright notice and this permission notice appear in supporting
                0034  * documentation, and that the name of Christopher J. Newman not be used in
                0035  * advertising or publicity pertaining to distribution of the software without
                0036  * specific, written prior permission.  Christopher J. Newman makes no
                0037  * representations about the suitability of this software for any purpose.  It
                0038  * is provided "as is" without express or implied warranty.
                0039  *
                0040  * CHRISTOPHER J. NEWMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
                0041  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
                0042  * SHALL CHRISTOPHER J. NEWMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
                0043  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
                0044  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
                0045  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
                0046  * OF THIS SOFTWARE.
                0047  *
                0048  * Author:  Christopher J. Newman
                0049  * Message: This is a nifty program.
                0050  */
                0051 
                0052 #include <string.h>
                0053 #include "macnapp.h"
                0054 
                0055 /* copy SFReply to StandardFileReply
                0056  */
                0057 static void sftostd(SFReply *rep, StandardFileReply *reply)
                0058 {
                0059     long procid = 0;
                0060     
                0061     if ((reply->sfGood = rep->good) == true) {
                0062         reply->sfReplacing = false;
                0063         reply->sfType = rep->fType;
                0064         memcpy((void *) reply->sfFile.name, rep->fName, *rep->fName + 1);
                0065         reply->sfFile.parID = 0;
                0066         reply->sfFile.vRefNum = rep->vRefNum;
                0067         GetWDInfo(rep->vRefNum, &reply->sfFile.vRefNum, &reply->sfFile.parID, &procid);
                0068     }
                0069 }
                0070 
                0071 /* get a file to save
                0072  */
                0073 void NAputFile(Str255 prompt, Str255 initfname, StandardFileReply *reply)
                0074 {
                0075     SFReply rep;
                0076     Point where;
                0077     
                0078     if (NAgestaltBits & NA_HASSTDFILE) {
                0079         StandardPutFile(prompt, initfname, reply);
                0080     } else {
                0081         where.h = where.v = 0;
                0082         SFPutFile(where, prompt, initfname, nil, &rep);
                0083         sftostd(&rep, reply);
                0084     }
                0085 }
                0086 
                0087 /* get a file to open
                0088  */
                0089 void NAgetFile(FileFilterProcPtr filter, short numtypes,
                0090     SFTypeList types, StandardFileReply *reply)
                0091 {
                0092     Point p;
                0093     SFReply rep;
                0094     
                0095     if (NAgestaltBits & NA_HASSTDFILE) {
                0096         StandardGetFile(filter, numtypes, types, reply);
                0097     } else {
                0098         p.h = p.v = 0;
                0099         SFGetFile(p, NULL, (ProcPtr) filter, numtypes, types, 0, &rep);
                0100         sftostd(&rep, reply);
                0101     }
                0102 }