summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 52fd1aa)
raw | patch | inline | side by side (parent: 52fd1aa)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 14 Jul 2006 08:56:28 +0000 (08:56 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 14 Jul 2006 08:56:28 +0000 (08:56 +0000) |
reset errno to zero before each loop -- Damien.Stuart usi.net
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@853 a5681a0c-68f1-0310-ab6d-d61299d08faa
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@853 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/doc/rrdtool.pod | patch | blob | history | |
program/src/rrd_tool.c | patch | blob | history |
index 0f41607aa1040127a3ae8411f0aba16991fa548c..cd3c785244c065fb1db4202f1d4a039658061a65 100644 (file)
--- a/program/doc/rrdtool.pod
+++ b/program/doc/rrdtool.pod
commands like B<quit, cd, mkdir> and B<ls>. For detailed help on the
server commands type:
- rrdtool help cd|mkdir|ls|quit
+ rrdtool help cd|mkdir|pwd|ls|quit
When a command is completed, RRDtool will print the string 'C<OK>',
followed by timing information of the form B<u:>I<usertime>
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index 5d49042a89aee1c8fe1b44d20c95ebbab3b41286..e91464dfddfc3876a8be3fe7de8f1566b9214d29 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
"\t\tlast, first, info, fetch, tune, resize, xport\n\n";
char help_listremote[] =
- "Valid remote commands: quit, ls, cd, mkdir\n\n";
+ "Valid remote commands: quit, ls, cd, mkdir, pwd\n\n";
char help_create[] =
" * mkdir - creates a new directory\n\n"
"\trrdtool mkdir newdirectoryname\n\n";
+ char help_pwd[] =
+ " * pwd - returns the current working directory\n\n"
+ "\trrdtool pwd\n\n";
+
char help_lic[] =
"RRDtool is distributed under the Terms of the GNU General\n"
"Public License Version 2. (www.gnu.org/copyleft/gpl.html)\n\n"
enum { C_NONE, C_CREATE, C_DUMP, C_INFO, C_RESTORE, C_LAST, C_FIRST,
C_UPDATE, C_FETCH, C_GRAPH, C_TUNE, C_RESIZE, C_XPORT,
- C_QUIT, C_LS, C_CD, C_MKDIR, C_UPDATEV };
+ C_QUIT, C_LS, C_CD, C_MKDIR, C_PWD, C_UPDATEV };
int help_cmd = C_NONE;
help_cmd = C_CD;
else if (!strcmp(cmd,"mkdir"))
help_cmd = C_MKDIR;
+ else if (!strcmp(cmd,"pwd"))
+ help_cmd = C_PWD;
}
fputs(help_main, stdout);
switch (help_cmd)
case C_MKDIR:
fputs(help_mkdir, stdout);
break;
+ case C_PWD:
+ fputs(help_pwd, stdout);
+ break;
}
fputs(help_lic, stdout);
}
#if defined(HAVE_SYS_STAT_H)
struct stat st;
#endif
+ char* cwd; /* To hold current working dir on call to pwd */
+
+ /* Reset errno to 0 before we start.
+ */
+ errno = 0;
if (RemoteMode){
if (argc>1 && strcmp("quit", argv[1]) == 0){
}
return(0);
}
+ if (argc>1 && strcmp("pwd", argv[1]) == 0){
+ if (argc>2){
+ printf("ERROR: invalid parameter count for pwd\n");
+ return(1);
+ }
+ cwd = getcwd(NULL, MAXPATH);
+ if(cwd == NULL) {
+ printf("ERROR: %s\n",rrd_strerror(errno));
+ return(1);
+ }
+ printf("%s\n", cwd);
+ free(cwd);
+ return(0);
+ }
if (argc>1 && strcmp("mkdir", argv[1]) == 0){
if (argc>3){
printf("ERROR: invalid parameter count for mkdir\n");