]> git.ozlabs.org Git - petitboot/blob - discover/paths.h
ui/ncurses: Handle arrow key variants
[petitboot] / discover / paths.h
1 #ifndef PATHS_H
2 #define PATHS_H
3
4 #include <url/url.h>
5 #include <waiter/waiter.h>
6 #include <process/process.h>
7
8 /**
9  * Utility function for joining two paths. Adds a / between a and b if
10  * required.
11  *
12  * Returns a newly-allocated string.
13  */
14 char *join_paths(void *alloc_ctx, const char *a, const char *b);
15
16 /**
17  * Returns the base path for mount points
18  */
19 const char *mount_base(void);
20
21 struct load_task;
22
23 struct load_url_result {
24         enum {
25                 LOAD_OK,    /* load complete. other members should only be
26                                accessed if status == LOAD_OK */
27
28                 LOAD_ERROR, /* only signalled to async loaders
29                              * (sync will see a NULL result) */
30
31                 LOAD_ASYNC, /* async load still in progress */
32
33                 LOAD_CANCELLED,
34         } status;
35         struct pb_url           *url;
36         const char              *local;
37         bool                    cleanup_local;
38         struct load_task        *task;
39 };
40
41 /* callback type for asynchronous loads. The callback implementation is
42  * responsible for freeing result.
43  */
44 typedef void (*load_url_complete)(struct load_url_result *result, void *data);
45
46 /* Start transfers that were waiting for network connectivity */
47 void pending_network_jobs_start(void);
48 void pending_network_jobs_cancel(void);
49
50 /* Load a (potentially remote) file, and return a guaranteed-local name */
51 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
52                 load_url_complete complete, void *data,
53                 waiter_cb stdout_cb, void *stdout_data);
54
55 /* Cancel a pending load */
56 void load_url_async_cancel(struct load_url_result *res);
57
58 struct load_url_result *load_url(void *ctx, struct pb_url *url);
59
60 #endif /* PATHS_H */