Skip to content

Commit

Permalink
history save and load
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@924 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
levsa committed Feb 27, 2003
1 parent 8b059de commit 967fd04
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mosh/src/mosh.cpp
Expand Up @@ -80,7 +80,9 @@ int main(int argc, char* argv[])

char* hostname ="localhost";
// TODO: add port nr. and host as command line option


char* historyfile = "mosh_history";
int maxhistoryfileentries = 3000;

/* Create the socket. */
int sock = socket (PF_INET, SOCK_STREAM, 0);
Expand Down Expand Up @@ -121,6 +123,13 @@ int main(int argc, char* argv[])
int cd_nbytes = write(sock,cd_cmd,strlen(cd_cmd)+1);
int cd_recvbytes = read(sock,buf,40000);

// initialize history usage
using_history();

// Read the history file
read_history(historyfile);


bool done=false;
while (!done) {
char* line = readline(">>> ");
Expand All @@ -146,7 +155,12 @@ int main(int argc, char* argv[])
}
free(line);
}
close (sock);
close (sock);

// write history file
write_history(historyfile);
history_truncate_file(historyfile, maxhistoryfileentries);

return EXIT_SUCCESS;
}

Expand Down

0 comments on commit 967fd04

Please sign in to comment.