Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 109 lines (99 sloc) 2.265 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
/* missing functions copied from perlio.c */

#include "perlioutil.h"

#if defined(WIN32)

PerlIO_funcs *
PerlIO_find_layer(pTHX_ const char *name, STRLEN len, int load)
{
    dVAR;
    IV i;
    if ((SSize_t) len <= 0)
len = strlen(name);
    for (i = 0; i < PL_known_layers->cur; i++) {
PerlIO_funcs * const f = PL_known_layers->array[i].funcs;
if (memEQ(f->name, name, len) && f->name[len] == 0) {
PerlIO_debug("%.*s => %p\n", (int) len, name, (void*)f);
return f;
}
    }
    if (load && PL_subname && PL_def_layerlist
&& PL_def_layerlist->cur >= 2) {
if (PL_in_load_module) {
Perl_croak(aTHX_ "Recursive call to Perl_load_module in PerlIO_find_layer");
return NULL;
} else {
SV * const pkgsv = newSVpvs("PerlIO");
SV * const layer = newSVpvn(name, len);
CV * const cv = get_cv("PerlIO::Layer::NoWarnings", FALSE);
ENTER;
SAVEINT(PL_in_load_module);
if (cv) {
SAVEGENERICSV(PL_warnhook);
PL_warnhook = (SV *) (SvREFCNT_inc_simple_NN(cv));
}
PL_in_load_module++;
/*
* The two SVs are magically freed by load_module
*/
Perl_load_module(aTHX_ 0, pkgsv, NULL, layer, NULL);
PL_in_load_module--;
LEAVE;
return PerlIO_find_layer(aTHX_ name, len, 0);
}
    }
    PerlIO_debug("Cannot find %.*s\n", (int) len, name);
    return NULL;
}


int
PerlIOUnix_oflags(const char *mode)
{
    int oflags = -1;
    if (*mode == IoTYPE_IMPLICIT || *mode == IoTYPE_NUMERIC)
mode++;
    switch (*mode) {
    case 'r':
oflags = O_RDONLY;
if (*++mode == '+') {
oflags = O_RDWR;
mode++;
}
break;

    case 'w':
oflags = O_CREAT | O_TRUNC;
if (*++mode == '+') {
oflags |= O_RDWR;
mode++;
}
else
oflags |= O_WRONLY;
break;

    case 'a':
oflags = O_CREAT | O_APPEND;
if (*++mode == '+') {
oflags |= O_RDWR;
mode++;
}
else
oflags |= O_WRONLY;
break;
    }
    if (*mode == 'b') {
oflags |= O_BINARY;
oflags &= ~O_TEXT;
mode++;
    }
    else if (*mode == 't') {
oflags |= O_TEXT;
oflags &= ~O_BINARY;
mode++;
    }
    /*
* Always open in binary mode
*/
    oflags |= O_BINARY;
    if (*mode || oflags == -1) {
SETERRNO(EINVAL, LIB_INVARG);
oflags = -1;
    }
    return oflags;
}



#endif /* WIN32 */
Something went wrong with that request. Please try again.