]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/plugins/node.c
Restore win32 dir from Branch-5.2 and update it
[bacula/bacula] / bacula / src / win32 / filed / plugins / node.c
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2008-2010 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation, which is 
11    listed in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /* 
29  *  Written by James Harper, October 2008
30  */
31
32 #include "exchange-fd.h"
33
34 node_t::node_t(char *name, int type)
35 {
36    this->type = type;
37    state = 0;
38    parent = NULL;
39    this->name = bstrdup(name);
40    full_path = make_full_path();
41    size = 0;
42    level = 0;
43 }
44
45 node_t::node_t(char *name, int type, node_t *parent_node)
46 {
47    this->type = type;
48    state = 0;
49    parent = parent_node;
50    this->name = bstrdup(name);
51    full_path = make_full_path();
52    size = 0;
53    level = parent->level + 1;
54 }
55
56 node_t::~node_t()
57 {
58    delete name;
59    delete full_path;
60 }
61
62 char *
63 node_t::make_full_path()
64 {
65    node_t *curr_node;
66    int len;
67    char *retval;
68
69    for (len = 0, curr_node = this; curr_node != NULL; curr_node = curr_node->parent)
70    {
71       len += strlen(curr_node->name) + 1;
72    }
73    if (type == NODE_TYPE_FILE || type == NODE_TYPE_DATABASE_INFO)
74    {
75       retval = new char[len + 1];
76       retval[len] = 0;
77    }
78    else
79    {
80       retval = new char[len + 2];
81       retval[len] = '/';
82       retval[len + 1] = 0;
83    }
84    for (curr_node = this; curr_node != NULL; curr_node = curr_node->parent)
85    {
86       len -= strlen(curr_node->name);
87       memcpy(retval + len, curr_node->name, strlen(curr_node->name));
88       retval[--len] = '/';
89    }
90    return retval;
91 }
92
93 bRC
94 node_t::pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io)
95 {
96    _DebugMessage(100, "pluginIoOpen_Node\n");
97    io->status = 0;
98    io->io_errno = 0;
99    return bRC_OK;
100 }
101
102 bRC
103 node_t::pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io)
104 {
105    _DebugMessage(100, "pluginIoRead_Node\n");
106    io->status = 0;
107    io->io_errno = 0;
108    return bRC_OK;
109 }
110
111 bRC
112 node_t::pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io)
113 {
114    _DebugMessage(100, "pluginIoWrite_Node\n");
115    io->status = 0;
116    io->io_errno = 1;
117    return bRC_Error;
118 }
119
120 bRC
121 node_t::pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io)
122 {
123    _DebugMessage(100, "pluginIoClose_Node\n");
124    io->status = 0;
125    io->io_errno = 0;
126    return bRC_OK;
127 }