int main(int argc, char **argv){ static struct app app; // first thing is to fork off all services if(app_load_services(&app, UBUS_SERVICE_ROOT) != 0){ fprintf(stderr, "***** ERROR ***** there were errors while loading lua services!\n"); //app_destroy(&app); //return -1; } app_init(&app); if(app_connect_to_ubus(&app, NULL) != 0){ DEBUG("failed to connect to ubus!\n"); return -1; } if(app_load_scripts(&app, UBUS_ROOT) != 0){ fprintf(stderr, "***** ERROR ******* there were errors while loading ubus scripts\n"); fprintf(stderr, "***** some ubus rpc call may not be available!\n"); //app_destroy(&app); //return -1; } app_run(&app); app_destroy(&app); return 0; }
int main(int argc, char **argv) { setlinebuf(stdout); g_thread_init(NULL); app_t *app = (app_t*) calloc(1, sizeof(app_t)); app->lcm = bot_lcm_get_global(NULL); app->ptr = new KinectPointCloudPub(argc, argv); app_run(app); app_destroy(app); return 0; }
int main (int argc, char **argv) { gtk_init (&argc, &argv); app_params_t params = { .foo = 1, .bar = NULL, .filename = NULL }; GOptionEntry options[] = { { "foo", 'f', 0, G_OPTION_ARG_INT, ¶ms.foo, "Example int parameter", "F" }, { "bar", 'b', 0, G_OPTION_ARG_STRING, ¶ms.filename, "Example filename parameter", "B" }, { NULL } }; GError *opt_error = NULL; GOptionContext *opt_parser; opt_parser = g_option_context_new (" - BotGtkGlImageArea tester"); g_option_context_add_main_entries (opt_parser, options, NULL); g_option_context_parse (opt_parser, &argc, &argv, &opt_error); g_option_context_free (opt_parser); if (argc < 2) { fprintf (stderr, "must specify filename\n"); return 0; } params.filename = strdup (argv[1]); app_t *app = app_create (¶ms); if (app) { app_run (app); app_destroy (app); } return 0; }
static app_t * app_create (const app_params_t *params) { app_t *self = (app_t*) calloc (1, sizeof (app_t)); self->foo = params->foo; if (0 != load_ppm (self, params->filename)) goto fail; setup_gui (self); bot_gtk_gl_image_area_set_image_format (self->gl_area, self->img_width, self->img_height, GL_RGB); bot_gtk_gl_image_area_upload_image (self->gl_area, self->img, self->img_stride); return self; fail: app_destroy (self); return NULL; }
static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { pj_thread_t *thread; switch (fdwCtrlType) { // Handle the CTRL+C signal. case CTRL_C_EVENT: case CTRL_CLOSE_EVENT: case CTRL_BREAK_EVENT: case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: pj_thread_register("ctrlhandler", handler_desc, &thread); PJ_LOG(3,(THIS_FILE, "Ctrl-C detected, quitting..")); app_destroy(); ExitProcess(1); PJ_UNREACHED(return TRUE;) default: return FALSE; }
int main(int argc, char *argv[]) { (void)argc; (void)argv; int res; int ret_val = 0; app_trace(TRACE_INFO, " << FAX HANDLING APPLICATION BU!!! >>"); res = app_init(); if(res) { app_trace(TRACE_ERR, "App init failed (%d)", res); ret_val = -1; goto _exit; } app_start(); app_destroy(); _exit: return ret_val; }
int main(int argc, char* argv[]) { if( argc < 2 ) { exit_usage(argv[0]); } int bit_rate = 0, fps = 60, port = 8080, width = 0, height = 0; // Parse command line options for( int i = 1; i < argc-1; i+=2 ) { if( strlen(argv[i]) < 2 || i >= argc-2 || argv[i][0] != '-' ) { exit_usage(argv[0]); } switch( argv[i][1] ) { case 'b': bit_rate = atoi(argv[i+1]) * 1000; break; case 'p': port = atoi(argv[i+1]); break; case 's': sscanf(argv[i+1], "%dx%d", &width, &height); break; case 'f': fps = atoi(argv[i+1]); break; default: exit_usage(argv[0]); } } // Find target window char *window_title = argv[argc-1]; HWND window = NULL; if( strcmp(window_title, "desktop") == 0 ) { window = GetDesktopWindow(); } else if( strcmp(window_title, "cursor") == 0 ) { POINT cursor; GetCursorPos(&cursor); window = WindowFromPoint(cursor); } else { window = window_with_prefix(window_title); } if( !window ) { printf("No window with title starting with \"%s\"\n", window_title); return 0; } // Start the app app_t *app = app_create(window, port, bit_rate, width, height); char real_window_title[56]; GetWindowTextA(window, real_window_title, sizeof(real_window_title)); printf( "Window 0x%08x: \"%s\"\n" "Window size: %dx%d, output size: %dx%d, bit rate: %d kb/s\n\n" "Server started on: http://%s:%d/\n\n", window, real_window_title, app->grabber->width, app->grabber->height, app->encoder->out_width, app->encoder->out_height, app->encoder->context->bit_rate / 1000, server_get_host_address(app->server), app->server->port ); app_run(app, fps); app_destroy(app); return 0; }