[asterisk-commits] junky: branch group/res_clialiases r145071 - in /team/group/res_clialiases: m...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Sep 28 13:03:10 CDT 2008
Author: junky
Date: Sun Sep 28 13:03:09 2008
New Revision: 145071
URL: http://svn.digium.com/view/asterisk?view=rev&rev=145071
Log:
changed the ulimit to keywords instead of real ulimit args.
i leave the limit in the struct limits, just to know the hashmap.
these keywords were decided by the cli crew @devcon
Modified:
team/group/res_clialiases/main/cli.c
team/group/res_clialiases/res/res_limit.c
Modified: team/group/res_clialiases/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/main/cli.c?view=diff&rev=145071&r1=145070&r2=145071
==============================================================================
--- team/group/res_clialiases/main/cli.c (original)
+++ team/group/res_clialiases/main/cli.c Sun Sep 28 13:03:09 2008
@@ -1341,7 +1341,7 @@
/*!
* \brief locate a cli command in the 'helpers' list (which must be locked).
- * exact has 3 values:
+ * Argument match_type has 3 values:
* 0 returns if the search key is equal or longer than the entry.
* note that trailing optional arguments are skipped.
* -1 true if the mismatch is on the last word XXX not true!
@@ -1389,6 +1389,7 @@
cand = e;
}
}
+
return e ? e : cand;
}
Modified: team/group/res_clialiases/res/res_limit.c
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/res/res_limit.c?view=diff&rev=145071&r1=145070&r2=145071
==============================================================================
--- team/group/res_clialiases/res/res_limit.c (original)
+++ team/group/res_clialiases/res/res_limit.c Sun Sep 28 13:03:09 2008
@@ -44,22 +44,23 @@
int resource;
char limit[3];
char desc[40];
+ char clicmd[15];
} limits[] = {
- { RLIMIT_CPU, "-t", "cpu time" },
- { RLIMIT_FSIZE, "-f", "file size" },
- { RLIMIT_DATA, "-d", "program data segment" },
- { RLIMIT_STACK, "-s", "program stack size" },
- { RLIMIT_CORE, "-c", "core file size" },
-#ifdef RLIMIT_RSS
- { RLIMIT_RSS, "-m", "resident memory" },
- { RLIMIT_MEMLOCK, "-l", "amount of memory locked into RAM" },
-#endif
-#ifdef RLIMIT_NPROC
- { RLIMIT_NPROC, "-u", "number of processes" },
-#endif
- { RLIMIT_NOFILE, "-n", "number of file descriptors" },
+ { RLIMIT_CPU, "-t", "cpu time", "time" },
+ { RLIMIT_FSIZE, "-f", "file size" , "file" },
+ { RLIMIT_DATA, "-d", "program data segment", "data" },
+ { RLIMIT_STACK, "-s", "program stack size", "stack" },
+ { RLIMIT_CORE, "-c", "core file size", "core" },
+#ifdef RLIMIT_RSS
+ { RLIMIT_RSS, "-m", "resident memory", "memory" },
+ { RLIMIT_MEMLOCK, "-l", "amount of memory locked into RAM", "locked" },
+#endif
+#ifdef RLIMIT_NPROC
+ { RLIMIT_NPROC, "-u", "number of processes", "processes" },
+#endif
+ { RLIMIT_NOFILE, "-n", "number of file descriptors", "descriptors" },
#ifdef VMEM_DEF
- { VMEM_DEF, "-v", "virtual memory" },
+ { VMEM_DEF, "-v", "virtual memory", "virtual" },
#endif
};
@@ -67,7 +68,7 @@
{
size_t i;
for (i = 0; i < ARRAY_LEN(limits); i++) {
- if (!strcasecmp(string, limits[i].limit))
+ if (!strcasecmp(string, limits[i].clicmd))
return limits[i].resource;
}
return -1;
@@ -77,7 +78,7 @@
{
size_t i;
for (i = 0; i < ARRAY_LEN(limits); i++) {
- if (!strcmp(string, limits[i].limit))
+ if (!strcmp(string, limits[i].clicmd))
return limits[i].desc;
}
return "<unknown>";
@@ -91,9 +92,9 @@
if (a->pos > 1)
return NULL;
for (i = 0; i < ARRAY_LEN(limits); i++) {
- if (!strncasecmp(limits[i].limit, a->word, wordlen)) {
+ if (!strncasecmp(limits[i].clicmd, a->word, wordlen)) {
if (++which > a->n)
- return ast_strdup(limits[i].limit);
+ return ast_strdup(limits[i].clicmd);
}
}
return NULL;
@@ -108,41 +109,41 @@
case CLI_INIT:
e->command = "ulimit";
e->usage =
- "Usage: ulimit {-d|"
-#ifdef RLIMIT_RSS
- "-l|"
-#endif
- "-f|"
-#ifdef RLIMIT_RSS
- "-m|"
-#endif
- "-s|-t|"
-#ifdef RLIMIT_NPROC
- "-u|"
+ "Usage: ulimit {data|"
+#ifdef RLIMIT_RSS
+ "limit|"
+#endif
+ "file|"
+#ifdef RLIMIT_RSS
+ "memory|"
+#endif
+ "stack|time|"
+#ifdef RLIMIT_NPROC
+ "processes|"
#endif
#ifdef VMEM_DEF
- "-v|"
-#endif
- "-c|-n} [<num>]\n"
+ "virtual|"
+#endif
+ "core|descriptors} [<num>]\n"
" Shows or sets the corresponding resource limit.\n"
- " -d Process data segment [readonly]\n"
-#ifdef RLIMIT_RSS
- " -l Memory lock size [readonly]\n"
-#endif
- " -f File size\n"
-#ifdef RLIMIT_RSS
- " -m Process resident memory [readonly]\n"
-#endif
- " -s Process stack size [readonly]\n"
- " -t CPU usage [readonly]\n"
-#ifdef RLIMIT_NPROC
- " -u Child processes\n"
+ " data Process data segment [readonly]\n"
+#ifdef RLIMIT_RSS
+ " lock Memory lock size [readonly]\n"
+#endif
+ " file File size\n"
+#ifdef RLIMIT_RSS
+ " memory Process resident memory [readonly]\n"
+#endif
+ " stack Process stack size [readonly]\n"
+ " time CPU usage [readonly]\n"
+#ifdef RLIMIT_NPROC
+ " processes Child processes\n"
#endif
#ifdef VMEM_DEF
- " -v Process virtual memory [readonly]\n"
-#endif
- " -c Core dump file size\n"
- " -n Number of file descriptors\n";
+ " virtual Process virtual memory [readonly]\n"
+#endif
+ " core Core dump file size\n"
+ " descriptors Number of file descriptors\n";
return NULL;
case CLI_GENERATE:
return complete_ulimit(a);
@@ -152,11 +153,11 @@
return CLI_SHOWUSAGE;
if (a->argc == 1) {
- char arg2[3];
+ char arg2[15];
char *newargv[2] = { "ulimit", arg2 };
for (resource = 0; resource < ARRAY_LEN(limits); resource++) {
struct ast_cli_args newArgs = { .argv = newargv, .argc = 2 };
- ast_copy_string(arg2, limits[resource].limit, sizeof(arg2));
+ ast_copy_string(arg2, limits[resource].clicmd, sizeof(arg2));
handle_cli_ulimit(e, CLI_HANDLER, &newArgs);
}
return CLI_SUCCESS;
More information about the asterisk-commits
mailing list