OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libnetworking/] [rtems_webserver/] [uemf.c] - Blame information for rev 507

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 * uemf.c -- GoAhead Micro Embedded Management Framework
3
 *
4
 * Copyright (c) Go Ahead Software, Inc., 1995-1999
5
 *
6
 * See the file "license.txt" for usage and redistribution license requirements
7
 */
8
 
9
/********************************** Description *******************************/
10
 
11
/*
12
 *      This module provides compatibility with the full GoAhead EMF.
13
 *      It is a collection of routines which permits the GoAhead WebServer to
14
 *      run stand-alone and to also load as a solution pack under the GoAhead EMF.
15
 */
16
 
17
/*********************************** Includes *********************************/
18
 
19
#include        "uemf.h"
20
 
21
/********************************** Local Data ********************************/
22
 
23
int emfInst;                                                    /* Application instance handle */
24
 
25
/************************************* Code ***********************************/
26
/*
27
 *      Error message that doesn't need user attention. Customize this code
28
 *      to direct error messages to whereever the developer wishes
29
 */
30
 
31
void error(E_ARGS_DEC, int flags, char_t *fmt, ...)
32
{
33
        if (flags & E_LOG) {
34
                /* Log error message */
35
 
36
        } else if (flags & E_ASSERT) {
37
                /* Assert message */
38
 
39
        } else if (flags & E_USER) {
40
                /* Display message to the user */
41
 
42
        }
43
}
44
 
45
/******************************************************************************/
46
/*
47
 *      Trace log. Customize this function to log trace output
48
 */
49
 
50
void goahead_trace(int level, char_t *afmt, ...)
51
{
52
#if DEBUG
53
        va_list         args;
54
        char_t          *buf;
55
 
56
        va_start(args, afmt);
57
        buf = NULL;
58
        gvsnprintf(&buf, VALUE_MAX_STRING, afmt, args);
59
        if (buf) {
60
                gprintf(buf);
61
                bfree(B_L, buf);
62
        }
63
        va_end(args);
64
#endif
65
}
66
 
67
/******************************************************************************/
68
/*
69
 *      Save the instance handle
70
 */
71
 
72
void emfInstSet(int inst)
73
{
74
        emfInst = inst;
75
}
76
 
77
/******************************************************************************/
78
/*
79
 *      Get the instance handle
80
 */
81
 
82
int emfInstGet()
83
{
84
        return emfInst;
85
}
86
 
87
/******************************************************************************/
88
/*
89
 *      Convert a string to lower case
90
 */
91
 
92
char_t *strlower(char_t *string)
93
{
94
        char_t  *s;
95
 
96
        a_assert(string);
97
 
98
        if (string == NULL) {
99
                return NULL;
100
        }
101
 
102
        s = string;
103
        while (*s) {
104
                if (gisupper(*s)) {
105
                        *s = (char_t) gtolower(*s);
106
                }
107
                s++;
108
        }
109
        *s = '\0';
110
        return string;
111
}
112
 
113
/******************************************************************************/
114
/*
115
 *      Convert a string to upper case
116
 */
117
 
118
char_t *strupper(char_t *string)
119
{
120
        char_t  *s;
121
 
122
        a_assert(string);
123
        if (string == NULL) {
124
                return NULL;
125
        }
126
 
127
        s = string;
128
        while (*s) {
129
                if (gislower(*s)) {
130
                        *s = (char_t) gtoupper(*s);
131
                }
132
                s++;
133
        }
134
        *s = '\0';
135
        return string;
136
}
137
 
138
/******************************************************************************/
139
/*
140
 *      Convert integer to ascii string. Allow a NULL string in which case we
141
 *      allocate a dynamic buffer.
142
 */
143
 
144
char_t *stritoa(int n, char_t *string, int width)
145
{
146
        char_t  *cp, *lim, *s;
147
        char_t  buf[16];                                                /* Just temp to hold number */
148
        int             next, minus;
149
 
150
        a_assert(string && width > 0);
151
 
152
        if (string == NULL) {
153
                if (width == 0) {
154
                        width = 10;
155
                }
156
                if ((string = balloc(B_L, width + 1)) == NULL) {
157
                        return NULL;
158
                }
159
        }
160
        if (n < 0) {
161
                minus = 1;
162
                n = -n;
163
                width--;
164
        } else {
165
                minus = 0;
166
        }
167
 
168
        cp = buf;
169
        lim = &buf[width - 1];
170
        while (n > 9 && cp < lim) {
171
                next = n;
172
                n /= 10;
173
                *cp++ = (char_t) (next - n * 10 + '0');
174
        }
175
        if (cp < lim) {
176
                *cp++ = (char_t) (n + '0');
177
        }
178
 
179
        s = string;
180
        if (minus) {
181
                *s++ = '-';
182
        }
183
 
184
        while (cp > buf) {
185
                *s++ = *--cp;
186
        }
187
 
188
        *s++ = '\0';
189
        return string;
190
}
191
 
192
/******************************************************************************/
193
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.