scc_maybe.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* Copyright 1990,1991 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Copyright 1995 by Cygnus Support.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*
*/
#include "scc.h"
#include <k5-int.h>
#ifdef macintosh
/*
* Kludge for the Macintosh, since fopen doesn't set errno, but open
* does...
*/
{
int fd, open_flags;
FILE *f;
if (f)
return f;
/*
* OK, fopen failed; let's try to figure out why....
*/
open_flags = O_RDWR;
else
open_flags |= O_APPEND;
if (fd == -1)
return NULL;
/*
* fopen failed, but open succeeded? W*E*I*R*D.....
*/
errno = KRB5_CC_IO;
return NULL;
}
#endif
{
int ret;
return KRB5_FCC_INTERNAL;
#ifdef ultrix
errno = 0;
#endif
#ifdef ultrix
/* their LIBC refuses to allow an fflush() of a read-only buffer!
We patch around it by only calling it an error if errno is set by a
(failed) syscall */
#endif
}
if (retval)
return retval;
else
}
int mode;
{
FILE *f;
char *open_flag;
krb5_error_code retval = 0;
/* Don't know what state it's in; shut down and start anew. */
}
#ifdef ANSI_STDIO
switch(mode) {
case SCC_OPEN_AND_ERASE:
/* XXX should do an exclusive open here, but no way to do */
/* this under stdio */
open_flag = "wb+";
break;
case SCC_OPEN_RDWR:
open_flag = "rb+";
break;
case SCC_OPEN_RDONLY:
default:
open_flag = "rb";
break;
}
#else
switch(mode) {
case SCC_OPEN_AND_ERASE:
/* XXX should do an exclusive open here, but no way to do */
/* this under stdio */
open_flag = "w+";
break;
case SCC_OPEN_RDWR:
open_flag = "r+";
break;
case SCC_OPEN_RDONLY:
default:
open_flag = "r";
break;
}
#endif
#ifdef macintosh
#else
#endif
if (!f)
#ifdef HAVE_SETVBUF
#else
#endif
switch (mode) {
case SCC_OPEN_RDONLY:
(void) fclose(f);
return retval;
}
break;
case SCC_OPEN_RDWR:
case SCC_OPEN_AND_ERASE:
(void) fclose(f);
return retval;
}
break;
}
if (mode == SCC_OPEN_AND_ERASE) {
/* write the version number */
scc_hlen = 0;
/* Write header length */
/* Write time offset tag */
}
}
goto done;
}
/* verify a valid version number is there */
{
goto done;
}
{
goto done;
}
char buf[1024];
{
goto done;
}
while (scc_hlen) {
{
goto done;
}
switch (scc_tag) {
case SCC_TAG_DELTATIME:
goto done;
}
{
goto done;
}
break;
}
{
goto done;
}
break;
default:
goto done;
}
break;
}
}
}
done:
if (retval)
if (f) {
(void) fclose(f);
}
return retval;
}