summaryrefslogtreecommitdiffstats
path: root/runtime/docs/html/group__string.html
blob: 834b751340d0aedecf6e763e37a75b32ab49acbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SystemTap: String Functions</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>String Functions</h1>One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack.  
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><b>string</b></td></tr>

<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ga8" doxytag="string::STP_STRING_SIZE"></a>
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga8">STP_STRING_SIZE</a>&nbsp;&nbsp;&nbsp;2048</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Maximum string size allowed in Strings. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga9">_stp_string_cat</a>(str1, str2)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">ConCATenate (append) a String or C string to a String.  <a href="#ga9"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ga1" doxytag="string::String"></a>
typedef string *&nbsp;</td><td class="memItemRight" valign="bottom"><b>String</b></td></tr>

<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">String&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga2">_stp_string_init</a> (int num)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a String for our use.  <a href="#ga2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga3">_stp_sprintf</a> (String str, const char *fmt,...)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Sprintf into a String.  <a href="#ga3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga4">_stp_vsprintf</a> (String str, const char *fmt, va_list args)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Vsprintf into a String Use this if your function already has a va_list.  <a href="#ga4"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga5">_stp_string_cat_cstr</a> (String str1, const char *str2)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">ConCATenate (append) a C string to a String.  <a href="#ga5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga6">_stp_string_cat_string</a> (String str1, String str2)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">ConCATenate (append) a String to a String.  <a href="#ga6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__string.html#ga7">_stp_string_ptr</a> (String str)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get a pointer to String's buffer For rare cases when a C string is needed and you have a String.  <a href="#ga7"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack. 
<p>
It is also not a good idea to dynamically allocate space for strings with kmalloc(). That leaves us with statically allocated space for strings. This is what is implemented in the String module. Strings use preallocated per-cpu buffers and are safe to use (unlike C strings). <hr><h2>Define Documentation</h2>
<a class="anchor" name="ga9" doxytag="string.c::_stp_string_cat"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">#define _stp_string_cat          </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">str1,         <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>str2&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
<b>Value:</b><div class="fragment"><pre class="fragment">({                                                            \
          <span class="keywordflow">if</span> (__builtin_types_compatible_p (typeof (str2), <span class="keywordtype">char</span>[])) {   \
                  <span class="keywordtype">char</span> *x = (<span class="keywordtype">char</span> *)str2;                               \
                  _str_string_cat_cstr(str1,x);                         \
          } <span class="keywordflow">else</span> {                                                      \
                  String x = (String)str2;                              \
                  _str_string_cat_string(str1,x);                       \
          }                                                             \
  })
</pre></div>ConCATenate (append) a String or C string to a String. 
<p>
This macro selects the proper function to call. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str1</em>&nbsp;</td><td>A String </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>str2</em>&nbsp;</td><td>A String or C string (char *) </td></tr>
  </table>
</dl>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__string.html#ga5">_stp_string_cat_cstr</a> <a class="el" href="group__string.html#ga6">_stp_string_cat_string</a> </dd></dl>

<p>
Definition at line <a class="el" href="string_8c-source.html#l00150">150</a> of file <a class="el" href="string_8c-source.html">string.c</a>.    </td>
  </tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="ga3" doxytag="string.c::_stp_sprintf"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void _stp_sprintf           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">String&nbsp;</td>
          <td class="mdname" nowrap> <em>str</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>fmt</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>&nbsp;</td>
          <td class="mdname" nowrap> <em>...</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Sprintf into a String. 
<p>
Like printf, except output goes into a String. Safe because overflowing the buffer is not allowed. Size is limited by length of String, <a class="el" href="group__string.html#ga8">STP_STRING_SIZE</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>String </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>fmt</em>&nbsp;</td><td>A printf-style format string followed by a variable number of args. </td></tr>
  </table>
</dl>

<p>
Definition at line <a class="el" href="string_8c-source.html#l00077">77</a> of file <a class="el" href="string_8c-source.html">string.c</a>.
<p>
References <a class="el" href="string_8c-source.html#l00020">STP_STRING_SIZE</a>.
<p>
Referenced by <a class="el" href="sym_8c-source.html#l00030">_stp_symbol_sprint()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga5" doxytag="string.c::_stp_string_cat_cstr"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void _stp_string_cat_cstr           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">String&nbsp;</td>
          <td class="mdname" nowrap> <em>str1</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>str2</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
ConCATenate (append) a C string to a String. 
<p>
Like strcat(). <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str1</em>&nbsp;</td><td>String </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>str2</em>&nbsp;</td><td>C string (char *) </td></tr>
  </table>
</dl>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__string.html#ga9">_stp_string_cat</a> </dd></dl>

<p>
Definition at line <a class="el" href="string_8c-source.html#l00106">106</a> of file <a class="el" href="string_8c-source.html">string.c</a>.
<p>
References <a class="el" href="string_8c-source.html#l00020">STP_STRING_SIZE</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga6" doxytag="string.c::_stp_string_cat_string"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void _stp_string_cat_string           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">String&nbsp;</td>
          <td class="mdname" nowrap> <em>str1</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>String&nbsp;</td>
          <td class="mdname" nowrap> <em>str2</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
ConCATenate (append) a String to a String. 
<p>
Like strcat(). <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str1</em>&nbsp;</td><td>String </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>str2</em>&nbsp;</td><td>String </td></tr>
  </table>
</dl>
<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__string.html#ga9">_stp_string_cat</a> </dd></dl>

<p>
Definition at line <a class="el" href="string_8c-source.html#l00121">121</a> of file <a class="el" href="string_8c-source.html">string.c</a>.
<p>
References <a class="el" href="string_8c-source.html#l00020">STP_STRING_SIZE</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga2" doxytag="string.c::_stp_string_init"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">String _stp_string_init           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">int&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>num</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Initialize a String for our use. 
<p>
This grabs one of the global Strings for our use.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>num</em>&nbsp;</td><td>Number of the preallocated String to use. #STP_NUM_STRINGS are statically allocated for our use. The translator (or author) should be sure to grab a free one. </td></tr>
  </table>
</dl>
<dl compact><dt><b><a class="el" href="todo.html#_todo000009">Todo:</a></b></dt><dd>Global (and static) Strings not implemented yet. </dd></dl>

<p>
Definition at line <a class="el" href="string_8c-source.html#l00042">42</a> of file <a class="el" href="string_8c-source.html">string.c</a>.
<p>
References <a class="el" href="io_8c-source.html#l00029">_stp_log()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga7" doxytag="string.c::_stp_string_ptr"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">char* _stp_string_ptr           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">String&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>str</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Get a pointer to String's buffer For rare cases when a C string is needed and you have a String. 
<p>
One example is when you want to print a String with <a class="el" href="group__print.html#ga3">_stp_printf()</a>. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>String </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>A C string (char *) </dd></dl>
<dl compact><dt><b>Note:</b></dt><dd>Readonly. Don't write to this pointer or it will mess up the internal String state and probably mess up your output or crash something. </dd></dl>

<p>
Definition at line <a class="el" href="string_8c-source.html#l00138">138</a> of file <a class="el" href="string_8c-source.html">string.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga4" doxytag="string.c::_stp_vsprintf"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void _stp_vsprintf           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">String&nbsp;</td>
          <td class="mdname" nowrap> <em>str</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>fmt</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>va_list&nbsp;</td>
          <td class="mdname" nowrap> <em>args</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Vsprintf into a String Use this if your function already has a va_list. 
<p>
You probably want <a class="el" href="group__string.html#ga3">_stp_sprintf()</a>. 
<p>
Definition at line <a class="el" href="string_8c-source.html#l00092">92</a> of file <a class="el" href="string_8c-source.html">string.c</a>.
<p>
References <a class="el" href="string_8c-source.html#l00020">STP_STRING_SIZE</a>.    </td>
  </tr>
</table>
</body></html>