security/nss/lib/jar/jarint.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/jar/jarint.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*
     1.9 + * Internal libjar routines.
    1.10 + */
    1.11 +
    1.12 +#include "jar.h"
    1.13 +#include "jarint.h"
    1.14 +
    1.15 +/*-----------------------------------------------------------------------
    1.16 + * JAR_FOPEN_to_PR_Open
    1.17 + * Translate JAR_FOPEN arguments to PR_Open arguments
    1.18 + */
    1.19 +PRFileDesc*
    1.20 +JAR_FOPEN_to_PR_Open(const char* name, const char *mode)
    1.21 +{
    1.22 +
    1.23 +    PRIntn  prflags=0, prmode=0;
    1.24 +
    1.25 +    /* Get read/write flags */
    1.26 +    if (strchr(mode, 'r') && !strchr(mode, '+')) {
    1.27 +	prflags |= PR_RDONLY;
    1.28 +    } else if( (strchr(mode, 'w') || strchr(mode, 'a')) &&
    1.29 +	!strchr(mode,'+') ) {
    1.30 +	prflags |= PR_WRONLY;
    1.31 +    } else {
    1.32 +	prflags |= PR_RDWR;
    1.33 +    }
    1.34 +
    1.35 +    /* Create a new file? */
    1.36 +    if (strchr(mode, 'w') || strchr(mode, 'a')) {
    1.37 +	prflags |= PR_CREATE_FILE;
    1.38 +    }
    1.39 +
    1.40 +    /* Append? */
    1.41 +    if (strchr(mode, 'a')) {
    1.42 +	prflags |= PR_APPEND;
    1.43 +    }
    1.44 +
    1.45 +    /* Truncate? */
    1.46 +    if (strchr(mode, 'w')) {
    1.47 +	prflags |= PR_TRUNCATE;
    1.48 +    }
    1.49 +
    1.50 +    /* We can't do umask because it isn't XP.  Choose some default
    1.51 +	   mode for created files */
    1.52 +    prmode = 0755;
    1.53 +
    1.54 +    return PR_Open(name, prflags, prmode);
    1.55 +}

mercurial