Subversion Repositories Kolibri OS

Rev

Rev 1870 | Rev 5270 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1870 Rev 4292
1
#include 
1
#include 
2
#include 
2
#include 
3
#include 
3
#include 
4
 
4
 
5
#pragma pack(push, 1)
5
#pragma pack(push, 1)
6
typedef struct
6
typedef struct
7
{
7
{
8
  char sec;
8
  char sec;
9
  char min;
9
  char min;
10
  char hour;
10
  char hour;
11
  char rsv;
11
  char rsv;
12
}detime_t;
12
}detime_t;
13
 
13
 
14
typedef struct
14
typedef struct
15
{
15
{
16
  char  day;
16
  char  day;
17
  char  month;
17
  char  month;
18
  short year;
18
  short year;
19
}dedate_t;
19
}dedate_t;
20
 
20
 
21
typedef struct
21
typedef struct
22
{
22
{
23
  unsigned    attr;
23
  unsigned    attr;
24
  unsigned    flags;
24
  unsigned    flags;
25
  union
25
  union
26
  {
26
  {
27
     detime_t  ctime;
27
     detime_t  ctime;
28
     unsigned  cr_time;
28
     unsigned  cr_time;
29
  };
29
  };
30
  union
30
  union
31
  {
31
  {
32
     dedate_t  cdate;
32
     dedate_t  cdate;
33
     unsigned  cr_date;
33
     unsigned  cr_date;
34
  };
34
  };
35
  union
35
  union
36
  {
36
  {
37
     detime_t  atime;
37
     detime_t  atime;
38
     unsigned  acc_time;
38
     unsigned  acc_time;
39
  };
39
  };
40
  union
40
  union
41
  {
41
  {
42
     dedate_t  adate;
42
     dedate_t  adate;
43
     unsigned  acc_date;
43
     unsigned  acc_date;
44
  };
44
  };
45
  union
45
  union
46
  {
46
  {
47
     detime_t  mtime;
47
     detime_t  mtime;
48
     unsigned  mod_time;
48
     unsigned  mod_time;
49
  };
49
  };
50
  union
50
  union
51
  {
51
  {
52
     dedate_t  mdate;
52
     dedate_t  mdate;
53
     unsigned  mod_date;
53
     unsigned  mod_date;
54
  };
54
  };
55
  unsigned    size;
55
  unsigned    size;
56
  unsigned    size_high;
56
  unsigned    size_high;
57
} FILEINFO;
57
} FILEINFO;
58
 
58
 
59
#pragma pack(pop)
59
#pragma pack(pop)
60
 
60
 
61
typedef struct
61
typedef struct
62
{
62
{
63
  char *path;
63
  char *path;
64
  int  offset;
64
  int  offset;
65
} dbgfile_t;
65
} dbgfile_t;
66
 
66
 
67
static dbgfile_t dbgfile;
67
static dbgfile_t dbgfile;
68
 
68
 
69
#define va_start(v,l)   __builtin_va_start(v,l)
69
#define va_start(v,l)   __builtin_va_start(v,l)
70
#define va_end(v)       __builtin_va_end(v)
70
#define va_end(v)       __builtin_va_end(v)
71
#define va_arg(v,l)     __builtin_va_arg(v,l)
71
#define va_arg(v,l)     __builtin_va_arg(v,l)
72
#define __va_copy(d,s)	__builtin_va_copy(d,s)
72
#define __va_copy(d,s)	__builtin_va_copy(d,s)
73
 
73
 
74
typedef __builtin_va_list __gnuc_va_list;
74
typedef __builtin_va_list __gnuc_va_list;
75
typedef __gnuc_va_list    va_list;
75
typedef __gnuc_va_list    va_list;
76
 
76
 
77
#define arg(x) va_arg (ap, u32_t)
77
#define arg(x) va_arg (ap, u32_t)
78
 
78
 
79
int dbg_open(char *path)
79
int dbg_open(char *path)
80
{
80
{
81
    FILEINFO info;
81
    FILEINFO info;
82
 
82
 
83
    dbgfile.offset = 0;
83
    dbgfile.offset = 0;
84
 
84
 
85
    if(get_fileinfo(path,&info))
85
    if(get_fileinfo(path,&info))
86
    {
86
    {
87
        if(!create_file(path))
87
        if(!create_file(path))
88
        {
88
        {
89
            dbgfile.path = path;
89
            dbgfile.path = path;
90
            return true;
90
            return true;
91
        }
91
        }
92
        else return false;
92
        else return false;
93
    };
93
    };
94
    set_file_size(path, 0);
94
    set_file_size(path, 0);
95
    dbgfile.path   = path;
95
    dbgfile.path   = path;
96
    dbgfile.offset = 0;
96
    dbgfile.offset = 0;
97
    return true;
97
    return true;
98
};
98
};
99
 
99
 
100
int vsnprintf(char *s, size_t n, const char *format, va_list arg);
100
int vsnprintf(char *s, size_t n, const char *format, va_list arg);
101
 
101
 
102
 
102
 
103
int printf(const char* format, ...)
103
int printf(const char* format, ...)
104
{
104
{
105
    char  txtbuf[1024];
105
    char  txtbuf[1024];
106
    int   len = 0;
106
    int   len = 0;
107
 
107
 
108
    va_list ap;
108
    va_list ap;
109
 
109
 
110
    va_start(ap, format);
110
    va_start(ap, format);
111
    if (format)
111
    if (format)
112
        len = vsnprintf(txtbuf, 1024, format, ap);
112
        len = vsnprintf(txtbuf, 1024, format, ap);
113
    va_end(ap);
113
    va_end(ap);
114
 
114
 
115
    if( len )
115
    if( len )
116
        SysMsgBoardStr(txtbuf);
116
        SysMsgBoardStr(txtbuf);
117
 
117
 
118
    return len;
118
    return len;
119
}
119
}
120
 
120
 
121
 
121
 
122
int dbgprintf(const char* format, ...)
122
int dbgprintf(const char* format, ...)
123
{
123
{
124
    char      txtbuf[1024];
124
    char      txtbuf[1024];
125
    unsigned  writes;
125
    unsigned  writes;
126
    int       len = 0;
126
    int       len = 0;
127
 
127
 
128
    va_list   ap;
128
    va_list   ap;
129
 
129
 
130
    va_start(ap, format);
130
    va_start(ap, format);
131
    if (format)
131
    if (format)
132
      len = vsnprintf(txtbuf, 1024, format, ap);
132
      len = vsnprintf(txtbuf, 1024, format, ap);
133
    va_end(ap);
133
    va_end(ap);
134
 
134
 
135
    if( len )
135
    if( len )
136
    {
136
    {
137
        SysMsgBoardStr(txtbuf);
137
        if( dbgfile.path)
138
 
138
        {
139
/*  do not write into log file if interrupts disabled */
139
/*  do not write into log file if interrupts disabled */
140
 
140
 
141
        if ( (get_eflags() & (1 << 9)) && dbgfile.path)
141
            if ( get_eflags() & (1 << 9) )
142
        {
142
            {
143
            write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
143
                write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
144
            dbgfile.offset+=writes;
144
                dbgfile.offset+=writes;
145
        };
145
            };
146
    };
146
        }
-
 
147
        else SysMsgBoardStr(txtbuf);
-
 
148
    };
147
    return len;
149
    return len;
148
}
150
}
149
 
151
 
150
int xf86DrvMsg(int skip, int code, const char* format, ...)
152
int xf86DrvMsg(int skip, int code, const char* format, ...)
151
{
153
{
152
    char      txtbuf[1024];
154
    char      txtbuf[1024];
153
    unsigned  writes;
155
    unsigned  writes;
154
    va_list   ap;
156
    va_list   ap;
155
 
157
 
156
    int       len = 0;
158
    int       len = 0;
157
 
159
 
158
    va_start(ap, format);
160
    va_start(ap, format);
159
    if (format)
161
    if (format)
160
        len = vsnprintf(txtbuf, 1024, format, ap);
162
        len = vsnprintf(txtbuf, 1024, format, ap);
161
    va_end(ap);
163
    va_end(ap);
162
 
164
 
163
    if( len )
165
    if( len )
164
    {
166
    {
165
        SysMsgBoardStr(txtbuf);
167
        SysMsgBoardStr(txtbuf);
166
 
168
 
167
        if(dbgfile.path)
169
        if(dbgfile.path)
168
        {
170
        {
169
            write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
171
            write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
170
            dbgfile.offset+=writes;
172
            dbgfile.offset+=writes;
171
        };
173
        };
172
    };
174
    };
173
    return len;
175
    return len;
174
}
176
}