/* Copy selection */ void copy(GtkWidget *widget, gpointer data){//widget and data are useless if (!selection_is_on) show_error_message("No hay nada seleccionado para copiar"); save_paste_positions(); clipboard_pixbuf = gdk_pixbuf_get_from_drawable(NULL,GDK_DRAWABLE(canvas->window),gdk_colormap_get_system(),selection_x1,selection_y1,0,0,selection_x2-selection_x1,selection_y2-selection_y1); }
gboolean test_battery_run (TestBattery *battery, GtkWindow *parent, gpointer data) { gchar *primary_text, *secondary_text; gint count = 0; primary_text = secondary_text = NULL; while (battery[count] && !primary_text) { (battery[count]) (&primary_text, &secondary_text, data); count++; } if (primary_text) { show_error_message (parent, primary_text, secondary_text); g_free (primary_text); g_free (secondary_text); return FALSE; } return TRUE; }
/** * name: cb_eval * * This callback function is invoked when the 'LispEdit: eval' menu option is selected. * If the cursor is placed after a closing parenthesis the function will look for the matching * opening parenthesis. If there is no matching parenthesis it will display a warning dialog box. * * If the closing parenthesis has a matching opening parenthesis, all the characters between the parentheses * including the parentheses are sent to the child process running in the VTE. * * @param menuitem GtkMenuItem. * @param gdata gpointer. * @return void **/ static void cb_eval(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata) { if (have_vte) { doc = document_get_current(); end_pos = sci_get_current_position(doc->editor->sci); if (end_pos > 0) end_pos--; gchar letter = sci_get_char_at(doc->editor->sci, end_pos); switch (letter) { case ')': start_pos = sci_find_matching_brace(doc->editor->sci, end_pos); if (start_pos < 0) { dialogs_show_msgbox(GTK_MESSAGE_WARNING, "Found an isolated closing brace!!!"); } else if (start_pos >= 0) { sci_get_text_range(doc->editor->sci, start_pos, ++end_pos, cmd_string); vte_terminal_feed_child(vte, "\n", strlen("\n")); vte_terminal_feed_child(vte, cmd_string, strlen(cmd_string)); vte_terminal_feed_child(vte, "\n", strlen("\n")); } break; } } else { show_error_message(); } }
void show_startup_error(const char* format, ...) { char buffer[1024]; va_list args; va_start(args, format); vsnprintf(buffer, 1024, format, args); va_end(args); show_error_message("Error Starting Abuse", "An error occurred which has prevented Abuse from starting:\n\n%s", buffer); }
void game_cache_options::purge_cache_callback() { if(purge_cache()) { show_message( _("Cache Purged"), _("The game data cache has been purged.")); } else { show_error_message(_("The game data cache could not be purged.")); } update_cache_size_display(); }
void game_cache_options::clean_cache_callback() { if(clean_cache()) { show_message( _("Cache Cleaned"), _("The game data cache has been cleaned.")); } else { show_error_message(_("The game data cache could not be completely cleaned.")); } update_cache_size_display(); }
static void error_cb(GstBus *bus, GstMessage *message, gpointer user_data) { GError *error = NULL; GstElement *pipeline = user_data; g_assert(pipeline); /* Make sure the pipeline is not running any more */ gst_element_set_state (pipeline, GST_STATE_NULL); gst_message_parse_error(message, &error, NULL); show_error_message(_("GStreamer runtime error."), error->message); g_error_free(error); }
/* Returns true iff given coordinate is within the posible selection */ gboolean click_is_within_selection(double x, double y){ if (!selection_is_on) return FALSE; if ((x > selection_x1) && (x < selection_x2) && (y > selection_y1) && (y < selection_y2)){ move_x1 = x; move_y1 = y; return TRUE; } show_error_message("No hay nada seleccionado para mover"); return FALSE; }
void print_foxinfo() { StrBuf sb; StrBuf_init(&sb, 32); StrBuf_add(&sb, "foxw ", -1); StrBuf_printf(&sb, "%d.%d.%d", FOX_VERSION_MAJOR, FOX_VERSION_MINOR, FOX_VERSION_REVISION); StrBuf_printf(&sb, ", %dbit", (int)sizeof(void*) * 8); #ifndef NO_DEBUG StrBuf_add(&sb, " (debug-build)", -1); #endif show_error_message(sb.p, sb.size, TRUE); StrBuf_close(&sb); }
/* Cut selection */ void cut(GtkWidget *widget, gpointer data){//widget and data are useless if (!selection_is_on) show_error_message("No hay nada seleccionado para cortar"); //get area clipboard_pixbuf = gdk_pixbuf_get_from_drawable(NULL,GDK_DRAWABLE(canvas->window),gdk_colormap_get_system(),selection_x1,selection_y1,0,0,selection_x2-selection_x1,selection_y2-selection_y1); cairo_t *cr = gdk_cairo_create(canvas->window); //erase selection paint_current_surface_on_canvas(cr); //draw white rectangle in selection area cairo_set_source_rgb(cr,1,1,1); cairo_rectangle(cr,selection_x1,selection_y1,selection_x2-selection_x1,selection_y2-selection_y1); cairo_fill(cr); save_paste_positions(); save_current_surface(cairo_get_target(cr)); save_current_surface_in_history(); }
void print_last_error() { if (fv->err_dst == NULL) { fv->err_dst = "alert"; } if (fg->error != VALUE_NULL && strcmp(fv->err_dst, "null") != 0) { StrBuf sb; StrBuf_init(&sb, 0); if (strcmp(fv->err_dst, "alert") == 0) { fox_error_dump(&sb, FALSE); show_error_message(sb.p, sb.size, FALSE); } else { FileHandle fh = open_errorlog_file(); fox_error_dump(&sb, TRUE); close_fox(fh); } StrBuf_close(&sb); } }
static int cftp_client_send_special_file(struct cftp_descriptor * desc, struct stat *st, struct cftp_file_request *req, ssize_t size) { union cftp_message *msg; ssize_t recvlen, sendlen; req->type = CFTP_PACKAGE_FILE_WRITE; req->st_mode = st->st_mode; req->st_rdev = st->st_rdev; sendlen = cftp_send_data_retry(desc, req, sizeof(*req) + size, desc->retry_count); if (sendlen < 0) { error_msg("cftp_send_data_retry"); return sendlen; } msg = (union cftp_message *) req; recvlen = cftp_receive_data(desc, msg, desc->max_xfer_length); if (recvlen < 0) { error_msg("cftp_receive_data"); return recvlen; } switch (msg->type) { case CFTP_PACKAGE_ACK: return 0; case CFTP_PACKAGE_ERROR: show_error_message(&msg->err_msg); return -msg->err_msg.err_code; default: error_msg("unknown package type"); return -EINVAL; } return 0; }
G_MODULE_EXPORT void sql_query_entry_activate_cb(GtkEntry* entry, gpointer user_data) { SSE_APP* app = (SSE_APP*)user_data; if(app->db != NULL) { sqlite3_stmt* query = NULL; const char* query_str = gtk_entry_get_text(entry); if(sqlite3_prepare(app->db, query_str, -1, &query, NULL) == SQLITE_OK) { reset_main_tree_view(app); if(sqlite3_column_count(query) != 0) { init_main_tree_view(app, query, FALSE); init_main_list_store(app->main_list_store, query); } else sqlite3_step(query); init_table_list_store(app); GList* last_item = app->last_query_item; g_free(last_item->data); last_item->data = g_strdup(query_str); app->last_query_item = last_item->next; } else { const char* error_msg = sqlite3_errmsg(app->db); show_error_message(app, error_msg); } sqlite3_finalize(query); } }
int main( int argc, char **argv) { int rval = -9, pass; if( argc == 2) { UCAC2_STAR star; long ucac2_number = atol( argv[1]); if( !extract_ucac2_info( ucac2_number, &star, "")) { char buff[200]; write_ucac2_star( ucac2_number, buff, &star); printf( "%s", buff); } else printf( "Couldn't get data\n"); exit( -1); } if( argc < 5) show_error_message( ); else { FILE *ofile = fopen( "ucac2.txt", "w"); for( pass = 0; pass < 2; pass++) { rval = extract_ucac2_stars( ofile, atof( argv[1]), atof( argv[2]), atof( argv[3]), atof( argv[4]), (argc > 5 ? argv[5] : ""), pass); printf( "%d stars extracted\n", rval); } fclose( ofile); } return( rval); }
void plugin_init(GeanyData *data) { /* get a handle on the frame that holds the vte stuff */ vte_frame = get_vte_frame(); /* make sure it's really the frame holding the vte stuff */ if (vte_frame == NULL || !holds_vte(vte_frame)) { show_error_message(); return; } /* set a flag for the cleanup function to use */ have_vte = TRUE; /* store where the vte frame is going to go */ vte_new_home = GTK_NOTEBOOK(geany_data->main_widgets->sidebar_notebook); /* store where the vte was so we can put it back */ vte_old_home = GTK_NOTEBOOK(gtk_widget_get_parent(vte_frame)); /* grab the notebook page label so we can set it on the new tab */ vte_tab_label = gtk_notebook_get_tab_label(vte_old_home, vte_frame); /* increase the ref count so the label doesn't get destroy when we * reparent the notebook child */ g_object_ref(G_OBJECT(vte_tab_label)); /* move the vte frame to the sidebar notebook */ gtk_widget_reparent(vte_frame, GTK_WIDGET(vte_new_home)); /* set the label again since it's gone somewhere */ gtk_notebook_set_tab_label(vte_new_home, GTK_WIDGET(vte_frame), vte_tab_label); /* select the new vte tab in the sidebar */ gtk_notebook_set_current_page(vte_new_home, -1); }
int cftp_server_send_file(struct cftp_descriptor *desc, const char *filename, u32 offset, size_t size) { int fd; int ret; union cftp_message *msg; struct cftp_data_package *data_pkg; ssize_t recvlen, sendlen, readlen; u16 blk_num; struct progress_bar bar; size_t max_xfer_length, max_data_length; struct stat st; max_xfer_length = desc->max_xfer_length; max_data_length = max_xfer_length - sizeof(msg->data_pkg); msg = malloc(max_xfer_length); if (msg == NULL) { pr_err_info("malloc"); return -ENOMEM; } fd = open(filename, O_RDONLY); if (fd < 0) { pr_err_info("open file %s faild", filename); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "open file %s faild", filename); ret = fd; goto out_free_msg; } ret = fstat(fd, &st); if (ret < 0) { pr_err_info("fstat"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "fstat"); goto out_close_file; } if (offset) { ret = lseek(fd, offset, SEEK_SET); if (ret < 0) { pr_err_info("lseek"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "seek file %s faild", filename); goto out_close_file; } } if (size == 0) { size = st.st_size - offset; } data_pkg = malloc(max_xfer_length); if (data_pkg == NULL) { pr_err_info("malloc"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "malloc"); ret = -ENOMEM; goto out_close_file; } println("filename = %s", filename); println("offset = %s", size2text(offset)); println("size = %s", size2text(size)); blk_num = 0; data_pkg->type = CFTP_PACKAGE_DATA; progress_bar_init(&bar, size, 0, PROGRESS_BAR_TYPE_DATA); while (1) { readlen = read(fd, data_pkg->data, max_data_length); if (readlen < 0) { pr_err_info("read file failed"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "read file failed"); ret = readlen; goto out_free_data_pkg; } data_pkg->blk_num = blk_num++; label_send_data: sendlen = cftp_send_data_retry(desc, data_pkg, sizeof(*data_pkg) + readlen, desc->retry_count); if (sendlen < 0) { pr_err_info("cftp_send_ack_message"); ret = sendlen; goto out_free_data_pkg; } recvlen = cftp_receive_data(desc, msg, max_xfer_length); if (recvlen < 0) { pr_err_info("cftp_receive_data"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "receive file failed"); ret = recvlen; goto out_free_data_pkg; } switch (msg->type) { case CFTP_PACKAGE_ERROR: show_error_message((struct cftp_error_message *) msg); ret = -EFAULT; goto out_free_data_pkg; case CFTP_PACKAGE_ACK: if (msg->ack_msg.blk_num != blk_num) { pr_warn_info("blk_num %d != %d", msg->ack_msg.blk_num, blk_num); goto label_send_data; } if ((size_t) readlen < max_data_length) { progress_bar_finish(&bar); println("Send data complete"); ret = 0; goto out_free_data_pkg; } progress_bar_add(&bar, max_data_length); break; default: pr_err_info("invalid package type"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "invalid package type"); ret = -EINVAL; goto out_free_data_pkg; } } out_free_data_pkg: free(data_pkg); out_close_file: close(fd); out_free_msg: free(msg); return ret; }
int cftp_server_receive_file(struct cftp_descriptor *desc, const char *filename, mode_t mode, u32 offset, size_t size) { int fd; int ret; union cftp_message *msg; ssize_t recvlen, sendlen; u16 blk_num; struct progress_bar bar; size_t max_xfer_length; max_xfer_length = desc->max_xfer_length; msg = malloc(max_xfer_length); if (msg == NULL) { pr_err_info("malloc"); return -ENOMEM; } fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, mode); if (fd < 0) { pr_err_info("open file %s faild", filename); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "open file %s faild", filename); ret = fd; goto out_free_msg; } if (offset) { ret = lseek(fd, offset, SEEK_SET); if (ret < 0) { pr_err_info("lseek"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "seek file %s faild", filename); goto out_free_msg; } } println("offset = %s", size2text(offset)); println("size = %s", size2text(size)); blk_num = 0; progress_bar_init(&bar, size, 0, PROGRESS_BAR_TYPE_DATA); while (1) { sendlen = cftp_send_ack_message(desc, (struct cftp_ack_message *) msg, blk_num, desc->retry_count); if (sendlen < 0) { pr_err_info("cftp_send_ack_message"); ret = sendlen; goto out_close_file; } recvlen = cftp_receive_data(desc, msg, max_xfer_length); if (recvlen < 0) { pr_err_info("cftp_receive_data"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "receive file failed"); ret = recvlen; goto out_close_file; } switch (msg->type) { case CFTP_PACKAGE_ERROR: show_error_message((struct cftp_error_message *) msg); ret = -EFAULT; goto out_close_file; case CFTP_PACKAGE_DATA: if (msg->data_pkg.blk_num != blk_num) { pr_warn_info("blk_num %d != %d", msg->data_pkg.blk_num, blk_num); continue; } sendlen = write(fd, msg->data_pkg.data, recvlen - sizeof(msg->data_pkg)); if (sendlen < 0) { pr_err_info("write"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "write file failed"); ret = sendlen; goto out_close_file; } blk_num++; if ((size_t) recvlen < max_xfer_length) { cftp_send_ack_message(desc, (struct cftp_ack_message *) msg, blk_num, 0); progress_bar_finish(&bar); println("Receive data complete"); ret = 0; goto out_close_file; } else { progress_bar_add(&bar, sendlen); } break; default: pr_err_info("invalid package type"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "invalid package type"); ret = -EINVAL; goto out_close_file; } } out_close_file: close(fd); out_free_msg: free(msg); return ret; }
int cftp_client_send_file(struct cftp_descriptor *desc, const char *file_in, u32 offset_in, const char *file_out, u32 offset_out, size_t size) { int fd; int ret; struct stat st; ssize_t recvlen, sendlen, readlen; u16 blk_num; union cftp_message *msg; struct cftp_data_package *data_msg; size_t max_xfer_length, max_data_length; struct progress_bar bar; ret = file_lstat(file_in, &st); if (ret < 0) { pr_err_info("fstat"); return ret; } max_xfer_length = desc->max_xfer_length; msg = malloc(max_xfer_length); if (msg == NULL) { pr_err_info("malloc"); return -ENOMEM; } switch (st.st_mode & S_IFMT) { case S_IFREG: println("Send File: %s => %s", file_in, file_out); break; case S_IFBLK: case S_IFCHR: println("Send Devicce: %s => %s", file_in, file_out); return cftp_client_send_special_file(desc, &st, &msg->file_req, text_copy(msg->file_req.filename, file_out) - msg->file_req.filename + 1); case S_IFLNK: println("Send Symlink: %s => %s", file_in, file_out); { char *p; p = text_copy(msg->file_req.filename, file_out) + 1; ret = readlink(file_in, p, 1024); if (ret < 0) { pr_err_info("readlink"); return ret; } return cftp_client_send_special_file(desc, &st, &msg->file_req, p - msg->file_req.filename + ret + 1); } case S_IFDIR: println("Send Directory: %s => %s", file_in, file_out); ret = cftp_client_send_special_file(desc, &st, &msg->file_req, text_copy(msg->file_req.filename, file_out) - msg->file_req.filename + 1); if (ret < 0) { pr_err_info("cftp_client_send_special_file"); return ret; } return cftp_client_send_directory(desc, file_in, file_out); default: pr_warn_info("File %s type is unknown", file_in); return 0; } fd = open(file_in, O_RDONLY); if (fd < 0) { pr_err_info("open file %s failed", file_in); goto out_free_msg; } if (offset_in) { ret = lseek(fd, offset_in, SEEK_SET); if (ret < 0) { pr_err_info("lseek"); goto out_close_file; } } if (size == 0) { size = st.st_size - offset_in; } data_msg = malloc(max_xfer_length); if (data_msg == NULL) { pr_err_info("malloc"); ret = -ENOMEM; goto out_close_file; } sendlen = cftp_send_file_reuest(desc, (void *) msg, file_out, &st, offset_out, size, 0); if (sendlen < 0) { ret = sendlen; pr_err_info("cftp_send_data_retry"); goto out_free_data_msg; } println("seek = %s", size2text(offset_out)); println("skip = %s", size2text(offset_in)); println("size = %s", size2text(size)); blk_num = 0; data_msg->type = CFTP_PACKAGE_DATA; max_data_length = max_xfer_length - sizeof(*data_msg); progress_bar_init(&bar, size, 0, PROGRESS_BAR_TYPE_DATA); readlen = max_data_length; while (1) { recvlen = cftp_receive_data(desc, msg, max_xfer_length); if (recvlen < 0) { pr_err_info("cftp_receive_data"); ret = recvlen; goto out_free_data_msg; } switch (msg->type) { case CFTP_PACKAGE_ERROR: show_error_message((struct cftp_error_message *) msg); ret = -EFAULT; goto out_free_data_msg; case CFTP_PACKAGE_ACK: if (msg->ack_msg.blk_num == blk_num) { if ((size_t) readlen < max_data_length) { ret = 0; progress_bar_finish(&bar); println("Send data complete"); goto out_free_data_msg; } readlen = read(fd, data_msg->data, max_data_length); if (readlen < 0) { pr_err_info("read"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "read file failed"); ret = readlen; goto out_free_data_msg; } data_msg->blk_num = blk_num++; progress_bar_add(&bar, readlen); } else { pr_warn_info("%d != %d", msg->ack_msg.blk_num, blk_num); if (blk_num == 0) { continue; } } sendlen = cftp_send_data_retry(desc, data_msg, sizeof(*data_msg) + readlen, desc->retry_count); if (sendlen < 0) { pr_err_info("cftp_send_data_retry"); goto out_free_data_msg; } break; default: pr_err_info("invalid package type"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "invalid package type"); ret = -EINVAL; goto out_free_data_msg; } } out_free_data_msg: free(data_msg); out_close_file: close(fd); out_free_msg: free(msg); return ret; }
int cftp_client_receive_file(struct cftp_descriptor *desc, const char *file_in, u32 offset_in, const char *file_out, u32 offset_out, size_t size) { int fd; int ret; ssize_t recvlen, sendlen; u16 blk_num; union cftp_message *msg; size_t max_xfer_length; fd = open(file_out, O_WRONLY | O_CREAT | O_TRUNC, 0777); if (fd < 0) { pr_err_info("open file %s failed", file_out); return fd; } if (offset_out) { ret = lseek(fd, offset_out, SEEK_SET); if (ret < 0) { pr_err_info("lseek"); goto out_close_file; } } max_xfer_length = desc->max_xfer_length; msg = malloc(max_xfer_length); if (msg == NULL) { pr_err_info("malloc"); ret = -ENOMEM; goto out_close_file; } sendlen = cftp_send_file_reuest(desc, (void *) msg, file_in, NULL, offset_in, size, 1); if (sendlen < 0) { pr_err_info("cftp_send_data_retry"); ret = sendlen; goto out_free_msg; } println("Remote@%s => Local@%s", file_in, file_out); println("seek = %s", size2text(offset_out)); println("skip = %s", size2text(offset_in)); println("size = %s", size2text(size)); blk_num = 0; while (1) { recvlen = cftp_receive_data(desc, msg, max_xfer_length); if (recvlen < 0) { pr_err_info("cftp_receive_data"); ret = recvlen; goto out_free_msg; } switch (msg->type) { case CFTP_PACKAGE_ERROR: show_error_message((struct cftp_error_message *) msg); ret = -EFAULT; goto out_free_msg; case CFTP_PACKAGE_DATA: if (msg->data_pkg.blk_num == blk_num) { sendlen = write(fd, msg->data_pkg.data, recvlen - sizeof(msg->data_pkg)); if (sendlen < 0) { pr_err_info("write"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "write file failed"); ret = sendlen; goto out_free_msg; } blk_num++; if ((blk_num & 0xFF) == 0) { print_char('.'); } if ((size_t) recvlen < max_xfer_length) { println(" Receive data complete"); cftp_send_ack_message(desc, (struct cftp_ack_message *) msg, blk_num, 0); ret = 0; goto out_free_msg; } } else { pr_warn_info("%d != %d", msg->data_pkg.blk_num, blk_num); } sendlen = cftp_send_ack_message(desc, (struct cftp_ack_message *) msg, blk_num, desc->retry_count); if (sendlen < 0) { pr_err_info("cftp_send_ack_message"); ret = sendlen; goto out_free_msg; } break; default: pr_err_info("invalid package type"); cftp_send_error_message(desc, (struct cftp_error_message *) msg, "invalid package type"); ret = -EINVAL; goto out_free_msg; } } out_free_msg: free(msg); out_close_file: close(fd); return ret; }
int main(int argc, char **argv) { QApplication app(argc, argv); KComponentData cd("kingston_update_notifier"); test_window_t* test_window = new test_window_t(); update_worker_t* update_worker = new update_worker_t(); QObject::connect(test_window,SIGNAL(check_for_updates_requested()),update_worker,SLOT(check_for_updates())); QObject::connect(update_worker,SIGNAL(updates_available(int,int)),test_window,SLOT(show_new_updates(int,int))); QObject::connect(update_worker,SIGNAL(error(QString,update_worker_t::error_code_t)),test_window,SLOT(show_error_message(QString,update_worker_t::error_code_t))); update_listener_t* update_listener = new update_listener_t(); QObject::connect(update_listener,SIGNAL(please_check_for_updates()),update_worker,SLOT(check_for_updates())); notifier_t* notifier = new notifier_t(cd); QObject::connect(update_worker,SIGNAL(updates_available(int,int)),notifier,SLOT(notify_new_updates(int,int))); test_window->show(); update_worker->check_for_updates(); reboot_listener_t* reboot_listener = new reboot_listener_t(); QObject::connect(reboot_listener,SIGNAL(request_reboot()),notifier,SLOT(notify_reboot())); reboot_listener->check_for_reboot(); return app.exec(); }
static gboolean on_button_press_event(ClutterActor *actor, ClutterButtonEvent *event, CalibArea *area) { gint num_clicks; gboolean success; if (area->success) return FALSE; if (event->click_count > 1) return FALSE; /* Check matching device ID if a device ID was provided */ if (area->device_id > -1) { ClutterInputDevice *device; device = clutter_event_get_source_device ((ClutterEvent *) event); if (device != NULL && clutter_input_device_get_device_id (device) != area->device_id) { char *name; g_object_get (G_OBJECT (device), "name", &name, NULL); g_debug ("Ignoring input from device %s (%d)", name, clutter_input_device_get_device_id (device)); g_free (name); return FALSE; } } /* Handle click */ clutter_timeline_stop (CLUTTER_TIMELINE (area->clock_timeline)); clutter_timeline_start (CLUTTER_TIMELINE (area->clock_timeline)); success = add_click(&area->calibrator, (int) event->x, (int) event->y); num_clicks = area->calibrator.num_clicks; if (!success && num_clicks == 0) show_error_message (area); else { gboolean visible; g_object_get (area->error_text, "visible", &visible, NULL); if (visible) hide_error_message (area); } /* Are we done yet? */ if (num_clicks >= 4) { set_calibration_status (area); return FALSE; } cc_target_actor_move_center (CC_TARGET_ACTOR (area->target), area->X[num_clicks], area->Y[num_clicks]); return FALSE; }
int main(int argc, char **argv) { // Declarations for getopt extern int optind; extern char * optarg; int ch; char * format = "f:hnBm:"; // Default makefile name will be Makefile char szMakefile[64] = "Makefile"; char szTarget[64]; char szLog[64]; // boolean flags for each option. int b = 0; int n = 0; int m = 0; int f = 0; int file; // keep track of stdout so we can return to default output int stdOutClone = dup(1); while((ch = getopt(argc, argv, format)) != -1) { switch(ch) { case 'f': strcpy(szMakefile, strdup(optarg)); f = 1; break; case 'n': n = 1; break; case 'B': b = 1; break; case 'm': m = 1; strcpy(szLog, strdup(optarg)); fprintf(stderr,"log name: %s\n",szLog); file = open(szLog, O_APPEND|O_RDWR|O_CREAT, 0777); dup2(file, 1); break; case 'h': show_error_message(argv[0]); exit(1); default: show_error_message(argv[0]); exit(1); } } argc -= optind; argv += optind; // at this point, what is left in argv is the targets that were // specified on the command line. argc has the number of them. // If getopt is still really confusing, // try printing out what's in argv right here, then just running // with various command-line arguments. if(argc > 1) { show_error_message(argv[0]); return EXIT_FAILURE; } // build a target_t array of all targets found in the specified Makefile. int parseResult = parse(szMakefile); // Parse graph file or die if(parseResult == -1) { return EXIT_FAILURE; } // target provided. if(argc == 1) { strcpy(szTarget,argv[0]); } // If no target provided, use the first one found in the Makefile. else { strcpy(szTarget,targets[0].szTarget); //fprintf(stderr, "szTarget: %s\n", szTarget); } int i; int j; // how many children to wait for. int waits = 0; for(i = 0; i < 10; i++) { // look for target in the targets array. if(strcmp(szTarget,targets[i].szTarget) == 0) { targets[i].nStatus = 0; targets[i].pid = 1; for(j = 0; j < targets[i].nDependencyCount; j++) { // if the dependency's associated file exists and needs to be updated (or b flag is set) make a child with it as the target. if(is_file_exist(targets[i].szDependencies[j]) != -1){ if(b || compare_modification_time(targets[i].szTarget,targets[i].szDependencies[j]) == 2) { if(targets[i].szDependencies[j][strlen(targets[i].szDependencies[j])-1] == 'c'){ break; } else { targets[i].pid = fork(); if(targets[i].pid == 0) { break; } else { // increment waits for each child created for a given adult. waits++; } } } // if the dependency's associated file does not exist, make a child with it as the target. } else { targets[i].pid = fork(); if(targets[i].pid == 0) { break; // increment waits for each child created for a given adult. } else { waits++; } } } if(targets[i].pid > 0){ int k; // wait for ALL children to finish. for(k = 0; k < waits; k++) { wait(NULL); } // echo commands if n if(n) { char* echoCommand = (char*) calloc(100, 1); strcat(echoCommand, "echo '"); char* command = &targets[i].szCommand[0]; strcat(echoCommand,command); strcat(echoCommand,"'"); system(echoCommand); } // else execute them else { system(targets[i].szCommand); } // debugging code /* echoCommand = (char*) calloc(100, 1); strcat(echoCommand, "echo 'command: "); command = &targets[i].szCommand[0]; strcat(echoCommand,command); strcat(echoCommand," is complete.'"); system(echoCommand); */ } else if (targets[i].pid == 0){ /* this is clunky, but we were up against the clock * so after making a *char[] and having it not work * we just copied that array into a char** */ char* nextArgs[7]; int k; for(k = 0; k < 7; k++){ nextArgs[k] = (char*) calloc(64, 1); } int ind = 1; strcpy(nextArgs[0],"./make4061"); if(f){ strcpy(nextArgs[ind], "-f"); ind++; char* makeFile = (char *) calloc(64, 1); strcpy(makeFile, &szMakefile[0]); strcpy(nextArgs[ind], makeFile); ind++; } if(n) { strcpy(nextArgs[ind], "-n"); ind++; } if(b) { strcpy(nextArgs[ind], "-B"); ind++; } if(m) { strcpy(nextArgs[ind], "-m"); ind++; char* logFile = (char *) calloc(64, 1); strcpy(logFile, &szLog[0]); strcpy(nextArgs[ind], logFile); ind++; } strcpy(nextArgs[ind], &targets[i].szDependencies[j][0]); k = 0; while(nextArgs[k][0] != 0) { k++; } char** realNextArgs = (char**) calloc(i,sizeof(char*)); int j; for(j= 0; j < k; j++){ realNextArgs[j] = (char*) calloc(64, 1); strcpy(realNextArgs[j], nextArgs[j]); } // it doesn't work without this line, but for some reason // this corrupts the third spot in the copy array (it's writing to the 6th). realNextArgs[j] = NULL; //debug /*m = 0; while(m != k){ fprintf(stderr,"Arg %d: %s\n", m, realNextArgs[m]); m++; }*/ execvp(realNextArgs[0], realNextArgs); // child failed if execvp returns. fprintf(stderr, "Not execvp\n"); exit(-1); } else { perror("bad forking"); exit(-1); } break; } } // close the file if writing to log, and reset stdout. if (m == 1) { close(file); dup2(stdOutClone,1); } return EXIT_SUCCESS; }
int main(int argc, char **argv) { // Declarations for getopt extern int optind; extern char * optarg; int ch; char * format = "f:hnBm:"; // Default makefile name will be Makefile char szMakefile[64] = "Makefile"; char szTarget[64]; char szLog[64]; while((ch = getopt(argc, argv, format)) != -1) { switch(ch) { case 'f': strcpy(szMakefile, strdup(optarg)); break; case 'n': commands[0] = 1; break; case 'B': commands[1] = 1; break; case 'm': commands[2] = 1; strcpy(szLog, strdup(optarg)); break; case 'h': default: show_error_message(argv[0]); exit(1); } } argc -= optind; argv += optind; // at this point, what is left in argv is the targets that were // specified on the command line. argc has the number of them. // If getopt is still really confusing, // try printing out what's in argv right here, then just running // with various command-line arguments. //redirect output if option is given if(commands[2]) { int fd; if((fd = open(szLog, O_CREAT | O_WRONLY, 0644)) == -1) { printf("Error opening log file\n"); return EXIT_FAILURE; } if(dup2(fd, 1) == -1) { printf("Error redirecting the output\n"); return EXIT_FAILURE; } if(close(fd) == -1) { printf("Error closing log file\n"); return EXIT_FAILURE; } } if(argc > 1) { show_error_message(argv[1]); return EXIT_FAILURE; } char* defTarget; /* Parse graph file or die */ if((parse(szMakefile, &defTarget)) == -1) { return EXIT_FAILURE; } assignParents(); //You may start your program by setting the target that make4061 should build. //if target is not set, set it to default (first target from makefile) if(argc == 1) { targ = argv[0]; if(removeNonTargets(argv[0]) == -1) { printf("Error: target was not found"); return EXIT_FAILURE; } } else { targ = defTarget; if(removeNonTargets(defTarget) == -1) { printf("Error: target was not found"); return EXIT_FAILURE; } } //printNodes(); if(run() == -1){ show_error_message(argv[0]); return EXIT_FAILURE; } //free all data structures freeEverything(); //after parsing the file, you'll want to check all dependencies (whether they are available targets or files) //then execute all of the targets that were specified on the command line, along with their dependencies, etc. return EXIT_SUCCESS; }
Recording* recording_start(const char* filename) { GMAudioProfile *profile; GstElement *pipeline, *oss_src, *encoder, *filesink; pipeline = oss_src = encoder = filesink = NULL; profile = gm_audio_profile_lookup(rec_settings.profile); g_assert(profile); pipeline = gst_pipeline_new("gnomeradio-record-pipeline"); if (!pipeline) { show_error_message(_("Could not create GStreamer pipeline."), _("Check your Gstreamer installation!")); goto error; } oss_src = gst_element_factory_make("osssrc", "oss-source"); if (!oss_src) { show_error_message(_("Could not open Gstreamer OSS Source."), _("Verify your Gstreamer OSS subsystem installation!")); goto error; } GstBus *bus = gst_element_get_bus(pipeline); gst_bus_add_signal_watch(bus); g_signal_connect(G_OBJECT(bus), "message::error", G_CALLBACK(error_cb), pipeline); char* pipeline_str = g_strdup_printf("audioconvert ! %s", gm_audio_profile_get_pipeline(profile)); encoder = my_gst_gconf_render_bin_from_description(pipeline_str); g_free(pipeline_str); if (!encoder) { char *caption = g_strdup_printf(_("Could not create encoder \"%s\"."), gm_audio_profile_get_name (profile)); show_error_message(caption, _("Verify your Gstreamer plugins installation!")); g_free(caption); goto error; } /* Write to disk */ filesink = gst_element_factory_make("filesink", "file-sink"); if (!filesink) { show_error_message(_("Could not create Gstreamer filesink."), _("Check your Gstreamer installation!")); goto error; } /* Add the elements to the pipeline */ gst_bin_add_many(GST_BIN(pipeline), oss_src, encoder, filesink, NULL); /* Link it all together */ if (!gst_element_link_many(oss_src, encoder, filesink, NULL)) { g_warning("Could not link elements. This is bad!\n"); goto error; } char* path = g_strdup_printf("%s.%s", filename, gm_audio_profile_get_extension(profile)); g_object_set(G_OBJECT(filesink), "location", path, NULL); gst_element_set_state(pipeline, GST_STATE_PLAYING); Recording *recording = g_malloc0(sizeof(Recording)); recording->filename = path; recording->pipeline = pipeline; return recording; error: if (pipeline) gst_object_unref(GST_OBJECT(pipeline)); if (oss_src) gst_object_unref(GST_OBJECT(oss_src)); if (encoder) gst_object_unref(GST_OBJECT(encoder)); if (filesink) gst_object_unref(GST_OBJECT(filesink)); return NULL; }
int mains(int argc, char **argv) { // Declarations for getopt extern int optind; extern char * optarg; int ch; char * format = "f:hnBm:"; // Default makefile name will be Makefile char szMakefile[64] = "Makefile"; char szTarget[64]; char szLog[64]; while((ch = getopt(argc, argv, format)) != -1) { switch(ch) { case 'f': strcpy(szMakefile, strdup(optarg)); break; case 'n': break; case 'B': break; case 'm': strcpy(szLog, strdup(optarg)); break; case 'h': default: show_error_message(argv[0]); exit(1); } } argc -= optind; argv += optind; // at this point, what is left in argv is the targets that were // specified on the command line. argc has the number of them. // If getopt is still really confusing, // try printing out what's in argv right here, then just running // with various command-line arguments. if(argc > 1) { show_error_message(argv[0]); return EXIT_FAILURE; } //You may start your program by setting the target that make406 should build. //if target is not set, set it to default (first target from makefile) if(argc == 1) { } else { } /* Parse graph file or die */ if((parse(szMakefile)) == -1) { return EXIT_FAILURE; } //after parsing the file, you'll want to check all dependencies (whether they are available targets or files) //then execute all of the targets that were specified on the command line, along with their dependencies, etc. return EXIT_SUCCESS; }
static gboolean startup ( G_GNUC_UNUSED gpointer data ) { TICK_N ( "Startup" ); // flags to run immediately and exit char *sname = NULL; char *msg = NULL; // // Sanity check if ( config_sanity_check ( ) ) { return G_SOURCE_REMOVE; } TICK_N ( "Config sanity check" ); // Parse the keybindings. if ( !parse_keys_abe () ) { // Error dialog return G_SOURCE_REMOVE; } TICK_N ( "Parse ABE" ); // Dmenu mode. if ( dmenu_mode == TRUE ) { // force off sidebar mode: config.sidebar_mode = FALSE; int retv = run_dmenu (); if ( retv ) { rofi_set_return_code ( EXIT_SUCCESS ); // Directly exit. g_main_loop_quit ( main_loop ); } } else if ( find_arg_str ( "-e", &( msg ) ) ) { int markup = FALSE; if ( find_arg ( "-markup" ) >= 0 ) { markup = TRUE; } if ( !show_error_message ( msg, markup ) ) { g_main_loop_quit ( main_loop ); } } else if ( find_arg_str ( "-show", &sname ) == TRUE ) { int index = switcher_get ( sname ); if ( index < 0 ) { // Add it to the list index = add_mode ( sname ); // Complain if ( index >= 0 ) { fprintf ( stdout, "Mode %s not enabled. Please add it to the list of enabled modi: %s\n", sname, config.modi ); fprintf ( stdout, "Adding mode: %s\n", sname ); } // Run it anyway if found. } if ( index >= 0 ) { run_switcher ( index ); } else { fprintf ( stderr, "The %s switcher has not been enabled\n", sname ); return G_SOURCE_REMOVE; } } else{ // Daemon mode fprintf ( stderr, "Rofi daemon mode is now removed.\n" ); fprintf ( stderr, "Please use your window manager binding functionality or xbindkeys to replace it.\n" ); g_main_loop_quit ( main_loop ); } return G_SOURCE_REMOVE; }
void show_error_message_and_exit(string message, int error_code) { show_error_message(message, error_code); exit(EXIT_FAILURE); }