Working on the same principle as the last mjpg_stream implemenation, here it is: a portace plugin !
/******************************************************************************
Description.: Send a complete HTTP response and a svg file
Input Value.: fildescriptor fd to send the answer to
Return Value: -
******************************************************************************/
void send_svg(int fd) {
unsigned char *frame=NULL;
int frame_size=0;
char buffer[BUFFER_SIZE] = {0};
if ( (frame = (unsigned char *)malloc(MAX_FRAME_SIZE)) == NULL ) {
fprintf(stderr, "not enough memory\n");
exit(EXIT_FAILURE);
}
/* wait for a fresh frame */
pthread_cond_wait(&pglobal->db_update, &pglobal->db);
/* read buffer */
frame_size = pglobal->size;
memcpy(frame, pglobal->buf, frame_size);
DBG("got frame (size: %d kB)\n", frame_size/1024);
pthread_mutex_unlock( &pglobal->db );
/* make file */
FILE *filesvg;
filesvg = fopen("/dev/shm/svgpipe", "w");
fwrite(frame, 1, frame_size, filesvg);
fclose(filesvg);
free(frame);
system("/usr/bin/convert /dev/shm/svgpipe /dev/shm/svgpipe.ppm");
system("/usr/bin/potrace -s /dev/shm/svgpipe.ppm");
/* response */
sprintf(buffer, "HTTP/1.0 200 OK\r\n" \
STD_HEADER \
"Content-type: image/svg+xml\r\n" \
"\r\n");
if( write(fd, buffer, strlen(buffer)) < 0 ) return;
/* read -> send file */
FILE *filesvg2;
filesvg2 = fopen("/dev/shm/svgpipe.svg", "r");
while (fgets(buffer,BUFFER_SIZE,filesvg2))
write(fd, buffer, strlen(buffer));
}

