plptools
Loading...
Searching...
No Matches
rpcs16.cc
Go to the documentation of this file.
1/*
2 * This file is part of plptools.
3 *
4 * Copyright (C) 1999 Matt J. Gumbley <matt@gumbley.demon.co.uk>
5 * Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * along with this program; if not, see <https://www.gnu.org/licenses/>.
19 *
20 */
21#include "config.h"
22
23#include "rpcs16.h"
24#include "bufferstore.h"
25#include "bufferarray.h"
26#include "tcpsocket.h"
27
28#include <memory>
29#include <stdio.h>
30#include <stdlib.h>
31#include <time.h>
32
33using namespace std;
34
35RPCS16::RPCS16(std::unique_ptr<TCPSocket> socket) {
36 socket_ = std::move(socket);
37 mtCacheS5mx = 0;
38 reset();
39}
40
41Enum<RFSV::errs> RPCS16::getCmdLine(const char *process, string &ret) {
44
45 a.addStringT(process);
48 }
49 if ((res = getResponse(a, true)) == RFSV::E_PSI_GEN_NONE) {
50 ret = a.getString(0);
51 }
52 return res;
53}
54
58
61 }
62 if ((res = (enum RFSV::errs)getResponse(a, true)) != RFSV::E_PSI_GEN_NONE) {
63 return res;
64 }
65
66 // Ensure the resulting buffer is null terminated.
67 a.addByte(0);
68
69 // It looks like the EPOC16 implementation returns a null-padded buffer with strings at fixed (52-character)
70 // offsets, so we read these into four separate strings and append them to our resulting array.
71 owner.clear();
72 for (int i = 0; i < 4; i++) {
74 b.addStringT(a.getString(52 * i));
75 owner += b;
76 }
77
79}
An array of BufferStores.
Definition: bufferarray.h:30
A generic container for an array of bytes.
Definition: bufferstore.h:36
void addStringT(const char *s)
Appends a string to the content of this instance.
Definition: bufferstore.cc:169
Wrapper class featuring range-checking and string representation of enumerated values.
Definition: Enum.h:135
errs
The known error codes.
Definition: rfsv.h:113
@ E_PSI_FILE_DISC
Definition: rfsv.h:156
@ E_PSI_GEN_NONE
Definition: rfsv.h:114
Enum< RFSV::errs > getCmdLine(const char *, std::string &)
Retrieves the command line of a running process.
Definition: rpcs16.cc:41
RPCS16(std::unique_ptr< TCPSocket > socket)
Definition: rpcs16.cc:35
Enum< RFSV::errs > getOwnerInfo(BufferArray &owner)
Retrieve owner information of the remote machine.
Definition: rpcs16.cc:55
std::unique_ptr< TCPSocket > socket_
The socket, used for communication with ncpd.
Definition: rpcs.h:447
int mtCacheS5mx
Flag: getMachineType and getMachineInfo have been called and the machine is an S5mx.
Definition: rpcs.h:490
bool sendCommand(enum commands cc, BufferStore &data)
Sends a command to the remote side.
Definition: rpcs.cc:134
void reset()
Initializes a connection to the remote machine.
Definition: rpcs.cc:109
Enum< RFSV::errs > getResponse(BufferStore &data, bool statusIsFirstByte)
Definition: rpcs.cc:156
@ GET_CMDLINE
Definition: rpcs.h:468
@ GET_OWNERINFO
Definition: rpcs.h:466
Definition: doctest.h:522
static BufferStore owner
Definition: main.cc:60
static RFSV * a
Definition: main.cc:55