本文整理汇总了C++中CHECK_ARGS函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_ARGS函数的具体用法?C++ CHECK_ARGS怎么用?C++ CHECK_ARGS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHECK_ARGS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int args, char **argv) {
RegexIsFunny *regexTest = new RegexIsFunny();
float quantity[4];
float price[5];
if (!CHECK_ARGS(args)) {
std::cerr << "NOT ENOUGH ARGS" << std::endl;
exit (84);
}
for (int i = 1; i < 5; ++i) {
quantity[i - 1] = regexTest->checkQuantity(argv[i]);
}
for (int i = 5; i < 10; ++i) {
price[i - 5] = regexTest->checkPrice(argv[i]);
}
Simplex toto(price, quantity);
toto.algorithm();
toto.display_result(price);
delete regexTest;
return 0;
}
示例2: process_stdout_read
/**
process_stdout_read : 'process -> buf:string -> pos:int -> len:int -> int
<doc>
Read up to [len] bytes in [buf] starting at [pos] from the process stdout.
Returns the number of bytes readed this way. Raise an exception if this
process stdout is closed and no more data is available for reading.
For hxcpp, the input buffer is in bytes, not characters
</doc>
**/
static value process_stdout_read( value vp, value str, value pos, value len ) {
CHECK_ARGS();
gc_enter_blocking();
# ifdef NEKO_WINDOWS
{
DWORD nbytes;
if( !ReadFile(p->oread,buffer_data(buf)+val_int(pos),val_int(len),&nbytes,NULL) )
{
gc_exit_blocking();
return alloc_null();
}
gc_exit_blocking();
return alloc_int(nbytes);
}
# else
int nbytes = read(p->oread,buffer_data(buf) + val_int(pos),val_int(len));
if( nbytes <= 0 )
{
gc_exit_blocking();
alloc_null();
}
gc_exit_blocking();
return alloc_int(nbytes);
# endif
}
示例3: set_counterfile
/* usage: CounterFile path */
MODRET set_counterfile(cmd_rec *cmd) {
config_rec *c;
const char *path;
CHECK_ARGS(cmd, 1);
CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL|CONF_ANON|CONF_DIR);
path = cmd->argv[1];
if (*path != '/') {
CONF_ERROR(cmd, "must be an absolute path");
}
/* In theory, we could open a filehandle on the configured path right
* here, and fail if the file couldn't be created/opened. Then we
* could just stash that filehandle in the cmd_rec. Easy.
*
* However, that would mean that we would have open descriptors for
* vhosts to which the client may not connect. We would also need to
* use pr_fs_get_usable_fd() so that these filehandles don't use the wrong
* fds. Instead, then, we wait to open the filehandles in sess_init(),
* where we know vhost to which the client connected.
*/
c = add_config_param_str(cmd->argv[0], 1, path);
c->flags |= CF_MERGEDOWN;
return PR_HANDLED(cmd);
}
示例4: info_mach_thread_command
static void
info_mach_thread_command (char *args, int from_tty)
{
union
{
struct thread_basic_info basic;
} thread_info_data;
thread_t thread;
kern_return_t result;
unsigned int info_count;
CHECK_ARGS (_("Thread"), args);
sscanf (args, "0x%x", &thread);
printf_unfiltered (_("THREAD_BASIC_INFO\n"));
info_count = THREAD_BASIC_INFO_COUNT;
result = thread_info (thread,
THREAD_BASIC_INFO,
(thread_info_t) & thread_info_data.basic,
&info_count);
MACH_CHECK_ERROR (result);
#if 0
PRINT_FIELD (&thread_info_data.basic, user_time);
PRINT_FIELD (&thread_info_data.basic, system_time);
#endif
PRINT_FIELD (&thread_info_data.basic, cpu_usage);
PRINT_FIELD (&thread_info_data.basic, run_state);
PRINT_FIELD (&thread_info_data.basic, flags);
PRINT_FIELD (&thread_info_data.basic, suspend_count);
PRINT_FIELD (&thread_info_data.basic, sleep_time);
}
示例5: info_mach_ports_command
static void
info_mach_ports_command (char *args, int from_tty)
{
port_name_array_t port_names_data;
port_type_array_t port_types_data;
unsigned int name_count, type_count;
kern_return_t result;
int index;
task_t task;
CHECK_ARGS ("Task", args);
sscanf (args, "0x%x", &task);
result = port_names (task,
&port_names_data,
&name_count, &port_types_data, &type_count);
MACH_CHECK_ERROR (result);
CHECK_FATAL (name_count == type_count);
printf_unfiltered ("Ports for task %#x:\n", task);
for (index = 0; index < name_count; ++index)
{
printf_unfiltered ("port name: %#x, type %#x\n",
port_names_data[index], port_types_data[index]);
}
vm_deallocate (task_self (), (vm_address_t) port_names_data,
(name_count * sizeof (mach_port_t)));
vm_deallocate (task_self (), (vm_address_t) port_types_data,
(type_count * sizeof (mach_port_type_t)));
}
示例6: set_memcacheconnectfailures
/* usage: MemcacheConnectFailures count */
MODRET set_memcacheconnectfailures(cmd_rec *cmd) {
char *ptr = NULL;
config_rec *c;
uint64_t count = 0;
CHECK_ARGS(cmd, 1);
CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);
#ifdef HAVE_STRTOULL
count = strtoull(cmd->argv[1], &ptr, 10);
#else
count = strtoul(cmd->argv[1], &ptr, 10);
#endif /* HAVE_STRTOULL */
if (ptr &&
*ptr) {
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "bad connect failures parameter: ",
cmd->argv[1], NULL));
}
c = add_config_param(cmd->argv[0], 1, NULL);
c->argv[0] = palloc(c->pool, sizeof(uint64_t));
*((uint64_t *) c->argv[0]) = count;
return PR_HANDLED(cmd);
}
示例7: set_countermaxreaderswriters
/* usage:
* CounterMaxReaders max
* CounterMaxWriters max
*/
MODRET set_countermaxreaderswriters(cmd_rec *cmd) {
int count;
config_rec *c;
CHECK_ARGS(cmd, 1);
CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL|CONF_ANON|CONF_DIR);
/* A count of zero means that an unlimited number of readers (or writers),
* as is the default without this module, is in effect.
*/
count = atoi(cmd->argv[1]);
if (count < 0 ||
count > INT_MAX) {
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "invalid number: ", cmd->argv[1],
NULL));
}
c = add_config_param(cmd->argv[0], 1, NULL);
c->argv[0] = pcalloc(c->pool, sizeof(int));
*((int *) c->argv[0]) = count;
c->flags |= CF_MERGEDOWN;
return PR_HANDLED(cmd);
}
示例8: set_modulepath
/* usage: ModulePath path */
MODRET set_modulepath(cmd_rec *cmd) {
int res;
struct stat st;
CHECK_ARGS(cmd, 1);
CHECK_CONF(cmd, CONF_ROOT);
if (pr_fs_valid_path(cmd->argv[1]) < 0)
CONF_ERROR(cmd, "must be an absolute path");
/* Make sure that the configured path is not world-writeable. */
res = pr_fsio_stat(cmd->argv[1], &st);
if (res < 0)
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "error checking '",
cmd->argv[1], "': ", strerror(errno), NULL));
if (!S_ISDIR(st.st_mode))
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, cmd->argv[1], " is not a directory",
NULL));
if (st.st_mode & S_IWOTH)
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, cmd->argv[1], " is world-writable",
NULL));
if (lt_dlsetsearchpath(cmd->argv[1]) < 0)
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "error setting module path: ",
lt_dlerror(), NULL));
dso_module_path = pstrdup(dso_pool, cmd->argv[1]);
return PR_HANDLED(cmd);
}
示例9: set_modulectrlsacls
/* usage: ModuleControlsACLs actions|all allow|deny user|group list */
MODRET set_modulectrlsacls(cmd_rec *cmd) {
#ifdef PR_USE_CTRLS
char *bad_action = NULL, **actions = NULL;
CHECK_ARGS(cmd, 4);
CHECK_CONF(cmd, CONF_ROOT);
actions = ctrls_parse_acl(cmd->tmp_pool, cmd->argv[1]);
if (strcmp(cmd->argv[2], "allow") != 0 &&
strcmp(cmd->argv[2], "deny") != 0)
CONF_ERROR(cmd, "second parameter must be 'allow' or 'deny'");
if (strcmp(cmd->argv[3], "user") != 0 &&
strcmp(cmd->argv[3], "group") != 0)
CONF_ERROR(cmd, "third parameter must be 'user' or 'group'");
bad_action = pr_ctrls_set_module_acls(dso_acttab, dso_pool, actions,
cmd->argv[2], cmd->argv[3], cmd->argv[4]);
if (bad_action != NULL)
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, ": unknown action: '",
bad_action, "'", NULL));
return PR_HANDLED(cmd);
#else
CONF_ERROR(cmd, "requires Controls support (--enable-ctrls)");
#endif
}
示例10: set_tcpservicename
/* usage: TCPServiceName <name> */
MODRET set_tcpservicename(cmd_rec *cmd) {
CHECK_ARGS(cmd, 1);
CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);
add_config_param_str(cmd->argv[0], 1, cmd->argv[1]);
return HANDLED(cmd);
}
示例11: info_mach_task_command
static void
info_mach_task_command (char *args, int from_tty)
{
union
{
struct task_basic_info basic;
struct task_events_info events;
struct task_thread_times_info thread_times;
} task_info_data;
kern_return_t result;
unsigned int info_count;
task_t task;
CHECK_ARGS ("Task", args);
sscanf (args, "0x%x", &task);
printf_unfiltered ("TASK_BASIC_INFO:\n");
info_count = TASK_BASIC_INFO_COUNT;
result = task_info (task,
TASK_BASIC_INFO,
(task_info_t) & task_info_data.basic, &info_count);
MACH_CHECK_ERROR (result);
PRINT_FIELD (&task_info_data.basic, suspend_count);
PRINT_FIELD (&task_info_data.basic, virtual_size);
PRINT_FIELD (&task_info_data.basic, resident_size);
#if 0
PRINT_FIELD (&task_info_data.basic, user_time);
PRINT_FIELD (&task_info_data.basic, system_time);
printf_unfiltered ("\nTASK_EVENTS_INFO:\n");
info_count = TASK_EVENTS_INFO_COUNT;
result = task_info (task,
TASK_EVENTS_INFO,
(task_info_t) & task_info_data.events, &info_count);
MACH_CHECK_ERROR (result);
PRINT_FIELD (&task_info_data.events, faults);
PRINT_FIELD (&task_info_data.events, zero_fills);
PRINT_FIELD (&task_info_data.events, reactivations);
PRINT_FIELD (&task_info_data.events, pageins);
PRINT_FIELD (&task_info_data.events, cow_faults);
PRINT_FIELD (&task_info_data.events, messages_sent);
PRINT_FIELD (&task_info_data.events, messages_received);
#endif
printf_unfiltered ("\nTASK_THREAD_TIMES_INFO:\n");
info_count = TASK_THREAD_TIMES_INFO_COUNT;
result = task_info (task,
TASK_THREAD_TIMES_INFO,
(task_info_t) & task_info_data.thread_times,
&info_count);
MACH_CHECK_ERROR (result);
#if 0
PRINT_FIELD (&task_info_data.thread_times, user_time);
PRINT_FIELD (&task_info_data.thread_times, system_time);
#endif
}
示例12: info_mach_port_command
static void
info_mach_port_command (char *args, int from_tty)
{
task_t task;
mach_port_t port;
CHECK_ARGS ("Task and port", args);
sscanf (args, "0x%x 0x%x", &task, &port);
macosx_debug_port_info (task, port);
}
示例13: set_counterlog
/* usage: CounterLog path|"none" */
MODRET set_counterlog(cmd_rec *cmd) {
CHECK_ARGS(cmd, 1);
CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);
if (pr_fs_valid_path(cmd->argv[1]) < 0) {
CONF_ERROR(cmd, "must be an absolute path");
}
add_config_param_str(cmd->argv[0], 1, cmd->argv[1]);
return PR_HANDLED(cmd);
}
示例14: set_dynmasqrefresh
/* usage: DynMasqRefresh <seconds> */
MODRET set_dynmasqrefresh(cmd_rec *cmd) {
CHECK_CONF(cmd, CONF_ROOT);
CHECK_ARGS(cmd, 1);
dynmasq_timer_interval = atoi(cmd->argv[1]);
if (dynmasq_timer_interval < 1)
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool,
"must be greater than zero: '", cmd->argv[1], "'", NULL));
return PR_HANDLED(cmd);
}
示例15: set_loadmodule
/* usage: LoadModule module */
MODRET set_loadmodule(cmd_rec *cmd) {
CHECK_ARGS(cmd, 1);
CHECK_CONF(cmd, CONF_ROOT);
if (dso_load_module(cmd->argv[1]) < 0)
CONF_ERROR(cmd, pstrcat(cmd->tmp_pool, "error loading module '",
cmd->argv[1], "': ", strerror(errno), NULL));
return PR_HANDLED(cmd);
}