E:/Ablage_Gerhard/10_Hobby/Elektronik/30_Atmel/20_Prog/AVR_CMD_INTERFACE/string_addon.h File Reference

some additional clever string functions More...

#include <stdio.h>

Go to the source code of this file.

Defines

#define STRING_ADDON_H
#define _ASCII_BEL   0x07
#define _ASCII_BS   0x08
#define _ASCII_CR   0x0D
#define _ASCII_LF   0x0A
#define _ASCII_ESC   0x1B
#define _ASCII_DEL   0x7F
#define _ASCII_SPACE   0x20
#define _ASCII_COMMA   0x2C
#define _STRING_EOS   0x00

Functions

void r_trim (char *string, char sign)
 eleminates all signs at the end of a string which are equal to the given one
void l_trim (char *string, char sign)
 eleminates all leading signs which are equal to the given one
void trim (char *string, char sign)
 eleminates all signs of the given type at the end or at the beginning of a string
char * strtrok_single_char (char *c_ptr_search, char c_search)
 searches for the first occurence of a single character in a string and creates a string with the content till this point.

Detailed Description

some additional clever string functions

Target/Compiler: AVR_MEGA / GCC(WinAVR)

Author:
Gerhard Bruenner
Version:
V0.13
Date:
2009.12.30 - removed split_string and string_copy added strtrok_single_char added define for ASCII-characters
2009.10.31 - Created - GB
Bug:
none that I am aware so far

\


Define Documentation

#define _ASCII_BEL   0x07

"Bell"

#define _ASCII_BS   0x08

Back Space

#define _ASCII_COMMA   0x2C

Comma

#define _ASCII_CR   0x0D

Carriage Return

#define _ASCII_DEL   0x7F

Delete

#define _ASCII_ESC   0x1B

Escape

#define _ASCII_LF   0x0A

Line Feed

#define _ASCII_SPACE   0x20

Space

#define _STRING_EOS   0x00

End of String

#define STRING_ADDON_H

precompiler help


Function Documentation

void l_trim ( char *  string,
char  sign 
)

eleminates all leading signs which are equal to the given one

Parameters:
*string - string to investigate
sign - character which shall be eliminated
Returns:
void

This function eliminates all leading characters in a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------------ Testcode sprintf(str_rcv_usart,""); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test x"); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test mit blanks "); l_trim(str_rcv_usart,_ASCII_SPACE);

void r_trim ( char *  string,
char  sign 
)

eleminates all signs at the end of a string which are equal to the given one

Parameters:
*string - string to investigate
sign - character which shall be eliminated
Returns:
void

This function eliminates all characters at the end of a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------------ Testcode sprintf(str_rcv_usart,""); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test x "); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test mit blanks "); r_trim(str_rcv_usart,_ASCII_SPACE);

char* strtrok_single_char ( char *  c_ptr_search,
char  c_search 
)

searches for the first occurence of a single character in a string and creates a string with the content till this point.

Parameters:
*c_ptr_search - string used for search
c_search - character which shall be searched
Returns:
char * - Pointer to string with content till first occurence of characeter beeing searched.
NULL - in case character has not been found or search passed end of string.

searches for the first occurence of a single character in a string and replaces it with '/0'. It returns a pointer to the beginning of the "new" string if it found the character. The function remembers the last position where a character has been found. Calling the function with a c_ptr_search=NULL continuous the search at the stored location.

void trim ( char *  string,
char  sign 
)

eleminates all signs of the given type at the end or at the beginning of a string

Parameters:
*string - string to investigate
sign - character which shall be eliminated
Returns:
void

This function eliminates all characters at the end and at the beginning of a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------- Testcode sprintf(str_rcv_usart," op1"); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," help aber woher%c ",toascii(13)); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,""); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"help %c",toascii(13)); trim(str_rcv_usart,_ASCII_SPACE);


Generated on Fri Jan 1 18:18:57 2010 for AVR_CMD_INTERFACE by  doxygen 1.6.1