Patchwork [10,of,11,c-hglib:level0,V2] hg_exitcode: the exitcode for the current command

login
register
mail settings
Submitter Iulian Stana
Date Sept. 13, 2013, 8:32 p.m.
Message ID <2f0834015db8af5b3328.1379104320@doppler>
Download mbox | patch
Permalink /patch/2442/
State Deferred, archived
Headers show

Comments

Iulian Stana - Sept. 13, 2013, 8:32 p.m.
# HG changeset patch
# User Iulian Stana <julian.stana@gmail.com>
# Date 1379103750 -10800
#      Fri Sep 13 23:22:30 2013 +0300
# Node ID 2f0834015db8af5b33286c68236be6221a6cfdd8
# Parent  cae0e15b9169080f054f3087b1dd6e44c419969c
hg_exitcode: the exitcode for the current command

Patch

diff --git a/client.c b/client.c
--- a/client.c
+++ b/client.c
@@ -287,3 +287,21 @@ 
 	return length;
 }
 
+/*
+ * The exitcode for the current command.
+ * */
+int hg_exitcode(hg_handle *handle)
+{
+	int exitcode;
+
+	if(handle == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	if(read(handle->p_read, &exitcode, sizeof(int)) < 0){
+		return -1;
+	}
+	handle->protect = 0;
+	return swap_uint32(exitcode);
+}
diff --git a/client.h b/client.h
--- a/client.h
+++ b/client.h
@@ -189,4 +189,20 @@ 
  * */
 int hg_rawwrite(hg_handle *handle, const char *buffer, size_t sizebuff);
 
+/**
+ * \brief The exitcode for the current command.
+ *
+ * The server tell use that he finished his action when the 'r' channel is send.
+ * This function will get the exitcode from the server, in as a measure to tell
+ * that the command was finished.
+ * \param handle The handle of the connection, wherewith I want to communicate
+ * \retval   exitcode if successful
+ * \retval   -1 to indicate an error, with errno set appropriately.
+ *
+ * errno can be:
+ *      - EINVAL  - Invalid argument (handle it's set to a null pointer)
+ *      - read(2) command errors
+ * */
+int hg_exitcode(hg_handle *handle);
+
 #endif