00001 /* 00002 * Microfeed - Backend for accessing feed-based services 00003 * Copyright (C) 2009 Henrik Hedberg <henrik.hedberg@innologies.fi> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as published by 00007 * the Free Software Foundation, or under the terms of the GNU Lesser General 00008 * Public License version 2.1 as published by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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 MicrofeedWeakReference* microfeed_weak_reference_new(void* referenced, MicrofeedWeakReference* existing_weak_reference); 00043 void microfeed_weak_reference_free(MicrofeedWeakReference* weak_refeference); 00044 void* microfeed_weak_reference_get_impl(MicrofeedWeakReference* weak_reference); 00045 #define microfeed_weak_reference_get(w, t) ((t*)microfeed_weak_reference_get_impl(w)) 00046 void microfeed_weak_reference_invalidate(MicrofeedWeakReference* weak_reference); 00047 00048 #define microfeed_memory_allocate(t) ((t*)microfeed_memory_allocate_bytes(sizeof(t))) 00049 void* microfeed_memory_allocate_bytes(size_t size); 00050 #define microfeed_memory_allocate_with_strings(t,...) ((t*)microfeed_memory_allocate_with_strings_impl(sizeof(t),__VA_ARGS__)) 00051 /* #define microfeed_memory_free(p) free(p) */ 00052 void microfeed_memory_free(void* p); 00053 00054 char* microfeed_util_string_concatenate(const char* s, ...); 00055 char* microfeed_util_string_percent_encoding_escape(const char* s); 00056 char* microfeed_util_string_percent_encoding_unescape(const char* s); 00057 char* microfeed_util_string_base64_encode(const char* s, size_t length); 00058 size_t microfeed_util_string_starts_with(const char* s, const char* prefix); 00059 00060 int microfeed_util_create_directory_recursively(const char* directory); 00061 00067 #endif