mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
common: Add func has_leading_keyword.
* common/stringhelp.c (has_leading_keyword): New.
This commit is contained in:
parent
21f5a9ec27
commit
2838385e76
@ -73,6 +73,29 @@ change_slashes (char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether STRINGS starts with KEYWORD. The keyword is
|
||||||
|
* delimited by end of string, a space or a tab. Returns NULL if not
|
||||||
|
* found or a pointer into STRING to the next non-space character
|
||||||
|
* after the KEYWORD (which may be end of string).
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
has_leading_keyword (const char *string, const char *keyword)
|
||||||
|
{
|
||||||
|
size_t n = strlen (keyword);
|
||||||
|
|
||||||
|
if (!strncmp (string, keyword, n)
|
||||||
|
&& (!string[n] || string[n] == ' ' || string[n] == '\t'))
|
||||||
|
{
|
||||||
|
string += n;
|
||||||
|
while (*string == ' ' || *string == '\t')
|
||||||
|
string++;
|
||||||
|
return (char*)string;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look for the substring SUB in buffer and return a pointer to that
|
* Look for the substring SUB in buffer and return a pointer to that
|
||||||
* substring in BUFFER or NULL if not found.
|
* substring in BUFFER or NULL if not found.
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
char *has_leading_keyword (const char *string, const char *keyword);
|
||||||
|
|
||||||
const char *memistr (const void *buf, size_t buflen, const char *sub);
|
const char *memistr (const void *buf, size_t buflen, const char *sub);
|
||||||
char *mem2str( char *, const void *, size_t);
|
char *mem2str( char *, const void *, size_t);
|
||||||
char *trim_spaces( char *string );
|
char *trim_spaces( char *string );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user