lpd-query.c revision 355b4669e025ff377602b6fc7caaf30dbc218371
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: lpd-query.c 155 2006-04-26 02:34:54Z ktou $ */
#pragma ident "%Z%%M% %I% %E% SMI"
#define __EXTENSIONS__ /* for strtok_r() */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <papi_impl.h>
static void
{
char line[128];
char *p;
int octets = 0;
return;
/*
* 1st line...
* user: rank [job (ID)(host)]\n
*/
return; /* invalid format */
"job-originating-user-name", p);
return;
while (isspace(*p)) p++;
"job-id", atoi(p));
while (isdigit(*(++p)));
while (isspace(*p)) p++;
"job-originating-host-name", p);
/*
* rest-o-lines
* [(num) copies of ]file size bytes\n
*/
char *q;
/* find the number of copies */
p += 9;
} else {
copies = 1;
p = line;
}
"copies", copies);
/* eat the leading whitespace */
while (isspace(*p) != 0)
p++;
/* back up to the beginning of the size */
do { q--; } while (isdigit(*q) != 0);
/* seperate the name and size */
*q = '\0';
q++;
PAPI_ATTR_APPEND, "job-name", p);
PAPI_ATTR_APPEND, "job-file-names", p);
}
}
"job-octets", octets);
}
static void
{
do {
}
void
{
char line[128];
char buf[1024];
/* get the status line */
return; /* this should not happen. */
"printer-uri-supported", buf);
"printer-state-reasons", line);
else
"printer-state", state);
return;
== NULL)
return;
/* get the jobs */
}
}
void
{
int fd;
return;
return;
return;
}
{
return (PAPI_BAD_ARGUMENT);
} else
return (result);
}
{
}
}
return (result);
}
{
int i;
int id = -1;
"job-id", &id);
}
}
return (result);
}
void
{
}
}