コード例 #1
0
ファイル: localos2.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalDateTime( sys_handle fh, int *time, int *date, int set )
/**************************************************************/
{
    struct _FILESTATUS fstatus;
    struct _FDATE *pdate;
    struct _FTIME *ptime;
    unsigned    rc;

    pdate = (struct _FDATE *)date;
    ptime = (struct _FTIME *)time;
    if( set ) {
        rc = DosQFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) );
        if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) );
        fstatus.ftimeLastWrite = *ptime;
        fstatus.fdateLastWrite = *pdate;
        rc = DosSetFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) );
        if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) );
    } else {
        rc = DosQFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) );
        if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) );
        *ptime = fstatus.ftimeLastWrite;
        *pdate = fstatus.fdateLastWrite;
    }
    return( 0 );
}
コード例 #2
0
error_handle LocalDateTime( sys_handle fh, int *time, int *date, int set )
/************************************************************************/
{
#if 0
    struct _FILESTATUS fstatus;
    struct _FDATE *pdate;
    struct _FTIME *ptime;
    unsigned    rc;

    pdate = (struct _FDATE *)date;
    ptime = (struct _FTIME *)time;
    if( set ) {
        rc = DosQueryFileInfo( fh, FIL_STANDARD, (PBYTE)&fstatus, sizeof( fstatus ) );
        if( rc != 0 )
            return( StashErrCode( rc, OP_LOCAL ) );
        fstatus.ftimeLastWrite = *ptime;
        fstatus.fdateLastWrite = *pdate;
        rc = DosSetFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) );
        if( rc != 0 ) {
            return( StashErrCode( rc, OP_LOCAL ) );
        }
    } else {
        rc = DosQueryFileInfo( fh, FIL_STANDARD, (PBYTE)&fstatus, sizeof( fstatus ) );
        if( rc != 0 )
            return( StashErrCode( rc, OP_LOCAL ) );
        *ptime = fstatus.ftimeLastWrite;
        *pdate = fstatus.fdateLastWrite;
    }
    return( 0 );
#else
    fh=fh;time=time;date=date;set=set;
    return 0;
#endif
}
コード例 #3
0
ファイル: remfile.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned long RemoteSeek( sys_handle hdl, unsigned long pos, unsigned method )
{
    file_seek_req       acc;
    file_seek_ret       ret;
    int                 locfile;

    if( SuppFileId == 0 ) return( 0 );

    /* Seek on local copy too (if available) */
    locfile = GetCachedHandle( hdl );
    if( locfile != -1 ) {
        lseek( locfile, pos, method );
    }

    SUPP_FILE_SERVICE( acc, REQ_FILE_SEEK );
    acc.handle = hdl;
    /* Magic again! The seek mode mapped exactly to our definition! */
    acc.mode = method;
    acc.pos = pos;
    CONV_LE_32( acc.handle );
    CONV_LE_32( acc.pos );
    TrapSimpAccess( sizeof( acc ), &acc, sizeof( ret ), &ret );
    CONV_LE_32( ret.pos );
    CONV_LE_32( ret.err );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( -1UL );
    } else {
        return( ret.pos );
    }
}
コード例 #4
0
ファイル: dosfilio.c プロジェクト: Azarien/open-watcom-v2
size_t LocalRead( sys_handle filehndl, void *ptr, size_t len )
{
    tiny_ret_t  ret;
    size_t      total;
    unsigned    piece_len;
    unsigned    read_len;

    piece_len = INT_MAX;
    total = 0;
    while( len > 0 ) {
        if( piece_len > len )
            piece_len = (unsigned)len;
        ret = TinyRead( filehndl, ptr, piece_len );
        if( TINY_ERROR( ret ) ) {
            StashErrCode( TINY_INFO( ret ), OP_LOCAL );
            return( ERR_RETURN );
        }
        read_len = TINY_INFO( ret );
        total += read_len;
        if( read_len != piece_len )
            break;
        ptr = (char *)ptr + read_len;
        len -= read_len;
    }
    return( total );
}
コード例 #5
0
sys_handle LocalOpen( const char *name, obj_attrs oattrs )
{
    unsigned    openmode;
    int         ret;
    sys_handle  sh;

    if( (oattrs & OP_WRITE) == 0 ) {
        openmode = O_RDONLY;
    } else if( oattrs & OP_READ ) {
        openmode = O_RDWR;
    } else {
        openmode = O_WRONLY;
    }
    if( oattrs & OP_CREATE )
        openmode |= O_CREAT;
    if( oattrs & OP_TRUNC )
        openmode |= O_TRUNC;
    ret = open( name, openmode | O_BINARY, 0666 );
    if( ret == -1 ) {
        StashErrCode( errno, OP_LOCAL );
        SET_SYSHANDLE_NULL( sh );
        return( sh );
    }
//    fcntl( ret, F_SETFD, (int)FD_CLOEXEC );
    LH2SYSH( sh, ret );
    return( sh );
}
コード例 #6
0
ファイル: remenv.c プロジェクト: groessler/open-watcom-v2
bool RemoteGetEnvironmentVariable( char *name, char *res, int res_len )
{
    in_mx_entry         in[2];
    mx_entry            out[2];
    env_get_var_req     acc;
    env_get_var_ret     ret;

    if( SuppEnvId == 0 ) return( false );
    SUPP_ENV_SERVICE( acc, REQ_ENV_GET_VAR );
    acc.res_len = res_len;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    out[1].ptr = res;
    out[1].len = res_len;
    TrapAccess( 2, in, 2, out );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( false );
    } else {
        return( true );
    }
}
コード例 #7
0
ファイル: remenv.c プロジェクト: groessler/open-watcom-v2
bool RemoteSetEnvironmentVariable( char *name, char *value )
{
    in_mx_entry         in[3];
    mx_entry            out[1];
    env_set_var_req     acc;
    env_set_var_ret     ret;

    if( SuppEnvId == 0 ) return( false );
    SUPP_ENV_SERVICE( acc, REQ_ENV_SET_VAR );
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    in[2].ptr = value;
    in[2].len = strlen( value ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 3, in, 1, out );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( false );
    } else {
        return( true );
    }
}
コード例 #8
0
ファイル: os2filio.c プロジェクト: Ukusbobra/open-watcom-v2
sys_handle LocalOpen( char *name, open_access access )
{
    HFILE       hdl;
    USHORT      action;
    USHORT      openflags;
    USHORT      openmode;
    USHORT      rc;

    if( (access & OP_WRITE) == 0 ) {
        openmode = READONLY;
        access &= ~(OP_CREATE|OP_TRUNC);
    } else if( access & OP_READ ) {
        openmode = READWRITE;
    } else {
        openmode = WRITEONLY;
    }
    openmode |= 0x20c0;
    openflags = 0;
    if( access & OP_CREATE ) openflags |= 0x10;
    openflags |= (access & OP_TRUNC) ? 0x02 : 0x01;
    rc = DosOpen( name,         /* name */
                &hdl,           /* handle to be filled in */
                &action,        /* action taken */
                0,              /* initial allocation */
                0,              /* normal file */
                openflags,      /* open the file */
                openmode,       /* deny-none, inheritance */
                0 );            /* reserved */
    if( rc != 0 ) {
        StashErrCode( rc, OP_LOCAL );
        return( NIL_SYS_HANDLE );
    }
    return( hdl );
}
コード例 #9
0
ファイル: os2filio.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalErase( char *name )
{
    USHORT      ret;

    ret = DosDelete( name, 0 );
    return( StashErrCode( ret, OP_LOCAL ) );
}
コード例 #10
0
ファイル: os2filio.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalClose( sys_handle filehndl )
{
    USHORT      ret;

    ret = DosClose( filehndl );
    return( StashErrCode( ret, OP_LOCAL ) );
}
コード例 #11
0
sys_handle LocalOpen( const char *name, open_access access )
{
    tiny_ret_t  ret;
    unsigned    mode;

    if( (access & OP_WRITE) == 0 ) {
        mode = TIO_READ;
        access &= ~(OP_CREATE|OP_TRUNC);
    } else if( access & OP_READ ) {
        mode = TIO_READ_WRITE;
    } else {
        mode = TIO_WRITE;
    }
    if( access & (OP_CREATE|OP_TRUNC) ) {
        ret = TinyCreate( name, TIO_NORMAL );
    } else {
        if( _osmajor >= 3 ) mode |= 0x80; /* set no inheritance */
        ret = TinyOpen( name, mode );
    }
    if( TINY_ERROR( ret ) ) {
        StashErrCode( TINY_INFO( ret ), OP_LOCAL );
        return( NIL_SYS_HANDLE );
    }
    return( TINY_INFO( ret ) );
}
コード例 #12
0
bool RemoteSetFileDate( const char *name, long date )
{
    in_mx_entry                 in[2];
    mx_entry                    out[1];
    file_info_set_date_req      acc;
    file_info_set_date_ret      ret;

    if( SuppFileInfoId == 0 )
        return( false );
    SUPP_FILE_INFO_SERVICE( acc, REQ_FILE_INFO_SET_DATE );
    acc.date = date;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = (trap_elen)( strlen( name ) + 1 );
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, in, 1, out );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( false );
    } else {
        return( true );
    }
}
コード例 #13
0
ファイル: remfile.c プロジェクト: Ukusbobra/open-watcom-v2
static unsigned DoAWrite( unsigned req, sys_handle hdl, void *ptr, unsigned len )
{
    mx_entry            in[2];
    mx_entry            out[1];
    union {
        file_write_req              file;
        file_write_console_req      con;
    } acc;
    file_write_ret      ret;

    SUPP_FILE_SERVICE( acc.file, req );
    if( req == REQ_FILE_WRITE_CONSOLE ) {
        in[0].len = sizeof( acc.con );
    } else {
        acc.file.handle = hdl;
    CONV_LE_32( acc.file.handle );
        in[0].len = sizeof( acc.file );
    }
    in[0].ptr = &acc;
    in[1].ptr = ptr;
    in[1].len = len;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, &in, 1, &out );
    CONV_LE_32( ret.err );
    CONV_LE_16( ret.len );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( ERR_RETURN );
    } else {
        return( ret.len );
    }
}
コード例 #14
0
ファイル: remfile.c プロジェクト: Ukusbobra/open-watcom-v2
static unsigned DoRead( sys_handle hdl, void *ptr, unsigned len )
{
    mx_entry            in[1];
    mx_entry            out[2];
    file_read_req       acc;
    file_read_ret       ret;
    unsigned            got;

    SUPP_FILE_SERVICE( acc, REQ_FILE_READ );
    acc.handle = hdl;
    acc.len = len;
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    out[1].ptr = ptr;
    out[1].len = len;
    CONV_LE_32( acc.handle );
    CONV_LE_16( acc.len );
    got = TrapAccess( 1, &in, 2, &out );
    CONV_LE_32( ret.err );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
        return( ERR_RETURN );
    } else {
        return( got - sizeof( ret ) );
    }
}
コード例 #15
0
ファイル: localos2.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalGetCwd( int drive, char *where )
/****************************************/
{
    USHORT len;

    len = 256;
    return( StashErrCode( DosQCurDir( drive, where, &len ), OP_LOCAL ) );
}
コード例 #16
0
ファイル: localos2.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalGetCwd( int drive, char *where )
/****************************************/
{
    ULONG len;

    len = 256;
    return( StashErrCode( DosQueryCurrentDir( drive, (PBYTE)where, &len ), OP_LOCAL ) );
}
コード例 #17
0
ファイル: localos2.c プロジェクト: Azarien/open-watcom-v2
error_handle LocalSetFileAttr( const char *name, long attr )
/**********************************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosSetFileMode( name, attr, 0 ), OP_LOCAL ) );
#else
    FILESTATUS3 fileinfo;
    APIRET      rc;

    rc = DosQueryPathInfo( name, FIL_STANDARD, &fileinfo, sizeof( fileinfo ) );
    if( rc == 0 ) {
        fileinfo.attrFile = attr;
        rc = DosSetPathInfo( name, FIL_STANDARD, &fileinfo, sizeof( fileinfo ), 0 );
    }
    return( StashErrCode( rc, OP_LOCAL ) );
#endif
}
コード例 #18
0
error_idx LocalErase( const char *name )
{
    tiny_ret_t  ret;

    ret = TinyDelete( name );
    if( TINY_ERROR( ret ) ) {
        return( StashErrCode( TINY_INFO( ret ), OP_LOCAL ) );
    }
    return( 0 );
}
コード例 #19
0
error_idx LocalClose( sys_handle filehndl )
{
    tiny_ret_t  ret;

    ret = TinyClose( filehndl );
    if( TINY_ERROR( ret ) ) {
        return( StashErrCode( TINY_INFO( ret ), OP_LOCAL ) );
    }
    return( 0 );
}
コード例 #20
0
unsigned LocalWrite( sys_handle filehndl, const void *ptr, unsigned len )
{
    tiny_ret_t  ret;

    ret = TinyWrite( filehndl, ptr, len );
    if( TINY_ERROR( ret ) ) {
        StashErrCode( TINY_INFO( ret ), OP_LOCAL );
        return( ERR_RETURN );
    }
    return( TINY_INFO( ret ) );
}
コード例 #21
0
unsigned long LocalSeek( sys_handle sh, unsigned long len, seek_method method )
{
    off_t       ret;

    ret = lseek( SYSH2LH( sh ), len, local_seek_method[method] );
    if( ret == (off_t)-1 ) {
        StashErrCode( errno, OP_LOCAL );
        return( ERR_SEEK );
    }
    return( ret );
}
コード例 #22
0
size_t LocalRead( sys_handle sh, void *ptr, size_t len )
{
    ssize_t ret;

    ret = posix_read( SYSH2LH( sh ), ptr, len );
    if( ret < 0 ) {
        StashErrCode( errno, OP_LOCAL );
        return( ERR_RETURN );
    }
    return( ret );
}
コード例 #23
0
unsigned LocalFindFirst( char *pattern, void *info, unsigned info_len, int attrib )
/*********************************************************************************/
{
    unsigned        rc;

    rc = _dos_findfirst( pattern, attrib, &Findbuf );
    if( rc )
        return( StashErrCode( rc , OP_LOCAL ) );
    makeDOSDTA( &Findbuf, info );
    return( 0 );
}
コード例 #24
0
ファイル: remfile.c プロジェクト: Ukusbobra/open-watcom-v2
sys_handle RemoteOpen( char *name, open_access mode )
{
    mx_entry            in[2];
    mx_entry            out[1];
    file_open_req       acc;
    file_open_ret       ret;
    int                 locfile;

    if( SuppFileId == 0 ) return( NIL_SYS_HANDLE );

    SUPP_FILE_SERVICE( acc, REQ_FILE_OPEN );
    acc.mode = 0;
    if( mode & OP_READ )
        acc.mode |= TF_READ;
    if( mode & OP_WRITE )
        acc.mode |= TF_WRITE;
    if( mode & OP_CREATE ) {
        acc.mode |= TF_CREATE;
        if( mode & OP_EXEC )
            acc.mode |= TF_EXEC;
    }
    in[0].ptr = &acc;
    in[0].len = sizeof( acc );
    in[1].ptr = name;
    in[1].len = strlen( name ) + 1;
    out[0].ptr = &ret;
    out[0].len = sizeof( ret );
    TrapAccess( 2, &in, 1, &out );
    CONV_LE_32( ret.err );
    CONV_LE_32( ret.handle );
    if( ret.err != 0 ) {
        StashErrCode( ret.err, OP_REMOTE );
            return( NIL_SYS_HANDLE );
    } else {
        /* See if the file is available locally. If so, open it here as
         * well as on the remote machine.
         */
        // TODO: check if remote file is the same!

#ifdef LOGGING
        fprintf( logf, "Trying to open local copy of remote file (remote handle %d)\n", ret.handle );
        fprintf( logf, "%s\n", name );
#endif

        if( (locfile = open(name, O_RDONLY | O_BINARY, 0 )) != -1 ) {
            if(AddCachedHandle( locfile, ret.handle ) != 0 )
                close( locfile );
#ifdef LOGGING
            fprintf(logf, "Success\n", name);
#endif
        }
        return( ret.handle );
    }
}
コード例 #25
0
ファイル: os2filio.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalRead( sys_handle filehndl, void *ptr, unsigned len )
{
    USHORT      read;
    USHORT      ret;

    ret = DosRead( filehndl, ptr, len, &read );
    if( ret != 0 ) {
        StashErrCode( ret, OP_LOCAL );
        return( ERR_RETURN );
    }
    return( read );
}
コード例 #26
0
ファイル: os2filio.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalWrite( sys_handle filehndl, void *ptr, unsigned len )
{
    USHORT  written;
    USHORT  ret;

    ret = DosWrite( filehndl, ptr, len, &written );
    if( ret != 0 ) {
        StashErrCode( ret, OP_LOCAL );
        return( ERR_RETURN );
    }
    return( written );
}
コード例 #27
0
ファイル: os2filio.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned long LocalSeek( sys_handle hdl, unsigned long len, unsigned method )
{
    unsigned long   new;
    USHORT          ret;

    ret = DosChgFilePtr( hdl, len, method, &new );
    if( ret != 0 ) {
        StashErrCode( ret, OP_LOCAL );
        return( -1UL );
    }
    return( new );
}
コード例 #28
0
unsigned long LocalSeek( sys_handle hdl, unsigned long npos, seek_method method )
{
    tiny_ret_t      ret;
    unsigned long   pos;

    ret = TinyLSeek( hdl, npos, method, (u32_stk_ptr)&pos );
    if( TINY_ERROR( ret ) ) {
        StashErrCode( TINY_INFO( ret ), OP_LOCAL );
        return( -1UL );
    }
    return( pos );
}
コード例 #29
0
ファイル: localos2.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalSetFileAttr( char *name, long attr )
/********************************************/
{
    FILESTATUS3 fileinfo;

    if ( DosQueryPathInfo( name, FIL_STANDARD, &fileinfo, sizeof( fileinfo ) ) )
        return -1;

    fileinfo.attrFile = attr;
    return( StashErrCode( DosSetPathInfo( name, FIL_STANDARD,
        &fileinfo, sizeof( fileinfo ) , 0), OP_LOCAL ) );
}
コード例 #30
0
unsigned long LocalSeek( sys_handle hdl, unsigned long len, unsigned method )
{
    tiny_ret_t      ret;
    unsigned long   pos;

    ret = TinyLSeek( hdl, len, method, &pos );
    if( TINY_ERROR( ret ) ) {
        StashErrCode( TINY_INFO( ret ), OP_LOCAL );
        return( -1UL );
    }
    return( pos );
}