Files
ncpfs/util/pqlist.c
ncpfs archive import 7bef99df0f Import ncpfs 0.14
2026-04-28 20:39:57 +02:00

76 lines
1.2 KiB
C

/*
* pqlist.c
*
* List all print queues on a server
*
* Copyright (C) 1996 by Volker Lendecke
*
*/
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include "ncplib.h"
int
main(int argc, char **argv)
{
struct ncp_conn conn;
struct ncp_bindery_object q;
int found = 0;
char default_pattern[] = "*";
char *pattern = default_pattern;
char *p;
if (ncp_initialize(&conn, &argc, argv, 1) != 0)
{
perror("Could not open connection");
return 1;
}
if (argc > 2)
{
fprintf(stderr, "usage: %s [options] [pattern]\n", argv[0]);
return 1;
}
if (argc == 2)
{
pattern = argv[1];
}
for (p = pattern; *p != '\0'; p++)
{
*p = toupper(*p);
}
if (isatty(1))
{
printf("\nServer: %s\n", conn.server);
printf("%-52s%-10s\n"
"-----------------------------------------------"
"-------------\n",
"Print queue name",
"Queue ID");
}
q.object_id = 0xffffffff;
while (ncp_scan_bindery_object(&conn, q.object_id,
NCP_BINDERY_PQUEUE, "*", &q) == 0)
{
found = 1;
printf("%-52s", q.object_name);
printf("%08x\n", q.object_id);
}
if ((found == 0) && (isatty(1)))
{
printf("No queues found\n");
}
ncp_close(&conn);
return 0;
}