コード例 #1
0
ファイル: file_get.c プロジェクト: jasonkfirth/fbc
/* Can fb_FileGetData() be removed? it's not used by the rtlib
 * nor is it referenced by fbc?  Compatibility with old libs? [jeffm]
 */
int fb_FileGetData( int fnum, fb_off_t pos, void *dst, size_t chars, int adjust_rec_pos )
{
    return fb_FileGetDataEx( FB_FILE_TO_HANDLE(fnum),
    						 pos,
    						 dst,
    						 chars,
							 NULL,
    						 adjust_rec_pos,
    						 FALSE );
}
コード例 #2
0
ファイル: file_lineinp_wstr.c プロジェクト: KurtWoloch/fbc
FBCALL int fb_FileLineInputWstr( int fnum, FB_WCHAR *dst, ssize_t max_chars )
{
    FB_FILE *handle = FB_FILE_TO_HANDLE(fnum);

    if( !FB_HANDLE_USED(handle) )
		return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );

    if( handle->hooks->pfnReadLineWstr == NULL )
        return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );

    return handle->hooks->pfnReadLineWstr( handle, dst, max_chars );
}
コード例 #3
0
ファイル: io_spc.c プロジェクト: KurtWoloch/fbc
FBCALL void fb_PrintSPC( int fnum, ssize_t n )
{
    FB_FILE *handle;
    int col, row, cols, rows, newcol;

    if( n==0 )
        return;

    fb_DevScrnInit_NoOpen( );

    FB_LOCK();

    handle = FB_FILE_TO_HANDLE(fnum);

	if( FB_HANDLE_IS_SCREEN(handle) || handle->type == FB_FILE_TYPE_CONSOLE )
	{
		if( n == 0 )
			return;

        if( handle->type == FB_FILE_TYPE_CONSOLE ) {
            if( handle->hooks && handle->hooks->pfnFlush )
                handle->hooks->pfnFlush( handle );
        }

        /* Ensure that we get the "real" cursor position - this quirk is
         * required for cursor positions at the right bottom of the screen */
        fb_PrintBufferEx( NULL, 0, FB_PRINT_FORCE_ADJUST );
		fb_GetXY( &col, &row );
		fb_GetSize( &cols, &rows );

    	newcol = col + n;
        if( newcol > cols ) {
            fb_PrintVoidEx ( handle, FB_PRINT_NEWLINE );
            newcol %= cols;
        }

        fb_Locate( 0, newcol, -1, 0, 0 );

    } else {

        fb_PrintStringEx( handle, fb_StrFill1( n, ' ' ), 0 );

    }

    FB_UNLOCK();
}
コード例 #4
0
ファイル: io_widthfile.c プロジェクト: KurtWoloch/fbc
/*:::::*/
FBCALL int fb_WidthFile( int fnum, int width )
{
    int cur = width;
    FB_FILE *handle;

    FB_LOCK();

    handle = FB_HANDLE_DEREF(FB_FILE_TO_HANDLE(fnum));

    if( !FB_HANDLE_USED(handle) ) {
        /* invalid file handle */
        FB_UNLOCK();
        return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
    }

    if( handle->hooks==NULL ) {
        /* not opened yet */
        FB_UNLOCK();
        return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
    }

    if( handle==FB_HANDLE_SCREEN ) {
        /* SCREEN device */
        if( width!=-1 ) {
            fb_Width( width, -1 );
        }
        cur = FB_HANDLE_SCREEN->width;

    } else {
        if( width!=-1 ) {
            handle->width = width;
            if( handle->hooks->pfnSetWidth!=NULL )
                handle->hooks->pfnSetWidth( handle, width );
        }
        cur = handle->width;
    }

	FB_UNLOCK();

    if( width==-1 ) {
        return cur;
    }

    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #5
0
ファイル: file_openscrn.c プロジェクト: KurtWoloch/fbc
/*:::::*/
FBCALL int fb_FileOpenScrn ( FBSTRING *str_filename, unsigned int mode,
                             unsigned int access, unsigned int lock,
                             int fnum, int len, const char *encoding )
{
    if( !FB_FILE_INDEX_VALID( fnum ) )
    	return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );

    fb_DevScrnInit( );

    return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
                             str_filename,
                             mode,
                             access,
                             lock,
                             len,
                             fb_hFileStrToEncoding( encoding ),
                             fb_DevScrnOpen );
}
コード例 #6
0
ファイル: io_print.c プロジェクト: KurtWoloch/fbc
/*:::::*/
FBCALL void fb_PrintString ( int fnum, FBSTRING *s, int mask )
{
    fb_PrintStringEx(FB_FILE_TO_HANDLE(fnum), s, mask);
}
コード例 #7
0
ファイル: io_spc.c プロジェクト: KurtWoloch/fbc
FBCALL void fb_PrintTab( int fnum, int newcol )
{
    FB_FILE *handle;
    int col, row, cols, rows;

    fb_DevScrnInit_NoOpen( );

    FB_LOCK();

    handle = FB_FILE_TO_HANDLE(fnum);

	if( FB_HANDLE_IS_SCREEN(handle) || handle->type == FB_FILE_TYPE_CONSOLE )
    {
        if( handle->type == FB_FILE_TYPE_CONSOLE ) {
            if( handle->hooks && handle->hooks->pfnFlush )
                handle->hooks->pfnFlush( handle );
        }

        /* Ensure that we get the "real" cursor position - this quirk is
         * required for cursor positions at the right bottom of the screen */
        fb_PrintBufferEx( NULL, 0, FB_PRINT_FORCE_ADJUST );
		fb_GetXY( &col, &row );
		fb_GetSize( &cols, &rows );

    	if( newcol > cols )
    		newcol %= cols;

        if( col > newcol ) {
            fb_PrintVoidEx ( handle, FB_PRINT_NEWLINE );
			fb_Locate( 0, newcol, -1, 0, 0 );

        } else if( newcol < 1 )
    		fb_Locate( 0, 1, -1, 0, 0 );

    	else
            fb_Locate( 0, newcol, -1, 0, 0 );

    } else {

        if( handle->type==FB_FILE_TYPE_PIPE ) {

            fb_PrintPadEx ( handle, 0 );

        } else {

            if( (newcol >= 0) && ((unsigned int)newcol > handle->line_length) ) {
                fb_PrintStringEx( handle,
                                  fb_StrFill1( newcol - handle->line_length - 1, ' ' ),
                                  0 );
            } else {

                if( handle->mode==FB_FILE_MODE_BINARY ) {
                    fb_PrintStringEx( handle,
                                      fb_StrAllocTempDescF( FB_BINARY_NEWLINE, sizeof( FB_BINARY_NEWLINE ) ),
                                      0 );
                } else {
                    fb_PrintStringEx( handle,
                                      fb_StrAllocTempDescF( FB_NEWLINE, sizeof( FB_NEWLINE ) ),
                                      0 );
                }

                if( newcol > 0 ) {
                    fb_PrintStringEx( handle,
                                      fb_StrFill1( newcol - 1, ' ' ),
                                      0 );
                }

            }

        }

    }

    FB_UNLOCK();
}
コード例 #8
0
ファイル: file_seek.c プロジェクト: KurtWoloch/fbc
FBCALL int fb_FileSeekLarge( int fnum, long long newpos )
{
    return fb_FileSeekEx( FB_FILE_TO_HANDLE(fnum), newpos );
}
コード例 #9
0
ファイル: io_printpad.c プロジェクト: ErosOlmi/fbc
/*:::::*/
FBCALL void fb_PrintPad ( int fnum, int mask )
{
    fb_PrintPadEx( FB_FILE_TO_HANDLE(fnum), mask );
}
コード例 #10
0
ファイル: file_attr.c プロジェクト: VlaBst6/fbc
FBCALL ssize_t fb_FileAttr( int handle, int returntype )
{
	ssize_t ret = 0;
	int err = 0;
	FB_FILE *file;

	file = FB_FILE_TO_HANDLE( handle );

	if( !file ) {
		ret = 0;
		err = FB_RTERROR_ILLEGALFUNCTIONCALL;
	} else {
		switch( returntype ) {
		case FB_FILE_ATTR_MODE:
			ret = file_mode_map[file->mode];
			err = FB_RTERROR_OK;
			break;

		case FB_FILE_ATTR_HANDLE:
			switch( file->type ) {
			case FB_FILE_TYPE_PRINTER:
				{
					DEV_LPT_INFO *lptinfo = file->opaque;
					if( lptinfo ) {
						#ifdef HOST_WIN32
							W32_PRINTER_INFO *printerinfo = lptinfo->driver_opaque;
							if( printerinfo ) {
								/* Win32: HANDLE */
								ret = (ssize_t)printerinfo->hPrinter;
								err = FB_RTERROR_OK;
							}
						#else
							/* Unix/DOS: CRT FILE* */
							ret = (ssize_t)lptinfo->driver_opaque;
							err = FB_RTERROR_OK;
						#endif
					}
				}
				break;

			case FB_FILE_TYPE_SERIAL:
				{
					DEV_COM_INFO *cominfo = file->opaque;
					if( cominfo ) {
						#ifdef HOST_WIN32
							W32_SERIAL_INFO *serialinfo = cominfo->hSerial;
							if( serialinfo ) {
								ret = (ssize_t)serialinfo->hDevice;
								err = FB_RTERROR_OK;
							}
						#elif defined HOST_LINUX
							LINUX_SERIAL_INFO *serialinfo = cominfo->hSerial;
							if( serialinfo ) {
								ret = serialinfo->sfd;
								err = FB_RTERROR_OK;
							}
						#elif defined HOST_DOS
							DOS_SERIAL_INFO *serialinfo = cominfo->hSerial;
							if( serialinfo ) {
								ret = serialinfo->com_num;
								err = FB_RTERROR_OK;
							}
						#endif
					}
				}
				break;

			default:
				ret = (ssize_t)file->opaque; /* CRT FILE* */
				err = FB_RTERROR_OK;
				break;
			}
			break;

		case FB_FILE_ATTR_ENCODING:
			ret = file->encod;
			err = FB_RTERROR_OK;
			break;

		default:
			ret = 0;
			err = FB_RTERROR_ILLEGALFUNCTIONCALL; 
			break;
		}
	}

	fb_ErrorSetNum( err );
	return ret;
}
コード例 #11
0
ファイル: io_print_fix.c プロジェクト: KurtWoloch/fbc
/*:::::*/
FBCALL void fb_PrintFixString ( int fnum, const char *s, int mask )
{
    fb_PrintFixStringEx(FB_FILE_TO_HANDLE(fnum), s, mask);
}
コード例 #12
0
ファイル: file_get_wstr.c プロジェクト: jasonkfirth/fbc
/*:::::*/
FBCALL int fb_FileGetWstrLargeIOB( int fnum, long long pos, FB_WCHAR *dst, int dst_chars, unsigned int *bytesread )
{
	return fb_FileGetWstrEx( FB_FILE_TO_HANDLE(fnum), pos, dst, dst_chars, bytesread );
}
コード例 #13
0
ファイル: file_get_wstr.c プロジェクト: jasonkfirth/fbc
/*:::::*/
FBCALL int fb_FileGetWstrLarge( int fnum, long long pos, FB_WCHAR *dst, int dst_chars )
{
	return fb_FileGetWstrEx( FB_FILE_TO_HANDLE(fnum), pos, dst, dst_chars, NULL );
}
コード例 #14
0
ファイル: file_putstr.c プロジェクト: jasonkfirth/fbc
/*:::::*/
FBCALL int fb_FilePutStr( int fnum, long pos, void *str, int str_len )
{
	return fb_FilePutStrEx(FB_FILE_TO_HANDLE(fnum), pos, str, str_len);
}
コード例 #15
0
ファイル: file_winputstr.c プロジェクト: KurtWoloch/fbc
FBCALL FB_WCHAR *fb_FileWstrInput( ssize_t chars, int fnum )
{
    FB_FILE *handle;
	FB_WCHAR *dst;
    size_t len;
    int res = FB_RTERROR_OK;

	fb_DevScrnInit_ReadWstr( );

	FB_LOCK();

    handle = FB_FILE_TO_HANDLE(fnum);
    if( !FB_HANDLE_USED(handle) )
    {
		FB_UNLOCK();
		return NULL;
	}

    dst = fb_wstr_AllocTemp( chars );
    if( dst != NULL )
    {
        ssize_t read_chars = 0;
        if( FB_HANDLE_IS_SCREEN(handle) )
        {
            while( read_chars != chars )
            {
                res = fb_FileGetDataEx( handle,
                                        0,
                                        (void *)&dst[read_chars],
										chars - read_chars,
                                        &len,
                                        TRUE,
                                        TRUE );
                if( res != FB_RTERROR_OK )
                    break;

                read_chars += len;
            }
        }
        else
        {
            res = fb_FileGetDataEx( handle,
                                    0,
                                    (void *)dst,
									chars,
                                    &len,
                                    TRUE,
                                    TRUE );
			read_chars = chars;
        }

		if( res == FB_RTERROR_OK )
		{
			dst[read_chars] = _LC('\0');
		}
		else
		{
			fb_wstr_Del( dst );
			dst = NULL;
		}

    }
    else
        res = FB_RTERROR_OUTOFMEM;

	FB_UNLOCK();

    return dst;
}
コード例 #16
0
ファイル: file_lineinp.c プロジェクト: KurtWoloch/fbc
FBCALL int fb_FileLineInput( int fnum, void *dst, ssize_t dst_len, int fillrem )
{
    return fb_hFileLineInputEx( FB_FILE_TO_HANDLE(fnum), dst, dst_len, fillrem );
}
コード例 #17
0
ファイル: qb_file_open.c プロジェクト: ErosOlmi/fbc
FBCALL int fb_FileOpenQB
	(
		FBSTRING *str,
		unsigned int mode,
		unsigned int access,
		unsigned int lock,
		int fnum,
		int len
	)
{
	if( !FB_FILE_INDEX_VALID( fnum ) )
		return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );

	ssize_t str_len = FB_STRSIZE( str );

	if( !str_len || (str->data == NULL) )
		return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );		
		
	/* serial? */
	if( (str_len > 3) && (strncasecmp( str->data, "COM", 3 ) == 0) )
	{
		ssize_t i = 3;
		while( (i < str_len) && (str->data[i] >= '0') && (str->data[i] <= '9' ) )
			++i;

		if( str->data[i] == ':' )
		{
			return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
									 str,
									 mode,
									 access,
									 lock,
									 len,
									 FB_FILE_ENCOD_ASCII,
									 fb_DevComOpen );
		}
	}
	/* parallel? */
	else if( (str_len > 3) && (strncasecmp( str->data, "LPT", 3 ) == 0) )
	{
		ssize_t i = 3;
		while( (i < str_len) && (str->data[i] >= '0') && (str->data[i] <= '9' ) )
			++i;

		if( str->data[i] == ':' )
		{
			return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
									 str,
									 mode,
									 access,
									 lock,
									 len,
									 FB_FILE_ENCOD_ASCII,
									 fb_DevLptOpen );
		}
	}
	/* default printer? */
	else if( (str_len == 4) && (strcasecmp( str->data, "PRN:" ) == 0) )
	{
		return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
								 str,
								 mode,
								 access,
								 lock,
								 len,
								 FB_FILE_ENCOD_ASCII,
								 fb_DevLptOpen );
	}
	/* console? */
	else if( (str_len == 5) && (strcasecmp( str->data, "CONS:" ) == 0) )
	{
		return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
								 str,
								 mode,
								 access,
								 lock,
								 len,
								 FB_FILE_ENCOD_ASCII,
								 fb_DevConsOpen );

	}
	/* screen? */
	else if( (str_len == 5) && (strcasecmp( str->data, "SCRN:" ) == 0) )
	{
		fb_DevScrnInit( );
	
		return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
								 str,
								 mode,
								 access,
								 lock,
								 len,
								 FB_FILE_ENCOD_ASCII,
								 fb_DevScrnOpen );
	}
	/* pipe? */
	else if( (str_len == 5) && (strcasecmp( str->data, "PIPE:" ) == 0) )
	{
		return fb_FileOpenVfsEx( FB_FILE_TO_HANDLE(fnum),
								 str,
								 mode,
								 access,
								 lock,
								 len,
								 FB_FILE_ENCOD_ASCII,
								 fb_DevPipeOpen );
	}
	
	/* ordinary file */
	return fb_FileOpenEx( FB_FILE_TO_HANDLE(fnum), str, mode, access, lock, len );
}
コード例 #18
0
ファイル: file_put_wstr.c プロジェクト: jasonkfirth/fbc
/*:::::*/
FBCALL int fb_FilePutWstrLarge( int fnum, long long pos, FB_WCHAR *str, int str_len )
{
	return fb_FilePutWstrEx(FB_FILE_TO_HANDLE(fnum), pos, str, str_len);
}
コード例 #19
0
ファイル: file_seek.c プロジェクト: KurtWoloch/fbc
FBCALL int fb_FileSeek( int fnum, int newpos )
{
    return fb_FileSeekEx( FB_FILE_TO_HANDLE(fnum), newpos );
}