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();
557 cout <<
_(
"Connected to a ") << machType <<
_(
" at ")
558 << speed <<
_(
" baud, OwnerInfo:") << endl;
565 cerr <<
_(
"OwnerInfo returned error ") << res << endl;
569 if (!strcmp(DDRIVE,
"AUTO")) {
579 cout <<
_(
"Psion dir is: \"") <<
psionDir <<
"\"" << endl;
593 if ((!strcmp(argv[0],
"help")) || (!strcmp(argv[0],
"?"))) {
597 if (!strcmp(argv[0],
"prompt")) {
599 cout <<
_(
"Prompting now ") << (prompt?
_(
"on") :
_(
"off")) << endl;
602 if (!strcmp(argv[0],
"hash")) {
604 cout <<
_(
"Hash printing now ") << (hash?
_(
"on") :
_(
"off")) << endl;
608 if (!strcmp(argv[0],
"pwd")) {
609 cout <<
_(
"Local dir: \"") <<
localDir <<
"\"" << endl;
610 cout <<
_(
"Psion dir: \"") <<
psionDir <<
"\"" << endl;
613 if (!strcmp(argv[0],
"volname") && (argc == 3) && (strlen(argv[1]) == 1)) {
615 cerr <<
_(
"Error: ") << res << endl;
619 if (!strcmp(argv[0],
"ren") && (argc == 3)) {
620 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
621 char *f2 = xasprintf(
"%s%s",
psionDir, argv[2]);
623 cerr <<
_(
"Error: ") << res << endl;
629 if (!strcmp(argv[0],
"cp") && (argc == 3)) {
630 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
631 char *f2 = xasprintf(
"%s%s",
psionDir, argv[2]);
633 cerr <<
_(
"Error: ") << res << endl;
639 if (!strcmp(argv[0],
"touch") && (argc == 2)) {
640 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
643 cerr <<
_(
"Error: ") << res << endl;
648 if (!strcmp(argv[0],
"test") && (argc == 2)) {
650 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
652 cerr <<
_(
"Error: ") << res << endl;
659 if (!strcmp(argv[0],
"gattr") && (argc == 2)) {
661 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
663 cerr <<
_(
"Error: ") << res << endl;
665 cout << hex << setw(4) << setfill(
'0') << attr;
666 cout <<
" (" << rfsv.
attr2String(attr) <<
")" << endl;
671 if (!strcmp(argv[0],
"gtime") && (argc == 2)) {
673 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
675 cerr <<
_(
"Error: ") << res << endl;
677 cout << mtime <<
"(" << hex
686 if (!strcmp(argv[0],
"sattr") && (argc == 3)) {
691 char *f1 = xasprintf(
"%s%s",
psionDir, argv[2]);
693 attr[0] = attr[1] = 0;
726 cerr <<
_(
"Error: ") << res << endl;
731 if (!strcmp(argv[0],
"dircnt")) {
734 cerr <<
_(
"Error: ") << res << endl;
736 cout << cnt <<
_(
" Entries") << endl;
740 if (!strcmp(argv[0],
"devs")) {
743 cout <<
_(
"Drive Type Volname Total Free UniqueID") << endl;
744 for (
int i = 0; i < 26; i++) {
747 if ((devbits & 1) != 0) {
749 cout << (char) (
'A' + i) <<
" " << hex
750 << setw(4) << setfill(
'0')
751 <<
static_cast<uint32_t
>(drive.
getMediaType()) <<
" " << setw(12)
752 << setfill(
' ') << setiosflags(ios::left)
754 << resetiosflags(ios::left) << dec << setw(9)
756 << drive.
getSpace() <<
" " << setw(8)
757 << setfill(
'0') << hex << drive.
getUID()
764 cerr <<
_(
"Error: ") << res << endl;
768 if (!strcmp(argv[0],
"ls") || !strcmp(argv[0],
"dir")) {
772 cerr <<
_(
"Error: ") << res << endl;
774 while (!files.empty()) {
775 cout << files[0] << endl;
782 if (!strcmp(argv[0],
"lcd")) {
786 if (chdir(argv[1]) == 0) {
789 cerr <<
_(
"No such directory") << endl
790 <<
_(
"Keeping original directory \"") <<
localDir <<
"\"" << endl;
795 if (!strcmp(argv[0],
"cd")) {
803 cerr <<
_(
"Error: ") << res << endl;
804 cerr <<
_(
"Keeping original directory \"") <<
psionDir <<
"\"" << endl;
813 if ((!strcmp(argv[0],
"get")) && (argc > 1)) {
814 struct timeval stime;
815 struct timeval etime;
820 char *f2 = xasprintf(
"%s%s%s",
localDir,
"/", argc == 2 ? basename.c_str() : argv[2]);
822 gettimeofday(&stime,
nullptr);
828 cerr <<
_(
"Error: ") << res << endl;
832 gettimeofday(&etime,
nullptr);
833 long dsec = etime.tv_sec - stime.tv_sec;
834 long dhse = (etime.tv_usec / 10000) -
835 (stime.tv_usec /10000);
844 float cps = (float)(stbuf.st_size) / dt;
845 cout <<
_(
"Transfer complete, (") << dec << stbuf.st_size
846 <<
_(
" bytes in ") << dsec <<
"."
847 << dhse <<
_(
" secs = ") << cps <<
" cps)\n";
852 }
else if ((!strcmp(argv[0],
"mget")) && (argc == 2)) {
853 char *pattern = argv[1];
856 cerr <<
_(
"Error: ") << res << endl;
859 for (
size_t i = 0; i < files.size(); i++) {
866 if (fnmatch(pattern, e.
getName(), FNM_NOESCAPE) == FNM_NOMATCH) {
869 cout <<
_(
"Get \"") << e.
getName() <<
"\" (y,n): ";
887 cerr <<
_(
"Error: ") << res << endl;
893 cout <<
_(
"Transfer complete\n");
901 if (!strcmp(argv[0],
"put") && (argc >= 2)) {
902 struct timeval stime;
903 struct timeval etime;
906 char *f1 = xasprintf(
"%s%s%s",
localDir,
"/", argv[1]);
907 char *f2 = xasprintf(
"%s%s",
psionDir, argc == 2 ? argv[1] : argv[2]);
908 gettimeofday(&stime,
nullptr);
914 cerr <<
_(
"Error: ") << res << endl;
918 gettimeofday(&etime,
nullptr);
919 long dsec = etime.tv_sec - stime.tv_sec;
920 long dhse = (etime.tv_usec / 10000) -
921 (stime.tv_usec /10000);
930 float cps = (float)(stbuf.st_size) / dt;
931 cout <<
_(
"Transfer complete, (") << dec << stbuf.st_size
932 <<
_(
" bytes in ") << dsec <<
"."
933 << dhse <<
_(
" secs = ") << cps <<
" cps)\n";
939 if ((!strcmp(argv[0],
"mput")) && (argc == 2)) {
940 char *pattern = argv[1];
949 if (fnmatch(pattern, de->d_name, FNM_NOESCAPE) == FNM_NOMATCH) {
952 char *f1 = xasprintf(
"%s%s%s",
localDir,
"/", de->d_name);
953 if (stat(f1, &st) == 0 && S_ISREG(st.st_mode)) {
954 cout <<
_(
"Put \"") << de->d_name <<
"\" y,n: ";
964 char *f2 = xasprintf(
"%s%s",
psionDir, de->d_name);
970 cerr <<
_(
"Error: ") << res << endl;
979 cout <<
_(
"Transfer complete\n");
988 cerr <<
_(
"Error in directory name \"") <<
localDir <<
"\"\n";
992 if ((!strcmp(argv[0],
"del") ||
993 !strcmp(argv[0],
"rm")) && (argc == 2)) {
994 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
996 cerr <<
_(
"Error: ") << res << endl;
1001 if (!strcmp(argv[0],
"mkdir") && (argc == 2)) {
1002 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
1004 cerr <<
_(
"Error: ") << res << endl;
1009 if (!strcmp(argv[0],
"rmdir") && (argc == 2)) {
1010 char *f1 = xasprintf(
"%s%s",
psionDir, argv[1]);
1012 cerr <<
_(
"Error: ") << res << endl;
1017 if (argv[0][0] ==
'!') {
1020 ignore_value(system(cmd));
1023 cout <<
_(
"Starting subshell ...\n");
1024 sh = getenv(
"SHELL");
1028 ignore_value(system(sh));
1034 if (!strcmp(argv[0],
"settime")) {
1036 cerr <<
_(
"Error: ") << res << endl;
1040 if (!strcmp(argv[0],
"setupinfo")) {
1045 cerr <<
_(
"Error: ") << res << endl;
1048 if (db.
getLen() < 1152) {
1049 cerr <<
_(
"Unknown setup info received") << endl;
1052 cout <<
_(
"Setup information:") << endl;
1053 cout <<
_(
" Screen contrast: ") << dec
1055 cout <<
_(
" Keyboard click: ")
1057 (db.
getDWord(0x204) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1058 cout <<
_(
" Screen click: ")
1060 (db.
getDWord(0x210) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1061 cout <<
_(
" Error sound: ")
1063 (db.
getDWord(0x218) ?
_(
"high") :
_(
"low")) :
_(
"off")) << endl;
1064 cout <<
_(
" Auto-switch off: ");
1070 cout <<
_(
"if running on battery power");
1073 cout <<
_(
"always");
1078 cout <<
_(
" Switch off after: ") << dec
1079 << db.
getDWord(0x22c) <<
_(
" seconds") << endl;
1080 cout <<
_(
" Backlight off after: ") << dec
1081 << db.
getDWord(0x234) <<
_(
" seconds") << endl;
1082 cout <<
_(
" Switch on when tapping on screen: ")
1083 << (db.
getDWord(0x238) ?
_(
"yes") :
_(
"no")) << endl;
1084 cout <<
_(
" Switch on when opening: ")
1085 << (db.
getDWord(0x23c) ?
_(
"yes") :
_(
"no")) << endl;
1086 cout <<
_(
" Switch off when closing: ")
1087 << (db.
getDWord(0x23c) ?
_(
"yes") :
_(
"no")) << endl;
1088 cout <<
_(
" Ask for password on startup: ")
1089 << (db.
getDWord(0x29c) ?
_(
"yes") :
_(
"no")) << endl;
1090 cout <<
_(
" Show Owner info on startup: ");
1096 cout <<
_(
"once a day");
1099 cout <<
_(
"always");
1105 if (!strcmp(argv[0],
"run") && (argc >= 2)) {
1106 vector<char *> args = {argv.begin() + 1, argv.end()};
1109 if (!strchr(argv[1],
':')) {
1110 cmd = xasprintf(
"%s%s",
psionDir, argv[1]);
1112 cmd = xstrdup(argv[1]);
1119 if (!strcmp(argv[0],
"ownerinfo")) {
1122 cerr <<
_(
"Error: ") << res << endl;
1125 while (!b.
empty()) {
1130 if (!strcmp(argv[0],
"machinfo")) {
1133 cerr <<
_(
"Error: ") << res << endl;
1137 cout <<
_(
"General:") << endl;
1138 cout <<
_(
" Machine Type: ") << mi.
machineType << endl;
1139 cout <<
_(
" Machine Name: ") << mi.
machineName << endl;
1140 cout <<
_(
" Machine UID: ") << hex << mi.
machineUID << dec << endl;
1141 cout <<
_(
" UI Language: ") << mi.
uiLanguage << endl;
1142 cout <<
_(
"ROM:") << endl;
1143 cout <<
_(
" Version: ") << mi.
romMajor <<
"." << setw(2) << setfill(
'0') <<
1145 cout <<
_(
" Size: ") << mi.
romSize / 1024 <<
"k" << endl;
1146 cout <<
_(
" Programmable: ") <<
1148 cout <<
_(
"RAM:") << endl;
1149 cout <<
_(
" Size: ") << mi.
ramSize / 1024 <<
"k" << endl;
1150 cout <<
_(
" Free: ") << mi.
ramFree / 1024 <<
"k" << endl;
1151 cout <<
_(
" Free max: ") << mi.
ramMaxFree / 1024 <<
"k" << endl;
1152 cout <<
_(
"RAM disk size: ") << mi.
ramDiskSize / 1024 <<
"k" << endl;
1156 cout <<
_(
"Time:") << endl;
1158 cout <<
_(
" Current time: ") << pt << endl;
1159 cout <<
_(
" UTC offset: ") << mi.
tz.
utc_offset <<
_(
" seconds") << endl;
1160 cout <<
_(
" DST: ") <<
1163 cout <<
_(
" Country Code: ") << mi.
countryCode << endl;
1164 cout <<
_(
"Main battery:") << endl;
1166 cout <<
_(
" Changed at: ") << pt << endl;
1173 cout <<
_(
"Backup battery:") << endl;
1177 cout <<
_(
"External power:") << endl;
1178 cout <<
_(
" Supplied: ")
1183 if (!strcmp(argv[0],
"runrestore") && (argc == 2)) {
1187 if (!strcmp(argv[0],
"killsave") && (argc == 2)) {
1191 if (!strcmp(argv[0],
"putclip") && (argc == 2)) {
1193 cerr <<
_(
"Error setting clipboard") << endl;
1197 if (!strcmp(argv[0],
"getclip") && (argc == 2)) {
1199 cerr <<
_(
"Error getting clipboard") << endl;
1203 if (!strcmp(argv[0],
"kill") && (argc >= 2)) {
1205 bool anykilled =
false;
1207 cerr <<
_(
"Error: ") << res << endl;
1209 for (
unsigned int i = 1; i < argc; i++) {
1211 if (!strcmp(argv[i],
"all")) {
1214 sscanf(argv[i],
"%d", &kpid);
1216 processList::iterator j;
1217 for (j = tmp.begin(); j != tmp.end(); j++) {
1218 if (kpid == -1 || kpid == j->getPID()) {
1228 cerr <<
_(
"no such process") << endl;
1233 if (!strcmp(argv[0],
"ps")) {
1236 cerr <<
_(
"Error: ") << res << endl;
1238 cout <<
"PID CMD ARGS" << endl;
1239 for (processList::iterator i = tmp.begin(); i != tmp.end(); i++) {
1245 if (strcmp(argv[0],
"bye") == 0 || strcmp(argv[0],
"quit") == 0) {
1248 cerr <<
_(
"syntax error. Try \"help\"") << endl;
1254#define MATCHFUNCTION rl_completion_matches
1257 "pwd",
"ren",
"touch",
"gtime",
"test",
"gattr",
"sattr",
"devs",
1258 "dir",
"ls",
"dircnt",
"cd",
"lcd",
"get",
"put",
"mget",
"mput",
1259 "del",
"rm",
"mkdir",
"rmdir",
"prompt",
"bye",
"cp",
"volname",
1260 "ps",
"kill",
"killsave",
"runrestore",
"run",
"machinfo",
1261 "ownerinfo",
"help",
"settime",
"setupinfo", NULL
1265 "lcd ",
"put ",
"mput ",
"killsave ",
"runrestore ", NULL
1269 "cd ",
"rmdir ", NULL
1289 cerr <<
_(
"Error: ") << res << endl;
1303 if (!(strncmp(tmp.c_str(), text, len))) {
1305 rl_completion_append_character =
'\0';
1308 return (strdup(tmp.c_str()));
1315 static int idx, len;
1324 if (!strncmp(name, text, len)) {
1325 return (strdup(name));
1334 static char null[1] =
"";
1339 char **matches = NULL;
1342 rl_completion_append_character =
' ';
1343 rl_attempted_completion_over = 1;
1351 rl_filename_quoting_desired = 1;
1354 if (!strncmp(name, rl_line_buffer, strlen(name))) {
1355 rl_completion_entry_function = NULL;
1371 if (!strncmp(name, rl_line_buffer, strlen(name))) {
1384 rl_readline_name =
"plpftp";
1387 rl_basic_word_break_characters =
" \t\n\"\\'`@><=;|&{(";
1388 rl_completer_quote_characters =
"\"";
1394 vector<char *> argv;
1408 for (
char *p = buf; *p; p++)
1430 cout <<
"bye" << endl;
1431 buf = strdup(
"bye");
1432 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