Files
ncpfs/util/nwborm.c
ncpfs archive import b8d830f9a3 Import ncpfs 2.0.1
2026-04-28 20:39:58 +02:00

106 lines
1.9 KiB
C

/*
* nwborm.c
*
* Destroy a bindery object on a NetWare server
*
* Copyright (C) 1996 by Volker Lendecke
*
*/
#include "ncplib.h"
#include <unistd.h>
#include <stdlib.h>
static char *progname;
static void
usage(void)
{
fprintf(stderr, "usage: %s [options]\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 to be removed\n"
"-t type Object type (decimal value)\n"
"\n");
}
int
main(int argc, char *argv[])
{
struct ncp_conn *conn;
char *object_name = NULL;
int object_type = -1;
long err;
int result = 1;
int opt;
progname = argv[0];
if ((conn = ncp_initialize(&argc, argv, 1, &err)) == NULL)
{
com_err(argv[0], err, "in ncp_initialize");
goto finished;
}
while ((opt = getopt(argc, argv, "ho:t:")) != EOF)
{
switch(opt) {
case 'o':
object_name = optarg;
str_upper(object_name);
break;
case 't':
object_type = atoi(optarg);
break;
case 'h':
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 (ncp_delete_bindery_object(conn, object_type, object_name) != 0)
{
fprintf(stderr, "%s: Could not delete the object\n", argv[0]);
}
else
{
result = 0;
}
finished:
ncp_close(conn);
return result;
}