public
Description: Library to access lastfm via it's 2.0 api
Homepage: https://launchpad.net/liblastfm
Clone URL: git://github.com/LCID-Fire/liblastfm.git
Click here to lend your support to: liblastfm and make a donation at www.pledgie.com !
liblastfm / include.c
100644 55 lines (46 sloc) 1.068 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <glib.h>
#include <string.h>
#include "include.h"
 
gboolean file_exists(const char* file)
{
return g_file_test(file, G_FILE_TEST_IS_REGULAR);
}
 
int isempty(const char* string)
{
return !string || (strlen(string) == 0);
}
 
guint countv(void** elements)
{
void** start = elements;
while(*elements)
{
elements++;
}
return elements - start;
}
 
void xwax_vprinterr(const char* module_name, const char* format, va_list args)
{
g_printerr("[");
g_printerr(module_name);
g_printerr("]: ");
gchar* output = g_strdup_vprintf(format, args);
g_printerr(output);
g_free(output);
g_printerr("\n");
}
 
void xwax_vprint(const char* module_name, const char* format, va_list args)
{
g_print("[");
g_print(module_name);
g_print("]: ");
gchar* output = g_strdup_vprintf(format, args);
g_print(output);
g_free(output);
g_print("\n");
}
 
gchar* utf8_get_null_terminated(const gchar* string, size_t string_size)
{
gchar* buffer = g_new0(gchar, string_size + 1);
 
g_utf8_strncpy(buffer, string, g_utf8_strlen(string, string_size));
 
return buffer;
}