re-format

This commit is contained in:
Doug MacEachern 2005-03-11 21:09:58 +00:00
parent 634ac82d1c
commit 94f842e473
1 changed files with 197 additions and 199 deletions

View File

@ -47,7 +47,6 @@ static char copyright[] =
#include <stropts.h> #include <stropts.h>
#include <unistd.h> #include <unistd.h>
/* /*
* Local static values * Local static values
*/ */
@ -60,7 +59,6 @@ static int Sd = -1; /* stream device descriptor; not open
* if -1 */ * if -1 */
static char ErrMsg[GET_MIB2_ERRMSGL]; /* error message buffer */ static char ErrMsg[GET_MIB2_ERRMSGL]; /* error message buffer */
/* /*
* close_mib2() - close MIB2 access * close_mib2() - close MIB2 access
* *
@ -72,10 +70,7 @@ static char ErrMsg[GET_MIB2_ERRMSGL]; /* error message buffer */
*/ */
int int
close_mib2( close_mib2(char **errmsg)
char **errmsg /* error message buffer return
* address */
)
{ {
*errmsg = ErrMsg; *errmsg = ErrMsg;
if (Sd < 0) { if (Sd < 0) {
@ -115,14 +110,10 @@ close_mib2(
*/ */
int int
get_mib2( get_mib2(struct opthdr **opt,
struct opthdr **opt, /* opthdr struct pointer return char **data,
* address */ int *datalen,
char **data, /* data buffer return address */ char **errmsg)
int *datalen, /* data length return address */
char **errmsg /* error message buffer return
* address */
)
{ {
static struct T_optmgmt_ack *a; /* message ACK pointer */ static struct T_optmgmt_ack *a; /* message ACK pointer */
static struct strbuf c; /* streams control buffer */ static struct strbuf c; /* streams control buffer */
@ -144,8 +135,9 @@ get_mib2(
/* /*
* Open access. Return on error. * Open access. Return on error.
*/ */
if ((err = open_mib2(errmsg))) if ((err = open_mib2(errmsg))) {
return(err); return(err);
}
/* /*
* Set up message request and option. * Set up message request and option.
*/ */
@ -201,17 +193,20 @@ get_mib2(
&& c.len >= sizeof(struct T_optmgmt_ack) && c.len >= sizeof(struct T_optmgmt_ack)
&& a->PRIM_type == T_OPTMGMT_ACK && a->PRIM_type == T_OPTMGMT_ACK
&& a->MGMT_flags == T_SUCCESS && a->MGMT_flags == T_SUCCESS
&& o->len == 0) { && o->len == 0)
{
err = close_mib2(errmsg); err = close_mib2(errmsg);
if (err) if (err) {
return(err); return(err);
}
return(GET_MIB2_EOD); return(GET_MIB2_EOD);
} }
/* /*
* Check for error. * Check for error.
*/ */
if (c.len >= sizeof(struct T_error_ack) if (c.len >= sizeof(struct T_error_ack)
&& e->PRIM_type == T_ERROR_ACK) { && e->PRIM_type == T_ERROR_ACK)
{
(void) sprintf(ErrMsg, (void) sprintf(ErrMsg,
"get_mib2: T_ERROR_ACK: len=%d, TLI=%#x, UNIX=%#x", "get_mib2: T_ERROR_ACK: len=%d, TLI=%#x, UNIX=%#x",
c.len, (int)e->TLI_error, (int)e->UNIX_error); c.len, (int)e->TLI_error, (int)e->UNIX_error);
@ -223,9 +218,11 @@ get_mib2(
if (rc != MOREDATA if (rc != MOREDATA
|| c.len < sizeof(struct T_optmgmt_ack) || c.len < sizeof(struct T_optmgmt_ack)
|| a->PRIM_type != T_OPTMGMT_ACK || a->PRIM_type != T_OPTMGMT_ACK
|| a->MGMT_flags != T_SUCCESS) { || a->MGMT_flags != T_SUCCESS)
{
(void) sprintf(ErrMsg, (void) sprintf(ErrMsg,
"get_mib2: T_OPTMGMT_ACK: rc=%d len=%d type=%#x flags=%#x", "get_mib2: T_OPTMGMT_ACK: "
"rc=%d len=%d type=%#x flags=%#x",
rc, c.len, (int)a->PRIM_type, (int)a->MGMT_flags); rc, c.len, (int)a->PRIM_type, (int)a->MGMT_flags);
return(GET_MIB2_ERR_NODATA); return(GET_MIB2_ERR_NODATA);
} }
@ -234,10 +231,12 @@ get_mib2(
*/ */
if (o->len >= Dbl) { if (o->len >= Dbl) {
Dbl = o->len; Dbl = o->len;
if (Db == NULL) if (Db == NULL) {
Db = (char *)malloc(Dbl); Db = (char *)malloc(Dbl);
else }
else {
Db = (char *)realloc(Db, Dbl); Db = (char *)realloc(Db, Dbl);
}
if (Db == NULL) { if (Db == NULL) {
(void) sprintf(ErrMsg, (void) sprintf(ErrMsg,
"get_mib2: no space for %d byte data buffer", Dbl); "get_mib2: no space for %d byte data buffer", Dbl);
@ -283,10 +282,7 @@ get_mib2(
*/ */
int int
open_mib2( open_mib2(char **errmsg)
char **errmsg /* error message buffer return
* address */
)
{ {
*errmsg = ErrMsg; *errmsg = ErrMsg;
/* /*
@ -318,10 +314,12 @@ open_mib2(
* Allocate a stream message buffer. * Allocate a stream message buffer.
*/ */
Smbl = sizeof(struct opthdr) + sizeof(struct T_optmgmt_req); Smbl = sizeof(struct opthdr) + sizeof(struct T_optmgmt_req);
if (Smbl < (sizeof (struct opthdr) + sizeof(struct T_optmgmt_ack))) if (Smbl < (sizeof (struct opthdr) + sizeof(struct T_optmgmt_ack))) {
Smbl = sizeof (struct opthdr) + sizeof(struct T_optmgmt_ack); Smbl = sizeof (struct opthdr) + sizeof(struct T_optmgmt_ack);
if (Smbl < sizeof(struct T_error_ack)) }
if (Smbl < sizeof(struct T_error_ack)) {
Smbl = sizeof(struct T_error_ack); Smbl = sizeof(struct T_error_ack);
}
if ((Smb = (char *)malloc(Smbl)) == NULL) { if ((Smb = (char *)malloc(Smbl)) == NULL) {
(void) strcpy(ErrMsg, (void) strcpy(ErrMsg,
"open_mib2: no space for stream message buffer"); "open_mib2: no space for stream message buffer");