comparison src/gpf2/inc/pco_util.h @ 1:864b8cc0cf63

src/gpf2: preened GPF goo from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 23:38:58 +0000
parents
children
comparison
equal deleted inserted replaced
0:945cf7f506b2 1:864b8cc0cf63
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : PCO2
4 | Modul : PCO_UTIL
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This Modul provides utillity functions for pco
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef _PCO_UTIL_H_
22 #define _PCO_UTIL_H_
23
24 /*==== INCLUDES ===================================================*/
25 #include <stdio.h>
26 #include "ipcapi.h"
27 #undef EXPORT
28 #include "typedefs.h"
29
30 /*==== TYPES ======================================================*/
31
32 /*==== CONSTANTS ==================================================*/
33 #define ZERO_COMPRESS_MIN 8
34
35 /*==== EXTERNALS ==================================================*/
36
37 /*==== VARIABLES ==================================================*/
38
39 /*==== PROTOTYPES =================================================*/
40
41 /*
42 +--------------------------------------------------------------------+
43 | PROJECT : PCO2 MODULE : PCO_UTIL |
44 | STATE : code ROUTINE : get_path |
45 +--------------------------------------------------------------------+
46
47 PURPOSE : Retrieves the pathname from a path/filename(path\filenames)-string.
48
49 PARAMS: fname ... path/filename
50 path ... retrieved path string
51 slash ... 1 -> '/'s are used as separators.
52 0 -> '\'s are used as separators
53 */
54 void get_path(const char* fname, char* path, int slash=1);
55
56
57 /*
58 +------------------------------------------------------+
59 | PROJECT : PCO2 MODULE : PCO_UTIL |
60 | STATE : code ROUTINE : read_string |
61 +------------------------------------------------------+
62
63 PURPOSE : Reads one line from a text file.
64
65 PARAMS: stream ... stream to read from
66 buf ... buffer to read into
67 max_len ... maximum length of line to read into buf
68
69 RETURNS: 0 ... no error
70 -1 ... buffer to small
71
72 */
73 int read_string (FILE * stream, char * buf, int max_len);
74
75
76 /*
77 +-------------------------------------------------------------------------------+
78 | PROJECT : PCO2 MODULE : PCO_UTIL |
79 | STATE : code ROUTINE : send_ipcmsg |
80 +-------------------------------------------------------------------------------+
81
82 PURPOSE : tries to send a message with ipc header to a receiver
83
84 PARAMS: buf ... pointer to buffer
85 size .. size of buffer
86 id ... message id
87 sender .. queuename of sender
88 receiver .. queuename of receiver
89
90 RETURNS: 0 .. sucess
91 -1 .. receiver not found
92 -2 .. error while contacting receiver
93
94 */
95 int send_ipcmsg(void* buf, U16 size, U16 id, const char* sender,
96 const char* receiver);
97
98
99 /*
100 +-------------------------------------------------------------------------------+
101 | PROJECT : PCO2 MODULE : PCO_UTIL |
102 | STATE : code ROUTINE : send_ipcmsg |
103 +-------------------------------------------------------------------------------+
104
105 PURPOSE : tries to send a message with ipc header to a receiver
106
107 PARAMS: buf ... pointer to buffer
108 size .. size of buffer
109 id ... message id
110 sender .. queuename of sender
111 receiver .. queuename of receiver
112 rqueue ... handle of receiver queue
113
114 RETURNS: 0 .. sucess
115 -1 .. error while contacting receiver
116
117 */
118 int send_ipcmsg(void* buf, U16 size, U16 id, const char* sender,
119 const char* receiver, CMS_HANDLE rqueue);
120
121 /*
122 +-------------------------------------------------------------------------------+
123 | PROJECT : PCO2 MODULE : PCO_VIEW_STD |
124 | STATE : code ROUTINE : create_hexdump |
125 +-------------------------------------------------------------------------------+
126
127 PURPOSE : creates hexdump string of given data
128
129 PARAMS: data .. the data
130 dsize .. size of data
131 dump .. buffer to receive hexdump
132 size .. size of dump
133 reverse.. if !=0 the hexdump will represent the reverse data buffer
134 zero_compress_min .. count of zeros from which on compression will be applied
135
136 RETURNS: 0 .. success
137 -1 .. dump buffer to small
138
139 */
140 int create_hexdump(const void *data, unsigned dsize, char *dump, unsigned size,
141 int reverse=0, int zero_compress_min=ZERO_COMPRESS_MIN);
142
143 /*
144 +-------------------------------------------------------------------------------+
145 | PROJECT : PCO2 MODULE : PCO_UTIL |
146 | STATE : code ROUTINE : interprete_hexdump |
147 +-------------------------------------------------------------------------------+
148
149 PURPOSE : tries to interprete a given string hexdump-like
150 Example: 00 44 (23*00) 47 11
151
152 PARAMS: dump .. string containing hexdump
153 buffer .. buffer to receive interpreted data
154 bsize .. size of buffer
155 count .. count of bytes writen to buffer
156
157 RETURNS: 0 .. success
158 -1 .. buffer to small
159 -2 .. invalid hexdump
160
161 */
162 int interprete_hexdump(const char *dump, void* buffer, unsigned bsize, unsigned& count);
163
164
165 /*
166 +-------------------------------------------------------------------------------+
167 | PROJECT : PCO2 MODULE : PCO_UTIL |
168 | STATE : code ROUTINE : get_time_hmsm |
169 +-------------------------------------------------------------------------------+
170
171 PURPOSE : calculates the current time in ms
172 (hour, minute, second and ms are taken into account)
173
174 RETURNS: current time in milliseconds
175
176 */
177 ULONG get_time_hmsm();
178
179 /*
180 +-------------------------------------------------------------------------------+
181 | PROJECT : PCO2 MODULE : PCO_UTIL |
182 | STATE : code ROUTINE : get_dll_size |
183 +-------------------------------------------------------------------------------+
184
185 PURPOSE : calculates the actual count of bytes used in a given DLL-file
186
187 PARAMS: dll_fname .. name of dll-file
188
189 RETURNS: count of bytes used, 0 if file is no WIN32-DLL
190
191 */
192 ULONG get_dll_size(const char* dll_fname);
193
194
195 #endif /* _PCO_UTIL_H_ */