- By default, this code is not used, since it requires that
- the user have a .netrc file in his/her home directory, or that the
- application designer be willing to have rexec prompt for login and
- password info. This may be unacceptable, and .rhosts files for use
- with rsh are much more common on BSD systems. */
+static long
+get_status (int handle)
+{
+ char command_buffer[COMMAND_BUFFER_SIZE];
+ const char *status = get_status_string (handle, command_buffer);
+ return status ? atol (status) : -1L;
+}
+
+static off_t
+get_status_off (int handle)
+{
+ char command_buffer[COMMAND_BUFFER_SIZE];
+ const char *status = get_status_string (handle, command_buffer);
+
+ if (! status)
+ return -1;
+ else
+ {
+ /* Parse status, taking care to check for overflow.
+ We can't use standard functions,
+ since off_t might be longer than long. */
+
+ off_t count = 0;
+ int negative;
+
+ for (; *status == ' ' || *status == '\t'; status++)
+ continue;
+
+ negative = *status == '-';
+ status += negative || *status == '+';
+
+ for (;;)
+ {
+ int digit = *status++ - '0';
+ if (9 < (unsigned) digit)
+ break;
+ else
+ {
+ off_t c10 = 10 * count;
+ off_t nc = negative ? c10 - digit : c10 + digit;
+ if (c10 / 10 != count || (negative ? c10 < nc : nc < c10))
+ return -1;
+ count = nc;
+ }
+ }
+
+ return count;
+ }
+}
+
+#if WITH_REXEC
+
+/*-------------------------------------------------------------------------.
+| Execute /etc/rmt as user USER on remote system HOST using rexec. Return |
+| a file descriptor of a bidirectional socket for stdin and stdout. If |
+| USER is NULL, use the current username. |
+| |
+| By default, this code is not used, since it requires that the user have |
+| a .netrc file in his/her home directory, or that the application |
+| designer be willing to have rexec prompt for login and password info. |
+| This may be unacceptable, and .rhosts files for use with rsh are much |
+| more common on BSD systems. |
+`-------------------------------------------------------------------------*/