[PATCH c-hglib] Initial commit
Matt Mackall
mpm at selenic.com
Tue Jul 2 17:30:31 UTC 2013
On Tue, 2013-07-02 at 00:31 +0300, Iulian Stana wrote:
> + #define p_read rpipe[0]
> + #define c_write rpipe[1]
> + #define c_read wpipe[0]
> + #define p_write wpipe[1]
Yuck.
> +hg_header* readheader(hg_handle *handle)
Please always put the * on the right side of the space. Why? Compare:
char* a, b;
char *a, b;
In the first, you mislead the reader into thinking that a and b are the
same type, and that C recognizes "char*" as a "thing". It does not, and
it binds the "*" to the right side regardless of where you put the
space.
(In fact, I recently fixed a bug where someone had mislead themselves
with exactly this nonsense.)
> + //TODO: Make a verification !!!
Let's avoid C++ comments, please. Slightly shorter comments isn't
sufficient reason to abandon compatibility with C89 compilers.
Ignoring the rest of the C code for now because I only wanted to see the
header... before you started actually writing the code.
> @@ -0,0 +1,37 @@
> +#ifndef _CLIENT_H_
> +#define _CLIENT_H_
> +#include <stdint.h>
> +
> +
> +struct hg_handle;
> +typedef struct hg_handle hg_handle;
Redundant.
> +
> +typedef struct hg_header{
> + char channel;
> + uint32_t length;
> +} hg_header;
> +
> +/*
> + * Create the connection with the mercurial cmdserver
> + * return the handle for this connection
> + * */
> +hg_handle* hg_open(const char *path, char *encoding, char *configs);
More const. Misplaced *. What is configs?
What if we want to run a command without a repository, like init or
clone?
> +
> +/*
> + * Close the connection for a specific handle.
> + * */
> +int hg_close(hg_handle *handle);
What does this return?
> +/*
> + * Send the "command" to the cmdserver through handle.
> + * */
> +int hg_rawcommand(hg_handle *handle, const char *command);
What does this return? How do we pass args with spaces?
> +/*
> + * Receive unparse data from the server through handle.
> + * Put the data into the buffer.
> + * */
> +int hg_rawread(hg_handle *handle, char *buffer, size_t sizebuff);
What does this return?
How do we get exit codes?
How do we send input to a command like 'hg import -'?
How do we handle interactive commands like merge?
How do we get error output and warnings?
DO NOT WRITE ANY CODE to answer these questions because I will have many
more questions. Just show me a proposed API.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list