コード例 #1
0
ファイル: io_printer.c プロジェクト: ErosOlmi/fbc
int fb_PrinterOpen( DEV_LPT_INFO *devInfo, int iPort, const char *pszDevice )
{
    int result;
    char filename[64];
    FILE *fp;
		
    if( iPort==0 ) {
				/* "LPT:" selects default "LPT1:" */
				devInfo->iPort = 1;
		} else {
				devInfo->iPort = iPort;
		}

		sprintf(filename, "LPT%d", devInfo->iPort);
		fp = fopen(filename, "wb");

		devInfo->driver_opaque = fp;

		if( fp==NULL ) {
				result = fb_ErrorSetNum( FB_RTERROR_FILENOTFOUND );
		} else {
				result = fb_ErrorSetNum( FB_RTERROR_OK );
		}

    return result;
}
コード例 #2
0
int fb_DevFileReadEncodWstr( FB_FILE *handle, FB_WCHAR *dst, size_t *max_chars )
{
    FILE *fp;
    size_t chars;

    FB_LOCK();

    chars = *max_chars;

    fp = (FILE *)handle->opaque;
    if( fp == stdout || fp == stderr )
        fp = stdin;

    if( fp == NULL )
    {
        FB_UNLOCK();
        return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
    }

	/* do read */
	chars = fb_hFileRead_UTFToWchar( fp, handle->encod, dst, chars );

	/* fill with nulls if at eof */
	if( chars != *max_chars )
        memset( (char *)&dst[chars], 0, (*max_chars - chars) * sizeof( FB_WCHAR ) );

    *max_chars = chars;

	FB_UNLOCK();

	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #3
0
ファイル: file_get_wstr.c プロジェクト: jasonkfirth/fbc
/*:::::*/
int fb_FileGetWstrEx( FB_FILE *handle, fb_off_t pos, FB_WCHAR *dst, int dst_chars, size_t *bytesread )
{
    int res;

	if( bytesread )
		*bytesread = 0;

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

	/* perform call ... but only if there's data ... */
    if( (dst != NULL) && (dst_chars > 0) )
    {
        size_t chars;
        res = fb_FileGetDataEx( handle, pos, (void *)dst, dst_chars, &chars, TRUE, TRUE );

        /* add the null-term */
        if( res == FB_RTERROR_OK )
        	dst[chars] = _LC('\0');

		if( bytesread )
			*bytesread = chars;
    }
    else
		res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );

	return res;
}
コード例 #4
0
ファイル: io_serial_linux.c プロジェクト: jofers/fbc
/*:::::*/
int fb_SerialRead( FB_FILE *handle, void *pvHandle, void *data, size_t *pLength )
{
    LINUX_SERIAL_INFO *pInfo = (LINUX_SERIAL_INFO *) pvHandle;
    int SerialFD;
    ssize_t count = 0;
    fd_set rfds;
    struct timeval tmout;

    SerialFD = pInfo->sfd;

    FD_ZERO( &rfds );
    FD_SET( SerialFD, &rfds );
    
    tmout.tv_sec = 0;
    tmout.tv_usec = (SREAD_TIMEOUT*1000L); /* convert to microsecs */
    
    select( SerialFD+1, &rfds, NULL, NULL, &tmout );
    if ( FD_ISSET(SerialFD, &rfds) ) 
    {
    	if ( (count = read(SerialFD, data, *pLength)) < 0 ) 
    	{
    		return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
		}
    } 

    *pLength = count;

    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #5
0
ファイル: dev_cons_open.c プロジェクト: dkoksal/fbc
int fb_DevConsOpen( FB_FILE *handle, const char *filename, size_t filename_len )
{
    switch ( handle->mode )
    {
	case FB_FILE_MODE_INPUT:
	case FB_FILE_MODE_OUTPUT:
	case FB_FILE_MODE_APPEND:
		break;

	default:
		return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
    }

    FB_LOCK();

    handle->hooks = &hooks_dev_cons;

    if ( handle->access == FB_FILE_ACCESS_ANY)
        handle->access = FB_FILE_ACCESS_WRITE;

	handle->opaque = (handle->mode == FB_FILE_MODE_INPUT? stdin : stdout);
    handle->type = FB_FILE_TYPE_PIPE;

    FB_UNLOCK();

	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #6
0
ファイル: con_lineinp_wstr.c プロジェクト: jasonkfirth/fbc
/*:::::*/
int fb_ConsoleLineInputWstr( const FB_WCHAR *text, FB_WCHAR *dst, int max_chars,
							 int addquestion, int addnewline )
{
    FBSTRING *tmp_result;

    /* !!!FIXME!!! no support for unicode input */

    FB_LOCK();

    fb_PrintBufferEx( NULL, 0, FB_PRINT_FORCE_ADJUST );

    if( text != NULL )
    {
        fb_PrintWstr( 0, text, 0 );

        if( addquestion != FB_FALSE )
            fb_PrintFixString( 0, pszDefaultQuestion, 0 );
    }

    FB_UNLOCK();

    tmp_result = fb_ConReadLine( FALSE );

    if( addnewline )
      fb_PrintVoid( 0, FB_PRINT_NEWLINE );

    if( tmp_result == NULL )
    	return fb_ErrorSetNum( FB_RTERROR_OUTOFMEM );

	fb_WstrAssignFromA( dst, max_chars, tmp_result, -1 );

	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #7
0
ファイル: file_copy_crt.c プロジェクト: KurtWoloch/fbc
FBCALL int fb_CrtFileCopy( const char *source, const char *destination )
{
	FILE *src, *dst;
	unsigned char buffer[BUFFER_SIZE];
	size_t bytesread;

	dst = NULL;
	src = fopen(source, "rb");
	if (!src)
		goto err;

	dst = fopen(destination, "wb");
	if (!dst)
		goto err;

	while( (bytesread = fread( buffer, 1, BUFFER_SIZE, src )) > 0 ) {
		if (fwrite( buffer, 1, bytesread, dst ) != bytesread)
			goto err;
	}

	if( !feof( src ) )
		goto err;

	fclose( src );
	fclose( dst );

	return fb_ErrorSetNum( FB_RTERROR_OK );

err:
	if (src) fclose( src );
	if (dst) fclose( dst );
	return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
}
コード例 #8
0
ファイル: file_seek.c プロジェクト: KurtWoloch/fbc
int fb_FileSeekEx( FB_FILE *handle, fb_off_t newpos )
{
	int res;

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

	FB_LOCK();

    /* clear put back buffer for every modifying non-read operation */
    handle->putback_size = 0;

    /* convert to 0 based file i/o */
    --newpos;
    if( handle->mode == FB_FILE_MODE_RANDOM )
        newpos = newpos * handle->len;

    if (handle->hooks->pfnSeek!=NULL) {
        res = handle->hooks->pfnSeek(handle, newpos, SEEK_SET );
    } else {
        res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
    }

	FB_UNLOCK();

	return res;
}
コード例 #9
0
ファイル: array_clear_obj.c プロジェクト: jofers/fbc
/*:::::*/
FBCALL int fb_ArrayClearObj
	( 
		FBARRAY *array, 
		FB_DEFCTOR ctor, 
		FB_DEFCTOR dtor, 
		int dofill
	)
{
    /* not an error, see fb_ArrayEraseObj() */
    if( array->ptr == NULL )
    	return fb_ErrorSetNum( FB_RTERROR_OK );
    
    /* call dtors */
    if( dtor )
    	fb_hArrayDtorObj( array, dtor, 0 );
	
	if( dofill != FB_FALSE )
	{
		/* clear stills needed, the default dtor will just call other dtors
	   	   and free dynamic data, the non-dynamic fields would still the same */ 
		memset( array->ptr, 0, array->size );
		
		/* call ctors */
		if( ctor )
			fb_hArrayCtorObj( array, ctor, 0 );
			
	}

   	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #10
0
ファイル: io_serial_linux.c プロジェクト: jofers/fbc
/*:::::*/
int fb_SerialWrite
	(
		FB_FILE *handle,
		void *pvHandle,
		const void *data,
		size_t length
	)
{
    ssize_t rlng=0;
    LINUX_SERIAL_INFO *pInfo = (LINUX_SERIAL_INFO *) pvHandle;
    int SerialFD = pInfo->sfd;

    (void) signal(SIGALRM,  alrm);
    alarm( SERIAL_TIMEOUT );
    rlng=write(SerialFD, data, length);
    alarm(0);
    
    if( rlng <= 0 )
        return fb_ErrorSetNum( FB_RTERROR_FILEIO );
    
    if( length != rlng  )
        return fb_ErrorSetNum( FB_RTERROR_FILEIO );

    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #11
0
ファイル: io_printer.c プロジェクト: ErosOlmi/fbc
int fb_PrinterWrite( DEV_LPT_INFO *devInfo, const void *data, size_t length )
{
    FILE *fp = (FILE*) devInfo->driver_opaque;
    if( fwrite( data, length, 1, fp ) != 1 ) {
        return fb_ErrorSetNum( FB_RTERROR_FILEIO );
    }
    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #12
0
ファイル: time_datepart.c プロジェクト: KurtWoloch/fbc
/*:::::*/
FBCALL int fb_DatePart( FBSTRING *interval, double serial, int first_day_of_week, int first_day_of_year )
{
    int result = 0;
    int year, month, day, hour, minute, second;
    int interval_type = fb_hTimeGetIntervalType( interval );

    fb_ErrorSetNum( FB_RTERROR_OK );

    switch ( interval_type ) {
    case FB_TIME_INTERVAL_YEAR:
        fb_hDateDecodeSerial ( serial, &year, NULL, NULL );
        result = year;
        break;
    case FB_TIME_INTERVAL_QUARTER:
        fb_hDateDecodeSerial ( serial, NULL, &month, NULL );
        result = ((month - 1) / 3) + 1;
        break;
    case FB_TIME_INTERVAL_MONTH:
        fb_hDateDecodeSerial ( serial, NULL, &month, NULL );
        result = month;
        break;
    case FB_TIME_INTERVAL_DAY_OF_YEAR:
        fb_hDateDecodeSerial ( serial, &year, &month, &day );
        result = fb_hGetDayOfYearEx( year, month, day );
        break;
    case FB_TIME_INTERVAL_DAY:
        fb_hDateDecodeSerial ( serial, NULL, NULL, &day );
        result = day;
        break;
    case FB_TIME_INTERVAL_WEEKDAY:
        result = fb_Weekday( serial, first_day_of_week );
        break;
    case FB_TIME_INTERVAL_WEEK_OF_YEAR:
        fb_hDateDecodeSerial ( serial, &year, NULL, NULL );
        result = fb_hGetWeekOfYear( year, serial, first_day_of_year, first_day_of_week );
        if( result < 0 )
            result = fb_hGetWeekOfYear( year - 1, serial, first_day_of_year, first_day_of_week );
        break;
    case FB_TIME_INTERVAL_HOUR:
        fb_hTimeDecodeSerial ( serial, &hour, NULL, NULL, FALSE );
        result = hour;
        break;
    case FB_TIME_INTERVAL_MINUTE:
        fb_hTimeDecodeSerial ( serial, NULL, &minute, NULL, FALSE );
        result = minute;
        break;
    case FB_TIME_INTERVAL_SECOND:
        fb_hTimeDecodeSerial ( serial, NULL, NULL, &second, FALSE );
        result = second;
        break;
    case FB_TIME_INTERVAL_INVALID:
    default:
        fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
        break;
    }

    return result;
}
コード例 #13
0
ファイル: gfx_screen.c プロジェクト: KurtWoloch/fbc
FBCALL int fb_GfxScreen
	(
		int mode, int depth, int num_pages,
		int flags, int refresh_rate
	)
{
	if( (mode < 0) || (mode >= NUM_MODES) )
		return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL);

	const MODEINFO *info = &mode_info[mode];

	/* One of the unsupported modes? */
	if( (mode > 0) && (info->w == 0) )
		return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL);

	switch( depth ) {
	case 8:
	case 15:
	case 16:
	case 24:
	case 32:
		/* user's depth overrides default for mode > 13 */
		if( mode <= 13 ) {
			depth = info->depth;
		}
		break;
	default:
		depth = info->depth;
		break;
	}

	if( num_pages <= 0 ) {
		num_pages = info->num_pages;
	}

	FB_GRAPHICS_LOCK( );

	int res = set_mode( mode,
	                    info->w, info->h,
	                    depth, info->scanline_size,
	                    num_pages, refresh_rate,
	                    info->palette, info->font,
	                    flags, 0.0,
	                    info->text_w, info->text_h );

	if( res == FB_RTERROR_OK ) {
		FB_LOCK( );
		FB_HANDLE_SCREEN->line_length = 0;
		FB_UNLOCK( );
	}

	FB_GRAPHICS_UNLOCK( );

	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #14
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 );
}
コード例 #15
0
ファイル: io_serial.c プロジェクト: KurtWoloch/fbc
int fb_SerialGetRemaining( FB_FILE *handle,
                           void *pvHandle, fb_off_t *pLength )
{
    W32_SERIAL_INFO *pInfo = (W32_SERIAL_INFO*) pvHandle;
    DWORD dwErrors;
    COMSTAT Status;
    if( !ClearCommError( pInfo->hDevice, &dwErrors, &Status ) )
        return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
    if( pLength )
        *pLength = (long) Status.cbInQue;
    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #16
0
ファイル: gfx_screen.c プロジェクト: dkoksal/fbc
FBCALL int fb_GfxScreenQB( int mode, int visible, int active )
{

	int res = fb_GfxScreen( mode, 0, 0, 0, 0 );
	if( res != FB_RTERROR_OK )
		return res;

	if( visible >= 0 || active >= 0 )
		return fb_ErrorSetNum( fb_PageSet( visible, active ) );
	else
		return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #17
0
ファイル: gfx_driver.c プロジェクト: jasonkfirth/fbc
/*:::::*/
FBCALL int fb_GfxGetJoystick(int id, int *buttons, float *a1, float *a2, float *a3, float *a4, float *a5, float *a6, float *a7, float *a8)
{
	static int inited = 0;

	*buttons = -1;
	*a1 = *a2 = *a3 = *a4 = *a5 = *a6 = *a7 = *a8 = -1000.0;

	if ((id < 0) || (id >= 4) || (!g_Pads[id].hPresent))
		return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL);

	if (!inited) {
		inited = 1;
		XInput_Init();
	}

	XInput_GetEvents();

	*buttons = !!g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_A] |
	           (!!g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_B] << 1) |
	           (!!g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_X] << 2) |
	           (!!g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_Y] << 3) |
	           (!!g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_BLACK] << 4) |
	           (!!g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_WHITE] << 5) |
	           (!!(g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_START) << 6) |
	           (!!(g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_BACK) << 7) |
	           (!!(g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_LEFT_THUMB) << 8) |
	           (!!(g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_RIGHT_THUMB) << 9);

	*a1 = JOYPOS(g_Pads[id].sLThumbX, -32768, 32767);
	*a2 = -JOYPOS(g_Pads[id].sLThumbY, -32768, 32767);
	*a3 = JOYPOS(g_Pads[id].sRThumbX, -32768, 32767);
	*a4 = -JOYPOS(g_Pads[id].sRThumbY, -32768, 32767);
	*a5 = (JOYPOS(g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_LEFT_TRIGGER], 0, 255) + 1.0) / 2.0;
	*a6 = (JOYPOS(g_Pads[id].CurrentButtons.ucAnalogButtons[XPAD_RIGHT_TRIGGER], 0, 255) + 1.0) / 2.0;

	if (g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_DPAD_RIGHT)
		*a7 = 1.0;
	else if (g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_DPAD_LEFT)
		*a7 = -1.0;
	else
		*a7 = 0.0;

	if (g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_DPAD_DOWN)
		*a8 = 1.0;
	else if (g_Pads[id].CurrentButtons.usDigitalButtons & XPAD_DPAD_UP)
		*a8 = -1.0;
	else
		*a8 = 0.0;

	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #18
0
ファイル: io_serial_linux.c プロジェクト: jofers/fbc
/*:::::*/
int fb_SerialGetRemaining( FB_FILE *handle, void *pvHandle, fb_off_t *pLength )
{
    int rBytes;
    int SerialFD;
    LINUX_SERIAL_INFO *pInfo = (LINUX_SERIAL_INFO *) pvHandle;

    SerialFD = pInfo->sfd;
    if( ioctl(SerialFD, FIONREAD, &rBytes) )
	    return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
    
    if( pLength )
    	*pLength = (long) rBytes;

    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #19
0
ファイル: gfx_screen.c プロジェクト: KurtWoloch/fbc
FBCALL int fb_GfxScreenRes
	(
		int w, int h,
		int depth, int num_pages,
		int flags, int refresh_rate
	)
{
	if ((w <= 0) || (h <= 0))
		return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL);

	switch (depth) {
	case 1:
	case 2:
	case 4:
	case 8:
	case 15:
	case 16:
	case 24:
	case 32:
		break;
	default:
		return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
	}

	if( num_pages <= 0 ) {
		num_pages = 1;
	}

	FB_GRAPHICS_LOCK( );

	int res = set_mode( -1,
	                    w, h,
	                    depth, 1,
	                    num_pages, refresh_rate,
	                    FB_PALETTE_256, FB_FONT_8,
	                    flags, 1.0,
	                    w / __fb_font[FB_FONT_8].w, h / __fb_font[FB_FONT_8].h );

	if( res == FB_RTERROR_OK ) {
		FB_LOCK( );
		FB_HANDLE_SCREEN->line_length = 0;
		FB_UNLOCK( );
	}

	FB_GRAPHICS_UNLOCK( );

	return res;
}
コード例 #20
0
int fb_hOut( unsigned short port, unsigned char value )
{
	//if (!__fb_con.has_perm)
	return fb_ErrorSetNum( FB_RTERROR_NOPRIVILEDGES );
	//__asm__ volatile ("outb %0, %1" : : "a" (value), "d" (port));
	//return FB_RTERROR_OK;
}
コード例 #21
0
ファイル: joystick_freebsd.c プロジェクト: jofers/fbc
/*:::::*/
FBCALL int fb_GfxGetJoystick(int id, int *buttons, float *a1, float *a2, float *a3, float *a4, float *a5, float *a6, float *a7, float *a8)
{
	*buttons = -1;
	*a1 = *a2 = *a3 = *a4 = *a5 = *a6 = *a7 = *a8 = -1000.0;

	return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL);
}
コード例 #22
0
ファイル: file_input_float.c プロジェクト: jasonkfirth/fbc
/*:::::*/
FBCALL int fb_InputSingle( float *dst )
{
    char buffer[FB_INPUT_MAXNUMERICLEN+1];
    int len, isfp;

	len = fb_FileInputNextToken( buffer, FB_INPUT_MAXNUMERICLEN, FB_FALSE, &isfp );

	if( isfp == FALSE )
	{
		if( len <= FB_INPUT_MAXINTLEN )
			*dst = (float)fb_hStr2Int( buffer, len );
		else if( len <= FB_INPUT_MAXLONGLEN )
			*dst = (float)fb_hStr2Longint( buffer, len );
		else
		{
			if( buffer[0] == '&' )
				*dst = (float)fb_hStr2Longint( buffer, len );
			else
				*dst = strtof( buffer, NULL );
		}
	}
	else
		*dst = strtof( buffer, NULL );

	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #23
0
int fb_DevFileReadLineWstr( FB_FILE *handle, FB_WCHAR *dst, int dst_chars )
{
    int res;
    FILE *fp;
    FBSTRING temp = { 0 };

	FB_LOCK();

    fp = (FILE *)handle->opaque;
    if( fp == stdout || fp == stderr )
        fp = stdin;

	if( fp == NULL )
	{
		FB_UNLOCK();
		return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
	}

    res = fb_DevFileReadLineDumb( fp, &temp, NULL );

	/* convert to wchar, file should be opened with the ENCODING option
	   to allow UTF characters to be read */
	if( (res == FB_RTERROR_OK) || (res == FB_RTERROR_ENDOFFILE) )
    	fb_WstrAssignFromA( dst, dst_chars, (void *)&temp, -1 );

    fb_StrDelete( &temp );

	FB_UNLOCK();

	return res;
}
コード例 #24
0
ファイル: gfx_setmouse.c プロジェクト: KurtWoloch/fbc
int fb_GfxSetMouse(int x, int y, int cursor, int clip)
{
	FB_GRAPHICS_LOCK( );

	if ((!__fb_gfx) || (!__fb_gfx->driver->set_mouse)) {
		FB_GRAPHICS_UNLOCK( );
		return fb_ErrorSetNum(FB_RTERROR_ILLEGALFUNCTIONCALL);
	}

	DRIVER_LOCK();
	__fb_gfx->driver->set_mouse(x, y, cursor, clip);
	DRIVER_UNLOCK();

	FB_GRAPHICS_UNLOCK( );
	return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #25
0
ファイル: io_serial.c プロジェクト: KurtWoloch/fbc
int fb_SerialClose( FB_FILE *handle, void *pvHandle )
{
    W32_SERIAL_INFO *pInfo = (W32_SERIAL_INFO*) pvHandle;
    CloseHandle( pInfo->hDevice );
    free(pInfo);
    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #26
0
ファイル: dev_lpt.c プロジェクト: dkoksal/fbc
int fb_DevPrinterSetWidth( const char *pszDevice, int width, int default_width )
{
		FB_FILE *tmp_handle = NULL;
    int cur = ((default_width==-1) ? 80 : default_width);
    char *pszDev;
		DEV_LPT_PROTOCOL *lpt_proto;

    if (!fb_DevLptParseProtocol( &lpt_proto, pszDevice, strlen(pszDevice), TRUE) )
		{
			if( lpt_proto )
				free( lpt_proto );
			return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
		}

		pszDev = fb_DevLptMakeDeviceName( lpt_proto );

    /* Test all printers. */
		tmp_handle = fb_DevLptFindDeviceByName( lpt_proto->iPort, pszDev, TRUE );
		if( tmp_handle )
		{
      if( width!=-1 )
          tmp_handle->width = width;
      cur = tmp_handle->width;
		}

		if( lpt_proto )
			free( lpt_proto );
    free(pszDev);

    return cur;
}
コード例 #27
0
ファイル: io_serial_linux.c プロジェクト: jofers/fbc
/*:::::*/
int fb_SerialClose( FB_FILE *handle, void *pvHandle )
{
    int SerialFD;
    struct termios oserp;
#ifdef HAS_LOCKDEV
    pid_t plckid;
#endif
    LINUX_SERIAL_INFO *pInfo = (LINUX_SERIAL_INFO *) pvHandle;

    SerialFD = pInfo->sfd;
    oserp = pInfo->oldtty;
#ifdef HAS_LOCKDEV
    plckid = pInfo->pplckid;
#endif
#ifdef HAS_LOCKDEV
	dev_unlock(DeviceName, plckid);
#endif
	
	/* Restore old parameter of serial line */
	tcsetattr( SerialFD, TCSAFLUSH, &oserp); 
    
    close(SerialFD);
	free(pInfo);
    
    return fb_ErrorSetNum( FB_RTERROR_OK );
}
コード例 #28
0
ファイル: dev_lpt.c プロジェクト: dkoksal/fbc
int fb_DevPrinterGetOffset( const char *pszDevice )
{
		FB_FILE *tmp_handle = NULL;
    int cur = 0;
    char *pszDev;
		DEV_LPT_PROTOCOL *lpt_proto;

    if (!fb_DevLptParseProtocol( &lpt_proto, pszDevice, strlen(pszDevice), TRUE) )
		{
			if( lpt_proto )
				free( lpt_proto );
			return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
		}

		pszDev = fb_DevLptMakeDeviceName( lpt_proto );

    /* Test all printers. */
		tmp_handle = fb_DevLptFindDeviceByName( lpt_proto->iPort, pszDev, TRUE );
		if( tmp_handle )
      cur = tmp_handle->line_length;

		if( lpt_proto )
			free( lpt_proto );
    free(pszDev);

    return cur;

}
コード例 #29
0
ファイル: file_resetex.c プロジェクト: jofers/fbc
FBCALL void fb_FileResetEx( int streamno )
{
	FILE *result;

	/*
		streamno
		0	Reset stdin
		1	Reset stdout
	*/

	if( streamno != 0 && streamno != 1 ) {
		fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL );
		return;
	}

	FB_LOCK();

#if defined( HOST_DOS )
	if( streamno == 0 ) {
		result = freopen( "CON", "r", stdin );
	} else {
		result = freopen( "CON", "w", stdout );
	}
#elif defined( HOST_WIN32 )
	/* in io_gethnd.c */
	fb_hConsoleResetHandles();

	if( streamno == 0 ) {
		result = freopen( "CONIN$", "r", stdin );
	} else {
		result = freopen( "CONOUT$", "w", stdout );
	}

	/* force handles to be reinitialized now */
	fb_hConsoleGetHandle( TRUE );
#else
	if( streamno == 0 ) {
		result = freopen( "/dev/tty", "r", stdin );
	} else {
		result = freopen( "/dev/tty", "w", stdout );
	}
#endif

	FB_UNLOCK();

	fb_ErrorSetNum( result ? FB_RTERROR_OK : FB_RTERROR_FILEIO );
}
コード例 #30
0
int fb_hIn( unsigned short port )
{
	//unsigned char value;
	//if (!__fb_con.has_perm)
	return -fb_ErrorSetNum( FB_RTERROR_NOPRIVILEDGES );
	//__asm__ volatile ("inb %1, %0" : "=a" (value) : "d" (port));
	//return (int)value;
}