56#include "ignore-value.h"
57#include "string-buffer.h"
59#include "xvasprintf.h"
66#if defined(HAVE_READLINE_READLINE_H)
67# include <readline/readline.h>
68#elif defined(HAVE_READLINE_H)
73#ifdef HAVE_READLINE_HISTORY
74# if defined(HAVE_READLINE_HISTORY_H)
75# include <readline/history.h>
76# elif defined(HAVE_HISTORY_H)
88#define CLIPFILE "C:/System/Data/Clpboard.cbd"
105 cout <<
_(
"Known FTP commands:") << endl << endl;
106 cout <<
" pwd" << endl;
107 cout <<
" ren <oldname> <newname>" << endl;
108 cout <<
" touch <psionfile>" << endl;
109 cout <<
" gtime <psionfile>" << endl;
110 cout <<
" test <psionfile>" << endl;
111 cout <<
" gattr <psionfile>" << endl;
112 cout <<
" sattr [[-|+]rwhsa] <psionfile>" << endl;
113 cout <<
" devs" << endl;
114 cout <<
" dir|ls" << endl;
115 cout <<
" dircnt" << endl;
116 cout <<
" cd <dir>" << endl;
117 cout <<
" lcd <dir>" << endl;
118 cout <<
" !<system command>" << endl;
119 cout <<
" get <psionfile>" << endl;
120 cout <<
" put <unixfile>" << endl;
121 cout <<
" mget <shellpattern>" << endl;
122 cout <<
" mput <shellpattern>" << endl;
123 cout <<
" cp <psionfile> <psionfile>" << endl;
124 cout <<
" del|rm <psionfile>" << endl;
125 cout <<
" mkdir <psiondir>" << endl;
126 cout <<
" rmdir <psiondir>" << endl;
127 cout <<
" volname <drive> <name>" << endl;
128 cout <<
" prompt" << endl;
129 cout <<
" hash" << endl;
130 cout <<
" bye" << endl;
131 cout << endl <<
_(
"Known RPC commands:") << endl << endl;
132 cout <<
" ps" << endl;
133 cout <<
" kill <pid|'all'>" << endl;
134 cout <<
" getclip <unixfile>" << endl;
135 cout <<
" putclip <unixfile>" << endl;
136 cout <<
" run <psionfile> [args]" << endl;
137 cout <<
" killsave <unixfile>" << endl;
138 cout <<
" runrestore <unixfile>" << endl;
139 cout <<
" machinfo" << endl;
140 cout <<
" ownerinfo" << endl;
141 cout <<
" settime" << endl;
142 cout <<
" setupinfo" << endl;
146 struct string_buffer sb;
148 int argc = argv.size();
149 for (
int i = 0; i < argc; i++) {
150 sb_append(&sb, argv[i]);
155 return sb_dupfree(&sb);
164 printf(
"#"); fflush(stdout);
183 FILE *fp = fopen(file,
"w");
186 cerr <<
_(
"Could not open command list file ") << file << endl;
189 fputs(
"#plpftp processlist\n", fp);
191 cerr <<
_(
"Could not get process list, Error: ") << res << endl;
194 for (processList::iterator i = tmp.begin(); i != tmp.end(); i++) {
195 fputs(i->getArgs(), fp);
199 time_t tstart = time(
nullptr) + 5;
200 while (!tmp.empty()) {
201 for (processList::iterator i = tmp.begin(); i != tmp.end(); i++) {
205 if (time(
nullptr) > tstart) {
206 cerr <<
_(
"Could not stop all processes. Please stop running\n"
207 "programs manually on the Psion, then hit return.") << flush;
208 cin.getline((
char *)&tstart, 1);
209 tstart = time(
nullptr) + 5;
212 cerr <<
_(
"Could not get process list, Error: ") << res << endl;
219static char *
get_upto(FILE *fp,
const char *term,
size_t *final_len) {
222 char *l = (
char *)malloc(len), *s = l;
225 for (c = getc(fp); c != EOF && strchr(term, c) == NULL; c = getc(fp)) {
227 l = (
char *)realloc(l, len * 2);
234 l = (
char *)realloc(l, len + 1);
242 l = (
char *)realloc(l, s - l);
253 FILE *fp = fopen(file,
"r");
257 cerr <<
_(
"Could not open command list file ") << file << endl;
260 cmd = string(
getln(fp));
261 if (strcmp(cmd.c_str(),
"#plpftp processlist")) {
263 cerr <<
_(
"Error: ") << file <<
264 _(
" is not a process list saved with killsave") << endl;
267 for (cmd =
string(
getln(fp)); cmd.length() > 0; cmd = string(
getln(fp))) {
268 int firstBlank = cmd.find(
' ');
269 string prog = string(cmd, 0, firstBlank);
270 string arg = string(cmd, firstBlank + 1);
276 if ((arg.size() > 2) && (arg[1] ==
':') && (arg[0] >=
'A') &&
287 if (prog.find(
'\\') == prog.npos) {
291 for (i = 0; i < 26; i++) {
292 if (devbits & (1 << i)) {
293 string tmp = string();
295 tmp +=
":\\System\\Apps\\" + prog +
"\\" + prog +
".app";
305 cerr <<
_(
"Could not start ") << cmd << endl;
306 cerr <<
_(
"Error: ") << res << endl;
315 cerr <<
_(
"Clipboard protocol not supported by Psion Series 3.") << endl;
323 cerr <<
_(
"Your Psion does not support the clipboard protocol.\n\
324 The reason for that is usually a missing server library.\n\
325 Make sure that C:\\System\\Libs\\clipsvr.rsy exists.\n\
326 This file is part of PsiWin and usually gets copied to\n\
327 your Psion when you enable CopyAnywhere in PsiWin.\n\
328 You can also get it from a PsiWin installation directory\n\
329 and copy it to your Psion manually.") << endl;
337 for (p = buf; len; len--, p++)
363 for (p = buf; len; len--, p++)
379static char *
slurp(FILE *fp,
size_t *final_len) {
387 const unsigned char *p;
396 if ((fp = fopen(file,
"r")) == NULL) {
401 data =
slurp(fp, &len);
424 p = (
const unsigned char *)b.
getString(0);
447 char *buf = (
char *)malloc(len);
450 cerr <<
"Out of memory in getClipData" << endl;
457 res =
a.
fread(fh, (
unsigned char *)buf, len, tmp);
463 uint32_t *ti = (uint32_t*)buf;
466 if (*ti++ != 0x10000037) {
470 if (*ti++ != 0x1000003b) {
478 if (*ti++ != 0x4739d53b) {
488 uint32_t *td = (uint32_t*)p;
490 uint32_t sType = *td++;
491 if (sType == 0x10000033) {
494 len = *((uint32_t*)p);
497 clipText += (
char *)p;
499 if (sType == 0x1000003d) {
512 FILE *fp = fopen(file,
"w");
516 fwrite(clipText.c_str(), 1, clipText.length(), fp);
529 if ((f1[strlen(f1) - 1] !=
'/') && (f1[strlen(f1) - 1] !=
'\\')) {
530 char *f2 = xasprintf(
"%s%s", f1,
"\\");
545 unsigned argc = argv.size();
555 cout <<
_(
"Connected to a ") << machType <<
_(
" at ")
556 << speed <<
_(
" baud.") << endl;
561 if (!strcmp(DDRIVE,
"AUTO")) {
571 cout <<
_(
"Psion dir is: \"") <<
psionDir <<
"\"" << endl;
585 if ((!strcmp(argv[0],
"help")) || (!strcmp(argv[0],
"?"))) {
589 if (!strcmp(argv[0],
"prompt")) {
591 cout <<
_(
"Prompting now ") << (prompt?
_(
"on") :
_(
"off")) << endl;
594 if (!strcmp(argv[0],
"hash")) {
596 cout <<
_(
"Hash printing now ") << (hash?
_(
"on") :
_(
"off")) << endl;
600 if (!strcmp(argv[0],
"pwd")) {
601 cout <<
_(
"Local dir: \"") <<
localDir <<
"\"" << endl;
602 cout <<
_(
"Psion dir: \"") <<
psionDir <<
"\"" << endl;
605 if (!strcmp(argv[0],
"volname") && (argc == 3) && (strlen(argv[1]) == 1)) {
607 cerr <<
_(
"Error: ") << res << endl;
611 if (!strcmp(argv[0],
"ren") && (argc == 3)) {
612 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
613 char *f2 = xasprintf(
"%s%s",
psionDir, argv[2]);
615 cerr <<
_(
"Error: ") << res << endl;
621 if (!strcmp(argv[0],
"cp") && (argc == 3)) {
622 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
623 char *f2 = xasprintf(
"%s%s",
psionDir, argv[2]);
625 cerr <<
_(
"Error: ") << res << endl;
631 if (!strcmp(argv[0],
"touch") && (argc == 2)) {
632 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
635 cerr <<
_(
"Error: ") << res << endl;
640 if (!strcmp(argv[0],
"test") && (argc == 2)) {
642 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
644 cerr <<
_(
"Error: ") << res << endl;
651 if (!strcmp(argv[0],
"gattr") && (argc == 2)) {
653 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
655 cerr <<
_(
"Error: ") << res << endl;
657 cout << hex << setw(4) << setfill(
'0') << attr;
658 cout <<
" (" << rfsv.
attr2String(attr) <<
")" << endl;
663 if (!strcmp(argv[0],
"gtime") && (argc == 2)) {
665 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
667 cerr <<
_(
"Error: ") << res << endl;
669 cout << mtime <<
"(" << hex
678 if (!strcmp(argv[0],
"sattr") && (argc == 3)) {
683 char *f1 = xasprintf(
"%s%s",
psionDir, argv[2]);
685 attr[0] = attr[1] = 0;
718 cerr <<
_(
"Error: ") << res << endl;
723 if (!strcmp(argv[0],
"dircnt")) {
726 cerr <<
_(
"Error: ") << res << endl;
728 cout << cnt <<
_(
" Entries") << endl;
732 if (!strcmp(argv[0],
"devs")) {
735 cout <<
_(
"Drive Type Volname Total Free UniqueID") << endl;
736 for (
int i = 0; i < 26; i++) {
739 if ((devbits & 1) != 0) {
741 cout << (char) (
'A' + i) <<
" " << hex
742 << setw(4) << setfill(
'0')
743 <<
static_cast<uint32_t
>(drive.
getMediaType()) <<
" " << setw(12)
744 << setfill(
' ') << setiosflags(ios::left)
746 << resetiosflags(ios::left) << dec << setw(9)
748 << drive.
getSpace() <<
" " << setw(8)
749 << setfill(
'0') << hex << drive.
getUID()
756 cerr <<
_(
"Error: ") << res << endl;
760 if (!strcmp(argv[0],
"ls") || !strcmp(argv[0],
"dir")) {
764 cerr <<
_(
"Error: ") << res << endl;
766 while (!files.empty()) {
767 cout << files[0] << endl;
774 if (!strcmp(argv[0],
"lcd")) {
778 if (chdir(argv[1]) == 0) {
781 cerr <<
_(
"No such directory") << endl
782 <<
_(
"Keeping original directory \"") <<
localDir <<
"\"" << endl;
787 if (!strcmp(argv[0],
"cd")) {
795 cerr <<
_(
"Error: ") << res << endl;
796 cerr <<
_(
"Keeping original directory \"") <<
psionDir <<
"\"" << endl;
805 if ((!strcmp(argv[0],
"get")) && (argc > 1)) {
806 struct timeval stime;
807 struct timeval etime;
812 char *f2 = xasprintf(
"%s%s%s",
localDir,
"/", argc == 2 ? basename.c_str() : argv[2]);
814 gettimeofday(&stime,
nullptr);
820 cerr <<
_(
"Error: ") << res << endl;
824 gettimeofday(&etime,
nullptr);
825 long dsec = etime.tv_sec - stime.tv_sec;
826 long dhse = (etime.tv_usec / 10000) -
827 (stime.tv_usec /10000);
836 float cps = (float)(stbuf.st_size) / dt;
837 cout <<
_(
"Transfer complete, (") << dec << stbuf.st_size
838 <<
_(
" bytes in ") << dsec <<
"."
839 << dhse <<
_(
" secs = ") << cps <<
" cps)\n";
844 }
else if ((!strcmp(argv[0],
"mget")) && (argc == 2)) {
845 char *pattern = argv[1];
848 cerr <<
_(
"Error: ") << res << endl;
851 for (
size_t i = 0; i < files.size(); i++) {
858 if (fnmatch(pattern, e.
getName(), FNM_NOESCAPE) == FNM_NOMATCH) {
861 cout <<
_(
"Get \"") << e.
getName() <<
"\" (y,n): ";
879 cerr <<
_(
"Error: ") << res << endl;
885 cout <<
_(
"Transfer complete\n");
893 if (!strcmp(argv[0],
"put") && (argc >= 2)) {
894 struct timeval stime;
895 struct timeval etime;
898 char *f1 = xasprintf(
"%s%s%s",
localDir,
"/", argv[1]);
899 char *f2 = xasprintf(
"%s%s",
psionDir, argc == 2 ? argv[1] : argv[2]);
900 gettimeofday(&stime,
nullptr);
906 cerr <<
_(
"Error: ") << res << endl;
910 gettimeofday(&etime,
nullptr);
911 long dsec = etime.tv_sec - stime.tv_sec;
912 long dhse = (etime.tv_usec / 10000) -
913 (stime.tv_usec /10000);
922 float cps = (float)(stbuf.st_size) / dt;
923 cout <<
_(
"Transfer complete, (") << dec << stbuf.st_size
924 <<
_(
" bytes in ") << dsec <<
"."
925 << dhse <<
_(
" secs = ") << cps <<
" cps)\n";
931 if ((!strcmp(argv[0],
"mput")) && (argc == 2)) {
932 char *pattern = argv[1];
941 if (fnmatch(pattern, de->d_name, FNM_NOESCAPE) == FNM_NOMATCH) {
944 char *f1 = xasprintf(
"%s%s%s",
localDir,
"/", de->d_name);
945 if (stat(f1, &st) == 0 && S_ISREG(st.st_mode)) {
946 cout <<
_(
"Put \"") << de->d_name <<
"\" y,n: ";
956 char *f2 = xasprintf(
"%s%s",
psionDir, de->d_name);
962 cerr <<
_(
"Error: ") << res << endl;
971 cout <<
_(
"Transfer complete\n");
980 cerr <<
_(
"Error in directory name \"") <<
localDir <<
"\"\n";
984 if ((!strcmp(argv[0],
"del") ||
985 !strcmp(argv[0],
"rm")) && (argc == 2)) {
986 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
988 cerr <<
_(
"Error: ") << res << endl;
993 if (!strcmp(argv[0],
"mkdir") && (argc == 2)) {
994 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
996 cerr <<
_(
"Error: ") << res << endl;
1001 if (!strcmp(argv[0],
"rmdir") && (argc == 2)) {
1002 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
1004 cerr <<
_(
"Error: ") << res << endl;
1009 if (argv[0][0] ==
'!') {
1012 ignore_value(system(cmd));
1015 cout <<
_(
"Starting subshell ...\n");
1016 sh = getenv(
"SHELL");
1020 ignore_value(system(sh));
1026 if (!strcmp(argv[0],
"settime")) {
1028 cerr <<
_(
"Error: ") << res << endl;
1032 if (!strcmp(argv[0],
"setupinfo")) {
1037 cerr <<
_(
"Error: ") << res << endl;
1040 if (db.
getLen() < 1152) {
1041 cerr <<
_(
"Unknown setup info received") << endl;
1044 cout <<
_(
"Setup information:") << endl;
1045 cout <<
_(
" Screen contrast: ") << dec
1047 cout <<
_(
" Keyboard click: ")
1049 (db.
getDWord(0x204) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1050 cout <<
_(
" Screen click: ")
1052 (db.
getDWord(0x210) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1053 cout <<
_(
" Error sound: ")
1055 (db.
getDWord(0x218) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1056 cout <<
_(
" Auto-switch off: ");
1062 cout <<
_(
"if running on battery power");
1065 cout <<
_(
"always");
1070 cout <<
_(
" Switch off after: ") << dec
1071 << db.
getDWord(0x22c) <<
_(
" seconds") << endl;
1072 cout <<
_(
" Backlight off after: ") << dec
1073 << db.
getDWord(0x234) <<
_(
" seconds") << endl;
1074 cout <<
_(
" Switch on when tapping on screen: ")
1075 << (db.
getDWord(0x238) ?
_(
"yes") :
_(
"no")) << endl;
1076 cout <<
_(
" Switch on when opening: ")
1077 << (db.
getDWord(0x23c) ?
_(
"yes") :
_(
"no")) << endl;
1078 cout <<
_(
" Switch off when closing: ")
1079 << (db.
getDWord(0x23c) ?
_(
"yes") :
_(
"no")) << endl;
1080 cout <<
_(
" Ask for password on startup: ")
1081 << (db.
getDWord(0x29c) ?
_(
"yes") :
_(
"no")) << endl;
1082 cout <<
_(
" Show Owner info on startup: ");
1088 cout <<
_(
"once a day");
1091 cout <<
_(
"always");
1097 if (!strcmp(argv[0],
"run") && (argc >= 2)) {
1098 vector<char *> args = {argv.begin() + 1, argv.end()};
1101 if (!strchr(argv[1],
':')) {
1102 cmd = xasprintf(
"%s%s",
psionDir, argv[1]);
1104 cmd = xstrdup(argv[1]);
1111 if (!strcmp(argv[0],
"ownerinfo")) {
1114 cerr <<
_(
"Error: ") << res << endl;
1117 while (!b.
empty()) {
1122 if (!strcmp(argv[0],
"machinfo")) {
1125 cerr <<
_(
"Error: ") << res << endl;
1129 cout <<
_(
"General:") << endl;
1130 cout <<
_(
" Machine Type: ") << mi.
machineType << endl;
1131 cout <<
_(
" Machine Name: ") << mi.
machineName << endl;
1132 cout <<
_(
" Machine UID: ") << hex << mi.
machineUID << dec << endl;
1133 cout <<
_(
" UI Language: ") << mi.
uiLanguage << endl;
1134 cout <<
_(
"ROM:") << endl;
1135 cout <<
_(
" Version: ") << mi.
romMajor <<
"." << setw(2) << setfill(
'0') <<
1137 cout <<
_(
" Size: ") << mi.
romSize / 1024 <<
"k" << endl;
1138 cout <<
_(
" Programmable: ") <<
1140 cout <<
_(
"RAM:") << endl;
1141 cout <<
_(
" Size: ") << mi.
ramSize / 1024 <<
"k" << endl;
1142 cout <<
_(
" Free: ") << mi.
ramFree / 1024 <<
"k" << endl;
1143 cout <<
_(
" Free max: ") << mi.
ramMaxFree / 1024 <<
"k" << endl;
1144 cout <<
_(
"RAM disk size: ") << mi.
ramDiskSize / 1024 <<
"k" << endl;
1148 cout <<
_(
"Time:") << endl;
1150 cout <<
_(
" Current time: ") << pt << endl;
1151 cout <<
_(
" UTC offset: ") << mi.
tz.
utc_offset <<
_(
" seconds") << endl;
1152 cout <<
_(
" DST: ") <<
1155 cout <<
_(
" Country Code: ") << mi.
countryCode << endl;
1156 cout <<
_(
"Main battery:") << endl;
1158 cout <<
_(
" Changed at: ") << pt << endl;
1165 cout <<
_(
"Backup battery:") << endl;
1169 cout <<
_(
"External power:") << endl;
1170 cout <<
_(
" Supplied: ")
1175 if (!strcmp(argv[0],
"runrestore") && (argc == 2)) {
1179 if (!strcmp(argv[0],
"killsave") && (argc == 2)) {
1183 if (!strcmp(argv[0],
"putclip") && (argc == 2)) {
1185 cerr <<
_(
"Error setting clipboard") << endl;
1189 if (!strcmp(argv[0],
"getclip") && (argc == 2)) {
1191 cerr <<
_(
"Error getting clipboard") << endl;
1195 if (!strcmp(argv[0],
"kill") && (argc >= 2)) {
1197 bool anykilled =
false;
1199 cerr <<
_(
"Error: ") << res << endl;
1201 for (
unsigned int i = 1; i < argc; i++) {
1203 if (!strcmp(argv[i],
"all")) {
1206 sscanf(argv[i],
"%d", &kpid);
1208 processList::iterator j;
1209 for (j = tmp.begin(); j != tmp.end(); j++) {
1210 if (kpid == -1 || kpid == j->getPID()) {
1220 cerr <<
_(
"no such process") << endl;
1225 if (!strcmp(argv[0],
"ps")) {
1228 cerr <<
_(
"Error: ") << res << endl;
1230 cout <<
"PID CMD ARGS" << endl;
1231 for (processList::iterator i = tmp.begin(); i != tmp.end(); i++) {
1237 if (strcmp(argv[0],
"bye") == 0 || strcmp(argv[0],
"quit") == 0) {
1240 cerr <<
_(
"syntax error. Try \"help\"") << endl;
1246#define MATCHFUNCTION rl_completion_matches
1249 "pwd",
"ren",
"touch",
"gtime",
"test",
"gattr",
"sattr",
"devs",
1250 "dir",
"ls",
"dircnt",
"cd",
"lcd",
"get",
"put",
"mget",
"mput",
1251 "del",
"rm",
"mkdir",
"rmdir",
"prompt",
"bye",
"cp",
"volname",
1252 "ps",
"kill",
"killsave",
"runrestore",
"run",
"machinfo",
1253 "ownerinfo",
"help",
"settime",
"setupinfo", NULL
1257 "lcd ",
"put ",
"mput ",
"killsave ",
"runrestore ", NULL
1261 "cd ",
"rmdir ", NULL
1281 cerr <<
_(
"Error: ") << res << endl;
1295 if (!(strncmp(tmp.c_str(), text, len))) {
1297 rl_completion_append_character =
'\0';
1300 return (strdup(tmp.c_str()));
1307 static int idx, len;
1316 if (!strncmp(name, text, len)) {
1317 return (strdup(name));
1326 static char null[1] =
"";
1331 char **matches = NULL;
1334 rl_completion_append_character =
' ';
1335 rl_attempted_completion_over = 1;
1343 rl_filename_quoting_desired = 1;
1346 if (!strncmp(name, rl_line_buffer, strlen(name))) {
1347 rl_completion_entry_function = NULL;
1363 if (!strncmp(name, rl_line_buffer, strlen(name))) {
1376 rl_readline_name =
"plpftp";
1379 rl_basic_word_break_characters =
" \t\n\"\\'`@><=;|&{(";
1380 rl_completer_quote_characters =
"\"";
1386 vector<char *> argv;
1400 for (
char *p = buf; *p; p++)
1422 cout <<
"bye" << endl;
1423 buf = strdup(
"bye");
1424 argv.push_back(buf);
An array of BufferStores.
bool empty() const
Checks if this BufferArray is empty.
BufferStore pop(void)
Removes the first BufferStore.
A generic container for an array of bytes.
const char * getString(long pos=0) const
Retrieves the characters at index pos.
uint32_t getDWord(long pos=0) const
Retrieves the dword at index pos.
void addByte(unsigned char c)
Appends a byte to the content of this instance.
void addStringT(const char *s)
Appends a string to the content of this instance.
void addDWord(long dw)
Appends a dword to the content of this instance.
unsigned long getLen() const
Retrieves the length of a BufferStore.
unsigned char getByte(long pos=0) const
Retrieves the byte at index pos.
A class representing information about a Disk drive on the psion.
uint32_t getUID() const
Retrieve the UID of the drive.
MediaType getMediaType() const
Retrieve the media type of the drive.
uint64_t getSpace() const
Retrieve the free capacity on the drive.
uint64_t getSize() const
Retrieve the total capacity of the drive.
std::string getName() const
Retrieve the volume name of the drive.
Wrapper class featuring range-checking and string representation of enumerated values.
std::vector< char * > getCommand()
int session(RFSV &rfsv, RPCS &rpcs, rclip &clipboard, std::vector< char * > argv)
int putClipText(RFSV &a, rclip &rc, const char *data)
bool checkClipConnection(RFSV &a, rclip &rc)
int getClipData(RFSV &a, rclip &rc, const char *file)
A class, representing a directory entry of the Psion.
uint32_t getAttr() const
Retrieves the file attributes of a directory entry.
const char * getName() const
Retrieve the file name of a directory entry.
uint32_t getSize() const
Retrieves the file size of a directory entry.
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.
Access remote file services of a Psion.
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 > 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.
virtual Enum< errs > fgetmtime(const char *const name, PsiTime &mtime)=0
Retrieves the modification time of a file 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 > remove(const char *const name)=0
Removes a file on the Psion.
virtual Enum< errs > fopen(const uint32_t attr, const char *const name, uint32_t &handle)=0
Opens a file.
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).
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 > fsetattr(const char *const name, const uint32_t seta, const uint32_t unseta)=0
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 > fgeteattr(const char *const name, PlpDirent &e)=0
Retrieves attributes, size and modification time of a file 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 > mkdir(const char *const name)=0
Creates a directory on the Psion.
virtual char defaultInternalDriveLetter()=0
virtual Enum< errs > fclose(const uint32_t handle)=0
Close a file on the Psion whih was previously opened/created by using fopen , fcreatefile ,...
Enum< errs > getStatus()
Retrieves the current connection status.
virtual Enum< errs > fgetattr(const char *const name, uint32_t &attr)=0
Retrieves attributes of 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 > dircount(const char *const name, uint32_t &count)=0
Counts number of entries in a directory.
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 > rmdir(const char *const name)=0
Removes a directory on the Psion.
virtual Enum< errs > devlist(uint32_t &devbits)=0
Retrieves available drives on the Psion.
virtual Enum< errs > devinfo(const char drive, Drive &dinfo)=0
Retrieves details about a drive.
static std::string convertSlash(const std::string &name)
Utility method, converts '/' to '\'.
virtual Enum< errs > rename(const char *const oldname, const char *const newname)=0
Renames a file on the Psion.
int getSpeed()
Retrieve speed of serial link.
virtual Enum< errs > copyFromPsion(const char *from, const char *to, void *context, cpCallback_t func)=0
Copies a file from the Psion to the local machine.
@ PSI_A_READ
Attributes, valid on SIBO only.
@ PSI_A_RDONLY
Attributes, valid on both EPOC and SIBO.
Remote procedure call services via PLP.
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 > getMachineInfo(machineInfo &machineInfo)
Retrieve general Information about the connected machine.
virtual Enum< RFSV::errs > configRead(uint32_t size, BufferStore &data)
Read from Series 5 scratch RAM.
Enum< RFSV::errs > stopProgram(const char *program)
Requests termination of a program running on the remote machine.
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 > setTime(time_t time)
Remote ClipBoard services via PLP.
Enum< RFSV::errs > initClipbd()
Send initialization frame.
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 int startPrograms(RPCS &r, RFSV &a, const char *file)
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 &rpcs, const char *file)
static void sigint_handler(int)
char * resolve_epoc_path(const char *path, const char *initialPath)
Returns a new absolute EPOC path, determined by resolving path relative to initialPath.
std::string epoc_basename(std::string path)
Returns the last path component of an EPOC path.
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.
unsigned long mainBatteryUsedPower
Enum< languages > uiLanguage
unsigned long displayHeight
unsigned long mainBatteryVoltage
psi_timeval externalPowerUsedTime
Enum< batterystates > backupBatteryStatus
psi_timeval mainBatteryInsertionTime
Enum< machs > machineType
unsigned long ramDiskSize
unsigned long mainBatteryCurrent
psi_timeval mainBatteryUsedTime
Enum< batterystates > mainBatteryStatus
unsigned long countryCode
unsigned long long machineUID
unsigned long backupBatteryMaxVoltage
unsigned long registrySize
unsigned long displayWidth
unsigned long mainBatteryMaxVoltage
unsigned long backupBatteryVoltage