qrexec-lib: use registered callbacks
...instead of exported symbols of certain name. This is first step to use change it to shared libraries.
This commit is contained in:
parent
1c6f44d7fa
commit
113826aa1a
@ -3,7 +3,11 @@
|
|||||||
#include "libqubes-rpc-filecopy.h"
|
#include "libqubes-rpc-filecopy.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
|
|
||||||
extern void notify_progress(int, int);
|
notify_progress_t *notify_progress_func = NULL;
|
||||||
|
void register_notify_progress(notify_progress_t *func)
|
||||||
|
{
|
||||||
|
notify_progress_func = func;
|
||||||
|
}
|
||||||
|
|
||||||
int copy_file(int outfd, int infd, long long size, unsigned long *crc32)
|
int copy_file(int outfd, int infd, long long size, unsigned long *crc32)
|
||||||
{
|
{
|
||||||
@ -26,7 +30,8 @@ int copy_file(int outfd, int infd, long long size, unsigned long *crc32)
|
|||||||
*crc32 = Crc32_ComputeBuf(*crc32, buf, ret);
|
*crc32 = Crc32_ComputeBuf(*crc32, buf, ret);
|
||||||
if (!write_all(outfd, buf, ret))
|
if (!write_all(outfd, buf, ret))
|
||||||
return COPY_FILE_WRITE_ERROR;
|
return COPY_FILE_WRITE_ERROR;
|
||||||
notify_progress(ret, 0);
|
if (notify_progress_func != NULL)
|
||||||
|
notify_progress_func(ret, 0);
|
||||||
written += ret;
|
written += ret;
|
||||||
}
|
}
|
||||||
return COPY_FILE_OK;
|
return COPY_FILE_OK;
|
||||||
|
@ -22,8 +22,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "libqrexec-utils.h"
|
||||||
|
|
||||||
extern void do_exec(const char *);
|
static do_exec_t *exec_func = NULL;
|
||||||
|
void register_exec_func(do_exec_t *func) {
|
||||||
|
exec_func = func;
|
||||||
|
}
|
||||||
|
|
||||||
void fix_fds(int fdin, int fdout, int fderr)
|
void fix_fds(int fdin, int fdout, int fderr)
|
||||||
{
|
{
|
||||||
@ -59,7 +63,8 @@ void do_fork_exec(const char *cmdline, int *pid, int *stdin_fd, int *stdout_fd,
|
|||||||
} else
|
} else
|
||||||
fix_fds(inpipe[0], outpipe[1], 2);
|
fix_fds(inpipe[0], outpipe[1], 2);
|
||||||
|
|
||||||
do_exec(cmdline);
|
if (exec_func != NULL)
|
||||||
|
exec_func(cmdline);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ struct buffer {
|
|||||||
int buflen;
|
int buflen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (do_exec_t)(const char *);
|
||||||
|
void register_exec_func(do_exec_t *func);
|
||||||
|
|
||||||
void buffer_init(struct buffer *b);
|
void buffer_init(struct buffer *b);
|
||||||
void buffer_free(struct buffer *b);
|
void buffer_free(struct buffer *b);
|
||||||
void buffer_append(struct buffer *b, const char *data, int len);
|
void buffer_append(struct buffer *b, const char *data, int len);
|
||||||
|
@ -60,6 +60,8 @@ enum {
|
|||||||
COPY_FILE_WRITE_ERROR
|
COPY_FILE_WRITE_ERROR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (notify_progress_t)(int, int);
|
||||||
|
void register_notify_progress(notify_progress_t *func);
|
||||||
int copy_file(int outfd, int infd, long long size, unsigned long *crc32);
|
int copy_file(int outfd, int infd, long long size, unsigned long *crc32);
|
||||||
char *copy_file_status_to_str(int status);
|
char *copy_file_status_to_str(int status);
|
||||||
void set_size_limit(long long new_bytes_limit, long long new_files_limit);
|
void set_size_limit(long long new_bytes_limit, long long new_files_limit);
|
||||||
|
Loading…
Reference in New Issue
Block a user