예제 #1
0
파일: wsproxy.c 프로젝트: abarnert/wsproxy
// websocket client has produced data, deframe if an send to server
static void client_read ( struct bufferevent* be, void* arg ) {
  struct bufferevent* server = (struct bufferevent*) arg;
  char buf[1024 * 10];
  int n = bufferevent_read ( be, buf, sizeof buf );
  if ( n > 0 ) {
    char* p = buf;
    while ( ( p = deframe ( p, buf + n - p ) ) != NULL ) {
      bufferevent_write ( server, p, strlen ( p ) );
      bufferevent_enable ( server, EV_WRITE );
    }
  }
}
예제 #2
0
파일: deframe.c 프로젝트: mnhrdt/imscript
int main(int c, char *v[])
{
	if (c != 10 && c != 11 && c != 12) {
		fprintf(stderr, "usage:\n\t"
				"%s ax ay bx by cx cy dx dy [in [out]]\n", *v);
	//                       0  1  2  3  4  5  6  7  8   9   10
		return EXIT_FAILURE;;
	}
	float points[4][2];
	for (int i = 0; i < 8; i++)
		points[i/2][i%2] = atof(v[1+i]);
	char *filename_in  = c > 9 ? v[9] : "-";
	char *filename_out = c > 10 ? v[10] : "-";
	int w[2], h[2], pd;
	float *x = iio_read_image_float_vec(filename_in, w, h, &pd);
	float *y = xmalloc(w[0] * h[0] * pd * sizeof*y);

	deframe(y, w+1, h+1, x, *w, *h, pd, points);

	iio_write_image_float_vec(filename_out, y, w[1], h[1], pd);
	free(y);
	free(x);
	return EXIT_SUCCESS;
}