Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. #include <ksys.h>
  2. #include "conio.h"
  3.  
  4. static char* __con_caption = "Console application";
  5. static char* __con_dllname = "/sys/lib/console.obj";
  6.  
  7. int __con_is_load = 0;
  8.  
  9. unsigned *__con_dll_ver;
  10. void stdcall (*__con_init_hidden)(int wnd_width, int wnd_height,int scr_width, int scr_height, const char* title);
  11. void stdcall (*__con_write_asciiz)(const char* str);
  12. void stdcall (*__con_write_string)(const char* str, unsigned length);
  13. int stdcall (*__con_getch)(void);
  14. short stdcall (*__con_getch2)(void);
  15. int stdcall (*__con_kbhit)(void);
  16. char* stdcall (*__con_gets)(char* str, int n);
  17. char* stdcall (*__con_gets2)(__con_gets2_callback callback, char* str, int n);
  18. void stdcall (*__con_exit)(int status);
  19.  
  20. static void __con_lib_link(ksys_coff_etable_t *exp)
  21. {
  22.     __con_dll_ver       = _ksys_cofflib_getproc(exp, "con_dll_ver");
  23.     __con_init_hidden   = _ksys_cofflib_getproc(exp, "con_init");
  24.     __con_write_asciiz  = _ksys_cofflib_getproc(exp, "con_write_asciiz");
  25.     __con_write_string  = _ksys_cofflib_getproc(exp, "con_write_string");
  26.     __con_getch         = _ksys_cofflib_getproc(exp, "con_getch");
  27.     __con_getch2        = _ksys_cofflib_getproc(exp, "con_getch2");
  28.     __con_kbhit         = _ksys_cofflib_getproc(exp, "con_kbhit");
  29.     __con_gets          = _ksys_cofflib_getproc(exp, "con_gets");
  30.     __con_gets2         = _ksys_cofflib_getproc(exp, "con_gets2");
  31.     __con_exit          = _ksys_cofflib_getproc(exp, "con_exit");
  32. }
  33.  
  34.  
  35. int __con_init(void)
  36. {
  37.     return __con_init_opt(-1, -1, -1, -1, __con_caption);
  38. }
  39.  
  40.  
  41. int __con_init_opt(int wnd_width, int wnd_height,int scr_width, int scr_height, const char* title)
  42. {  
  43.     if(!__con_is_load){
  44.         ksys_coff_etable_t *__con_lib;
  45.         __con_lib = _ksys_cofflib_load(__con_dllname);
  46.         if(__con_lib==NULL){
  47.             _ksys_debug_puts("Error! Can't load console.obj lib\n");
  48.             return 1;
  49.         }
  50.         __con_lib_link(__con_lib);
  51.         __con_init_hidden(wnd_width, wnd_height, scr_width, scr_height, title);
  52.         __con_is_load= 1;
  53.         return 0;
  54.     }
  55.     return 1;
  56. }
  57.