mirror of
https://github.com/git/git.git
synced 2024-11-01 06:47:52 +01:00
7663cdc86c
When using the hashmap a common need is to have access to caller provided data in the compare function. A couple of times we abuse the keydata field to pass in the data needed. This happens for example in patch-ids.c. This patch changes the function signature of the compare function to have one more void pointer available. The pointer given for each invocation of the compare function must be defined in the init function of the hashmap and is just passed through. Documentation of this new feature is deferred to a later patch. This is a rather mechanical conversion, just adding the new pass-through parameter. However while at it improve the naming of the fields of all compare functions used by hashmaps by ensuring unused parameters are prefixed with 'unused_' and naming the parameters what they are (instead of 'unused' make it 'unused_keydata'). Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
#ifndef SUBPROCESS_H
|
|
#define SUBPROCESS_H
|
|
|
|
#include "git-compat-util.h"
|
|
#include "hashmap.h"
|
|
#include "run-command.h"
|
|
|
|
/*
|
|
* Generic implementation of background process infrastructure.
|
|
* See: Documentation/technical/api-sub-process.txt
|
|
*/
|
|
|
|
/* data structures */
|
|
|
|
struct subprocess_entry {
|
|
struct hashmap_entry ent; /* must be the first member! */
|
|
const char *cmd;
|
|
struct child_process process;
|
|
};
|
|
|
|
/* subprocess functions */
|
|
|
|
extern int cmd2process_cmp(const void *unused_cmp_data,
|
|
const struct subprocess_entry *e1,
|
|
const struct subprocess_entry *e2,
|
|
const void *unused_keydata);
|
|
|
|
typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
|
|
int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
|
|
subprocess_start_fn startfn);
|
|
|
|
void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
|
|
|
|
struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
|
|
|
|
/* subprocess helper functions */
|
|
|
|
static inline struct child_process *subprocess_get_child_process(
|
|
struct subprocess_entry *entry)
|
|
{
|
|
return &entry->process;
|
|
}
|
|
|
|
/*
|
|
* Helper function that will read packets looking for "status=<foo>"
|
|
* key/value pairs and return the value from the last "status" packet
|
|
*/
|
|
|
|
int subprocess_read_status(int fd, struct strbuf *status);
|
|
|
|
#endif
|