SCTC
the soundcloud.com terminal client
helper.h
Go to the documentation of this file.
1 /*
2  SCTC - the soundcloud.com client
3  Copyright (C) 2015 Christian Eichler
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>
17 */
18 
23 #ifndef _HELPER_H
24  #define _HELPER_H
25  //\cond
26  #include <stdbool.h> // for bool
27  #include <stddef.h> // for size_t
28  //\endcond
29 
35  char* smprintf(char *fmt, ...);
36 
48  int snprint_ftime(char *buffer, size_t buffer_size, int time_secs);
49 
56  void strcrep(char *str, char s, char r);
57 
58  char* strstrp(char *str);
59 
65  bool yank(char *text);
66 
67 
68  #define INVALID_TIME ((unsigned int) ~0)
69 
70 
78  unsigned int parse_time_to_sec(char *str);
79 
87  #define lmalloc(S) _lmalloc (__FILE__, __LINE__, __func__, S)
88 
96  #define lcalloc(N,S) _lcalloc (__FILE__, __LINE__, __func__, N, S)
97 
105  #define lrealloc(P,S) _lrealloc(__FILE__, __LINE__, __func__, P, S)
106 
117  void* _lmalloc (char *srcfile, int srcline, const char *srcfunc, size_t size);
118 
130  void* _lcalloc (char *srcfile, int srcline, const char *srcfunc, size_t nmemb, size_t size);
131 
143  void* _lrealloc(char *srcfile, int srcline, const char *srcfunc, void *ptr, size_t size);
144 
152  #define lstrdup(S) _lstrdup(__FILE__, __LINE__, __func__, S)
153 
164  char *_lstrdup(char *srcfile, int srcline, const char *srcfunc, const char *s);
165 #endif /* _HELPER_H */
void * _lmalloc(char *srcfile, int srcline, const char *srcfunc, size_t size)
Definition: helper.c:111
void * _lrealloc(char *srcfile, int srcline, const char *srcfunc, void *ptr, size_t size)
Definition: helper.c:129
static volatile char * buffer
Definition: sound.c:61
char * smprintf(char *fmt,...)
printf style function with automated allocation of buffer.
Definition: helper.c:36
char * strstrp(char *str)
Definition: helper.c:73
unsigned int parse_time_to_sec(char *str)
Parse a string to seconds.
Definition: helper.c:147
void strcrep(char *str, char s, char r)
replace a char with another char in a given string
Definition: helper.c:51
void * _lcalloc(char *srcfile, int srcline, const char *srcfunc, size_t nmemb, size_t size)
Definition: helper.c:120
bool yank(char *text)
Yank the provided text.
Definition: helper.c:86
char * _lstrdup(char *srcfile, int srcline, const char *srcfunc, const char *s)
Definition: helper.c:138
int snprint_ftime(char *buffer, size_t buffer_size, int time_secs)
Write a formated version of time_secs to buffer.
Definition: helper.c:60