diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 9 | ||||
-rw-r--r-- | src/Makefile.in | 22 | ||||
-rw-r--r-- | src/dirax.c | 58 | ||||
-rw-r--r-- | src/dirax.h | 9 | ||||
-rw-r--r-- | src/hdfsee.c | 1 | ||||
-rw-r--r-- | src/image.h | 5 |
6 files changed, 44 insertions, 60 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 3240290a..e696fcbf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,15 +23,12 @@ process_hkl_LDADD = @LIBS@ indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \ intensities.c peaks.c index.c filters.c \ - diffraction.c detector.c sfac.c + diffraction.c detector.c sfac.c dirax.c indexamajig_LDADD = @LIBS@ if HAVE_OPENCL indexamajig_SOURCES += diffraction-gpu.c cl-utils.c endif -if HAVE_GLIB -indexamajig_SOURCES += dirax.c -endif if HAVE_GTK hdfsee_SOURCES = hdfsee.c displaywindow.c render.c hdf5-file.c utils.c image.c \ @@ -49,8 +46,4 @@ powder_plot_SOURCES = powder_plot.c cell.c utils.c image.c hdf5-file.c \ detector.c powder_plot_LDADD = @LIBS@ -if HAVE_GLIB -powder_plot_SOURCES += dirax.c -endif - INCLUDES = "-I$(top_srcdir)/data" diff --git a/src/Makefile.in b/src/Makefile.in index 0eccb84c..5e775b44 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -38,8 +38,6 @@ bin_PROGRAMS = pattern_sim$(EXEEXT) process_hkl$(EXEEXT) \ @HAVE_GTK_TRUE@am__append_1 = hdfsee @HAVE_OPENCL_TRUE@am__append_2 = diffraction-gpu.c cl-utils.c @HAVE_OPENCL_TRUE@am__append_3 = diffraction-gpu.c cl-utils.c -@HAVE_GLIB_TRUE@am__append_4 = dirax.c -@HAVE_GLIB_TRUE@am__append_5 = dirax.c subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -71,16 +69,15 @@ hdfsee_OBJECTS = $(am_hdfsee_OBJECTS) hdfsee_DEPENDENCIES = am__indexamajig_SOURCES_DIST = indexamajig.c hdf5-file.c utils.c \ cell.c image.c intensities.c peaks.c index.c filters.c \ - diffraction.c detector.c sfac.c diffraction-gpu.c cl-utils.c \ - dirax.c + diffraction.c detector.c sfac.c dirax.c diffraction-gpu.c \ + cl-utils.c @HAVE_OPENCL_TRUE@am__objects_1 = diffraction-gpu.$(OBJEXT) \ @HAVE_OPENCL_TRUE@ cl-utils.$(OBJEXT) -@HAVE_GLIB_TRUE@am__objects_2 = dirax.$(OBJEXT) am_indexamajig_OBJECTS = indexamajig.$(OBJEXT) hdf5-file.$(OBJEXT) \ utils.$(OBJEXT) cell.$(OBJEXT) image.$(OBJEXT) \ intensities.$(OBJEXT) peaks.$(OBJEXT) index.$(OBJEXT) \ filters.$(OBJEXT) diffraction.$(OBJEXT) detector.$(OBJEXT) \ - sfac.$(OBJEXT) $(am__objects_1) $(am__objects_2) + sfac.$(OBJEXT) dirax.$(OBJEXT) $(am__objects_1) indexamajig_OBJECTS = $(am_indexamajig_OBJECTS) indexamajig_DEPENDENCIES = am__pattern_sim_SOURCES_DIST = pattern_sim.c diffraction.c utils.c \ @@ -92,11 +89,9 @@ am_pattern_sim_OBJECTS = pattern_sim.$(OBJEXT) diffraction.$(OBJEXT) \ intensities.$(OBJEXT) reflections.$(OBJEXT) $(am__objects_1) pattern_sim_OBJECTS = $(am_pattern_sim_OBJECTS) pattern_sim_DEPENDENCIES = -am__powder_plot_SOURCES_DIST = powder_plot.c cell.c utils.c image.c \ - hdf5-file.c detector.c dirax.c am_powder_plot_OBJECTS = powder_plot.$(OBJEXT) cell.$(OBJEXT) \ utils.$(OBJEXT) image.$(OBJEXT) hdf5-file.$(OBJEXT) \ - detector.$(OBJEXT) $(am__objects_2) + detector.$(OBJEXT) powder_plot_OBJECTS = $(am_powder_plot_OBJECTS) powder_plot_DEPENDENCIES = am_process_hkl_OBJECTS = process_hkl.$(OBJEXT) sfac.$(OBJEXT) \ @@ -117,8 +112,8 @@ SOURCES = $(compare_hkl_SOURCES) $(get_hkl_SOURCES) $(hdfsee_SOURCES) \ $(powder_plot_SOURCES) $(process_hkl_SOURCES) DIST_SOURCES = $(compare_hkl_SOURCES) $(get_hkl_SOURCES) \ $(am__hdfsee_SOURCES_DIST) $(am__indexamajig_SOURCES_DIST) \ - $(am__pattern_sim_SOURCES_DIST) \ - $(am__powder_plot_SOURCES_DIST) $(process_hkl_SOURCES) + $(am__pattern_sim_SOURCES_DIST) $(powder_plot_SOURCES) \ + $(process_hkl_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -223,7 +218,7 @@ process_hkl_SOURCES = process_hkl.c sfac.c statistics.c cell.c utils.c \ process_hkl_LDADD = @LIBS@ indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \ intensities.c peaks.c index.c filters.c diffraction.c \ - detector.c sfac.c $(am__append_3) $(am__append_4) + detector.c sfac.c dirax.c $(am__append_3) indexamajig_LDADD = @LIBS@ @HAVE_GTK_TRUE@hdfsee_SOURCES = hdfsee.c displaywindow.c render.c hdf5-file.c utils.c image.c \ @HAVE_GTK_TRUE@ filters.c @@ -234,7 +229,8 @@ get_hkl_LDADD = @LIBS@ compare_hkl_SOURCES = compare_hkl.c sfac.c cell.c utils.c reflections.c compare_hkl_LDADD = @LIBS@ powder_plot_SOURCES = powder_plot.c cell.c utils.c image.c hdf5-file.c \ - detector.c $(am__append_5) + detector.c + powder_plot_LDADD = @LIBS@ INCLUDES = "-I$(top_srcdir)/data" all: all-am diff --git a/src/dirax.c b/src/dirax.c index 78f2f2b3..8a6f05fd 100644 --- a/src/dirax.c +++ b/src/dirax.c @@ -15,7 +15,6 @@ #endif -#include <glib.h> #include <stdlib.h> #include <stdio.h> #include <math.h> @@ -165,8 +164,7 @@ static void dirax_send_next(struct image *image) break; default: - image->dirax_step = 0; - g_main_loop_quit(image->dirax_ml); + dirax_sendline("exit\n", image); return; } @@ -175,24 +173,15 @@ static void dirax_send_next(struct image *image) } -static gboolean dirax_readable(GIOChannel *dirax, GIOCondition condition, - struct image *image) +static int dirax_readable(struct image *image) { int rval; int no_string = 0; rval = read(image->dirax_pty, image->dirax_rbuffer+image->dirax_rbufpos, - image->dirax_rbuflen-image->dirax_rbufpos); + image->dirax_rbuflen-image->dirax_rbufpos); - if ( (rval == -1) || (rval == 0) ) { - - ERROR("Lost connection to DirAx (rval=%i)\n", rval); - waitpid(image->dirax_pid, NULL, 0); - g_io_channel_shutdown(image->dirax, FALSE, NULL); - image->dirax = NULL; - return FALSE; - - } + if ( (rval == -1) || (rval == 0) ) return 1; image->dirax_rbufpos += rval; assert(image->dirax_rbufpos <= image->dirax_rbuflen); @@ -264,10 +253,7 @@ static gboolean dirax_readable(GIOChannel *dirax, GIOCondition condition, /* Obviously, this never happens :) */ ERROR("Unrecognised DirAx input mode! " "I don't know how to understand DirAx\n"); - waitpid(image->dirax_pid, NULL, 0); - g_io_channel_shutdown(image->dirax, FALSE, NULL); - image->dirax = NULL; - return FALSE; + return 1; } @@ -306,7 +292,7 @@ static gboolean dirax_readable(GIOChannel *dirax, GIOCondition condition, } - return TRUE; + return 0; } @@ -315,6 +301,7 @@ void run_dirax(struct image *image) unsigned int opts; int saved_stderr; int status; + int rval; saved_stderr = dup(STDERR_FILENO); image->dirax_pid = forkpty(&image->dirax_pty, NULL, NULL, NULL); @@ -352,13 +339,34 @@ void run_dirax(struct image *image) image->dirax_step = 1; /* This starts the "initialisation" procedure */ image->dirax_read_cell = 0; - image->dirax = g_io_channel_unix_new(image->dirax_pty); - g_io_add_watch(image->dirax, G_IO_IN | G_IO_HUP, - (GIOFunc)dirax_readable, image); + do { + + fd_set fds; + struct timeval tv; + int sval; + + FD_ZERO(&fds); + FD_SET(image->dirax_pty, &fds); + + tv.tv_sec = 1; + tv.tv_usec = 0; + + sval = select(image->dirax_pty+1, &fds, NULL, NULL, &tv); + + if ( sval == -1 ) { + ERROR("select() failed.\n"); + rval = 1; + } else if ( sval != 0 ) { + rval = dirax_readable(image); + } else { + ERROR("No response from DirAx..\n"); + rval = 1; + } + + } while ( !rval ); - image->dirax_ml = g_main_loop_new(NULL, FALSE); - g_main_loop_run(image->dirax_ml); close(image->dirax_pty); + close(saved_stderr); wait(&status); return; diff --git a/src/dirax.h b/src/dirax.h index 530d2696..8c429710 100644 --- a/src/dirax.h +++ b/src/dirax.h @@ -19,17 +19,8 @@ #include "utils.h" -#if HAVE_GLIB extern void run_dirax(struct image *image); -#else - -static void run_dirax(struct image *image) -{ - ERROR("Can't run DirAx without GLib.\n"); -} - -#endif #endif /* DIRAX_H */ diff --git a/src/hdfsee.c b/src/hdfsee.c index 5306059b..a1d16b56 100644 --- a/src/hdfsee.c +++ b/src/hdfsee.c @@ -91,7 +91,6 @@ int main(int argc, char *argv[]) {0, 0, NULL, 0} }; - g_thread_init(NULL); gtk_init(&argc, &argv); /* Short options */ diff --git a/src/image.h b/src/image.h index 349e680c..413f633b 100644 --- a/src/image.h +++ b/src/image.h @@ -87,19 +87,16 @@ struct image { ImageFeatureList *rflist; /* "Predicted" features */ /* DirAx auto-indexing low-level stuff */ -#if HAVE_GLIB - GIOChannel *dirax; int dirax_pty; pid_t dirax_pid; char *dirax_rbuffer; int dirax_rbufpos; int dirax_rbuflen; - GMainLoop *dirax_ml; /* DirAx auto-indexing high-level stuff */ int dirax_step; int dirax_read_cell; -#endif + }; /* An opaque type representing a list of images */ |