1
/* string-utils.c - Functions dealing with string contents.
3
* Copyright (C) 2001 Oskar Liljeblad
5
* This file is part of the file renaming utilities (renameutils)
8
* This software is copyrighted work licensed under the terms of the
9
* GNU General Public License. Please consult the file `COPYING' for
13
#ifndef __STRING_UTILS_H__
14
#define __STRING_UTILS_H__
16
#include <sys/types.h>
17
#include <ctype.h> /* for toupper and tolower */
21
int strindex(const char *str, char ch);
22
void chomp(char *str);
23
void strip_leading(char *line, int (*check)(int));
24
int char_index(const char *line, int (*check)(int));
25
bool ends_with(const char *str, const char *end);
26
bool starts_with(const char *str, const char *start);
27
int translate_char(char *str, char from, char to);
28
void str_convert(char *str, int (*convert)(int));
29
#define str_toupper(str) str_convert((str), toupper)
30
#define str_tolower(str) str_convert((str), tolower)
31
int iswordchar(int ch);
32
bool replace_str(char *str, const char *from, const char *to);
33
char *cat_files(const char *file, const char *file2);
34
char *substring(const char *buf, int start, int end);
36
int string_strip_trailing(char *str, const char *stripchars);
37
int string_strip_trailing_c(char *str, char stripchar);
38
/* int string_strip_trailing_f(char *str, int (*function)(int)); */
39
int string_strip_leading(char *str, const char *stripchars);
40
int string_strip_leading_c(char *str, char stripchar);
41
/* int string_strip_leading_f(char *str, int (*function)(int)); */
43
#define string_index_of_c strindex
44
/* int string_index_of(const char *str, const char *findstr);
45
int string_index_of_char(const char *str, char findchar);
46
int string_index_of_any_f(const char *str, int (*function)(int)); */
47
int string_index_of_any(const char *str, const char *findchars);
49
int word_get_index(const char *str, int pos);
50
char *word_get(const char *str, int idx);
52
int uintlen(uint64_t value);
53
char *xdirname(const char *path);
55
bool ends_with_nocase(const char *str, const char *end);
56
bool starts_with_nocase(const char *str, const char *start);