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 <stdio.h>
29#include <stdlib.h>
30#include <time.h>
31
32using namespace std;
33
35{
36 skt = _skt;
37 mtCacheS5mx = 0;
38 reset();
39}
40
42getCmdLine(const char *process, string &ret)
43{
46
47 a.addStringT(process);
50 if ((res = getResponse(a, true)) == rfsv::E_PSI_GEN_NONE)
51 ret = a.getString(0);
52 return res;
53}
54
57{
60
63 }
64 if ((res = (enum rfsv::errs)getResponse(a, true)) != rfsv::E_PSI_GEN_NONE) {
65 return res;
66 }
67
68 // Ensure the resulting buffer is null terminated.
69 a.addByte(0);
70
71 // It looks like the EPOC16 implementation returns a null-padded buffer with strings at fixed (52-character)
72 // offsets, so we read these into four separate strings and append them to our resulting array.
73 owner.clear();
74 for (int i = 0; i < 4; i++) {
76 b.addString(a.getString(52 * i));
77 owner += b;
78 }
79
81}
Wrapper class featuring range-checking and string representation of enumerated values.
Definition: Enum.h:136
A class for dealing with sockets.
Definition: tcpsocket.h:38
An array of bufferStores.
Definition: bufferarray.h:31
A generic container for an array of bytes.
Definition: bufferstore.h:37
void addString(const char *s)
Appends a string to the content of this instance.
Definition: bufferstore.cc:164
errs
The known error codes.
Definition: rfsv.h:109
@ E_PSI_GEN_NONE
Definition: rfsv.h:110
@ E_PSI_FILE_DISC
Definition: rfsv.h:152
Enum< rfsv::errs > getCmdLine(const char *, std::string &)
Retrieves the command line of a running process.
Definition: rpcs16.cc:42
rpcs16(TCPSocket *)
Definition: rpcs16.cc:34
Enum< rfsv::errs > getOwnerInfo(bufferArray &owner)
Retrieve owner information of the remote machine.
Definition: rpcs16.cc:56
TCPSocket * skt
The socket, used for communication with ncpd.
Definition: rpcs.h:420
bool sendCommand(enum commands cc, bufferStore &data)
Sends a command to the remote side.
Definition: rpcs.cc:135
@ GET_CMDLINE
Definition: rpcs.h:441
@ GET_OWNERINFO
Definition: rpcs.h:439
Enum< rfsv::errs > getResponse(bufferStore &data, bool statusIsFirstByte)
Definition: rpcs.cc:157
void reset()
Initializes a connection to the remote machine.
Definition: rpcs.cc:105
int mtCacheS5mx
Flag: getMachineType and getMachineInfo have been called and the machine is an S5mx.
Definition: rpcs.h:463
Definition: doctest.h:522
static bufferStore owner
Definition: main.cc:58
static rfsv * a
Definition: main.cc:53