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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
#include "psion.h"
#include <plpintl.h>
#include <rfsv.h>
#include <rpcs.h>
#include <rfsvfactory.h>
#include <rpcsfactory.h>
#include <bufferarray.h>
#include <bufferstore.h>
#include <ppsocket.h>
#include <dirent.h>
#include <netdb.h>
#include <stdio.h>
Psion::~Psion()
{
disconnect();
}
bool
Psion::connect()
{
int sockNum = DPORT;
#if 0
setlocale (LC_ALL, "");
textdomain(PACKAGE);
#endif
struct servent *se = getservbyname("psion", "tcp");
endservent();
if (se != 0L)
sockNum = ntohs(se->s_port);
#if 0
// Command line parameter processing
if ((argc > 2) && !strcmp(argv[1], "-p")) {
sockNum = atoi(argv[2]);
argc -= 2;
for (int i = 1; i < argc; i++)
argv[i] = argv[i + 2];
}
#endif
m_skt = new ppsocket();
if (!m_skt->connect(NULL, sockNum)) {
return false;
}
m_skt2 = new ppsocket();
if (!m_skt2->connect(NULL, sockNum)) {
return false;
}
m_rfsvFactory = new rfsvfactory(m_skt);
m_rpcsFactory = new rpcsfactory(m_skt2);
m_rfsv = m_rfsvFactory->create(true);
m_rpcs = m_rpcsFactory->create(true);
if ((m_rfsv != NULL) && (m_rpcs != NULL))
return true;
return false;
}
Enum<rfsv::errs>
Psion::copyFromPsion(const char * const from, int fd,
cpCallback_t func)
{
return m_rfsv->copyFromPsion(from, fd, func);
}
Enum<rfsv::errs>
Psion::copyToPsion(const char * const from, const char * const to,
void *, cpCallback_t func)
{
Enum<rfsv::errs> res;
res = m_rfsv->copyToPsion(from, to, NULL, func);
// printf("Returned to Psion\n");
return res;
}
Enum<rfsv::errs>
Psion::devinfo(const char drive, PlpDrive& plpDrive)
{
return m_rfsv->devinfo(drive, plpDrive);
}
Enum<rfsv::errs>
Psion::devlist(u_int32_t& devbits)
{
Enum<rfsv::errs> res;
res = m_rfsv->devlist(devbits);
return res;
}
Enum<rfsv::errs>
Psion::dir(const char* dir, PlpDir& files)
{
return m_rfsv->dir(dir, files);
}
bool
Psion::dirExists(const char* name)
{
rfsvDirhandle handle;
Enum<rfsv::errs> res;
bool exists = false;
res = m_rfsv->opendir(rfsv::PSI_A_ARCHIVE, name, handle);
if (res == rfsv::E_PSI_GEN_NONE)
exists = true;
res = m_rfsv->closedir(handle);
return exists;
}
void
Psion::disconnect()
{
delete m_rfsv;
delete m_rpcs;
delete m_skt;
delete m_skt2;
delete m_rfsvFactory;
delete m_rpcsFactory;
}
Enum<rfsv::errs>
Psion::mkdir(const char* dir)
{
return m_rfsv->mkdir(dir);
}
void
Psion::remove(const char* name)
{
m_rfsv->remove(name);
}
|