|
|
1.1.1.2 ! root 1: /* $Id: ciolib.c,v 1.113 2011/05/07 22:00:09 deuce Exp $ */ 1.1 root 2: 3: /**************************************************************************** 4: * @format.tab-size 4 (Plain Text/Source Code File Header) * 5: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * 6: * * 7: * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html * 8: * * 9: * This library is free software; you can redistribute it and/or * 10: * modify it under the terms of the GNU Lesser General Public License * 11: * as published by the Free Software Foundation; either version 2 * 12: * of the License, or (at your option) any later version. * 13: * See the GNU Lesser General Public License for more details: lgpl.txt or * 14: * http://www.fsf.org/copyleft/lesser.html * 15: * * 16: * Anonymous FTP access to the most recent released source is available at * 17: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * 18: * * 19: * Anonymous CVS access to the development source and modification history * 20: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * 21: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * 22: * (just hit return, no password is necessary) * 23: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * 24: * * 25: * For Synchronet coding style and modification guidelines, see * 26: * http://www.synchro.net/source.html * 27: * * 28: * You are encouraged to submit any modifications (preferably in Unix diff * 29: * format) via e-mail to [email protected] * 30: * * 31: * Note: If this box doesn't appear square, then you need to fix your tabs. * 32: ****************************************************************************/ 33: 34: /* Icon file! */ 35: #ifdef __BORLANDC__ 36: #pragma resource "ciolib.res" 1.1.1.2 ! root 37: /* DO NOT REMOVE THE EXTRA \r! */ 1.1 root 38: #endif 39: 40: #include <stdarg.h> 41: #include <stdlib.h> /* alloca */ 42: #include <stdio.h> 43: #if defined(_WIN32) 44: #include <malloc.h> /* alloca() on Win32 */ 45: #endif 46: 47: #include <threadwrap.h> 1.1.1.2 ! root 48: #include <genwrap.h> ! 49: #include <xpbeep.h> 1.1 root 50: 51: #define CIOLIB_NO_MACROS 52: #include "ciolib.h" 53: 1.1.1.2 ! root 54: #if defined(WITH_SDL) || defined(WITH_SDL_AUDIO) 1.1 root 55: #include "sdl_con.h" 56: #endif 57: #ifdef _WIN32 58: #include "win32cio.h" 59: #else 60: #ifndef NO_X 61: #include "x_cio.h" 62: #endif 63: #include "curs_cio.h" 64: #undef getch 65: #endif 66: 1.1.1.2 ! root 67: #include "bitmap_con.h" 1.1 root 68: #include "ansi_cio.h" 69: 70: CIOLIBEXPORT cioapi_t cio_api; 71: 1.1.1.2 ! root 72: static const int tabs[]={1,9,17,25,33,41,49,57,65,73,81,89,97,105,113,121,129,137,145}; 1.1 root 73: static int ungotch; 1.1.1.2 ! root 74: struct text_info cio_textinfo; ! 75: static int lastmode=C80; 1.1 root 76: CIOLIBEXPORT int _wscroll=1; 77: CIOLIBEXPORT int directvideo=0; 78: CIOLIBEXPORT int hold_update=0; 79: CIOLIBEXPORT int puttext_can_move=0; 80: static int initialized=0; 81: 82: CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy); 83: CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str); 84: CIOLIBEXPORT int CIOLIBCALL ciolib_cscanf (char *format , ...); 85: CIOLIBEXPORT int CIOLIBCALL ciolib_kbhit(void); 86: CIOLIBEXPORT int CIOLIBCALL ciolib_getch(void); 87: CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void); 88: CIOLIBEXPORT int CIOLIBCALL ciolib_ungetch(int ch); 89: CIOLIBEXPORT void CIOLIBCALL ciolib_gettextinfo(struct text_info *info); 90: CIOLIBEXPORT int CIOLIBCALL ciolib_wherex(void); 91: CIOLIBEXPORT int CIOLIBCALL ciolib_wherey(void); 92: CIOLIBEXPORT void CIOLIBCALL ciolib_wscroll(void); 93: CIOLIBEXPORT void CIOLIBCALL ciolib_gotoxy(int x, int y); 94: CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void); 95: CIOLIBEXPORT void CIOLIBCALL ciolib_clrscr(void); 96: CIOLIBEXPORT int CIOLIBCALL ciolib_cputs(char *str); 97: CIOLIBEXPORT int CIOLIBCALL ciolib_cprintf(char *fmat, ...); 98: CIOLIBEXPORT void CIOLIBCALL ciolib_textbackground(int colour); 99: CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour); 100: CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void); 101: CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void); 102: CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void); 103: CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e); 104: CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e); 105: CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a); 106: CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a); 107: CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a); 108: CIOLIBEXPORT void CIOLIBCALL ciolib_setcursortype(int a); 109: CIOLIBEXPORT void CIOLIBCALL ciolib_textmode(int mode); 110: CIOLIBEXPORT void CIOLIBCALL ciolib_window(int sx, int sy, int ex, int ey); 111: CIOLIBEXPORT void CIOLIBCALL ciolib_delline(void); 112: CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void); 113: CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt); 114: CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen); 115: CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void); 1.1.1.2 ! root 116: CIOLIBEXPORT int CIOLIBCALL ciolib_get_window_info(int *width, int *height, int *xpos, int *ypos); 1.1 root 117: 118: #define CIOLIB_INIT() { if(initialized != 1) initciolib(CIOLIB_MODE_AUTO); } 119: 1.1.1.2 ! root 120: #if defined(WITH_SDL) || defined(WITH_SDL_AUDIO) 1.1 root 121: int try_sdl_init(int mode) 122: { 123: if(!sdl_initciolib(mode)) { 124: cio_api.mouse=1; 1.1.1.2 ! root 125: cio_api.puttext=bitmap_puttext; ! 126: cio_api.gettext=bitmap_gettext; ! 127: cio_api.gotoxy=bitmap_gotoxy; ! 128: cio_api.setcursortype=bitmap_setcursortype; ! 129: cio_api.setfont=bitmap_setfont; ! 130: cio_api.getfont=bitmap_getfont; ! 131: cio_api.loadfont=bitmap_loadfont; ! 132: cio_api.movetext=bitmap_movetext; ! 133: cio_api.clreol=bitmap_clreol; ! 134: cio_api.clrscr=bitmap_clrscr; ! 135: cio_api.getcustomcursor=bitmap_getcustomcursor; ! 136: cio_api.setcustomcursor=bitmap_setcustomcursor; ! 137: cio_api.getvideoflags=bitmap_getvideoflags; ! 138: cio_api.setvideoflags=bitmap_setvideoflags; ! 139: 1.1 root 140: cio_api.kbhit=sdl_kbhit; 141: cio_api.getch=sdl_getch; 142: cio_api.textmode=sdl_textmode; 143: cio_api.showmouse=sdl_showmouse; 144: cio_api.hidemouse=sdl_hidemouse; 145: cio_api.setname=sdl_setname; 1.1.1.2 ! root 146: cio_api.seticon=sdl_seticon; 1.1 root 147: cio_api.settitle=sdl_settitle; 148: #ifdef _WIN32 149: cio_api.copytext=win32_copytext; 150: cio_api.getcliptext=win32_getcliptext; 151: #else 152: cio_api.copytext=sdl_copytext; 153: cio_api.getcliptext=sdl_getcliptext; 154: #endif 1.1.1.2 ! root 155: cio_api.get_window_info=sdl_get_window_info; 1.1 root 156: return(1); 157: } 158: return(0); 159: } 160: #endif 161: 162: #ifndef _WIN32 163: #ifndef NO_X 164: int try_x_init(int mode) 165: { 1.1.1.2 ! root 166: if(!x_init()) { 1.1 root 167: cio_api.mode=CIOLIB_MODE_X; 168: cio_api.mouse=1; 1.1.1.2 ! root 169: cio_api.puttext=bitmap_puttext; ! 170: cio_api.gettext=bitmap_gettext; ! 171: cio_api.gotoxy=bitmap_gotoxy; ! 172: cio_api.setcursortype=bitmap_setcursortype; ! 173: cio_api.setfont=bitmap_setfont; ! 174: cio_api.getfont=bitmap_getfont; ! 175: cio_api.loadfont=bitmap_loadfont; ! 176: cio_api.beep=x_beep; ! 177: cio_api.movetext=bitmap_movetext; ! 178: cio_api.clreol=bitmap_clreol; ! 179: cio_api.clrscr=bitmap_clrscr; ! 180: cio_api.getcustomcursor=bitmap_getcustomcursor; ! 181: cio_api.setcustomcursor=bitmap_setcustomcursor; ! 182: cio_api.getvideoflags=bitmap_getvideoflags; ! 183: cio_api.setvideoflags=bitmap_setvideoflags; ! 184: 1.1 root 185: cio_api.kbhit=x_kbhit; 186: cio_api.getch=x_getch; 187: cio_api.textmode=x_textmode; 188: cio_api.setname=x_setname; 189: cio_api.settitle=x_settitle; 190: cio_api.copytext=x_copytext; 191: cio_api.getcliptext=x_getcliptext; 1.1.1.2 ! root 192: cio_api.get_window_info=x_get_window_info; 1.1 root 193: return(1); 194: } 195: return(0); 196: } 197: #endif 198: 199: int try_curses_init(int mode) 200: { 201: if(curs_initciolib(mode)) { 1.1.1.2 ! root 202: if(mode==CIOLIB_MODE_AUTO) ! 203: mode=CIOLIB_MODE_CURSES; ! 204: cio_api.mode=mode; 1.1 root 205: cio_api.puttext=curs_puttext; 206: cio_api.gettext=curs_gettext; 207: cio_api.textattr=curs_textattr; 208: cio_api.kbhit=curs_kbhit; 209: cio_api.gotoxy=curs_gotoxy; 210: cio_api.setcursortype=curs_setcursortype; 211: cio_api.getch=curs_getch; 212: cio_api.textmode=curs_textmode; 213: cio_api.showmouse=curs_showmouse; 214: cio_api.hidemouse=curs_hidemouse; 215: cio_api.suspend=curs_suspend; 216: cio_api.resume=curs_resume; 1.1.1.2 ! root 217: cio_api.beep=curs_beep; ! 218: #if defined(NCURSES_VERSION_MAJOR) || defined (__NetBSD__) 1.1 root 219: cio_api.ESCDELAY=&ESCDELAY; 220: #endif 221: return(1); 222: } 223: return(0); 224: } 225: #endif 226: 227: int try_ansi_init(int mode) 228: { 229: if(ansi_initciolib(mode)) { 230: cio_api.mode=CIOLIB_MODE_ANSI; 231: cio_api.mouse=0; 232: cio_api.puttext=ansi_puttext; 233: cio_api.gettext=ansi_gettext; 234: cio_api.textattr=ansi_textattr; 235: cio_api.kbhit=ansi_kbhit; 236: cio_api.gotoxy=ansi_gotoxy; 237: cio_api.setcursortype=ansi_setcursortype; 238: cio_api.getch=ansi_getch; 239: cio_api.textmode=ansi_textmode; 240: cio_api.ESCDELAY=&CIOLIB_ANSI_TIMEOUT; 1.1.1.2 ! root 241: cio_api.beep=ansi_beep; 1.1 root 242: return(1); 243: } 244: return(0); 245: } 246: 247: #ifdef _WIN32 248: #if defined(__BORLANDC__) 249: #pragma argsused 250: #endif 251: int try_conio_init(int mode) 252: { 253: /* This should test for something or other */ 254: if(win32_initciolib(mode)) { 1.1.1.2 ! root 255: if(mode==CIOLIB_MODE_AUTO) ! 256: cio_api.mode=CIOLIB_MODE_CONIO; ! 257: else ! 258: cio_api.mode=mode; /* CIOLIB_MODE_CONIO or CIOLIB_MODE_CONIO_FULLSCREEN */ 1.1 root 259: cio_api.mouse=1; 260: cio_api.puttext=win32_puttext; 261: cio_api.gettext=win32_gettext; 262: cio_api.kbhit=win32_kbhit; 263: cio_api.gotoxy=win32_gotoxy; 264: cio_api.setcursortype=win32_setcursortype; 265: cio_api.getch=win32_getch; 266: cio_api.textmode=win32_textmode; 267: cio_api.showmouse=win32_showmouse; 268: cio_api.hidemouse=win32_hidemouse; 269: cio_api.setname=win32_settitle; 270: cio_api.settitle=win32_settitle; 271: cio_api.copytext=win32_copytext; 272: cio_api.getcliptext=win32_getcliptext; 273: cio_api.suspend=win32_suspend; 274: cio_api.resume=win32_resume; 1.1.1.2 ! root 275: cio_api.getcustomcursor=win32_getcustomcursor; ! 276: cio_api.setcustomcursor=win32_setcustomcursor; ! 277: cio_api.getvideoflags=win32_getvideoflags; 1.1 root 278: return(1); 279: } 280: return(0); 281: } 282: #endif 283: 1.1.1.2 ! root 284: /* Optional */ 1.1 root 285: CIOLIBEXPORT void CIOLIBCALL suspendciolib(void) 286: { 287: ciolib_clrscr(); 288: if(cio_api.suspend != NULL) 289: cio_api.suspend(); 290: initialized=-1; 291: } 292: 293: CIOLIBEXPORT int CIOLIBCALL initciolib(int mode) 294: { 295: switch(initialized) { 296: case 1: 297: return(0); 298: case -1: 299: initialized=1; 300: if(cio_api.resume != NULL) 301: cio_api.resume(); 302: ciolib_clrscr(); 303: return(0); 304: } 305: 306: memset(&cio_api,0,sizeof(cio_api)); 307: 308: switch(mode) { 309: case CIOLIB_MODE_AUTO: 1.1.1.2 ! root 310: #if defined(WITH_SDL) || defined(WITH_SDL_AUDIO) ! 311: if(!try_sdl_init(CIOLIB_MODE_SDL)) 1.1 root 312: #endif 313: #ifdef _WIN32 314: if(!try_conio_init(mode)) 315: #else 316: #ifndef NO_X 317: if(!try_x_init(mode)) 318: #endif 319: if(!try_curses_init(mode)) 320: #endif 321: try_ansi_init(mode); 322: break; 323: #ifdef _WIN32 324: case CIOLIB_MODE_CONIO: 1.1.1.2 ! root 325: case CIOLIB_MODE_CONIO_FULLSCREEN: 1.1 root 326: try_conio_init(mode); 327: break; 328: #else 329: case CIOLIB_MODE_CURSES: 330: case CIOLIB_MODE_CURSES_IBM: 331: try_curses_init(mode); 332: break; 333: 334: case CIOLIB_MODE_X: 335: #ifndef NO_X 336: try_x_init(mode); 337: #endif 338: break; 339: #endif 340: case CIOLIB_MODE_ANSI: 341: try_ansi_init(mode); 342: break; 343: 1.1.1.2 ! root 344: #if defined(WITH_SDL) || defined(WITH_SDL_AUDIO) 1.1 root 345: case CIOLIB_MODE_SDL: 346: case CIOLIB_MODE_SDL_FULLSCREEN: 1.1.1.2 ! root 347: case CIOLIB_MODE_SDL_YUV: ! 348: case CIOLIB_MODE_SDL_YUV_FULLSCREEN: 1.1 root 349: try_sdl_init(mode); 350: break; 351: #endif 352: } 353: if(cio_api.mode==CIOLIB_MODE_AUTO) { 354: fprintf(stderr,"CIOLIB initialization failed!\n"); 355: return(-1); 356: } 357: 358: initialized=1; 359: cio_textinfo.winleft=1; 360: cio_textinfo.wintop=1; 361: cio_textinfo.winright=cio_textinfo.screenwidth; 362: cio_textinfo.winbottom=cio_textinfo.screenheight; 1.1.1.2 ! root 363: /* Default C64 is Lt Blue on Black (As per CGTerm) */ ! 364: switch(cio_textinfo.currmode) { ! 365: case C64_40X25: ! 366: case C128_40X25: ! 367: case C128_80X25: ! 368: cio_textinfo.normattr=14; ! 369: break; ! 370: default: ! 371: cio_textinfo.normattr=LIGHTGRAY; ! 372: } 1.1 root 373: _beginthread(ciolib_mouse_thread,0,NULL); 374: return(0); 375: } 376: 1.1.1.2 ! root 377: /* **MUST** be implemented */ 1.1 root 378: CIOLIBEXPORT int CIOLIBCALL ciolib_kbhit(void) 379: { 380: CIOLIB_INIT(); 381: if(ungotch) 382: return(1); 383: return(cio_api.kbhit()); 384: } 385: 1.1.1.2 ! root 386: /* **MUST** be implemented */ 1.1 root 387: CIOLIBEXPORT int CIOLIBCALL ciolib_getch(void) 388: { 389: int ch; 390: 391: CIOLIB_INIT(); 392: 393: if(ungotch) { 394: ch=ungotch; 395: ungotch=0; 396: return(ch); 397: } 398: return(cio_api.getch()); 399: } 400: 1.1.1.2 ! root 401: /* Optional */ 1.1 root 402: CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void) 403: { 404: int ch; 405: 406: CIOLIB_INIT(); 407: 408: if(ungotch) { 409: ch=ungotch; 410: ungotch=0; 411: ciolib_putch(ch); 412: return(ch); 413: } 1.1.1.2 ! root 414: if(cio_api.getche()) ! 415: return(cio_api.getche()); ! 416: else { ! 417: while(1) { ! 418: ch=ciolib_getch(); ! 419: if(ch != 0 && ch != 0xe0) { ! 420: ciolib_putch(ch); ! 421: return(ch); ! 422: } ! 423: /* Eat extended chars - except ESC which is an abort */ ! 424: if(ciolib_getch()==1) ! 425: return(EOF); ! 426: } ! 427: } 1.1 root 428: } 429: 1.1.1.2 ! root 430: /* Optional */ 1.1 root 431: CIOLIBEXPORT int CIOLIBCALL ciolib_ungetch(int ch) 432: { 433: CIOLIB_INIT(); 1.1.1.2 ! root 434: 1.1 root 435: if(ungotch) 436: return(EOF); 1.1.1.2 ! root 437: if(cio_api.ungetch) ! 438: return(cio_api.ungetch(ch)); 1.1 root 439: ungotch=ch; 440: return(ch); 441: } 442: 1.1.1.2 ! root 443: /* Optional */ 1.1 root 444: CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy) 445: { 446: int width; 447: int height; 448: unsigned char *buf; 449: 450: CIOLIB_INIT(); 451: 452: if(cio_api.movetext != NULL) 453: return(cio_api.movetext(sx, sy, ex, ey, dx, dy)); 454: 455: width=ex-sx; 456: height=ey-sy; 457: buf=(unsigned char *)alloca((width+1)*(height+1)*2); 458: if(buf==NULL) 459: return(0); 460: if(!ciolib_gettext(sx,sy,ex,ey,buf)) 461: return(0); 462: if(!ciolib_puttext(dx,dy,dx+width,dy+height,buf)) 463: return(0); 464: return(1); 465: } 466: 1.1.1.2 ! root 467: /* Optional */ 1.1 root 468: CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str) 469: { 470: int maxlen; 471: int len=0; 472: int ch; 473: 474: CIOLIB_INIT(); 1.1.1.2 ! root 475: ! 476: if(cio_api.cgets) ! 477: return(cio_api.cgets(str)); ! 478: 1.1 root 479: maxlen=*(unsigned char *)str; 480: while((ch=ciolib_getch())!='\n' && ch !='\r') { 481: switch(ch) { 1.1.1.2 ! root 482: case 0: /* Skip extended keys */ ! 483: case 0xe0: /* Skip extended keys */ ! 484: if(ciolib_getche()==1) ! 485: goto early_return; 1.1 root 486: break; 487: case '\r': /* Skip \r (ToDo: Should this be treated as a \n? */ 488: break; 489: case '\b': 490: if(len==0) { 491: ciolib_putch(7); 492: break; 493: } 494: ciolib_putch('\b'); 495: len--; 496: break; 497: default: 498: ciolib_putch(ch); 499: str[(len++)+2]=ch; 500: if(len==maxlen) { 501: str[len+2]=0; 502: *((unsigned char *)(str+1))=(unsigned char)len; 503: ciolib_putch('\r'); 504: ciolib_putch('\n'); 505: return(&str[2]); 506: } 507: break; 508: } 509: } 1.1.1.2 ! root 510: early_return: 1.1 root 511: str[len+2]=0; 512: *((unsigned char *)(str+1))=(unsigned char)len; 513: ciolib_putch('\r'); 514: ciolib_putch('\n'); 515: return(&str[2]); 516: } 517: 518: #ifdef _MSC_VER /* Use lame vsscanf() implementation */ 519: /* This is a way to do _vsscanf without using fancy stack tricks or using the 520: * "_input" method provided by Microsoft, which is no longer exported as of .NET. 521: * The function has a limit of 25 arguments (or less if you run out of stack space), 522: * but how many arguments do you need? 523: */ 524: /* From "krabsheva" - http://www.codeguru.com/Cpp/Cpp/string/comments.php/c5631/?thread=1051 */ 525: int vsscanf( const char *buffer, const char *format, va_list arg_ptr ) 526: { 527: int i, ret; 528: void *arg_arr[25]; 529: 530: /* Do exception handling in case we go too far // */ 531: __try 532: { 533: for ( i = 0; i < 25; i++ ) 534: arg_arr[i] = va_arg( arg_ptr, void * ); 535: } 536: __except( EXCEPTION_EXECUTE_HANDLER ) 537: { 538: } 539: 540: /* This is lame, but the extra arguments won't be used by sscanf */ 541: ret = sscanf( buffer, format, arg_arr[0], arg_arr[1], arg_arr[2], arg_arr[3], 542: arg_arr[4], arg_arr[5], arg_arr[6], arg_arr[7], arg_arr[8], arg_arr[9], 543: arg_arr[10], arg_arr[11], arg_arr[12], arg_arr[13], arg_arr[14], 544: arg_arr[15], arg_arr[16], arg_arr[17], arg_arr[18], arg_arr[19], 545: arg_arr[20], arg_arr[21], arg_arr[22], arg_arr[23], arg_arr[24] ); 546: 547: return ret; 548: } 549: #endif 550: 1.1.1.2 ! root 551: /* Optional... in fact, since it's varargs, you can't override it */ 1.1 root 552: CIOLIBEXPORT int CIOLIBCALL ciolib_cscanf (char *format , ...) 553: { 554: char str[255]; 555: va_list argptr; 556: int ret; 557: 558: CIOLIB_INIT(); 1.1.1.2 ! root 559: 1.1 root 560: str[0]=-1; 561: va_start(argptr,format); 562: ret=vsscanf(ciolib_cgets(str),format,argptr); 563: va_end(argptr); 564: return(ret); 565: } 566: 1.1.1.2 ! root 567: /* Optional */ 1.1 root 568: CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt) 569: { 570: static char pass[9]; 571: int len=0; 572: int ch; 573: 574: CIOLIB_INIT(); 1.1.1.2 ! root 575: ! 576: if(cio_api.getpass) ! 577: return(cio_api.getpass(prompt)); ! 578: 1.1 root 579: ciolib_cputs((char *)prompt); 580: while((ch=ciolib_getch())!='\n') { 581: switch(ch) { 1.1.1.2 ! root 582: case 0: /* Skip extended keys */ ! 583: case 0xe0: /* Skip extended keys */ ! 584: if(ciolib_getch()==1) ! 585: goto early_return; 1.1 root 586: break; 587: case '\r': /* Skip \r (ToDo: Should this be treeated as a \n? */ 588: break; 589: case '\b': 590: if(len==0) { 591: ciolib_putch(7); 592: break; 593: } 594: len--; 595: break; 596: default: 597: if(len==8) 598: ciolib_putch(7); 599: else 600: pass[len++]=ch; 601: break; 602: } 603: } 1.1.1.2 ! root 604: early_return: 1.1 root 605: pass[len]=0; 606: return(pass); 607: } 608: 1.1.1.2 ! root 609: /* TODO: Hackery here... must fix */ ! 610: /* Optional */ 1.1 root 611: CIOLIBEXPORT void CIOLIBCALL ciolib_gettextinfo(struct text_info *info) 612: { 1.1.1.2 ! root 613: ! 614: CIOLIB_INIT() ! 615: ! 616: if(cio_api.gettextinfo) { 1.1 root 617: cio_api.gettextinfo(&cio_textinfo); 1.1.1.2 ! root 618: return; 1.1 root 619: } 1.1.1.2 ! root 620: ! 621: if(info!=&cio_textinfo) ! 622: *info=cio_textinfo; 1.1 root 623: } 624: 1.1.1.2 ! root 625: /* Optional */ 1.1 root 626: CIOLIBEXPORT void CIOLIBCALL ciolib_wscroll(void) 627: { 628: int os; 629: 630: CIOLIB_INIT(); 631: 632: if(cio_api.wscroll!=NULL) { 633: cio_api.wscroll(); 634: return; 635: } 636: if(!_wscroll) 637: return; 1.1.1.2 ! root 638: ciolib_movetext(cio_textinfo.winleft ! 639: ,cio_textinfo.wintop+1 ! 640: ,cio_textinfo.winright ! 641: ,cio_textinfo.winbottom ! 642: ,cio_textinfo.winleft ! 643: ,cio_textinfo.wintop); ! 644: ciolib_gotoxy(1,cio_textinfo.winbottom-cio_textinfo.wintop+1); 1.1 root 645: os=_wscroll; 646: _wscroll=0; 647: /* ciolib_cprintf("%*s",ti.winright-ti.winleft+1,""); */ 648: ciolib_clreol(); 649: _wscroll=os; 1.1.1.2 ! root 650: ciolib_gotoxy(cio_textinfo.curx,cio_textinfo.cury); 1.1 root 651: } 652: 1.1.1.2 ! root 653: /* Optional */ 1.1 root 654: CIOLIBEXPORT int CIOLIBCALL ciolib_wherex(void) 655: { 656: int x; 657: 658: CIOLIB_INIT(); 1.1.1.2 ! root 659: ! 660: if(cio_api.wherex) { ! 661: /* TODO: This is old hackery... beware */ ! 662: x=cio_api.wherex(); ! 663: x=x-cio_textinfo.winleft+1; ! 664: } ! 665: else ! 666: x=cio_textinfo.curx; 1.1 root 667: return(x); 668: } 669: 1.1.1.2 ! root 670: /* Optional */ 1.1 root 671: CIOLIBEXPORT int CIOLIBCALL ciolib_wherey(void) 672: { 673: int y; 674: 675: CIOLIB_INIT(); 1.1.1.2 ! root 676: ! 677: if(cio_api.wherey) { ! 678: /* TODO: This is old hackery... beware */ ! 679: y=cio_api.wherey(); ! 680: y=y-cio_textinfo.wintop+1; ! 681: } ! 682: else ! 683: y=cio_textinfo.cury; 1.1 root 684: return(y); 685: } 686: 1.1.1.2 ! root 687: /* **MUST** be implemented */ 1.1 root 688: CIOLIBEXPORT void CIOLIBCALL ciolib_gotoxy(int x, int y) 689: { 690: CIOLIB_INIT(); 1.1.1.2 ! root 691: 1.1 root 692: if( x < 1 1.1.1.2 ! root 693: || x > cio_textinfo.winright-cio_textinfo.winleft+1 1.1 root 694: || y < 1 1.1.1.2 ! root 695: || y > cio_textinfo.winbottom-cio_textinfo.wintop+1) 1.1 root 696: return; 1.1.1.2 ! root 697: cio_api.gotoxy(x,y); 1.1 root 698: } 699: 1.1.1.2 ! root 700: /* **MUST** be implemented */ 1.1 root 701: CIOLIBEXPORT void CIOLIBCALL ciolib_textmode(int mode) 702: { 703: CIOLIB_INIT(); 1.1.1.2 ! root 704: ! 705: if(mode==LASTMODE) { 1.1 root 706: cio_api.textmode(lastmode); 707: lastmode=cio_textinfo.currmode; 708: } 709: else { 1.1.1.2 ! root 710: if(mode==64) ! 711: mode=C80X50; ! 712: if(mode==_ORIGMODE) ! 713: mode=C80; 1.1 root 714: lastmode=cio_textinfo.currmode; 715: cio_api.textmode(mode); 716: } 717: cio_textinfo.winleft=1; 718: cio_textinfo.wintop=1; 719: cio_textinfo.winright=cio_textinfo.screenwidth; 720: cio_textinfo.winbottom=cio_textinfo.screenheight; 1.1.1.2 ! root 721: switch(cio_textinfo.currmode) { ! 722: case C64_40X25: ! 723: case C128_40X25: ! 724: case C128_80X25: ! 725: cio_textinfo.normattr=14; ! 726: break; ! 727: default: ! 728: cio_textinfo.normattr=7; ! 729: } 1.1 root 730: } 731: 1.1.1.2 ! root 732: /* Optional */ 1.1 root 733: CIOLIBEXPORT void CIOLIBCALL ciolib_window(int sx, int sy, int ex, int ey) 734: { 735: CIOLIB_INIT(); 1.1.1.2 ! root 736: ! 737: if(cio_api.window) ! 738: cio_api.window(sx,sy,ex,ey); ! 739: 1.1 root 740: if( sx < 1 741: || sy < 1 742: || ex < 1 743: || ey < 1 744: || sx > cio_textinfo.screenwidth 745: || sy > cio_textinfo.screenheight 746: || sx > ex 747: || sy > ey 748: || ex > cio_textinfo.screenwidth 749: || ey > cio_textinfo.screenheight) 750: return; 751: cio_textinfo.winleft=sx; 752: cio_textinfo.wintop=sy; 753: cio_textinfo.winright=ex; 754: cio_textinfo.winbottom=ey; 755: ciolib_gotoxy(1,1); 756: } 757: 1.1.1.2 ! root 758: /* Optional */ 1.1 root 759: CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void) 760: { 761: unsigned char *buf; 762: int i; 763: int width,height; 764: 765: CIOLIB_INIT(); 766: 1.1.1.2 ! root 767: if(cio_api.clreol) { ! 768: cio_api.clreol(); ! 769: return; ! 770: } ! 771: ! 772: width=cio_textinfo.winright-cio_textinfo.winleft+1-cio_textinfo.curx+1; 1.1 root 773: height=1; 774: buf=(unsigned char *)alloca(width*height*2); 775: for(i=0;i<width*height*2;) { 776: buf[i++]=' '; 1.1.1.2 ! root 777: buf[i++]=cio_textinfo.attribute; 1.1 root 778: } 1.1.1.2 ! root 779: ciolib_puttext( ! 780: cio_textinfo.curx+cio_textinfo.winleft-1, ! 781: cio_textinfo.cury+cio_textinfo.wintop-1, ! 782: cio_textinfo.winright, ! 783: cio_textinfo.cury+cio_textinfo.wintop-1, ! 784: buf); 1.1 root 785: } 786: 1.1.1.2 ! root 787: /* Optional */ 1.1 root 788: CIOLIBEXPORT void CIOLIBCALL ciolib_clrscr(void) 789: { 790: unsigned char *buf; 791: int i; 792: int width,height; 1.1.1.2 ! root 793: int old_ptcm=puttext_can_move; 1.1 root 794: 795: CIOLIB_INIT(); 1.1.1.2 ! root 796: if(cio_api.clrscr) { ! 797: cio_api.clrscr(); ! 798: return; ! 799: } 1.1 root 800: 1.1.1.2 ! root 801: width=cio_textinfo.winright-cio_textinfo.winleft+1; ! 802: height=cio_textinfo.winbottom-cio_textinfo.wintop+1; 1.1 root 803: buf=(unsigned char *)alloca(width*height*2); 804: for(i=0;i<width*height*2;) { 805: buf[i++]=' '; 1.1.1.2 ! root 806: buf[i++]=cio_textinfo.attribute; 1.1 root 807: } 1.1.1.2 ! root 808: puttext_can_move=1; ! 809: ciolib_puttext(cio_textinfo.winleft,cio_textinfo.wintop,cio_textinfo.winright,cio_textinfo.winbottom,buf); 1.1 root 810: ciolib_gotoxy(1,1); 1.1.1.2 ! root 811: puttext_can_move=old_ptcm; 1.1 root 812: } 813: 1.1.1.2 ! root 814: /* Optional */ 1.1 root 815: CIOLIBEXPORT void CIOLIBCALL ciolib_delline(void) 816: { 817: CIOLIB_INIT(); 818: 1.1.1.2 ! root 819: if(cio_api.delline) { ! 820: cio_api.delline(); ! 821: return; ! 822: } ! 823: ciolib_movetext(cio_textinfo.winleft ! 824: ,cio_textinfo.cury+1 ! 825: ,cio_textinfo.winright ! 826: ,cio_textinfo.winbottom ! 827: ,cio_textinfo.winleft ! 828: ,cio_textinfo.cury); ! 829: ciolib_gotoxy(1,cio_textinfo.winbottom-cio_textinfo.wintop+1); 1.1 root 830: ciolib_clreol(); 1.1.1.2 ! root 831: ciolib_gotoxy(cio_textinfo.curx,cio_textinfo.cury); 1.1 root 832: } 833: 1.1.1.2 ! root 834: /* Optional */ 1.1 root 835: CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void) 836: { 837: CIOLIB_INIT(); 838: 1.1.1.2 ! root 839: if(cio_api.insline) { ! 840: cio_api.insline(); ! 841: return; ! 842: } ! 843: ciolib_movetext(cio_textinfo.winleft,cio_textinfo.cury,cio_textinfo.winright,cio_textinfo.winbottom,cio_textinfo.winleft,cio_textinfo.cury+1); ! 844: ciolib_gotoxy(1,cio_textinfo.cury); 1.1 root 845: ciolib_clreol(); 1.1.1.2 ! root 846: ciolib_gotoxy(cio_textinfo.curx,cio_textinfo.cury); 1.1 root 847: } 848: 1.1.1.2 ! root 849: /* Not overridable due to varargs */ 1.1 root 850: CIOLIBEXPORT int CIOLIBCALL ciolib_cprintf(char *fmat, ...) 851: { 852: va_list argptr; 853: int ret; 854: #ifdef _MSC_VER /* Can't figure out a way to allocate a "big enough" buffer for Win32. */ 855: char str[16384]; 856: #else 857: char *str; 1.1.1.2 ! root 858: #ifndef HAVE_VASPRINTF ! 859: va_list argptr2; ! 860: #endif 1.1 root 861: #endif 862: 863: CIOLIB_INIT(); 864: 865: va_start(argptr,fmat); 1.1.1.2 ! root 866: ! 867: #ifdef HAVE_VASPRINTF ! 868: ret=vasprintf(&str, fmat, argptr); ! 869: if(ret>=0) ! 870: ciolib_cputs(str); ! 871: else ! 872: ret=EOF; ! 873: free(str); ! 874: #else ! 875: 1.1 root 876: #ifdef _MSC_VER 877: ret=_vsnprintf(str,sizeof(str)-1,fmat,argptr); 878: #else 1.1.1.2 ! root 879: ! 880: #ifdef __BORLANDC__ ! 881: argptr2=argptr; ! 882: #else ! 883: va_copy(argptr2, argptr); ! 884: #endif 1.1 root 885: ret=vsnprintf(NULL,0,fmat,argptr); 886: if(ret<0) 887: return(EOF); 888: str=(char *)alloca(ret+1); 889: if(str==NULL) 890: return(EOF); 1.1.1.2 ! root 891: ret=vsprintf(str,fmat,argptr2); 1.1 root 892: #endif 893: va_end(argptr); 1.1.1.2 ! root 894: #ifndef _MSC_VER ! 895: va_end(argptr2); ! 896: #endif 1.1 root 897: if(ret>=0) 898: ciolib_cputs(str); 899: else 900: ret=EOF; 1.1.1.2 ! root 901: ! 902: #endif ! 903: 1.1 root 904: return(ret); 905: } 906: 1.1.1.2 ! root 907: /* Optional */ 1.1 root 908: CIOLIBEXPORT int CIOLIBCALL ciolib_cputs(char *str) 909: { 910: int pos; 911: int ret=0; 912: int olddmc; 913: 914: CIOLIB_INIT(); 915: 1.1.1.2 ! root 916: if(cio_api.cputs) ! 917: return(cio_api.cputs(str)); ! 918: 1.1 root 919: olddmc=hold_update; 920: hold_update=1; 921: for(pos=0;str[pos];pos++) 922: { 923: ret=str[pos]; 924: if(str[pos]=='\n') 925: ciolib_putch('\r'); 926: ciolib_putch(str[pos]); 927: } 928: hold_update=olddmc; 929: ciolib_gotoxy(ciolib_wherex(),ciolib_wherey()); 930: return(ret); 931: } 932: 1.1.1.2 ! root 933: /* Optional... and overriding is silly */ 1.1 root 934: CIOLIBEXPORT void CIOLIBCALL ciolib_textbackground(int colour) 935: { 936: unsigned char attr; 937: unsigned char col; 938: 939: CIOLIB_INIT(); 1.1.1.2 ! root 940: ! 941: if(cio_api.textbackground) { ! 942: cio_api.textbackground(colour); ! 943: return; ! 944: } ! 945: 1.1 root 946: attr=cio_textinfo.attribute; 947: attr&=143; 948: col=(colour & 0x07); 949: attr|=(col<<4); 950: ciolib_textattr(attr); 951: } 952: 1.1.1.2 ! root 953: /* Optional... and overriding is silly */ 1.1 root 954: CIOLIBEXPORT void CIOLIBCALL ciolib_textcolor(int colour) 955: { 956: unsigned char attr; 957: unsigned char col; 958: 959: CIOLIB_INIT(); 1.1.1.2 ! root 960: ! 961: if(cio_api.textcolor) { ! 962: cio_api.textcolor(colour); ! 963: return; ! 964: } ! 965: 1.1 root 966: attr=cio_textinfo.attribute; 967: attr&=240; 968: col=colour&0x0f; 969: attr|=col; 970: ciolib_textattr(attr); 971: } 972: 1.1.1.2 ! root 973: /* Optional... and overriding is silly */ 1.1 root 974: CIOLIBEXPORT void CIOLIBCALL ciolib_highvideo(void) 975: { 976: int attr; 977: 978: CIOLIB_INIT(); 1.1.1.2 ! root 979: ! 980: if(cio_api.highvideo) { ! 981: cio_api.highvideo(); ! 982: return; ! 983: } ! 984: 1.1 root 985: attr=cio_textinfo.attribute; 986: attr |= 8; 987: ciolib_textattr(attr); 988: } 989: 1.1.1.2 ! root 990: /* Optional... and overriding is silly */ 1.1 root 991: CIOLIBEXPORT void CIOLIBCALL ciolib_lowvideo(void) 992: { 993: int attr; 994: 995: CIOLIB_INIT(); 1.1.1.2 ! root 996: ! 997: if(cio_api.lowvideo) { ! 998: cio_api.lowvideo(); ! 999: return; ! 1000: } ! 1001: 1.1 root 1002: attr=cio_textinfo.attribute; 1003: attr &= 0xf7; 1004: ciolib_textattr(attr); 1005: } 1006: 1.1.1.2 ! root 1007: /* Optional... and overriding is silly */ 1.1 root 1008: CIOLIBEXPORT void CIOLIBCALL ciolib_normvideo(void) 1009: { 1010: CIOLIB_INIT(); 1011: 1.1.1.2 ! root 1012: if(cio_api.normvideo) { ! 1013: cio_api.normvideo(); ! 1014: return; ! 1015: } ! 1016: ciolib_textattr(cio_textinfo.normattr); 1.1 root 1017: } 1018: 1.1.1.2 ! root 1019: /* **MUST** be implemented */ 1.1 root 1020: CIOLIBEXPORT int CIOLIBCALL ciolib_puttext(int a,int b,int c,int d,unsigned char *e) 1021: { 1022: CIOLIB_INIT(); 1023: 1024: return(cio_api.puttext(a,b,c,d,e)); 1025: } 1026: 1.1.1.2 ! root 1027: /* **MUST** be implemented */ 1.1 root 1028: CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,unsigned char *e) 1029: { 1030: CIOLIB_INIT(); 1031: 1032: return(cio_api.gettext(a,b,c,d,e)); 1033: } 1034: 1.1.1.2 ! root 1035: /* Optional */ 1.1 root 1036: CIOLIBEXPORT void CIOLIBCALL ciolib_textattr(int a) 1037: { 1038: CIOLIB_INIT(); 1.1.1.2 ! root 1039: ! 1040: if(cio_api.textattr) { ! 1041: cio_api.textattr(a); ! 1042: return; ! 1043: } ! 1044: ! 1045: cio_textinfo.attribute=a; 1.1 root 1046: } 1047: 1.1.1.2 ! root 1048: /* Optional */ 1.1 root 1049: CIOLIBEXPORT void CIOLIBCALL ciolib_delay(long a) 1050: { 1051: CIOLIB_INIT(); 1.1.1.2 ! root 1052: ! 1053: if(cio_api.delay) { ! 1054: cio_api.delay(a); ! 1055: return; ! 1056: } ! 1057: SLEEP(a); 1.1 root 1058: } 1059: 1.1.1.2 ! root 1060: /* Optional */ 1.1 root 1061: CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a) 1062: { 1063: unsigned char a1=a; 1.1.1.2 ! root 1064: unsigned char buf[2]; ! 1065: int i; ! 1066: int old_puttext_can_move=puttext_can_move; ! 1067: 1.1 root 1068: CIOLIB_INIT(); 1069: 1.1.1.2 ! root 1070: if(cio_api.putch) 1.1 root 1071: return(cio_api.putch(a1)); 1.1.1.2 ! root 1072: ! 1073: puttext_can_move=1; ! 1074: ! 1075: buf[0]=a1; ! 1076: buf[1]=cio_textinfo.attribute; ! 1077: ! 1078: switch(a1) { ! 1079: case '\r': ! 1080: ciolib_gotoxy(1,cio_textinfo.cury); ! 1081: break; ! 1082: case '\n': ! 1083: if(cio_textinfo.cury==cio_textinfo.winbottom-cio_textinfo.wintop+1) ! 1084: ciolib_wscroll(); ! 1085: else ! 1086: ciolib_gotoxy(cio_textinfo.curx, cio_textinfo.cury+1); ! 1087: break; ! 1088: case '\b': ! 1089: if(cio_textinfo.curx>1) { ! 1090: ciolib_gotoxy(cio_textinfo.curx-1,cio_textinfo.cury); ! 1091: buf[0]=' '; ! 1092: ciolib_puttext(cio_textinfo.curx+cio_textinfo.winleft-1 ! 1093: ,cio_textinfo.cury+cio_textinfo.wintop-1 ! 1094: ,cio_textinfo.curx+cio_textinfo.winleft-1 ! 1095: ,cio_textinfo.cury+cio_textinfo.wintop-1 ! 1096: ,buf); ! 1097: } ! 1098: break; ! 1099: case 7: /* Bell */ ! 1100: ciolib_beep(); ! 1101: break; ! 1102: case '\t': ! 1103: for(i=0;i<(sizeof(tabs)/sizeof(int));i++) { ! 1104: if(tabs[i]>cio_textinfo.curx) { ! 1105: buf[0]=' '; ! 1106: while(cio_textinfo.curx<tabs[i]) { ! 1107: ciolib_puttext(cio_textinfo.curx+cio_textinfo.winleft-1 ! 1108: ,cio_textinfo.cury+cio_textinfo.wintop-1 ! 1109: ,cio_textinfo.curx+cio_textinfo.winleft-1 ! 1110: ,cio_textinfo.cury+cio_textinfo.wintop-1 ! 1111: ,buf); ! 1112: ciolib_gotoxy(cio_textinfo.curx+1,cio_textinfo.cury); ! 1113: if(cio_textinfo.curx==cio_textinfo.screenwidth) ! 1114: break; ! 1115: } ! 1116: break; ! 1117: } ! 1118: } ! 1119: if(cio_textinfo.curx==cio_textinfo.screenwidth) { ! 1120: ciolib_gotoxy(1,cio_textinfo.cury); ! 1121: if(cio_textinfo.cury==cio_textinfo.winbottom-cio_textinfo.wintop+1) ! 1122: ciolib_wscroll(); ! 1123: else ! 1124: ciolib_gotoxy(cio_textinfo.curx, cio_textinfo.cury+1); ! 1125: } ! 1126: break; ! 1127: default: ! 1128: if(cio_textinfo.cury==cio_textinfo.winbottom-cio_textinfo.wintop+1 ! 1129: && cio_textinfo.curx==cio_textinfo.winright-cio_textinfo.winleft+1) { ! 1130: ciolib_puttext(ciolib_wherex()+cio_textinfo.winleft-1 ! 1131: ,ciolib_wherey()+cio_textinfo.wintop-1 ! 1132: ,ciolib_wherex()+cio_textinfo.winleft-1 ! 1133: ,ciolib_wherey()+cio_textinfo.wintop-1 ! 1134: ,buf); ! 1135: ciolib_wscroll(); ! 1136: ciolib_gotoxy(1, cio_textinfo.winbottom-cio_textinfo.wintop+1); ! 1137: } ! 1138: else { ! 1139: if(cio_textinfo.curx==cio_textinfo.winright-cio_textinfo.winleft+1) { ! 1140: ciolib_puttext(ciolib_wherex()+cio_textinfo.winleft-1 ! 1141: ,ciolib_wherey()+cio_textinfo.wintop-1 ! 1142: ,ciolib_wherex()+cio_textinfo.winleft-1 ! 1143: ,ciolib_wherey()+cio_textinfo.wintop-1 ! 1144: ,buf); ! 1145: ciolib_gotoxy(1,cio_textinfo.cury+1); ! 1146: } ! 1147: else { ! 1148: ciolib_puttext(ciolib_wherex()+cio_textinfo.winleft-1 ! 1149: ,ciolib_wherey()+cio_textinfo.wintop-1 ! 1150: ,ciolib_wherex()+cio_textinfo.winleft-1 ! 1151: ,ciolib_wherey()+cio_textinfo.wintop-1 ! 1152: ,buf); ! 1153: ciolib_gotoxy(cio_textinfo.curx+1, cio_textinfo.cury); ! 1154: } ! 1155: } ! 1156: break; ! 1157: } ! 1158: ! 1159: puttext_can_move=old_puttext_can_move; ! 1160: ! 1161: return(a1); ! 1162: 1.1 root 1163: } 1164: 1.1.1.2 ! root 1165: /* **MUST** be implemented */ 1.1 root 1166: CIOLIBEXPORT void CIOLIBCALL ciolib_setcursortype(int a) 1167: { 1168: CIOLIB_INIT(); 1169: 1170: cio_api.setcursortype(a); 1171: } 1172: 1.1.1.2 ! root 1173: /* Optional */ 1.1 root 1174: CIOLIBEXPORT int CIOLIBCALL ciolib_showmouse(void) { 1175: CIOLIB_INIT(); 1176: 1177: if(cio_api.showmouse!=NULL) 1178: return(cio_api.showmouse()); 1179: return(-1); 1180: } 1181: 1.1.1.2 ! root 1182: /* Optional */ 1.1 root 1183: CIOLIBEXPORT int CIOLIBCALL ciolib_hidemouse(void) { 1184: CIOLIB_INIT(); 1185: 1186: if(cio_api.hidemouse!=NULL) 1187: return(cio_api.hidemouse()); 1188: return(-1); 1189: } 1190: 1.1.1.2 ! root 1191: /* Optional */ 1.1 root 1192: CIOLIBEXPORT void CIOLIBCALL ciolib_setname(const char *name) { 1193: CIOLIB_INIT(); 1194: 1195: if(cio_api.setname!=NULL) 1196: cio_api.setname(name); 1197: } 1198: 1.1.1.2 ! root 1199: /* Optional */ ! 1200: CIOLIBEXPORT void CIOLIBCALL ciolib_seticon(const void *icon, unsigned long size) { ! 1201: CIOLIB_INIT(); ! 1202: ! 1203: if(cio_api.seticon!=NULL) ! 1204: cio_api.seticon(icon,size); ! 1205: } ! 1206: ! 1207: /* Optional */ 1.1 root 1208: CIOLIBEXPORT void CIOLIBCALL ciolib_settitle(const char *title) { 1209: CIOLIB_INIT(); 1210: 1211: if(cio_api.settitle!=NULL) 1212: cio_api.settitle(title); 1213: } 1214: 1.1.1.2 ! root 1215: /* Optional */ 1.1 root 1216: CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen) 1217: { 1218: CIOLIB_INIT(); 1219: 1220: if(cio_api.copytext!=NULL) 1221: cio_api.copytext(text,buflen); 1222: } 1223: 1.1.1.2 ! root 1224: /* Optional */ 1.1 root 1225: CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void) 1226: { 1227: CIOLIB_INIT(); 1228: 1229: if(cio_api.getcliptext!=NULL) 1230: return(cio_api.getcliptext()); 1231: else 1232: return(NULL); 1233: } 1234: 1.1.1.2 ! root 1235: /* Optional */ ! 1236: CIOLIBEXPORT int CIOLIBCALL ciolib_setfont(int font, int force, int font_num) 1.1 root 1237: { 1238: CIOLIB_INIT(); 1239: 1240: if(cio_api.setfont!=NULL) 1.1.1.2 ! root 1241: return(cio_api.setfont(font,force,font_num)); 1.1 root 1242: else 1243: return(-1); 1244: } 1245: 1.1.1.2 ! root 1246: /* Optional */ 1.1 root 1247: CIOLIBEXPORT int CIOLIBCALL ciolib_getfont(void) 1248: { 1249: CIOLIB_INIT(); 1250: 1251: if(cio_api.getfont!=NULL) 1252: return(cio_api.getfont()); 1253: else 1254: return(-1); 1255: } 1256: 1.1.1.2 ! root 1257: /* Optional */ 1.1 root 1258: CIOLIBEXPORT int CIOLIBCALL ciolib_loadfont(char *filename) 1259: { 1260: CIOLIB_INIT(); 1261: 1262: if(cio_api.loadfont!=NULL) 1263: return(cio_api.loadfont(filename)); 1264: else 1265: return(-1); 1266: } 1.1.1.2 ! root 1267: ! 1268: /* Optional */ ! 1269: CIOLIBEXPORT int CIOLIBCALL ciolib_get_window_info(int *width, int *height, int *xpos, int *ypos) ! 1270: { ! 1271: CIOLIB_INIT(); ! 1272: ! 1273: if(cio_api.get_window_info!=NULL) ! 1274: return(cio_api.get_window_info(width,height,xpos,ypos)); ! 1275: else { ! 1276: if(width) ! 1277: *width=-1; ! 1278: if(height) ! 1279: *height=-1; ! 1280: if(xpos) ! 1281: *xpos=-1; ! 1282: if(ypos) ! 1283: *ypos=-1; ! 1284: } ! 1285: return(-1); ! 1286: } ! 1287: ! 1288: /* Optional */ ! 1289: CIOLIBEXPORT int CIOLIBCALL ciolib_beep(void) ! 1290: { ! 1291: if(cio_api.beep) ! 1292: return(cio_api.beep()); ! 1293: BEEP(440,100); ! 1294: return(0); ! 1295: } ! 1296: ! 1297: /* Optional */ ! 1298: CIOLIBEXPORT void CIOLIBCALL ciolib_getcustomcursor(int *start, int *end, int *range, int *blink, int *visible) ! 1299: { ! 1300: if(cio_api.getcustomcursor) ! 1301: cio_api.getcustomcursor(start,end,range,blink,visible); ! 1302: } ! 1303: ! 1304: /* Optional */ ! 1305: CIOLIBEXPORT void CIOLIBCALL ciolib_setcustomcursor(int start, int end, int range, int blink, int visible) ! 1306: { ! 1307: if(cio_api.setcustomcursor) ! 1308: cio_api.setcustomcursor(start,end,range,blink,visible); ! 1309: } ! 1310: ! 1311: /* Optional */ ! 1312: CIOLIBEXPORT void CIOLIBCALL ciolib_setvideoflags(int flags) ! 1313: { ! 1314: if(cio_api.setvideoflags) ! 1315: cio_api.setvideoflags(flags); ! 1316: } ! 1317: ! 1318: /* Optional */ ! 1319: CIOLIBEXPORT int CIOLIBCALL ciolib_getvideoflags(void) ! 1320: { ! 1321: if(cio_api.getvideoflags) ! 1322: return(cio_api.getvideoflags()); ! 1323: return(0); ! 1324: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.