Blame backend/test1284.c

Packit 2fc92b
/*
Packit 2fc92b
 * IEEE-1284 support functions test program for CUPS.
Packit 2fc92b
 *
Packit 2fc92b
 * Copyright 2007-2010 by Apple Inc.
Packit 2fc92b
 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
Packit 2fc92b
 *
Packit 2fc92b
 * These coded instructions, statements, and computer programs are the
Packit 2fc92b
 * property of Apple Inc. and are protected by Federal copyright
Packit 2fc92b
 * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
Packit 2fc92b
 * "LICENSE" which should have been included with this file.  If this
Packit 2fc92b
 * file is missing or damaged, see the license at "http://www.cups.org/".
Packit 2fc92b
 *
Packit 2fc92b
 * This file is subject to the Apple OS-Developed Software exception.
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
/*
Packit 2fc92b
 * Include necessary headers.
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
#include <cups/string-private.h>
Packit 2fc92b
#ifdef WIN32
Packit 2fc92b
#  include <io.h>
Packit 2fc92b
#else
Packit 2fc92b
#  include <unistd.h>
Packit 2fc92b
#  include <fcntl.h>
Packit 2fc92b
#endif /* WIN32 */
Packit 2fc92b
Packit 2fc92b
#include "ieee1284.c"
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
/*
Packit 2fc92b
 * 'main()' - Test the device-ID functions.
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
int					/* O - Exit status */
Packit 2fc92b
main(int  argc,				/* I - Number of command-line args */
Packit 2fc92b
     char *argv[])			/* I - Command-line arguments */
Packit 2fc92b
{
Packit 2fc92b
  int	i,				/* Looping var */
Packit 2fc92b
	fd;				/* File descriptor */
Packit 2fc92b
  char	device_id[1024],		/* 1284 device ID string */
Packit 2fc92b
	make_model[1024],		/* make-and-model string */
Packit 2fc92b
	uri[1024];			/* URI string */
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
  if (argc < 2)
Packit 2fc92b
  {
Packit 2fc92b
    puts("Usage: test1284 device-file [... device-file-N]");
Packit 2fc92b
    exit(1);
Packit 2fc92b
  }
Packit 2fc92b
Packit 2fc92b
  for (i = 1; i < argc; i ++)
Packit 2fc92b
  {
Packit 2fc92b
    if ((fd = open(argv[i], O_RDWR)) < 0)
Packit 2fc92b
    {
Packit 2fc92b
      perror(argv[i]);
Packit 2fc92b
      return (errno);
Packit 2fc92b
    }
Packit 2fc92b
Packit 2fc92b
    printf("%s:\n", argv[i]);
Packit 2fc92b
Packit 2fc92b
    backendGetDeviceID(fd, device_id, sizeof(device_id), make_model,
Packit 2fc92b
                       sizeof(make_model), "test", uri, sizeof(uri));
Packit 2fc92b
Packit 2fc92b
    printf("    device_id=\"%s\"\n", device_id);
Packit 2fc92b
    printf("    make_model=\"%s\"\n", make_model);
Packit 2fc92b
    printf("    uri=\"%s\"\n", uri);
Packit 2fc92b
Packit 2fc92b
    close(fd);
Packit 2fc92b
  }
Packit 2fc92b
Packit 2fc92b
  return (0);
Packit 2fc92b
}