|
i |
|
This code translates enumerations into strings and back.
It can be used on either the client or server side, but the interface
is declared in the client header.
/*
* DO NOT EDIT THIS FILE (nfsv4-enum.c)
*
* It has been AutoGen-ed Saturday August 12, 2006 at 11:32:10 AM PDT
* From the definitions nfsv4.def
* and the template file autoxdr.tpl
*
* This file has been generated by the AutoXDR AutoGen template suite.
*
* These files are compatible with:
* RFC1831 - Remote Procedure Call Protocol Specification Version 2
* RFC1832 - External Data Representation Standard
* and are intended to be used as a layer on top of the ONC IDL
* in conjunction with RPCGEN.
*
*/
#include <stdio.h>
#include "nfsv4-clhdr.h"
#include "nfsv4.h"
static const char enum_text[224] =
"`%d' is not in NFS4's %s enumeration\n\0"
"`%s' is not in NFS4's %s enumeration\n\0"
"OK\0"
"successful completion\0"
"PERM\0"
"caller is either not privileged or not owner\0"
"NOENT\0"
"No such file or directory\0"
"OMITTED\0"
"operation omitted\0"
"status\0"
"ACCESS4\0";
static char zOops[ 101 ];
typedef struct enum_info {
int eid;
char const* pz_name;
char const* pz_info;
int unused;
} enum_info_t;
/*
* NFS4's status enumeration conversions
*/
static enum_info_t a_nfs4_status_info[] = {
{ 0, enum_text+ 76, enum_text+ 79, 0 },
{ 1, enum_text+101, enum_text+106, 0 },
{ 2, enum_text+151, enum_text+157, 0 },
{ 256, enum_text+183, enum_text+191, 0 }
};
char const*
info_nfs4_status( nfs4_status eid )
{
int lo = 0;
int hi = 3;
int av = (lo + hi)/2;
for (;;)
{
int c = (int)eid - a_nfs4_status_info[ av ].eid;
if (c == 0)
return a_nfs4_status_info[ av ].pz_info;
if (c < 0)
hi = av - 1;
else
lo = av + 1;
if (hi < lo)
break;
av = (lo + hi)/2;
}
snprintf( zOops, 101, enum_text+ 0, eid, enum_text+209 );
return zOops;
}
char const*
name_nfs4_status( nfs4_status eid )
{
int lo = 0;
int hi = 3;
int av = (lo + hi)/2;
for (;;)
{
int c = (int)eid - a_nfs4_status_info[ av ].eid;
if (c == 0)
return a_nfs4_status_info[ av ].pz_name;
if (c < 0)
hi = av - 1;
else
lo = av + 1;
if (hi < lo)
break;
av = (lo + hi)/2;
}
snprintf( zOops, 101, enum_text+ 0, eid, enum_text+209 );
return zOops;
}
nfs4_status
nfs4_status_enum( char const* pz_name )
{
int i = 0;
do
{
char const* pz = a_nfs4_status_info[i].pz_name;
if ((pz != NULL) && (strcmp( pz, pz_name ) == 0))
return a_nfs4_status_info[i].eid;
}
while (++i < 4);
fprintf( stderr, enum_text+ 38, pz_name, enum_text+209 );
return (nfs4_status)-1;
}
char const*
name_nfs4_compound_ops( nfs4_compound_ops op )
{
static char const * const apz_op_names[] = {
enum_text+216 };
int idx = (int)op - 3;
if ((unsigned)idx > 0)
return (char const*)NULL;
return apz_op_names[ idx ];
}
|