From: <dg...@su...> - 2009-01-08 19:06:37
|
Author: bricks Date: Thu Jan 8 20:06:03 2009 New Revision: 5059 URL: http://www.opensync.org/changeset/5059 Log: added additional application examples Added: trunk/docs/examples/applications/list_all_formats.c trunk/docs/examples/applications/list_all_plugins.c Modified: trunk/docs/examples/applications/CMakeLists.txt trunk/docs/examples/applications/list_all_groups.c Modified: trunk/docs/examples/applications/CMakeLists.txt ============================================================================== --- trunk/docs/examples/applications/CMakeLists.txt Thu Jan 8 19:27:30 2009 (r5058) +++ trunk/docs/examples/applications/CMakeLists.txt Thu Jan 8 20:06:03 2009 (r5059) @@ -14,4 +14,14 @@ SET( appl_SRCS list_all_groups.c ) SET( appl_NAME list_all_groups ) ADD_EXECUTABLE( ${appl_NAME} ${appl_SRCS} ) +TARGET_LINK_LIBRARIES( ${appl_NAME} ${OPENSYNC_LIBRARIES} ) + +SET( appl_SRCS list_all_plugins.c ) +SET( appl_NAME list_all_plugins ) +ADD_EXECUTABLE( ${appl_NAME} ${appl_SRCS} ) +TARGET_LINK_LIBRARIES( ${appl_NAME} ${OPENSYNC_LIBRARIES} ) + +SET( appl_SRCS list_all_formats.c ) +SET( appl_NAME list_all_formats ) +ADD_EXECUTABLE( ${appl_NAME} ${appl_SRCS} ) TARGET_LINK_LIBRARIES( ${appl_NAME} ${OPENSYNC_LIBRARIES} ) \ No newline at end of file Added: trunk/docs/examples/applications/list_all_formats.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/applications/list_all_formats.c Thu Jan 8 20:06:03 2009 (r5059) @@ -0,0 +1,33 @@ +#include <opensync/opensync.h> +#include <opensync/opensync-format.h> + +int main(int argc, char *argv[]) { + OSyncFormatEnv *env; + OSyncObjFormat *format; + + osync_bool couldloadformats; + + int numformats = 0; + int i = 0; + + env = osync_format_env_new (NULL); + /* load formats from default dir */ + couldloadformats= osync_format_env_load_plugins(env, NULL, NULL); + if (!couldloadformats) { + /* print error */ + printf("Could not load formats."); + return -1; + } + + numformats = osync_format_env_num_objformats(env); + printf("found %i formats\n", numformats); + + for( i = 0; i < numformats; i++ ) { + format = osync_format_env_nth_objformat(env, i); + printf("format nr. %i is %s\n", i+1, osync_objformat_get_name(format)); + } + + osync_format_env_unref(env); + + return 0; +} Modified: trunk/docs/examples/applications/list_all_groups.c ============================================================================== --- trunk/docs/examples/applications/list_all_groups.c Thu Jan 8 19:27:30 2009 (r5058) +++ trunk/docs/examples/applications/list_all_groups.c Thu Jan 8 20:06:03 2009 (r5059) @@ -4,7 +4,7 @@ int main(int argc, char *argv[]) { int numgroups = 0; - int i; + int i = 0; osync_bool couldloadgroups; @@ -16,13 +16,21 @@ couldloadgroups = osync_group_env_load_groups(groupenv, NULL, NULL); if ( !couldloadgroups ) { - /* print error to stderr */ + /* print error */ + printf("Could not load groups."); return -1; } numgroups = osync_group_env_num_groups(groupenv); + printf("found %i groups\n", numgroups); + for( i = 0; i < numgroups; i++ ) { group = osync_group_env_nth_group(groupenv, i); + printf("group nr. %i is %s\n", i+1, osync_group_get_name(group)); } + /* free env */ + osync_group_env_unref(groupenv); + + return 0; } Added: trunk/docs/examples/applications/list_all_plugins.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/docs/examples/applications/list_all_plugins.c Thu Jan 8 20:06:03 2009 (r5059) @@ -0,0 +1,35 @@ +#include <opensync/opensync.h> +#include <opensync/opensync-plugin.h> + +int main(int argc, char *argv[]) { + + OSyncPluginEnv *env; + OSyncPlugin* plugin; + + osync_bool couldloadplugins; + + int numplugins; + int i = 0; + + env = osync_plugin_env_new(NULL); + /* load plugins from default dir */ + couldloadplugins = osync_plugin_env_load(env, NULL, NULL); + if (!couldloadplugins) { + /* print error */ + printf("Could not load plugins."); + return -1; + } + + numplugins = osync_plugin_env_num_plugins(env); + printf("found %i plugins\n", i); + + for( i=0; i < numplugins; i++ ) { + plugin = osync_plugin_env_nth_plugin(env, i); + printf("plugin nr. %i is %s\n", i+1, osync_plugin_get_name(plugin)); + } + + /* free env */ + osync_plugin_env_unref(env); + + return 0; +} |