File: check.c

package info (click to toggle)
cups-filters 1.0.18-2.1%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,632 kB
  • sloc: ansic: 26,569; cpp: 20,175; makefile: 652; sh: 406; perl: 73; php: 28; python: 8
file content (111 lines) | stat: -rw-r--r-- 2,284 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * "$Id$"
 *
 *   Byte checking routines for CUPS.
 *
 *   Copyright 2007 by Apple Inc.
 *   Copyright 1993-2005 by Easy Software Products.
 *
 *   These coded instructions, statements, and computer programs are the
 *   property of Apple Inc. and are protected by Federal copyright
 *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
 *   which should have been included with this file.  If this file is
 *   file is missing or damaged, see the license at "http://www.cups.org/".
 *
 * Contents:
 *
 *   cupsCheckBytes() - Check to see if all bytes are zero.
 *   cupsCheckValue() - Check to see if all bytes match the given value.
 */

/*
 * Include necessary headers.
 */

#include "driver.h"


/*
 * 'cupsCheckBytes()' - Check to see if all bytes are zero.
 */

int						/* O - 1 if they match */
cupsCheckBytes(const unsigned char *bytes,	/* I - Bytes to check */
               int                 length)	/* I - Number of bytes to check */
{
  while (length > 7)
  {
    if (*bytes++)
      return (0);
    if (*bytes++)
      return (0);
    if (*bytes++)
      return (0);
    if (*bytes++)
      return (0);
    if (*bytes++)
      return (0);
    if (*bytes++)
      return (0);
    if (*bytes++)
      return (0);
    if (*bytes++)
      return (0);

    length -= 8;
  }

  while (length > 0)
    if (*bytes++)
      return (0);
    else
      length --;

  return (1);
}


/*
 * 'cupsCheckValue()' - Check to see if all bytes match the given value.
 */

int						/* O - 1 if they match */
cupsCheckValue(const unsigned char *bytes,	/* I - Bytes to check */
               int                 length,	/* I - Number of bytes to check */
	       const unsigned char value)	/* I - Value to check */
{
  while (length > 7)
  {
    if (*bytes++ != value)
      return (0);
    if (*bytes++ != value)
      return (0);
    if (*bytes++ != value)
      return (0);
    if (*bytes++ != value)
      return (0);
    if (*bytes++ != value)
      return (0);
    if (*bytes++ != value)
      return (0);
    if (*bytes++ != value)
      return (0);
    if (*bytes++ != value)
      return (0);

    length -= 8;
  }

  while (length > 0)
    if (*bytes++ != value)
      return (0);
    else
      length --;

  return (1);
}


/*
 * End of "$Id$".
 */