Subversion Repositories Kolibri OS

Rev

Rev 6424 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6424 Rev 6429
Line 1... Line 1...
1
#include 
1
#include 
2
#include 
2
#include 
3
#include 
3
#include 
4
#include 
-
 
5
 
-
 
6
char* dllname="/sys/lib/console.obj";
-
 
7
int   console_init_status;
-
 
8
 
-
 
9
char* imports[] = {"START","version","con_init","con_write_asciiz","con_printf","con_exit",NULL};
-
 
10
char* caption = "Console app";
-
 
11
extern int __argc;
-
 
12
extern char** __argv;
-
 
13
extern char* __path;
-
 
14
 
-
 
15
 
-
 
16
dword* dll_ver;
-
 
17
void stdcall (* con_init)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title);
-
 
18
void stdcall (* con_write_asciiz)(const char* string);
-
 
19
void cdecl  (* con_printf)(const char* format,...);
-
 
20
void stdcall (* con_exit)(dword bCloseWindow);
-
 
21
 
-
 
22
struct import{
-
 
23
        char *name;
-
 
24
        void *data;
-
 
25
};
-
 
26
 
-
 
27
void printf_link(struct import *exp, char** imports){
-
 
28
 
-
 
29
        dll_ver = (dword*)
-
 
30
                _ksys_cofflib_getproc(exp, imports[1]);
-
 
31
        con_init = (void stdcall (*)(dword , dword, dword, dword, const char*))
-
 
32
                _ksys_cofflib_getproc(exp, imports[2]);
-
 
33
        con_printf = (void cdecl (*)(const char*,...))
-
 
34
                _ksys_cofflib_getproc(exp, imports[4]);
-
 
35
        con_exit = (void stdcall (*)(dword))
-
 
36
                _ksys_cofflib_getproc(exp, imports[5]);
-
 
37
}
-
 
38
 
-
 
39
 
-
 
40
int init_console(void)
-
 
41
{
-
 
42
  struct import * hDll;
-
 
43
 
-
 
44
        if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0){
-
 
45
                debug_out_str("can't load lib\n");
-
 
46
                return 1;
-
 
47
        }
-
 
48
        printf_link(hDll, imports);
-
 
49
//        debug_out_str("dll loaded\n");
-
 
50
 
-
 
51
        con_init(-1, -1, -1, -1, caption); //__argv[0] && __path dont work
-
 
52
        return(0);
-
 
53
}
-
 
Line 54... Line 4...
54
 
4
 
55
int printf(const char *format,...)
5
int printf(const char *format, ...)
56
{
6
{
57
   int          i = 0;
7
   int          i = 0;
58
   int          printed_simbols;
8
   int          printed_simbols = 0;
59
   va_list      arg;
-
 
60
   char         simbol[]={"%s"};
9
   va_list      arg;
Line 61... Line 10...
61
   char         *s;
10
   char         *s;
Line 62... Line -...
62
 
-
 
63
   va_start(arg,format);
-
 
64
 
11
 
65
   if (console_init_status==0)
-
 
66
    {
-
 
Line 67... Line 12...
67
      i=init_console();
12
   va_start(arg,format);
68
      console_init_status=1;
13
 
69
    }
14
   i=con_init_console_dll();
70
 
15
 
71
   if (i==0)
16
   if (i==0)
72
   {
17
   {
73
     s=malloc(4096);
18
     s=malloc(4096);
74
     printed_simbols=format_print(s,4096,format,arg);
19
     printed_simbols=format_print(s,4096,format,arg);
75
     con_printf(simbol,s);
20
     con_write_string(s, printed_simbols);