00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MICROFEEDMISC_H
00021 #define MICROFEEDMISC_H
00022
00023 #include <stdlib.h>
00024 #include <sys/types.h>
00025 #include <dirent.h>
00026
00040 typedef struct _MicrofeedWeakReference MicrofeedWeakReference;
00041
00042 typedef void (*MicrofeedFreeCallback)(void* referenced, void* user_data);
00043
00044 MicrofeedWeakReference* microfeed_weak_reference_new(void* referenced, MicrofeedWeakReference* existing_weak_reference);
00045 void microfeed_weak_reference_free(MicrofeedWeakReference* weak_refeference);
00046 void* microfeed_weak_reference_get_impl(MicrofeedWeakReference* weak_reference);
00047 #define microfeed_weak_reference_get(w, t) ((t*)microfeed_weak_reference_get_impl(w))
00048 void microfeed_weak_reference_invalidate(MicrofeedWeakReference* weak_reference);
00049 MicrofeedWeakReference* microfeed_weak_reference_add_free_callback(MicrofeedWeakReference* weak_reference, void* referenced, MicrofeedFreeCallback free_callback, void* user_data);
00050 void microfeed_weak_reference_remove_free_callback(MicrofeedWeakReference* weak_reference, MicrofeedFreeCallback free_callback, void* user_data);
00051
00052 #define microfeed_memory_allocate(t) ((t*)microfeed_memory_allocate_bytes(sizeof(t)))
00053 void* microfeed_memory_allocate_bytes(size_t size);
00054 #define microfeed_memory_allocate_with_strings(t,...) ((t*)microfeed_memory_allocate_with_strings_impl(sizeof(t),__VA_ARGS__))
00055
00056 void microfeed_memory_free(void* p);
00057
00058 char* microfeed_util_string_concatenate(const char* s, ...);
00059 char* microfeed_util_string_percent_encoding_escape(const char* s);
00060 char* microfeed_util_string_percent_encoding_unescape(const char* s);
00061 char* microfeed_util_string_base64_encode(const char* s, size_t length);
00062 size_t microfeed_util_string_starts_with(const char* s, const char* prefix);
00063
00064 int microfeed_util_create_directory_recursively(const char* directory);
00065
00071 #endif