mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
s390-tools: Move function util_strstrip
This patch - moves function util_strstrip to libutil/util_libc.c and deletes the extra files util_strstip.[ch] - adds doxygen comments for util_strstrip() - provides an example on how to use util_strstrip(). Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
08bc0a947a
commit
427dff3450
@@ -10,10 +10,13 @@
|
||||
//! [code]
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_panic.h"
|
||||
|
||||
#define EXAMPLE_WORD " /sys/devices/system/cpu "
|
||||
|
||||
/*
|
||||
* Demonstrate that out of memory is automatically handled via panic()
|
||||
*/
|
||||
@@ -22,6 +25,12 @@ int main(void)
|
||||
unsigned long ulong_max = (unsigned long)-1;
|
||||
void *ptr;
|
||||
char *zeroes, *str;
|
||||
char buffer[sizeof(EXAMPLE_WORD)];
|
||||
|
||||
strcat(buffer, EXAMPLE_WORD);
|
||||
fprintf(stderr, "Try to remove leading and trailing spaces from "
|
||||
"\"%s\"\nresult = \"%s\"\n", EXAMPLE_WORD,
|
||||
util_strstrip(buffer));
|
||||
|
||||
/* Use util_strcat_realloc() for string concatenation */
|
||||
fprintf(stderr, "Try to concatenate \"Hello\", \", \" and \"world!\": ");
|
||||
|
||||
Reference in New Issue
Block a user