comparison src/gpf/frame/xalert.c @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1 /*
2 +------------------------------------------------------------------------------
3 | File: xalert.c
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose :
17 +-----------------------------------------------------------------------------
18 */
19 /*lint -emacro(718,va_start) Symbol 'Symbol' undeclared, assumed to return int */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include "typedefs.h"
24 #include "vsi.h"
25 #include "frm_glob.h"
26
27 /* To store values from _Alert to alert_info */
28 T_HANDLE AlertCallerStore;
29 ULONG AlertClassStore;
30
31 BOOL _Alert(char *msg, T_HANDLE Caller, ULONG alertclass)
32 {
33 int max = TextTracePartitionSize - sizeof(T_S_HEADER) - sizeof(T_PRIM_HEADER);
34 int len;
35 int end_filepos=0;
36 max=80;
37 while (msg[end_filepos] && msg[end_filepos] != ')')
38 {
39 end_filepos++;
40 }
41 len = end_filepos;
42 while (msg[len])
43 {
44 len++;
45 }
46
47 if ( len < max)
48 {
49 /* nice short message */
50 vsi_o_ttrace(Caller, alertclass, "%s", msg);
51 }
52 else
53 {
54 /* if string is to long we need to cut of */
55 if (end_filepos < max - 3)
56 {
57 /* if there is room for the file location we cut of at the end */
58 vsi_o_ttrace(Caller, alertclass, "%.*s...", max - 3, msg);
59 }
60 else
61 {
62 /* if there is not even room for the file location we cut of as many directories at the start as needed */
63 char *separator = NULL;
64 char *p = msg;
65 int l = end_filepos;
66 max -= 6; /* make room for ... at both end */
67 /* find filename */
68 while (l >= max)
69 {
70 separator = p;
71 while (l > 0 && *p != '/' && *p != '\\')
72 {
73 l--;
74 p++;
75 }
76 }
77 vsi_o_ttrace(Caller, alertclass, "...%.*s...", max - 6, separator);
78 }
79 }
80
81 AlertCallerStore = Caller;
82 AlertClassStore = alertclass;
83 /*
84 * Note: this return value controls if alert_info is called,
85 * i.e. alert_info is not called if FALSE is returned.
86 */
87 return TRUE;
88 }
89
90 int int_vsi_o_ttrace ( T_HANDLE Caller, ULONG TraceClass, const char * const format, va_list varpars );
91
92 /*
93 * Alert Information
94 */
95 BOOL alert_info(char *format, ...)
96 {
97 va_list args;
98
99 if ( (format != NULL) && (format[0] != 0) && (AlertCallerStore >= 0) && (TraceMask[AlertCallerStore] & AlertClassStore))
100 {
101 va_start(args, format);
102 int_vsi_o_ttrace(AlertCallerStore, AlertClassStore, format, args);
103 va_end(args);
104 }
105
106 /* The expression evaluated to FALSE by definition if this was called */
107 return FALSE;
108 }
109