static void write_complete(int fd, const void *buf, size_t count) { int r; if (count <= 0) return; r = write(fd, buf, count); if (r < 0) { perror("write"); exit(1); } // tail recursion needs gcc -O write_complete(fd, buf+r, count-r); }
/* void gtkwave_input_received (gpointer data, int source, GdkInputCondition condition) { char buf[10000]; int size = read (source, buf, 10000); buf[size] = 0; printf ("received:%s.\n",buf); } */ void gtkwave_send_command (char *command) { // printf ("sent:%s.\n",command); write_complete (gtkwave_pipe1[1], command, strlen (command)); // gdk_input_add (gtkwave_pipe2[0], GDK_INPUT_READ, gtkwave_input_received, NULL); char buf[10000]; int size = read (gtkwave_pipe2[0], buf, 10000); buf[size] = 0; // printf ("received:%s.\n",buf); }
void CondorFileCompress::end_compression() { if( last_action==WRITE ) { write_complete(); deflateEnd(&stream); } if( last_action==READ ) { inflateEnd(&stream); } last_action = NONE; }
void SendSetspeedCommand (gboolean force) { // set speed static gfloat oldfvalue = -1; GtkWidget *scale = gtk_object_get_data (GTK_OBJECT (MainWindow2), "SimulationSpeedScale"); gfloat fvalue = GTK_RANGE (scale)->old_value; if ((simulationIsRunning && oldfvalue != fvalue) || force) { oldfvalue = fvalue; int value = (int) pow (10, fvalue); char *command = g_strdup_printf ("setspeed %d\n", value); // printf("%s\n",command); write_complete (breezesim_pipe[1], command, strlen (command)); g_free (command); } }