Revision: 76656
http://sourceforge.net/p/brlcad/code/76656
Author: starseeker
Date: 2020-08-03 21:32:52 +0000 (Mon, 03 Aug 2020)
Log Message:
-----------
Cherrypick r76655 from trunk
Modified Paths:
--------------
brlcad/branches/RELEASE/include/bu/process.h
brlcad/branches/RELEASE/include/ged/defines.h
brlcad/branches/RELEASE/include/tclcad.h
brlcad/branches/RELEASE/src/libbu/process.c
brlcad/branches/RELEASE/src/libtclcad/tclcad_obj.c
Property Changed:
----------------
brlcad/branches/RELEASE/
brlcad/branches/RELEASE/src/libbu/
Index: brlcad/branches/RELEASE
===================================================================
--- brlcad/branches/RELEASE 2020-08-03 21:17:01 UTC (rev 76655)
+++ brlcad/branches/RELEASE 2020-08-03 21:32:52 UTC (rev 76656)
Property changes on: brlcad/branches/RELEASE
___________________________________________________________________
Modified: svn:mergeinfo
## -7,4 +7,4 ##
/brlcad/branches/opencl:65867-66137
/brlcad/branches/osg:62110-62113
/brlcad/branches/prep-cache:68236-68933
-/brlcad/trunk:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-75207,75325,75375,75377-75378,75387,75470-75472,75477,75492,75495,75549,75565-75566,75656-75661,75672,75675,75678,75729,75811,76641-76644
\ No newline at end of property
+/brlcad/trunk:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-75207,75325,75375,75377-75378,75387,75470-75472,75477,75492,75495,75549,75565-75566,75656-75661,75672,75675,75678,75729,75811,76641-76644,76655
\ No newline at end of property
Modified: brlcad/branches/RELEASE/include/bu/process.h
===================================================================
--- brlcad/branches/RELEASE/include/bu/process.h 2020-08-03 21:17:01 UTC
(rev 76655)
+++ brlcad/branches/RELEASE/include/bu/process.h 2020-08-03 21:32:52 UTC
(rev 76656)
@@ -48,11 +48,12 @@
/* Wrappers for using subprocess execution */
struct bu_process;
-#define BU_PROCESS_STDIN 0
-#define BU_PROCESS_STDOUT 1
-#define BU_PROCESS_STDERR 2
+typedef enum {
+ BU_PROCESS_STDIN,
+ BU_PROCESS_STDOUT,
+ BU_PROCESS_STDERR
+} bu_process_io_t;
-
/**
* Open and return a FILE pointer associated with the specified file
* descriptor for input (0), output (1), or error (2) respectively.
@@ -66,7 +67,7 @@
* FIXME: misnomer, this does not open a process. Probably doesn't
* need to exist; just call fdopen().
*/
-BU_EXPORT extern FILE *bu_process_open(struct bu_process *pinfo, int fd);
+BU_EXPORT extern FILE *bu_process_open(struct bu_process *pinfo,
bu_process_io_t d);
/**
@@ -75,19 +76,20 @@
* FIXME: misnomer, this does not close a process. Probably doesn't
* need to exist; just call fclose().
*/
-BU_EXPORT extern void bu_process_close(struct bu_process *pinfo, int fd);
+BU_EXPORT extern void bu_process_close(struct bu_process *pinfo,
bu_process_io_t d);
/**
- * Retrieve the pointer to the input (0), output (1), or error (2) file
- * descriptor associated with the process. To use this in calling code, the
- * caller must cast the supplied pointer to the file handle type of the
- * calling code's specific platform.
+ * Retrieve the pointer to the input (BU_PROCESS_STDIN), output
+ * (BU_PROCESS_STDOUT), or error (BU_PROCESS_STDERR) file descriptor associated
+ * with the process. To use this in calling code, the caller must cast the
+ * supplied pointer to the file handle type of the calling code's specific
+ * platform.
*
* FIXME: void pointer casting is bad. this function probably
* shouldn't exist.
*/
-BU_EXPORT void *bu_process_fd(struct bu_process *pinfo, int fd);
+BU_EXPORT void *bu_process_fd(struct bu_process *pinfo, bu_process_io_t d);
/**
@@ -127,7 +129,7 @@
* FIXME: arg ordering and input/output grouping is wrong. partially
* redundant with bu_process_fd() and/or bu_process_open().
*/
-BU_EXPORT extern int bu_process_read(char *buff, int *count, struct bu_process
*pinfo, int fd, int n);
+BU_EXPORT extern int bu_process_read(char *buff, int *count, struct bu_process
*pinfo, bu_process_io_t d, int n);
/**
Modified: brlcad/branches/RELEASE/include/ged/defines.h
===================================================================
--- brlcad/branches/RELEASE/include/ged/defines.h 2020-08-03 21:17:01 UTC
(rev 76655)
+++ brlcad/branches/RELEASE/include/ged/defines.h 2020-08-03 21:32:52 UTC
(rev 76656)
@@ -218,8 +218,8 @@
/* Handler functions for I/O communication with asynchronous subprocess
commands */
int io_mode;
- void (*ged_create_io_handler)(void **chan, struct bu_process *p, int fd,
int mode, void *data, ged_io_handler_callback_t callback);
- void (*ged_delete_io_handler)(void *interp, void *chan, struct bu_process
*p, int fd, void *data, ged_io_handler_callback_t callback);
+ void (*ged_create_io_handler)(void **chan, struct bu_process *p,
bu_process_io_t d, int mode, void *data, ged_io_handler_callback_t callback);
+ void (*ged_delete_io_handler)(void *interp, void *chan, struct bu_process
*p, bu_process_io_t d, void *data, ged_io_handler_callback_t callback);
/* FOR LIBGED INTERNAL USE */
struct ged_cmd *cmds;
Modified: brlcad/branches/RELEASE/include/tclcad.h
===================================================================
--- brlcad/branches/RELEASE/include/tclcad.h 2020-08-03 21:17:01 UTC (rev
76655)
+++ brlcad/branches/RELEASE/include/tclcad.h 2020-08-03 21:32:52 UTC (rev
76656)
@@ -34,6 +34,7 @@
#include "common.h"
#include "bu/cmd.h"
+#include "bu/process.h"
#include "tcl.h"
#include "dm.h"
#include "ged.h"
@@ -515,13 +516,13 @@
* Create Tcl specific I/O handlers
*/
TCLCAD_EXPORT void
-tclcad_create_io_handler(void **chan, struct bu_process *p, int fd, int mode,
void *data, ged_io_handler_callback_t callback);
+tclcad_create_io_handler(void **chan, struct bu_process *p, bu_process_io_t d,
int mode, void *data, ged_io_handler_callback_t callback);
/**
* Delete Tcl specific I/O handlers
*/
TCLCAD_EXPORT void
-tclcad_delete_io_handler(void *interp, void *chan, struct bu_process *p, int
fd, void *data, ged_io_handler_callback_t callback);
+tclcad_delete_io_handler(void *interp, void *chan, struct bu_process *p,
bu_process_io_t d, void *data, ged_io_handler_callback_t callback);
/* dm_tcl.c */
Index: brlcad/branches/RELEASE/src/libbu
===================================================================
--- brlcad/branches/RELEASE/src/libbu 2020-08-03 21:17:01 UTC (rev 76655)
+++ brlcad/branches/RELEASE/src/libbu 2020-08-03 21:32:52 UTC (rev 76656)
Property changes on: brlcad/branches/RELEASE/src/libbu
___________________________________________________________________
Modified: svn:mergeinfo
## -1,2 +1,2 ##
/brlcad/branches/bioh/src/libbu:75720-75728
-/brlcad/trunk/src/libbu:72518-74373,74376-75207,75729
\ No newline at end of property
+/brlcad/trunk/src/libbu:72518-74373,74376-75207,75729,76655
\ No newline at end of property
Modified: brlcad/branches/RELEASE/src/libbu/process.c
===================================================================
--- brlcad/branches/RELEASE/src/libbu/process.c 2020-08-03 21:17:01 UTC (rev
76655)
+++ brlcad/branches/RELEASE/src/libbu/process.c 2020-08-03 21:32:52 UTC (rev
76656)
@@ -76,12 +76,12 @@
void
-bu_process_close(struct bu_process *pinfo, int fd)
+bu_process_close(struct bu_process *pinfo, bu_process_io_t d)
{
if (!pinfo)
return;
- if (fd == fileno(stdin)) {
+ if (d == BU_PROCESS_STDIN) {
if (!pinfo->fp_in)
return;
(void)fclose(pinfo->fp_in);
@@ -88,7 +88,7 @@
pinfo->fp_in = NULL;
return;
}
- if (fd == fileno(stdout)) {
+ if (d == BU_PROCESS_STDOUT) {
if (!pinfo->fp_out)
return;
(void)fclose(pinfo->fp_out);
@@ -95,7 +95,7 @@
pinfo->fp_out = NULL;
return;
}
- if (fd == fileno(stderr)) {
+ if (d == BU_PROCESS_STDERR) {
if (!pinfo->fp_err)
return;
(void)fclose(pinfo->fp_err);
@@ -106,14 +106,14 @@
FILE *
-bu_process_open(struct bu_process *pinfo, int fd)
+bu_process_open(struct bu_process *pinfo, bu_process_io_t d)
{
if (!pinfo)
return NULL;
- bu_process_close(pinfo, fd);
+ bu_process_close(pinfo, d);
- if (fd == fileno(stdin)) {
+ if (d == BU_PROCESS_STDIN) {
#ifndef _WIN32
pinfo->fp_in = fdopen(pinfo->fd_in, "wb");
#else
@@ -121,7 +121,7 @@
#endif
return pinfo->fp_in;
}
- if (fd == fileno(stdout)) {
+ if (d == BU_PROCESS_STDOUT) {
#ifndef _WIN32
pinfo->fp_out = fdopen(pinfo->fd_out, "rb");
#else
@@ -129,7 +129,7 @@
#endif
return pinfo->fp_out;
}
- if (fd == fileno(stderr)) {
+ if (d == BU_PROCESS_STDERR) {
#ifndef _WIN32
pinfo->fp_err = fdopen(pinfo->fd_err, "rb");
#else
@@ -143,16 +143,16 @@
void *
-bu_process_fd(struct bu_process *pinfo, int fd)
+bu_process_fd(struct bu_process *pinfo, bu_process_io_t d)
{
- if (!pinfo || fd < 0)
+ if (!pinfo)
return NULL;
- if (fd == fileno(stdin))
+ if (d == BU_PROCESS_STDIN)
return (void *)(&(pinfo->fd_in));
- if (fd == fileno(stdout))
+ if (d == BU_PROCESS_STDOUT)
return (void *)(&(pinfo->fd_out));
- if (fd == fileno(stderr))
+ if (d == BU_PROCESS_STDERR)
return (void *)(&(pinfo->fd_err));
return NULL;
@@ -184,13 +184,13 @@
int
-bu_process_read(char *buff, int *count, struct bu_process *pinfo, int fd, int
n)
+bu_process_read(char *buff, int *count, struct bu_process *pinfo,
bu_process_io_t d, int n)
{
int ret = 1;
- if (!pinfo || !buff || !n || !count || fd < 1)
+ if (!pinfo || !buff || !n || !count)
return -1;
- if (fd == fileno(stdout)) {
+ if (d == BU_PROCESS_STDOUT) {
#ifndef _WIN32
(*count) = read((int)pinfo->fd_out, buff, n);
if ((*count) <= 0) {
@@ -205,7 +205,7 @@
(*count) = (int)dcount;
#endif
}
- if (fd == fileno(stderr)) {
+ if (d == BU_PROCESS_STDERR) {
#ifndef _WIN32
(*count) = read((int)pinfo->fd_err, buff, n);
if ((*count) <= 0) {
@@ -308,17 +308,17 @@
setpgid(0, 0);
/* Redirect stdin and stderr */
- (void)close(fileno(stdin));
+ (void)close(BU_PROCESS_STDIN);
pret = dup(pipe_in[0]);
if (pret < 0) {
perror("dup");
}
- (void)close(fileno(stdout));
+ (void)close(BU_PROCESS_STDOUT);
pret = dup(pipe_out[1]);
if (pret < 0) {
perror("dup");
}
- (void)close(fileno(stderr));
+ (void)close(BU_PROCESS_STDERR);
pret = dup(pipe_err[1]);
if (pret < 0) {
perror("dup");
@@ -522,8 +522,8 @@
}
/* Clean up */
- bu_process_close(pinfo, fileno(stdout));
- bu_process_close(pinfo, fileno(stderr));
+ bu_process_close(pinfo, BU_PROCESS_STDOUT);
+ bu_process_close(pinfo, BU_PROCESS_STDERR);
/* Free copy of exec args */
if (pinfo->cmd) {
Modified: brlcad/branches/RELEASE/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/branches/RELEASE/src/libtclcad/tclcad_obj.c 2020-08-03 21:17:01 UTC
(rev 76655)
+++ brlcad/branches/RELEASE/src/libtclcad/tclcad_obj.c 2020-08-03 21:32:52 UTC
(rev 76656)
@@ -1148,21 +1148,21 @@
/* Wrappers for setting up/tearing down IO handler */
#ifndef _WIN32
void
-tclcad_create_io_handler(void **UNUSED(chan), struct bu_process *p, int fd,
int mode, void *data, ged_io_handler_callback_t callback)
+tclcad_create_io_handler(void **UNUSED(chan), struct bu_process *p,
bu_process_io_t d, int mode, void *data, ged_io_handler_callback_t callback)
{
int *fdp;
if (!p) return;
- fdp = (int *)bu_process_fd(p, fd);
+ fdp = (int *)bu_process_fd(p, d);
if (fdp)
Tcl_CreateFileHandler(*fdp, mode, callback, (ClientData)data);
}
void
-tclcad_delete_io_handler(void *UNUSED(interp), void *UNUSED(chan), struct
bu_process *p, int fd, void *UNUSED(data), ged_io_handler_callback_t
UNUSED(callback))
+tclcad_delete_io_handler(void *UNUSED(interp), void *UNUSED(chan), struct
bu_process *p, bu_process_io_t d, void *UNUSED(data), ged_io_handler_callback_t
UNUSED(callback))
{
int *fdp;
if (!p) return;
- fdp = (int *)bu_process_fd(p, fd);
+ fdp = (int *)bu_process_fd(p, d);
if (fdp) {
Tcl_DeleteFileHandler(*fdp);
close(*fdp);
@@ -1171,11 +1171,11 @@
#else
void
-tclcad_create_io_handler(void **chan, struct bu_process *p, int fd, int mode,
void *data, ged_io_handler_callback_t callback)
+tclcad_create_io_handler(void **chan, struct bu_process *p, bu_process_io_t d,
int mode, void *data, ged_io_handler_callback_t callback)
{
HANDLE *fdp;
if (!chan || !p) return;
- fdp = (HANDLE *)bu_process_fd(p, fd);
+ fdp = (HANDLE *)bu_process_fd(p, d);
if (fdp) {
(*chan) = (void *)Tcl_MakeFileChannel(*fdp, mode);
Tcl_CreateChannelHandler((Tcl_Channel)(*chan), mode, callback,
(ClientData)data);
@@ -1183,7 +1183,7 @@
}
void
-tclcad_delete_io_handler(void *interp, void *chan, struct bu_process *p, int
fd, void *data, ged_io_handler_callback_t callback)
+tclcad_delete_io_handler(void *interp, void *chan, struct bu_process *p,
bu_process_io_t d, void *data, ged_io_handler_callback_t callback)
{
HANDLE *fdp;
Tcl_Interp *tcl_interp;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits