This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
forked from inteos/pgsql-plugin
-
Notifications
You must be signed in to change notification settings - Fork 7
/
pluglib.c
67 lines (56 loc) · 1.43 KB
/
pluglib.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright (c) 2013 by Inteos sp. z o.o.
* All rights reserved. See LICENSE.Inteos for details.
*
* Common utility functions for Inteos plugins.
* Functions defines a common framework used in all utilities and plugins.
*/
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "bareos.h"
#include "fd_plugins.h"
#include "pluglib.h"
#if 0
/*
* XXX: from unknown reason struct restore_pkt (esp. struct stat) differ in size and
* alligment which produce SEGV
*/
/*
* Check if 'Where' is set then we have to remove it from restored filename.
* This is a very stupid Bacula BUG, but Kern doesn't see it, what a shame !!!
* It works as designed and Bacula Team doesn't want to change it because
* they has to fix all existing plugins and perform a regression tests, but
* no one want to do it. We have to workaround a plugin API design mismatch!
*/
char * check_ofname ( struct restore_pkt *rp ){
char * ofname;
int len;
ofname = (char *)rp->ofname;
if ( rp->where ){
len = strlen ( rp->where );
if ( len ){
ofname += len + 1;
}
}
return ofname;
}
/*
* providing missing bstrndup function
*/
char * bstrndup ( char * str, unsigned int n ){
char * buf = NULL;
if ( !str ){
return NULL;
}
buf = (char *) malloc ( n + 1 );
if ( !buf ){
return NULL;
}
if ( n ){
strncpy ( buf, str, n + 1 );
}
buf [ n ] = '\0';
return buf;
}
#endif