mdb_argvec.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <mdb/mdb_types.h>
#include <mdb/mdb_argvec.h>
#include <mdb/mdb_string.h>
#include <mdb/mdb_stdlib.h>
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_frame.h>
#include <alloca.h>
void
{
}
void
{
}
}
void
{
warn("failed to grow argument vector");
}
}
}
void
{
}
}
void
{
#ifdef DEBUG
size_t i;
}
#endif
}
void
{
warn("failed to grow argument vector");
}
}
}
static int
{
const char *start;
const char *next;
char error[32];
uint_t i;
for (i = 0; ; i++) {
else
/*
* Record the index of the subopt if a match if found.
*/
goto found;
}
}
return (-1);
break;
}
return (0);
}
static int
{
case MDB_OPT_SETBITS:
break;
case MDB_OPT_CLRBITS:
break;
case MDB_OPT_STR:
warn("string argument required for -%c\n",
return (-1);
}
break;
case MDB_OPT_UINTPTR_SET:
/* FALLTHROUGH */
case MDB_OPT_UINTPTR:
else
break;
case MDB_OPT_UINT64:
else
break;
case MDB_OPT_SUBOPTS:
warn("string argument required for -%c\n",
return (-1);
}
default:
warn("internal: bad opt=%p type=%hx\n",
return (-1);
}
return (0);
}
static const mdb_opt_t *
{
return (optp);
}
return (NULL);
}
static int
{
const char *p;
int i;
int nargs; /* Number of arguments consumed in an iteration */
/*
* Each option must begin with a string argument whose first
* character is '-' and has additional characters afterward.
*/
return (i);
/*
* The special prefix '--' ends option processing.
*/
return (i);
/*
* Locate an option struct whose opt_char field
* matches the current option letter.
*/
warn("illegal option -- %c\n", *p);
return (i);
}
/*
* Require an argument for strings, immediate
* values, subopt-lists and callback functions
* which require arguments.
*/
/*
* More text after the option letter:
* forge a string argument from remainder.
*/
if (p[1] != '\0') {
p += strlen(p) - 1;
nargs = 0;
/*
* Otherwise use the next argv element as
* the argument if there is one.
*/
} else if (++i == argc) {
warn("option requires an "
"argument -- %c\n", *p);
return (i - 1);
} else {
nargs = 1;
}
} else {
nargs = 0;
}
/*
* Perform type-specific handling for this option.
*/
return (i - nargs);
}
}
return (i);
}
int
{
/*
* For simplicity just declare enough options on the stack to handle
* a-z and A-Z and an extra terminator.
*/
int c, i = 0;
break; /* end of options */
}
}
}
/*
* The old adb breakpoint and watchpoint routines did not accept any arguments;
* all characters after the verb were concatenated to form the string callback.
* This utility function concatenates all arguments in argv[] into a single
* string to simplify the implementation of these legacy routines.
*/
char *
{
char *s = NULL;
size_t n = 0;
int i;
for (i = 0; i < argc; i++) {
}
if (n != 0) {
(void) strcat(s, " ");
}
}
return (s);
}