$Log$
+ Revision 613.6 2003/12/21 19:07:28 error
+ * Start a new thread and fork() for image viewer (broken/disabled; for
+ refernce only)
+
Revision 613.5 2003/12/21 01:23:12 nbryant
added some additional comments to citadel.rc concerning possible image viewers
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
# endif
#endif
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
+
#include <stdarg.h>
#include "citadel.h"
#include "citadel_ipc.h"
int has_images = 0; /* Current msg has images */
struct parts *last_message_parts = NULL; /* Parts from last msg */
+
+
void ka_sigcatch(int signum)
{
alarm(S_KEEPALIVE);
scr_printf("\n");
}
+
+/*
+ * Image viewer thread (for background image viewing)
+ */
+void *image_view_thread(void *filename)
+{
+ char cmd[SIZ];
+ pid_t childpid;
+ int retcode;
+
+ snprintf(cmd, sizeof cmd, imagecmd, (char *)filename);
+ childpid = fork();
+ if (childpid < 0) {
+ color(BRIGHT_RED);
+ perror("Cannot fork");
+ color(DIM_WHITE);
+ unlink((char *)filename);
+ return ((void *) childpid);
+ }
+
+ if (childpid == 0) {
+ execlp("/bin/sh", "sh", "-c", cmd, NULL);
+ exit(127);
+ }
+
+ if (childpid > 0) {
+ waitpid(childpid, &retcode, 0);
+ unlink((char *)filename);
+ return ((void *)retcode);
+ }
+
+ return ((void *)-1);
+}
+
+
/*
* View an image attached to a message
*/
char tmp[PATH_MAX];
char buf[SIZ];
void *file = NULL; /* The downloaded file */
+#ifdef THREADED_CLIENT
+ pthread_t *ivthread = NULL;
+#endif
int r;
// view image
strcpy(tmp, tmpnam(NULL));
save_buffer(file, len, tmp);
free(file);
+ #if 0
+ pthread_create(ivthread, NULL, image_view_thread, tmp);
+ #endif
snprintf(buf, sizeof buf, imagecmd, tmp);
system(buf);
unlink(tmp);
}
+ break;
}
}
}