Subversion Repositories Kolibri OS

Rev

Rev 8793 | Rev 9554 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <sys/ksys.h>
  2. #include <conio.h>
  3. #include "stdio.h"
  4.  
  5. static char* __con_caption = "Console application";
  6. static char* __con_dllname = "/sys/lib/console.obj";
  7.  
  8. int __con_is_load = 0;
  9.  
  10. void  stdcall (*__con_init_hidden)(int wnd_width, unsigned wnd_height, int scr_width, int scr_height, const char* title);
  11. void  stdcall (*con_exit)(int);
  12. void  stdcall (*con_set_title)(const char* title);
  13. void  stdcall (*con_write_asciiz)(const char* str);
  14. void  stdcall (*con_write_string)(const char* str, dword length);
  15. int   cdecl   (*con_printf)(const char* format, ...);
  16. dword stdcall (*con_get_flags)(void);
  17. dword stdcall (*con_set_flags)(dword new_flags);
  18. int   stdcall (*con_get_font_height)(void);
  19. int   stdcall (*con_get_cursor_height)(void);
  20. int   stdcall (*con_set_cursor_height)(int new_height);
  21. int   stdcall (*con_getch)(void);
  22. word  stdcall (*con_getch2)(void);
  23. int   stdcall (*con_kbhit)(void);
  24. char* stdcall (*con_gets)(char* str, int n);
  25. char* stdcall (*con_gets2)(con_gets2_callback callback, char* str, int n);
  26. void  stdcall (*con_cls)();
  27. void  stdcall (*con_get_cursor_pos)(int* px, int* py);
  28. void  stdcall (*con_set_cursor_pos)(int x, int y);
  29.  
  30. /*static void __con_panic(char* func_name)
  31. {
  32.     debug_printf("In console.obj %s=NULL!\n", func_name);
  33.     _ksys_exit();
  34. }*/
  35.  
  36. static void __con_lib_link(ksys_dll_t *exp)
  37. {
  38.     __con_init_hidden = _ksys_dlsym(exp, "con_init");
  39.     con_exit          = _ksys_dlsym(exp, "con_exit");
  40.     con_set_title     = _ksys_dlsym(exp, "con_set_title");
  41.     con_write_asciiz  = _ksys_dlsym(exp, "con_write_asciiz");
  42.     con_write_string  = _ksys_dlsym(exp, "con_write_string");
  43.     con_printf        = _ksys_dlsym(exp, "con_printf");
  44.     con_get_flags     = _ksys_dlsym(exp, "con_get_flags");
  45.     con_set_flags     = _ksys_dlsym(exp, "con_set_flags");
  46.     con_get_font_height = _ksys_dlsym(exp, "con_get_font_height");
  47.     con_get_cursor_height = _ksys_dlsym(exp, "con_get_cursor_height");
  48.     con_set_cursor_height = _ksys_dlsym(exp, "con_set_cursor_height");
  49.     con_getch           = _ksys_dlsym(exp, "con_getch");
  50.     con_getch2          = _ksys_dlsym(exp, "con_getch2");
  51.     con_kbhit           = _ksys_dlsym(exp, "con_kbhit");
  52.     con_gets            = _ksys_dlsym(exp, "con_gets");
  53.     con_gets2           = _ksys_dlsym(exp, "con_gets2");
  54.     con_cls             = _ksys_dlsym(exp, "con_cls");
  55.     con_get_cursor_pos  = _ksys_dlsym(exp, "con_get_cursor_pos");
  56.     con_set_cursor_pos  = _ksys_dlsym(exp, "con_set_cursor_pos");
  57. }
  58.  
  59. int con_init_opt(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title)
  60. {  
  61.     if(!__con_is_load){
  62.         ksys_dll_t *__con_lib;
  63.         __con_lib = _ksys_dlopen(__con_dllname);
  64.         if(__con_lib==NULL){
  65.             _ksys_debug_puts("Error! Can't load console.obj lib\n");
  66.             return 1;
  67.         }
  68.         __con_lib_link(__con_lib);
  69.         __con_init_hidden(wnd_width, wnd_height, scr_width, scr_height, title);
  70.         __con_is_load= 1;
  71.         return 0;
  72.     }
  73.     return 1;
  74. }
  75.  
  76.  
  77. int con_init(void)
  78. {
  79.     return con_init_opt(-1, -1, -1, -1, __con_caption);
  80. }
  81.  
  82.