53#include "ignore-value.h"
54#include "string-buffer.h"
56#include "xvasprintf.h"
63#if defined(HAVE_READLINE_READLINE_H)
64# include <readline/readline.h>
65#elif defined(HAVE_READLINE_H)
70#ifdef HAVE_READLINE_HISTORY
71# if defined(HAVE_READLINE_HISTORY_H)
72# include <readline/history.h>
73# elif defined(HAVE_HISTORY_H)
85#define CLIPFILE "C:/System/Data/Clpboard.cbd"
106 cout <<
_(
"Known FTP commands:") << endl << endl;
107 cout <<
" pwd" << endl;
108 cout <<
" ren <oldname> <newname>" << endl;
109 cout <<
" touch <psionfile>" << endl;
110 cout <<
" gtime <psionfile>" << endl;
111 cout <<
" test <psionfile>" << endl;
112 cout <<
" gattr <psionfile>" << endl;
113 cout <<
" sattr [[-|+]rwhsa] <psionfile>" << endl;
114 cout <<
" devs" << endl;
115 cout <<
" dir|ls" << endl;
116 cout <<
" dircnt" << endl;
117 cout <<
" cd <dir>" << endl;
118 cout <<
" lcd <dir>" << endl;
119 cout <<
" !<system command>" << endl;
120 cout <<
" get <psionfile>" << endl;
121 cout <<
" put <unixfile>" << endl;
122 cout <<
" mget <shellpattern>" << endl;
123 cout <<
" mput <shellpattern>" << endl;
124 cout <<
" cp <psionfile> <psionfile>" << endl;
125 cout <<
" del|rm <psionfile>" << endl;
126 cout <<
" mkdir <psiondir>" << endl;
127 cout <<
" rmdir <psiondir>" << endl;
128 cout <<
" volname <drive> <name>" << endl;
129 cout <<
" prompt" << endl;
130 cout <<
" hash" << endl;
131 cout <<
" bye" << endl;
132 cout << endl <<
_(
"Known RPC commands:") << endl << endl;
133 cout <<
" ps" << endl;
134 cout <<
" kill <pid|'all'>" << endl;
135 cout <<
" getclip <unixfile>" << endl;
136 cout <<
" putclip <unixfile>" << endl;
137 cout <<
" run <psionfile> [args]" << endl;
138 cout <<
" killsave <unixfile>" << endl;
139 cout <<
" runrestore <unixfile>" << endl;
140 cout <<
" machinfo" << endl;
141 cout <<
" ownerinfo" << endl;
142 cout <<
" settime" << endl;
143 cout <<
" setupinfo" << endl;
148 struct string_buffer sb;
150 int argc = argv.size();
151 for (
int i = 0; i < argc; i++) {
152 sb_append(&sb, argv[i]);
156 return sb_dupfree(&sb);
169 printf(
"#"); fflush(stdout);
191 FILE *fp = fopen(file,
"w");
194 cerr <<
_(
"Could not open command list file ") << file << endl;
197 fputs(
"#plpftp processlist\n", fp);
199 cerr <<
_(
"Could not get process list, Error: ") << res << endl;
202 for (processList::iterator i = tmp.begin(); i != tmp.end(); i++) {
203 fputs(i->getArgs(), fp);
207 time_t tstart = time(
nullptr) + 5;
208 while (!tmp.empty()) {
209 for (processList::iterator i = tmp.begin(); i != tmp.end(); i++) {
213 if (time(
nullptr) > tstart) {
215 "Could not stop all processes. Please stop running\n"
216 "programs manually on the Psion, then hit return.") << flush;
217 cin.getline((
char *)&tstart, 1);
218 tstart = time(
nullptr) + 5;
221 cerr <<
_(
"Could not get process list, Error: ") << res << endl;
229get_upto(FILE *fp,
const char *term,
size_t *final_len)
233 char *l = (
char *)malloc(len), *s = l;
236 for (c = getc(fp); c != EOF && strchr(term, c) == NULL; c = getc(fp)) {
238 l = (
char *)realloc(l, len * 2);
245 l = (
char *)realloc(l, len + 1);
253 l = (
char *)realloc(l, s - l);
267 FILE *fp = fopen(file,
"r");
271 cerr <<
_(
"Could not open command list file ") << file << endl;
274 cmd = string(
getln(fp));
275 if (strcmp(cmd.c_str(),
"#plpftp processlist")) {
277 cerr <<
_(
"Error: ") << file <<
278 _(
" is not a process list saved with killsave") << endl;
281 for (cmd =
string(
getln(fp)); cmd.length() > 0; cmd = string(
getln(fp))) {
282 int firstBlank = cmd.find(
' ');
283 string prog = string(cmd, 0, firstBlank);
284 string arg = string(cmd, firstBlank + 1);
290 if ((arg.size() > 2) && (arg[1] ==
':') && (arg[0] >=
'A') &&
301 if (prog.find(
'\\') == prog.npos) {
305 for (i = 0; i < 26; i++) {
306 if (devbits & (1 << i)) {
307 string tmp = string();
309 tmp +=
":\\System\\Apps\\" + prog +
"\\" + prog +
".app";
319 cerr <<
_(
"Could not start ") << cmd << endl;
320 cerr <<
_(
"Error: ") << res << endl;
334 cerr <<
_(
"Clipboard protocol not supported by Psion Series 3.") << endl;
342 cerr <<
_(
"Your Psion does not support the clipboard protocol.\n\
343 The reason for that is usually a missing server library.\n\
344 Make sure that C:\\System\\Libs\\clipsvr.rsy exists.\n\
345 This file is part of PsiWin and usually gets copied to\n\
346 your Psion when you enable CopyAnywhere in PsiWin.\n\
347 You can also get it from a PsiWin installation directory\n\
348 and copy it to your Psion manually.") << endl;
356 for (p = buf; len; len--, p++)
383 for (p = buf; len; len--, p++)
411 const unsigned char *p;
419 if ((fp = fopen(file,
"r")) == NULL)
423 data =
slurp(fp, &len);
446 p = (
const unsigned char *)b.
getString(0);
544 char *buf = (
char *)malloc(len);
547 cerr <<
"Out of memory in getClipData" << endl;
554 res =
a.
fread(fh, (
unsigned char *)buf, len, tmp);
560 uint32_t *ti = (uint32_t*)buf;
563 if (*ti++ != 0x10000037) {
567 if (*ti++ != 0x1000003b) {
575 if (*ti++ != 0x4739d53b) {
585 uint32_t *td = (uint32_t*)p;
587 uint32_t sType = *td++;
588 if (sType == 0x10000033) {
591 len = *((uint32_t*)p);
594 clipText += (
char *)p;
596 if (sType == 0x1000003d) {
614 FILE *fp = fopen(file,
"w");
617 fwrite(clipText.c_str(), 1, clipText.length(), fp);
630 if ((f1[strlen(f1) - 1] !=
'/') && (f1[strlen(f1) - 1] !=
'\\')) {
631 char *f2 = xasprintf(
"%s%s", f1,
"\\");
648 unsigned argc = argv.size();
659 cout <<
_(
"Connected to a ") << machType <<
_(
" at ")
660 << speed <<
_(
" baud, OwnerInfo:") << endl;
666 cerr <<
_(
"OwnerInfo returned error ") << res << endl;
669 if (!strcmp(DDRIVE,
"AUTO")) {
676 for (i = 0; i < 26; i++) {
686 cerr <<
_(
"FATAL: Couldn't find default Drive") << endl;
695 cout <<
_(
"Psion dir is: \"") <<
psionDir <<
"\"" << endl;
709 if ((!strcmp(argv[0],
"help")) || (!strcmp(argv[0],
"?"))) {
713 if (!strcmp(argv[0],
"prompt")) {
715 cout <<
_(
"Prompting now ") << (prompt?
_(
"on") :
_(
"off")) << endl;
718 if (!strcmp(argv[0],
"hash")) {
720 cout <<
_(
"Hash printing now ") << (hash?
_(
"on") :
_(
"off")) << endl;
724 if (!strcmp(argv[0],
"pwd")) {
725 cout <<
_(
"Local dir: \"") <<
localDir <<
"\"" << endl;
726 cout <<
_(
"Psion dir: \"") <<
psionDir <<
"\"" << endl;
729 if (!strcmp(argv[0],
"volname") && (argc == 3) && (strlen(argv[1]) == 1)) {
731 cerr <<
_(
"Error: ") << res << endl;
735 if (!strcmp(argv[0],
"ren") && (argc == 3)) {
736 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
737 char *f2 = xasprintf(
"%s%s",
psionDir, argv[2]);
739 cerr <<
_(
"Error: ") << res << endl;
744 if (!strcmp(argv[0],
"cp") && (argc == 3)) {
745 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
746 char *f2 = xasprintf(
"%s%s",
psionDir, argv[2]);
748 cerr <<
_(
"Error: ") << res << endl;
753 if (!strcmp(argv[0],
"touch") && (argc == 2)) {
754 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
757 cerr <<
_(
"Error: ") << res << endl;
761 if (!strcmp(argv[0],
"test") && (argc == 2)) {
763 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
765 cerr <<
_(
"Error: ") << res << endl;
771 if (!strcmp(argv[0],
"gattr") && (argc == 2)) {
773 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
775 cerr <<
_(
"Error: ") << res << endl;
777 cout << hex << setw(4) << setfill(
'0') << attr;
783 if (!strcmp(argv[0],
"gtime") && (argc == 2)) {
785 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
787 cerr <<
_(
"Error: ") << res << endl;
789 cout << mtime <<
"(" << hex
797 if (!strcmp(argv[0],
"sattr") && (argc == 3)) {
802 char *f1 = xasprintf(
"%s%s",
psionDir, argv[2]);
804 attr[0] = attr[1] = 0;
837 cerr <<
_(
"Error: ") << res << endl;
841 if (!strcmp(argv[0],
"dircnt")) {
844 cerr <<
_(
"Error: ") << res << endl;
846 cout << cnt <<
_(
" Entries") << endl;
849 if (!strcmp(argv[0],
"devs")) {
852 cout <<
_(
"Drive Type Volname Total Free UniqueID") << endl;
853 for (
int i = 0; i < 26; i++) {
856 if ((devbits & 1) != 0) {
858 cout << (char) (
'A' + i) <<
" " << hex
859 << setw(4) << setfill(
'0')
861 << setfill(
' ') << setiosflags(ios::left)
863 << resetiosflags(ios::left) << dec << setw(9)
865 << drive.
getSpace() <<
" " << setw(8)
866 << setfill(
'0') << hex << drive.
getUID()
872 cerr <<
_(
"Error: ") << res << endl;
875 if (!strcmp(argv[0],
"ls") || !strcmp(argv[0],
"dir")) {
879 cerr <<
_(
"Error: ") << res << endl;
881 while (!files.empty()) {
882 cout << files[0] << endl;
888 if (!strcmp(argv[0],
"lcd")) {
892 if (chdir(argv[1]) == 0) {
895 cerr <<
_(
"No such directory") << endl
896 <<
_(
"Keeping original directory \"") <<
localDir <<
"\"" << endl;
900 if (!strcmp(argv[0],
"cd")) {
908 cerr <<
_(
"Error: ") << res << endl;
909 cerr <<
_(
"Keeping original directory \"") <<
psionDir <<
"\"" << endl;
918 if ((!strcmp(argv[0],
"get")) && (argc > 1)) {
919 struct timeval stime;
920 struct timeval etime;
925 char *f2 = xasprintf(
"%s%s%s",
localDir,
"/", argc == 2 ? basename.c_str() : argv[2]);
927 gettimeofday(&stime,
nullptr);
932 cerr <<
_(
"Error: ") << res << endl;
936 gettimeofday(&etime,
nullptr);
937 long dsec = etime.tv_sec - stime.tv_sec;
938 long dhse = (etime.tv_usec / 10000) -
939 (stime.tv_usec /10000);
948 float cps = (float)(stbuf.st_size) / dt;
949 cout <<
_(
"Transfer complete, (") << dec << stbuf.st_size
950 <<
_(
" bytes in ") << dsec <<
"."
951 << dhse <<
_(
" secs = ") << cps <<
" cps)\n";
956 }
else if ((!strcmp(argv[0],
"mget")) && (argc == 2)) {
957 char *pattern = argv[1];
960 cerr <<
_(
"Error: ") << res << endl;
963 for (
size_t i = 0; i < files.size(); i++) {
969 if (fnmatch(pattern, e.
getName(), FNM_NOESCAPE) == FNM_NOMATCH)
971 cout <<
_(
"Get \"") << e.
getName() <<
"\" (y,n): ";
988 cerr <<
_(
"Error: ") << res << endl;
993 cout <<
_(
"Transfer complete\n");
1001 if (!strcmp(argv[0],
"put") && (argc >= 2)) {
1002 struct timeval stime;
1003 struct timeval etime;
1006 char *f1 = xasprintf(
"%s%s%s",
localDir,
"/", argv[1]);
1007 char *f2 = xasprintf(
"%s%s",
psionDir, argc == 2 ? argv[1] : argv[2]);
1008 gettimeofday(&stime,
nullptr);
1013 cerr <<
_(
"Error: ") << res << endl;
1017 gettimeofday(&etime,
nullptr);
1018 long dsec = etime.tv_sec - stime.tv_sec;
1019 long dhse = (etime.tv_usec / 10000) -
1020 (stime.tv_usec /10000);
1029 float cps = (float)(stbuf.st_size) / dt;
1030 cout <<
_(
"Transfer complete, (") << dec << stbuf.st_size
1031 <<
_(
" bytes in ") << dsec <<
"."
1032 << dhse <<
_(
" secs = ") << cps <<
" cps)\n";
1038 if ((!strcmp(argv[0],
"mput")) && (argc == 2)) {
1039 char *pattern = argv[1];
1048 if (fnmatch(pattern, de->d_name, FNM_NOESCAPE) == FNM_NOMATCH)
1050 char *f1 = xasprintf(
"%s%s%s",
localDir,
"/", de->d_name);
1051 if (stat(f1, &st) == 0 && S_ISREG(st.st_mode)) {
1052 cout <<
_(
"Put \"") << de->d_name <<
"\" y,n: ";
1062 char *f2 = xasprintf(
"%s%s",
psionDir, de->d_name);
1067 cerr <<
_(
"Error: ") << res << endl;
1075 cout <<
_(
"Transfer complete\n");
1084 cerr <<
_(
"Error in directory name \"") <<
localDir <<
"\"\n";
1087 if ((!strcmp(argv[0],
"del") ||
1088 !strcmp(argv[0],
"rm")) && (argc == 2)) {
1089 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
1091 cerr <<
_(
"Error: ") << res << endl;
1095 if (!strcmp(argv[0],
"mkdir") && (argc == 2)) {
1096 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
1098 cerr <<
_(
"Error: ") << res << endl;
1102 if (!strcmp(argv[0],
"rmdir") && (argc == 2)) {
1103 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
1105 cerr <<
_(
"Error: ") << res << endl;
1109 if (argv[0][0] ==
'!') {
1112 ignore_value(system(cmd));
1115 cout <<
_(
"Starting subshell ...\n");
1116 sh = getenv(
"SHELL");
1119 ignore_value(system(sh));
1125 if (!strcmp(argv[0],
"settime")) {
1127 cerr <<
_(
"Error: ") << res << endl;
1130 if (!strcmp(argv[0],
"setupinfo")) {
1135 cerr <<
_(
"Error: ") << res << endl;
1138 if (db.
getLen() < 1152) {
1139 cerr <<
_(
"Unknown setup info received") << endl;
1142 cout <<
_(
"Setup information:") << endl;
1143 cout <<
_(
" Screen contrast: ") << dec
1145 cout <<
_(
" Keyboard click: ")
1147 (db.
getDWord(0x204) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1148 cout <<
_(
" Screen click: ")
1150 (db.
getDWord(0x210) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1151 cout <<
_(
" Error sound: ")
1153 (db.
getDWord(0x218) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1154 cout <<
_(
" Auto-switch off: ");
1160 cout <<
_(
"if running on battery power");
1163 cout <<
_(
"always");
1168 cout <<
_(
" Switch off after: ") << dec
1169 << db.
getDWord(0x22c) <<
_(
" seconds") << endl;
1170 cout <<
_(
" Backlight off after: ") << dec
1171 << db.
getDWord(0x234) <<
_(
" seconds") << endl;
1172 cout <<
_(
" Switch on when tapping on screen: ")
1173 << (db.
getDWord(0x238) ?
_(
"yes") :
_(
"no")) << endl;
1174 cout <<
_(
" Switch on when opening: ")
1175 << (db.
getDWord(0x23c) ?
_(
"yes") :
_(
"no")) << endl;
1176 cout <<
_(
" Switch off when closing: ")
1177 << (db.
getDWord(0x23c) ?
_(
"yes") :
_(
"no")) << endl;
1178 cout <<
_(
" Ask for password on startup: ")
1179 << (db.
getDWord(0x29c) ?
_(
"yes") :
_(
"no")) << endl;
1180 cout <<
_(
" Show Owner info on startup: ");
1186 cout <<
_(
"once a day");
1189 cout <<
_(
"always");
1195 if (!strcmp(argv[0],
"run") && (argc >= 2)) {
1196 vector<char *> args = {argv.begin() + 1, argv.end()};
1199 if (!strchr(argv[1],
':'))
1200 cmd = xasprintf(
"%s%s",
psionDir, argv[1]);
1202 cmd = xstrdup(argv[1]);
1208 if (!strcmp(argv[0],
"ownerinfo")) {
1211 cerr <<
_(
"Error: ") << res << endl;
1218 if (!strcmp(argv[0],
"machinfo")) {
1221 cerr <<
_(
"Error: ") << res << endl;
1225 cout <<
_(
"General:") << endl;
1226 cout <<
_(
" Machine Type: ") << mi.
machineType << endl;
1227 cout <<
_(
" Machine Name: ") << mi.
machineName << endl;
1228 cout <<
_(
" Machine UID: ") << hex << mi.
machineUID << dec << endl;
1229 cout <<
_(
" UI Language: ") << mi.
uiLanguage << endl;
1230 cout <<
_(
"ROM:") << endl;
1231 cout <<
_(
" Version: ") << mi.
romMajor <<
"." << setw(2) << setfill(
'0') <<
1233 cout <<
_(
" Size: ") << mi.
romSize / 1024 <<
"k" << endl;
1234 cout <<
_(
" Programmable: ") <<
1236 cout <<
_(
"RAM:") << endl;
1237 cout <<
_(
" Size: ") << mi.
ramSize / 1024 <<
"k" << endl;
1238 cout <<
_(
" Free: ") << mi.
ramFree / 1024 <<
"k" << endl;
1239 cout <<
_(
" Free max: ") << mi.
ramMaxFree / 1024 <<
"k" << endl;
1240 cout <<
_(
"RAM disk size: ") << mi.
ramDiskSize / 1024 <<
"k" << endl;
1244 cout <<
_(
"Time:") << endl;
1246 cout <<
_(
" Current time: ") << pt << endl;
1247 cout <<
_(
" UTC offset: ") << mi.
tz.
utc_offset <<
_(
" seconds") << endl;
1248 cout <<
_(
" DST: ") <<
1251 cout <<
_(
" Country Code: ") << mi.
countryCode << endl;
1252 cout <<
_(
"Main battery:") << endl;
1254 cout <<
_(
" Changed at: ") << pt << endl;
1261 cout <<
_(
"Backup battery:") << endl;
1265 cout <<
_(
"External power:") << endl;
1266 cout <<
_(
" Supplied: ")
1271 if (!strcmp(argv[0],
"runrestore") && (argc == 2)) {
1275 if (!strcmp(argv[0],
"killsave") && (argc == 2)) {
1279 if (!strcmp(argv[0],
"putclip") && (argc == 2)) {
1281 cerr <<
_(
"Error setting clipboard") << endl;
1284 if (!strcmp(argv[0],
"getclip") && (argc == 2)) {
1286 cerr <<
_(
"Error getting clipboard") << endl;
1289 if (!strcmp(argv[0],
"kill") && (argc >= 2)) {
1291 bool anykilled =
false;
1293 cerr <<
_(
"Error: ") << res << endl;
1295 for (
int i = 1; i < argc; i++) {
1297 if (!strcmp(argv[i],
"all"))
1300 sscanf(argv[i],
"%d", &kpid);
1301 processList::iterator j;
1302 for (j = tmp.begin(); j != tmp.end(); j++) {
1303 if (kpid == -1 || kpid == j->getPID()) {
1312 cerr <<
_(
"no such process") << endl;
1316 if (!strcmp(argv[0],
"ps")) {
1319 cerr <<
_(
"Error: ") << res << endl;
1321 cout <<
"PID CMD ARGS" << endl;
1322 for (processList::iterator i = tmp.begin(); i != tmp.end(); i++)
1327 if (strcmp(argv[0],
"bye") == 0 || strcmp(argv[0],
"quit") == 0)
1330 cerr <<
_(
"syntax error. Try \"help\"") << endl;
1335#define MATCHFUNCTION rl_completion_matches
1338 "pwd",
"ren",
"touch",
"gtime",
"test",
"gattr",
"sattr",
"devs",
1339 "dir",
"ls",
"dircnt",
"cd",
"lcd",
"get",
"put",
"mget",
"mput",
1340 "del",
"rm",
"mkdir",
"rmdir",
"prompt",
"bye",
"cp",
"volname",
1341 "ps",
"kill",
"killsave",
"runrestore",
"run",
"machinfo",
1342 "ownerinfo",
"help",
"settime",
"setupinfo", NULL
1346 "lcd ",
"put ",
"mput ",
"killsave ",
"runrestore ", NULL
1350 "cd ",
"rmdir ", NULL
1372 cerr <<
_(
"Error: ") << res << endl;
1385 if (!(strncmp(tmp.c_str(), text, len))) {
1387 rl_completion_append_character =
'\0';
1390 return (strdup(tmp.c_str()));
1401 static int idx, len;
1410 if (!strncmp(name, text, len))
1411 return (strdup(name));
1419 static char null[1] =
"";
1426 char **matches = NULL;
1429 rl_completion_append_character =
' ';
1430 rl_attempted_completion_over = 1;
1438 rl_filename_quoting_desired = 1;
1441 if (!strncmp(name, rl_line_buffer, strlen(name))) {
1442 rl_completion_entry_function = NULL;
1457 if (!strncmp(name, rl_line_buffer, strlen(name)))
1471 rl_readline_name =
"plpftp";
1474 rl_basic_word_break_characters =
" \t\n\"\\'`@><=;|&{(";
1475 rl_completer_quote_characters =
"\"";
1483 vector<char *> argv;
1497 for (
char *p = buf; *p; p++)
1517 cout <<
"bye" << endl;
Wrapper class featuring range-checking and string representation of enumerated values.
static std::string getEPOCBasename(std::string path)
Returns the last path component of an EPOC path.
static char * resolveEPOCPath(const char *path, const char *initialPath)
Returns a new absolute EPOC path, determined by resolving path relative to initialPath.
A class, representing a directory entry of the Psion.
uint32_t getSize()
Retrieves the file size of a directory entry.
uint32_t getAttr()
Retrieves the file attributes of a directory entry.
const char * getName()
Retrieve the file name of a directory entry.
A class representing information about a Disk drive on the psion.
std::string getName()
Retrieve the volume name of the drive.
uint64_t getSize()
Retrieve the total capacity of the drive.
uint32_t getMediaType()
Retrieve the media type of the drive.
uint32_t getUID()
Retrieve the UID of the drive.
uint64_t getSpace()
Retrieve the free capacity on the drive.
Psion time related utility class.
uint32_t getPsiTimeHi(void)
Retrieves the instance's current value in Psion time format, low 32 bits.
uint32_t getPsiTimeLo(void)
Retrieves the instance's current value in Psion time format, high 32 bits.
void setPsiTime(psi_timeval *_ptv)
Modifies the value of this instance.
A class for dealing with sockets.
An array of bufferStores.
bufferStore pop(void)
Removes the first bufferStore.
bool empty() const
Checks if this bufferArray is empty.
A generic container for an array of bytes.
void addByte(unsigned char c)
Appends a byte to the content of this instance.
const char * getString(long pos=0) const
Retrieves the characters at index pos.
void addDWord(long dw)
Appends a dword to the content of this instance.
void addStringT(const char *s)
Appends a string to the content of this instance.
unsigned long getLen() const
Retrieves the length of a bufferStore.
uint32_t getDWord(long pos=0) const
Retrieves the dword at index pos.
unsigned char getByte(long pos=0) const
Retrieves the byte at index pos.
std::vector< char * > getCommand()
int putClipText(rpcs &r, rfsv &a, rclip &rc, TCPSocket &rclipSocket, const char *data)
bool checkClipConnection(rfsv &a, rclip &rc, TCPSocket &rclipSocket)
int getClipData(rpcs &r, rfsv &a, rclip &rc, TCPSocket &rclipSocket, const char *file)
int session(rfsv &a, rpcs &r, rclip &rc, TCPSocket &rclipSocket, std::vector< char * > argv)
Remote ClipBoard services via PLP.
Enum< rfsv::errs > initClipbd()
Send initialization frame.
Access remote file services of a Psion.
virtual Enum< errs > mkdir(const char *const name)=0
Creates a directory on the Psion.
virtual uint32_t opMode(const uint32_t mode)=0
Converts an open-mode (A combination of the PSI_O_ constants.) from generic representation to the mac...
virtual Enum< errs > copyToPsion(const char *const from, const char *const to, void *, cpCallback_t func)=0
Copies a file from local machine to the Psion.
virtual Enum< errs > fgetattr(const char *const name, uint32_t &attr)=0
Retrieves attributes of a file on the Psion.
Enum< errs > getStatus()
Retrieves the current connection status.
virtual Enum< errs > fwrite(const uint32_t handle, const unsigned char *const buffer, const uint32_t len, uint32_t &count)=0
Write to a file on the Psion.
int getSpeed()
Retrieve speed of serial link.
virtual Enum< errs > copyOnPsion(const char *const from, const char *const to, void *, cpCallback_t func)=0
Copies a file from the Psion to the Psion.
virtual Enum< errs > fsetattr(const char *const name, const uint32_t seta, const uint32_t unseta)=0
virtual Enum< errs > copyFromPsion(const char *from, const char *to, void *, cpCallback_t func)=0
Copies a file from the Psion to the local machine.
virtual Enum< errs > devlist(uint32_t &devbits)=0
Retrieves available drives on the Psion.
virtual Enum< errs > fsetmtime(const char *const name, const PsiTime mtime)=0
Sets the modification time of a file on the Psion.
virtual Enum< errs > fclose(const uint32_t handle)=0
Close a file on the Psion whih was previously opened/created by using fopen , fcreatefile ,...
std::string attr2String(const uint32_t attr)
Converts a file attribute rfsv::file_attribs to human readable format, usable for showing them in dir...
virtual Enum< errs > setVolumeName(const char drive, const char *const name)=0
Set the name of a Psion Volume (Drive).
@ PSI_A_RDONLY
Attributes, valid on both EPOC and SIBO.
@ PSI_A_READ
Attributes, valid on SIBO only.
virtual Enum< errs > rename(const char *const oldname, const char *const newname)=0
Renames a file on the Psion.
virtual Enum< errs > freplacefile(const uint32_t attr, const char *const name, uint32_t &handle)=0
Creates an named file, overwriting an existing file.
virtual int getProtocolVersion()=0
Retrieves the protocol version.
virtual Enum< errs > fopen(const uint32_t attr, const char *const name, uint32_t &handle)=0
Opens a file.
static std::string convertSlash(const std::string &name)
Utility method, converts '/' to '\'.
virtual Enum< errs > fgetmtime(const char *const name, PsiTime &mtime)=0
Retrieves the modification time of a file on the Psion.
virtual Enum< errs > dircount(const char *const name, uint32_t &count)=0
Counts number of entries in a directory.
virtual Enum< errs > fread(const uint32_t handle, unsigned char *const buffer, const uint32_t len, uint32_t &count)=0
Reads from a file on the Psion.
virtual Enum< errs > fgeteattr(const char *const name, PlpDirent &e)=0
Retrieves attributes, size and modification time of a file on the Psion.
virtual Enum< errs > rmdir(const char *const name)=0
Removes a directory on the Psion.
virtual Enum< errs > remove(const char *const name)=0
Removes a file on the Psion.
virtual Enum< errs > dir(const char *const name, PlpDir &ret)=0
Reads a directory on the Psion.
virtual Enum< errs > devinfo(const char drive, PlpDrive &dinfo)=0
Retrieves details about a drive.
Remote procedure call services via PLP.
virtual Enum< rfsv::errs > getMachineInfo(machineInfo &machineInfo)
Retrieve general Information about the connected machine.
Enum< rfsv::errs > stopProgram(const char *program)
Requests termination of a program running on the remote machine.
virtual Enum< rfsv::errs > getOwnerInfo(bufferArray &owner)=0
Retrieve owner information of the remote machine.
Enum< rfsv::errs > queryPrograms(processList &ret)
Retrieves a list of all running Programs.
virtual Enum< rfsv::errs > setTime(time_t time)
Enum< rfsv::errs > getMachineType(Enum< machs > &type)
Retrieves the type of machine on the remote side as defined in machs.
Enum< rfsv::errs > execProgram(const char *program, const char *args)
Starts execution of a program on the remote machine.
virtual Enum< rfsv::errs > configRead(uint32_t size, bufferStore &data)
Read from Series 5 scratch RAM.
static char ** do_completion(const char *text, int start, int)
static char * join_string_vector(vector< char * > argv, const char *sep)
static int checkAbortHash(void *, uint32_t)
static int checkAbortNoHash(void *, uint32_t)
static void ascii2PsiText(char *buf, int len)
static void psiText2ascii(char *buf, int len)
static char * null_completion(const char *, int)
static char * epoc_dir_from(const char *path)
Compute new directory from path, which may be absolute or relative, and cwd.
static char * command_generator(const char *text, int state)
static const char * remote_dir_commands[]
static char * getln(FILE *fp)
static const char * all_commands[]
static const char * localfile_commands[]
static void sigint_handler2(int)
static int continueRunning
static char * filename_generator(const char *text, int state)
static char * slurp(FILE *fp, size_t *final_len)
static char * get_upto(FILE *fp, const char *term, size_t *final_len)
static int stopPrograms(rpcs &r, const char *file)
static int startPrograms(rpcs &r, rfsv &a, const char *file)
static void sigint_handler(int)
int(* cpCallback_t)(void *, uint32_t)
Defines the callback procedure for progress indication of copy operations.
std::deque< class PlpDirent > PlpDir
std::vector< PsiProcess > processList
This struct holds the data returned by rpcs::getMachineInfo.
Enum< languages > uiLanguage
psi_timeval mainBatteryUsedTime
unsigned long displayWidth
unsigned long long machineUID
Enum< batterystates > backupBatteryStatus
psi_timeval externalPowerUsedTime
Enum< batterystates > mainBatteryStatus
unsigned long mainBatteryVoltage
unsigned long countryCode
unsigned long mainBatteryUsedPower
unsigned long ramDiskSize
unsigned long displayHeight
unsigned long backupBatteryMaxVoltage
psi_timeval mainBatteryInsertionTime
unsigned long mainBatteryMaxVoltage
unsigned long mainBatteryCurrent
unsigned long registrySize
unsigned long backupBatteryVoltage
Enum< machs > machineType