Files
ncpfs/util/nwbprm.c
ncpfs archive import f88460b2e6 Import ncpfs 2.0.9
2026-04-28 20:39:58 +02:00

123 lines
2.3 KiB
C

/*
* nwbprm.c
*
* Delete a property of a bindery object on a NetWare server
*
* Copyright (C) 1996 by Volker Lendecke
*
*/
#include <unistd.h>
#include <stdlib.h>
#include "ncplib.h"
static char *progname;
static void
usage(void)
{
fprintf(stderr, "usage: %s [options] [pattern]\n", progname);
}
static void
help(void)
{
printf("\n");
printf("usage: %s [options]\n", progname);
printf("\n"
"-h Print this help text\n"
"-S server Server name to be used\n"
"-U username Username sent to server\n"
"-P password Use this password\n"
"-n Do not use any password\n"
"-C Don't convert password to uppercase\n"
"\n"
"-o object_name Name of object\n"
"-t type Object type (decimal value)\n"
"-p property Name of property to be deleted\n"
"\n");
}
int
main(int argc, char *argv[])
{
struct ncp_conn *conn;
char *object_name = NULL;
int object_type = -1;
char *property_name = NULL;
long err;
int result = 1;
int opt;
progname = argv[0];
if ((conn = ncp_initialize(&argc, argv, 1, &err)) == NULL)
{
com_err(argv[0], err, "when initializing");
goto finished;
}
while ((opt = getopt(argc, argv, "h?o:t:p:")) != EOF)
{
switch (opt)
{
case 'o':
object_name = optarg;
str_upper(object_name);
break;
case 't':
object_type = atoi(optarg);
break;
case 'p':
property_name = optarg;
if (strlen(property_name) > 15)
{
fprintf(stderr, "%s: Property Name too long\n",
argv[0]);
exit(1);
}
str_upper(property_name);
break;
case 'h':
case '?':
help();
goto finished;
default:
usage();
goto finished;
}
}
if (object_type < 0)
{
fprintf(stderr, "%s: You must specify an object type\n",
argv[0]);
goto finished;
}
if (object_name == NULL)
{
fprintf(stderr, "%s: You must specify an object name\n",
argv[0]);
goto finished;
}
if (property_name == NULL)
{
fprintf(stderr, "%s: You must specify a property name\n",
argv[0]);
goto finished;
}
if (ncp_delete_property(conn, object_type, object_name,
property_name) != 0)
{
fprintf(stderr, "%s: Could not delete the property\n", argv[0]);
} else
{
result = 0;
}
finished:
ncp_close(conn);
return result;
}