cupsArrayAdd:
   74|   677k|{
   75|       |  // Range check input...
   76|   677k|  if (!a || !e)
  ------------------
  |  Branch (76:7): [True: 0, False: 677k]
  |  Branch (76:13): [True: 0, False: 677k]
  ------------------
   77|      0|    return (false);
   78|       |
   79|       |  // Append the element...
   80|   677k|  return (cups_array_add(a, e, false));
   81|   677k|}
cupsArrayFind:
  321|  13.0M|{
  322|  13.0M|  size_t	current,		// Current element
  323|  13.0M|		hash;			// Hash index
  324|  13.0M|  int		diff;			// Difference
  325|       |
  326|       |
  327|       |  // Range check input...
  328|  13.0M|  if (!a || !a->num_elements || !e)
  ------------------
  |  Branch (328:7): [True: 0, False: 13.0M]
  |  Branch (328:13): [True: 1, False: 13.0M]
  |  Branch (328:33): [True: 0, False: 13.0M]
  ------------------
  329|      1|    return (NULL);
  330|       |
  331|       |  // Look for a match...
  332|  13.0M|  if (a->hash)
  ------------------
  |  Branch (332:7): [True: 0, False: 13.0M]
  ------------------
  333|      0|  {
  334|      0|    if ((hash = (*(a->hashfunc))(e, a->data)) >= a->hashsize)
  ------------------
  |  Branch (334:9): [True: 0, False: 0]
  ------------------
  335|      0|    {
  336|      0|      current = a->current;
  337|      0|      hash    = SIZE_MAX;
  338|      0|    }
  339|      0|    else if ((current = a->hash[hash]) >= a->num_elements)
  ------------------
  |  Branch (339:14): [True: 0, False: 0]
  ------------------
  340|      0|      current = a->current;
  341|      0|  }
  342|  13.0M|  else
  343|  13.0M|  {
  344|  13.0M|    current = a->current;
  345|  13.0M|    hash    = SIZE_MAX;
  346|  13.0M|  }
  347|       |
  348|  13.0M|  current = cups_array_find(a, e, current, &diff);
  349|  13.0M|  if (!diff)
  ------------------
  |  Branch (349:7): [True: 12.3M, False: 677k]
  ------------------
  350|  12.3M|  {
  351|       |    // Found a match!  If the array does not contain unique values, find the
  352|       |    // first element that is the same...
  353|  12.3M|    if (!a->unique && a->compare)
  ------------------
  |  Branch (353:9): [True: 0, False: 12.3M]
  |  Branch (353:23): [True: 0, False: 0]
  ------------------
  354|      0|    {
  355|       |      // The array is not unique, find the first match...
  356|      0|      while (current > 0 && !(*(a->compare))(e, a->elements[current - 1], a->data))
  ------------------
  |  Branch (356:14): [True: 0, False: 0]
  |  Branch (356:29): [True: 0, False: 0]
  ------------------
  357|      0|        current --;
  358|      0|    }
  359|       |
  360|  12.3M|    a->current = current;
  361|       |
  362|  12.3M|    if (hash < a->hashsize)
  ------------------
  |  Branch (362:9): [True: 0, False: 12.3M]
  ------------------
  363|      0|      a->hash[hash] = current;
  364|       |
  365|  12.3M|    return (a->elements[current]);
  366|  12.3M|  }
  367|   677k|  else
  368|   677k|  {
  369|       |    // No match...
  370|   677k|    a->current = SIZE_MAX;
  371|       |
  372|       |    return (NULL);
  373|   677k|  }
  374|  13.0M|}
cupsArrayNew:
  639|      1|{
  640|      1|  cups_array_t	*a;			// Array
  641|       |
  642|       |
  643|       |  // Allocate memory for the array...
  644|      1|  if ((a = calloc(1, sizeof(cups_array_t))) == NULL)
  ------------------
  |  Branch (644:7): [True: 0, False: 1]
  ------------------
  645|      0|    return (NULL);
  646|       |
  647|      1|  a->compare   = f;
  648|      1|  a->data      = d;
  649|      1|  a->current   = SIZE_MAX;
  650|      1|  a->insert    = SIZE_MAX;
  651|      1|  a->num_saved = 0;
  652|      1|  a->unique    = true;
  653|       |
  654|      1|  if (hsize > 0 && hf)
  ------------------
  |  Branch (654:7): [True: 0, False: 1]
  |  Branch (654:20): [True: 0, False: 0]
  ------------------
  655|      0|  {
  656|      0|    a->hashfunc  = hf;
  657|      0|    a->hashsize  = hsize;
  658|      0|    a->hash      = malloc((size_t)hsize * sizeof(size_t));
  659|       |
  660|      0|    if (!a->hash)
  ------------------
  |  Branch (660:9): [True: 0, False: 0]
  ------------------
  661|      0|    {
  662|      0|      free(a);
  663|      0|      return (NULL);
  664|      0|    }
  665|       |
  666|      0|    memset(a->hash, -1, (size_t)hsize * sizeof(size_t));
  667|      0|  }
  668|       |
  669|      1|  a->copyfunc = cf;
  670|      1|  a->freefunc = ff;
  671|       |
  672|      1|  return (a);
  673|      1|}
cupsArrayRemove:
  713|   673k|{
  714|   673k|  size_t	i,			// Looping var
  715|   673k|		current;		// Current element
  716|   673k|  int		diff;			// Difference
  717|       |
  718|       |
  719|       |  // Range check input...
  720|   673k|  if (!a || a->num_elements == 0 || !e)
  ------------------
  |  Branch (720:7): [True: 0, False: 673k]
  |  Branch (720:13): [True: 0, False: 673k]
  |  Branch (720:37): [True: 0, False: 673k]
  ------------------
  721|      0|    return (false);
  722|       |
  723|       |  // See if the element is in the array...
  724|   673k|  current = cups_array_find(a, e, a->current, &diff);
  725|   673k|  if (diff)
  ------------------
  |  Branch (725:7): [True: 0, False: 673k]
  ------------------
  726|      0|    return (false);
  727|       |
  728|       |  // Yes, now remove it...
  729|   673k|  a->num_elements --;
  730|       |
  731|   673k|  if (a->freefunc)
  ------------------
  |  Branch (731:7): [True: 0, False: 673k]
  ------------------
  732|      0|    (a->freefunc)(a->elements[current], a->data);
  733|       |
  734|   673k|  if (current < a->num_elements)
  ------------------
  |  Branch (734:7): [True: 671k, False: 1.80k]
  ------------------
  735|   671k|    memmove(a->elements + current, a->elements + current + 1, (a->num_elements - current) * sizeof(void *));
  736|       |
  737|   673k|  if (current <= a->current)
  ------------------
  |  Branch (737:7): [True: 673k, False: 0]
  ------------------
  738|   673k|  {
  739|   673k|    if (a->current)
  ------------------
  |  Branch (739:9): [True: 673k, False: 0]
  ------------------
  740|   673k|      a->current --;
  741|      0|    else
  742|      0|      a->current = SIZE_MAX;
  743|   673k|  }
  744|       |
  745|   673k|  if (current < a->insert)
  ------------------
  |  Branch (745:7): [True: 493k, False: 180k]
  ------------------
  746|   493k|    a->insert --;
  747|   180k|  else if (current == a->insert)
  ------------------
  |  Branch (747:12): [True: 7.56k, False: 173k]
  ------------------
  748|  7.56k|    a->insert = SIZE_MAX;
  749|       |
  750|   673k|  for (i = 0; i < a->num_saved; i ++)
  ------------------
  |  Branch (750:15): [True: 0, False: 673k]
  ------------------
  751|      0|  {
  752|      0|    if (current <= a->saved[i])
  ------------------
  |  Branch (752:9): [True: 0, False: 0]
  ------------------
  753|      0|      a->saved[i] --;
  754|      0|  }
  755|       |
  756|   673k|  if (a->num_elements <= 1)
  ------------------
  |  Branch (756:7): [True: 0, False: 673k]
  ------------------
  757|      0|    a->unique = true;
  758|       |
  759|       |  return (true);
  760|   673k|}
array.c:cups_array_add:
  845|   677k|{
  846|   677k|  size_t	i,			// Looping var
  847|   677k|		current;		// Current element
  848|   677k|  int		diff;			// Comparison with current element
  849|       |
  850|       |
  851|       |  // Verify we have room for the new element...
  852|   677k|  if (a->num_elements >= a->alloc_elements)
  ------------------
  |  Branch (852:7): [True: 43, False: 677k]
  ------------------
  853|     43|  {
  854|       |    // Allocate additional elements; start with 16 elements, then double the
  855|       |    // size until 1024 elements, then add 1024 elements thereafter...
  856|     43|    void	**temp;			// New array elements
  857|     43|    size_t	count;			// New allocation count
  858|       |
  859|     43|    if (a->alloc_elements == 0)
  ------------------
  |  Branch (859:9): [True: 1, False: 42]
  ------------------
  860|      1|      count = 16;
  861|     42|    else if (a->alloc_elements < 1024)
  ------------------
  |  Branch (861:14): [True: 6, False: 36]
  ------------------
  862|      6|      count = a->alloc_elements * 2;
  863|     36|    else
  864|     36|      count = a->alloc_elements + 1024;
  865|       |
  866|     43|    if ((temp = realloc(a->elements, count * sizeof(void *))) == NULL)
  ------------------
  |  Branch (866:9): [True: 0, False: 43]
  ------------------
  867|      0|      return (false);
  868|       |
  869|     43|    a->alloc_elements = count;
  870|     43|    a->elements       = temp;
  871|     43|  }
  872|       |
  873|       |  // Find the insertion point for the new element; if there is no compare
  874|       |  // function or elements, just add it to the beginning or end...
  875|   677k|  if (!a->num_elements || !a->compare)
  ------------------
  |  Branch (875:7): [True: 1, False: 677k]
  |  Branch (875:27): [True: 0, False: 677k]
  ------------------
  876|      1|  {
  877|       |    // No elements or comparison function, insert/append as needed...
  878|      1|    if (insert)
  ------------------
  |  Branch (878:9): [True: 0, False: 1]
  ------------------
  879|      0|      current = 0;			// Insert at beginning
  880|      1|    else
  881|      1|      current = a->num_elements;	// Append to the end
  882|      1|  }
  883|   677k|  else
  884|   677k|  {
  885|       |    // Do a binary search for the insertion point...
  886|   677k|    current = cups_array_find(a, e, a->insert, &diff);
  887|       |
  888|   677k|    if (diff > 0)
  ------------------
  |  Branch (888:9): [True: 3.88k, False: 674k]
  ------------------
  889|  3.88k|    {
  890|       |      // Insert after the current element...
  891|  3.88k|      current ++;
  892|  3.88k|    }
  893|   674k|    else if (!diff)
  ------------------
  |  Branch (893:14): [True: 0, False: 674k]
  ------------------
  894|      0|    {
  895|       |      // Compared equal, make sure we add to the begining or end of the current
  896|       |      // run of equal elements...
  897|      0|      a->unique = false;
  898|       |
  899|      0|      if (insert)
  ------------------
  |  Branch (899:11): [True: 0, False: 0]
  ------------------
  900|      0|      {
  901|       |        // Insert at beginning of run...
  902|      0|	while (current > 0 && !(*(a->compare))(e, a->elements[current - 1], a->data))
  ------------------
  |  Branch (902:9): [True: 0, False: 0]
  |  Branch (902:24): [True: 0, False: 0]
  ------------------
  903|      0|          current --;
  904|      0|      }
  905|      0|      else
  906|      0|      {
  907|       |        // Append at end of run...
  908|      0|	do
  909|      0|	{
  910|      0|          current ++;
  911|      0|	}
  912|      0|	while (current < a->num_elements && !(*(a->compare))(e, a->elements[current], a->data));
  ------------------
  |  Branch (912:9): [True: 0, False: 0]
  |  Branch (912:38): [True: 0, False: 0]
  ------------------
  913|      0|      }
  914|      0|    }
  915|   677k|  }
  916|       |
  917|       |  // Insert or append the element...
  918|   677k|  if (current < a->num_elements)
  ------------------
  |  Branch (918:7): [True: 674k, False: 3.88k]
  ------------------
  919|   674k|  {
  920|       |    // Shift other elements to the right...
  921|   674k|    memmove(a->elements + current + 1, a->elements + current, (a->num_elements - current) * sizeof(void *));
  922|       |
  923|   674k|    if (a->current >= current)
  ------------------
  |  Branch (923:9): [True: 674k, False: 0]
  ------------------
  924|   674k|      a->current ++;
  925|       |
  926|   674k|    for (i = 0; i < a->num_saved; i ++)
  ------------------
  |  Branch (926:17): [True: 0, False: 674k]
  ------------------
  927|      0|    {
  928|      0|      if (a->saved[i] >= current)
  ------------------
  |  Branch (928:11): [True: 0, False: 0]
  ------------------
  929|      0|	a->saved[i] ++;
  930|      0|    }
  931|   674k|  }
  932|       |
  933|   677k|  if (a->copyfunc)
  ------------------
  |  Branch (933:7): [True: 0, False: 677k]
  ------------------
  934|      0|  {
  935|      0|    if ((a->elements[current] = (a->copyfunc)(e, a->data)) == NULL)
  ------------------
  |  Branch (935:9): [True: 0, False: 0]
  ------------------
  936|      0|      return (false);
  937|      0|  }
  938|   677k|  else
  939|   677k|  {
  940|   677k|    a->elements[current] = e;
  941|   677k|  }
  942|       |
  943|   677k|  a->num_elements ++;
  944|   677k|  a->insert = current;
  945|       |
  946|       |  return (true);
  947|   677k|}
array.c:cups_array_find:
  959|  14.3M|{
  960|  14.3M|  size_t	left,			// Left side of search
  961|  14.3M|		right,			// Right side of search
  962|  14.3M|		current;		// Current element
  963|  14.3M|  int		diff;			// Comparison with current element
  964|       |
  965|       |
  966|  14.3M|  if (a->compare)
  ------------------
  |  Branch (966:7): [True: 14.3M, False: 0]
  ------------------
  967|  14.3M|  {
  968|       |    // Do a binary search for the element...
  969|  14.3M|    if (prev < a->num_elements)
  ------------------
  |  Branch (969:9): [True: 14.3M, False: 11.4k]
  ------------------
  970|  14.3M|    {
  971|       |      // Start search on either side of previous...
  972|  14.3M|      if ((diff = (*(a->compare))(e, a->elements[prev], a->data)) == 0 || (diff < 0 && prev == 0) || (diff > 0 && prev == (a->num_elements - 1)))
  ------------------
  |  Branch (972:11): [True: 11.9M, False: 2.35M]
  |  Branch (972:76): [True: 834k, False: 1.52M]
  |  Branch (972:88): [True: 1, False: 834k]
  |  Branch (972:103): [True: 1.52M, False: 834k]
  |  Branch (972:115): [True: 998, False: 1.52M]
  ------------------
  973|  11.9M|      {
  974|       |        // Exact or edge match, return it!
  975|  11.9M|	*rdiff = diff;
  976|       |
  977|  11.9M|	return (prev);
  978|  11.9M|      }
  979|  2.35M|      else if (diff < 0)
  ------------------
  |  Branch (979:16): [True: 834k, False: 1.52M]
  ------------------
  980|   834k|      {
  981|       |        // Start with previous on right side...
  982|   834k|	left  = 0;
  983|   834k|	right = prev;
  984|   834k|      }
  985|  1.52M|      else
  986|  1.52M|      {
  987|       |        // Start wih previous on left side...
  988|  1.52M|        left  = prev;
  989|  1.52M|	right = a->num_elements - 1;
  990|  1.52M|      }
  991|  14.3M|    }
  992|  11.4k|    else
  993|  11.4k|    {
  994|       |      // Start search in the middle...
  995|  11.4k|      left  = 0;
  996|  11.4k|      right = a->num_elements - 1;
  997|  11.4k|    }
  998|       |
  999|  2.36M|    do
 1000|  28.5M|    {
 1001|  28.5M|      current = (left + right) / 2;
 1002|  28.5M|      diff    = (*(a->compare))(e, a->elements[current], a->data);
 1003|       |
 1004|  28.5M|      if (diff == 0)
  ------------------
  |  Branch (1004:11): [True: 997k, False: 27.5M]
  ------------------
 1005|   997k|	break;
 1006|  27.5M|      else if (diff < 0)
  ------------------
  |  Branch (1006:16): [True: 14.7M, False: 12.8M]
  ------------------
 1007|  14.7M|	right = current;
 1008|  12.8M|      else
 1009|  12.8M|	left = current;
 1010|  28.5M|    }
 1011|  27.5M|    while ((right - left) > 1);
  ------------------
  |  Branch (1011:12): [True: 26.1M, False: 1.36M]
  ------------------
 1012|       |
 1013|  2.36M|    if (diff != 0)
  ------------------
  |  Branch (1013:9): [True: 1.36M, False: 997k]
  ------------------
 1014|  1.36M|    {
 1015|       |      // Check the last 1 or 2 elements...
 1016|  1.36M|      if ((diff = (*(a->compare))(e, a->elements[left], a->data)) <= 0)
  ------------------
  |  Branch (1016:11): [True: 9.55k, False: 1.35M]
  ------------------
 1017|  9.55k|      {
 1018|  9.55k|        current = left;
 1019|  9.55k|      }
 1020|  1.35M|      else
 1021|  1.35M|      {
 1022|  1.35M|        diff    = (*(a->compare))(e, a->elements[right], a->data);
 1023|  1.35M|        current = right;
 1024|  1.35M|      }
 1025|  1.36M|    }
 1026|  2.36M|  }
 1027|      0|  else
 1028|      0|  {
 1029|       |    // Do a linear pointer search...
 1030|      0|    diff = 1;
 1031|       |
 1032|      0|    for (current = 0; current < a->num_elements; current ++)
  ------------------
  |  Branch (1032:23): [True: 0, False: 0]
  ------------------
 1033|      0|    {
 1034|      0|      if (a->elements[current] == e)
  ------------------
  |  Branch (1034:11): [True: 0, False: 0]
  ------------------
 1035|      0|      {
 1036|      0|        diff = 0;
 1037|      0|        break;
 1038|      0|      }
 1039|      0|    }
 1040|      0|  }
 1041|       |
 1042|       |  // Return the closest element and the difference...
 1043|  2.36M|  *rdiff = diff;
 1044|       |
 1045|  2.36M|  return (current);
 1046|  14.3M|}

cupsFileClose:
   70|  8.10k|{
   71|  8.10k|  int	fd;				// File descriptor
   72|  8.10k|  char	mode;				// Open mode
   73|  8.10k|  bool	status;				// Return status
   74|       |
   75|       |
   76|       |  // Range check...
   77|  8.10k|  if (!fp)
  ------------------
  |  Branch (77:7): [True: 0, False: 8.10k]
  ------------------
   78|      0|    return (false);
   79|       |
   80|       |  // Flush pending write data...
   81|  8.10k|  if (fp->mode == 'w')
  ------------------
  |  Branch (81:7): [True: 5.40k, False: 2.70k]
  ------------------
   82|  5.40k|    status = cupsFileFlush(fp);
   83|  2.70k|  else
   84|  2.70k|    status = true;
   85|       |
   86|  8.10k|  if (fp->compressed && status)
  ------------------
  |  Branch (86:7): [True: 1.61k, False: 6.49k]
  |  Branch (86:25): [True: 1.61k, False: 0]
  ------------------
   87|  1.61k|  {
   88|  1.61k|    if (fp->mode == 'r')
  ------------------
  |  Branch (88:9): [True: 1.61k, False: 0]
  ------------------
   89|  1.61k|    {
   90|       |      // Free decompression data...
   91|  1.61k|      inflateEnd(&fp->stream);
   92|  1.61k|    }
   93|      0|    else
   94|      0|    {
   95|       |      // Flush any remaining compressed data...
   96|      0|      unsigned char	trailer[8];	// Trailer CRC and length
   97|      0|      bool		done;		// Done writing...
   98|       |
   99|       |
  100|      0|      fp->stream.avail_in = 0;
  101|       |
  102|      0|      for (done = false;;)
  103|      0|      {
  104|      0|        if (fp->stream.next_out > fp->cbuf)
  ------------------
  |  Branch (104:13): [True: 0, False: 0]
  ------------------
  105|      0|	{
  106|      0|	  status = cups_write(fp, (char *)fp->cbuf, (size_t)(fp->stream.next_out - fp->cbuf));
  107|       |
  108|      0|	  fp->stream.next_out  = fp->cbuf;
  109|      0|	  fp->stream.avail_out = sizeof(fp->cbuf);
  110|      0|	}
  111|       |
  112|      0|        if (done || !status)
  ------------------
  |  Branch (112:13): [True: 0, False: 0]
  |  Branch (112:21): [True: 0, False: 0]
  ------------------
  113|      0|	  break;
  114|       |
  115|      0|        done = deflate(&fp->stream, Z_FINISH) == Z_STREAM_END && fp->stream.next_out == fp->cbuf;
  ------------------
  |  Branch (115:16): [True: 0, False: 0]
  |  Branch (115:66): [True: 0, False: 0]
  ------------------
  116|      0|      }
  117|       |
  118|       |      // Write the CRC and length...
  119|      0|      trailer[0] = (unsigned char)fp->crc;
  120|      0|      trailer[1] = (unsigned char)(fp->crc >> 8);
  121|      0|      trailer[2] = (unsigned char)(fp->crc >> 16);
  122|      0|      trailer[3] = (unsigned char)(fp->crc >> 24);
  123|      0|      trailer[4] = (unsigned char)fp->pos;
  124|      0|      trailer[5] = (unsigned char)(fp->pos >> 8);
  125|      0|      trailer[6] = (unsigned char)(fp->pos >> 16);
  126|      0|      trailer[7] = (unsigned char)(fp->pos >> 24);
  127|       |
  128|      0|      status = cups_write(fp, (char *)trailer, 8);
  129|       |
  130|       |      // Free all memory used by the compression stream...
  131|      0|      deflateEnd(&(fp->stream));
  132|      0|    }
  133|  1.61k|  }
  134|       |
  135|       |  // If this is one of the cupsFileStdin/out/err files, return now and don't
  136|       |  // actually free memory or close (these last the life of the process...)
  137|  8.10k|  if (fp->is_stdio)
  ------------------
  |  Branch (137:7): [True: 0, False: 8.10k]
  ------------------
  138|      0|    return (status);
  139|       |
  140|       |  // Save the file descriptor we used and free memory...
  141|  8.10k|  fd   = fp->fd;
  142|  8.10k|  mode = fp->mode;
  143|       |
  144|  8.10k|  free(fp->printf_buffer);
  145|  8.10k|  free(fp);
  146|       |
  147|       |  // Close the file, returning the close status...
  148|  8.10k|  if (mode == 's')
  ------------------
  |  Branch (148:7): [True: 0, False: 8.10k]
  ------------------
  149|      0|    status = httpAddrClose(NULL, fd);
  150|  8.10k|  else if (close(fd) < 0)
  ------------------
  |  Branch (150:12): [True: 0, False: 8.10k]
  ------------------
  151|      0|    status = false;
  152|       |
  153|  8.10k|  return (status);
  154|  8.10k|}
cupsFileFlush:
  258|   143k|{
  259|   143k|  ssize_t	bytes;			// Bytes to write
  260|   143k|  bool		ret;			// Return value
  261|       |
  262|       |
  263|       |  // Range check input...
  264|   143k|  if (!fp || fp->mode != 'w')
  ------------------
  |  Branch (264:7): [True: 0, False: 143k]
  |  Branch (264:14): [True: 0, False: 143k]
  ------------------
  265|      0|    return (false);
  266|       |
  267|   143k|  bytes = (ssize_t)(fp->ptr - fp->buf);
  268|       |
  269|   143k|  if (bytes > 0)
  ------------------
  |  Branch (269:7): [True: 135k, False: 7.89k]
  ------------------
  270|   135k|  {
  271|   135k|    if (fp->compressed)
  ------------------
  |  Branch (271:9): [True: 0, False: 135k]
  ------------------
  272|      0|      ret = cups_compress(fp, fp->buf, (size_t)bytes);
  273|   135k|    else
  274|   135k|      ret = cups_write(fp, fp->buf, (size_t)bytes);
  275|       |
  276|   135k|    fp->ptr = fp->buf;
  277|       |
  278|   135k|    return (ret);
  279|   135k|  }
  280|       |
  281|  7.89k|  return (true);
  282|   143k|}
cupsFileOpen:
  628|  8.11k|{
  629|  8.11k|  cups_file_t	*fp;			// New CUPS file
  630|  8.11k|  int		fd;			// File descriptor
  631|  8.11k|  char		hostname[1024],		// Hostname
  632|  8.11k|		*portname;		// Port "name" (number or service)
  633|  8.11k|  http_addrlist_t *addrlist;		// Host address list
  634|  8.11k|  int		perm = 0664;		// Permissions for write/append
  635|  8.11k|  const char	*ptr;			// Pointer into mode string
  636|       |
  637|       |
  638|       |  // Range check input...
  639|  8.11k|  if (!filename || !mode || (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's') || (*mode == 'a' && isdigit(mode[1] & 255)))
  ------------------
  |  Branch (639:7): [True: 0, False: 8.11k]
  |  Branch (639:20): [True: 0, False: 8.11k]
  |  Branch (639:30): [True: 5.40k, False: 2.70k]
  |  Branch (639:46): [True: 0, False: 5.40k]
  |  Branch (639:62): [True: 0, False: 0]
  |  Branch (639:78): [True: 0, False: 0]
  |  Branch (639:96): [True: 0, False: 8.11k]
  |  Branch (639:112): [True: 0, False: 0]
  ------------------
  640|      0|    return (NULL);
  641|       |
  642|  8.11k|  if ((ptr = strchr(mode, 'm')) != NULL && ptr[1] >= '0' && ptr[1] <= '7')
  ------------------
  |  Branch (642:7): [True: 0, False: 8.11k]
  |  Branch (642:44): [True: 0, False: 0]
  |  Branch (642:61): [True: 0, False: 0]
  ------------------
  643|      0|  {
  644|       |    // Get permissions from mode string...
  645|      0|    perm = (int)strtol(mode + 1, NULL, 8);
  646|      0|  }
  647|       |
  648|       |  // Open the file...
  649|  8.11k|  switch (*mode)
  650|  8.11k|  {
  651|      0|    case 'a' : // Append file
  ------------------
  |  Branch (651:5): [True: 0, False: 8.11k]
  ------------------
  652|      0|        fd = cups_open(filename, O_WRONLY | O_CREAT | O_APPEND | O_LARGEFILE | O_BINARY, perm);
  ------------------
  |  |   32|      0|#    define O_BINARY 0
  ------------------
  653|      0|        break;
  654|       |
  655|  2.70k|    case 'r' : // Read file
  ------------------
  |  Branch (655:5): [True: 2.70k, False: 5.40k]
  ------------------
  656|  2.70k|	fd = open(filename, O_RDONLY | O_LARGEFILE | O_BINARY, 0);
  ------------------
  |  |   32|  2.70k|#    define O_BINARY 0
  ------------------
  657|  2.70k|	break;
  658|       |
  659|  5.40k|    case 'w' : // Write file
  ------------------
  |  Branch (659:5): [True: 5.40k, False: 2.70k]
  ------------------
  660|  5.40k|        fd    = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY, perm);
  ------------------
  |  |   32|  5.40k|#    define O_BINARY 0
  ------------------
  661|  5.40k|	if (fd < 0 && errno == ENOENT)
  ------------------
  |  Branch (661:6): [True: 2.70k, False: 2.70k]
  |  Branch (661:16): [True: 2.70k, False: 0]
  ------------------
  662|  2.70k|	{
  663|  2.70k|	  fd = cups_open(filename, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE | O_BINARY, perm);
  ------------------
  |  |   32|  2.70k|#    define O_BINARY 0
  ------------------
  664|  2.70k|	  if (fd < 0 && errno == EEXIST)
  ------------------
  |  Branch (664:8): [True: 0, False: 2.70k]
  |  Branch (664:18): [True: 0, False: 0]
  ------------------
  665|      0|	    fd = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY, perm);
  ------------------
  |  |   32|      0|#    define O_BINARY 0
  ------------------
  666|  2.70k|	}
  667|       |
  668|  5.40k|	if (fd >= 0)
  ------------------
  |  Branch (668:6): [True: 5.40k, False: 0]
  ------------------
  669|       |#ifdef _WIN32
  670|       |	  _chsize(fd, 0);
  671|       |#else
  672|  5.40k|	  ftruncate(fd, 0);
  673|  5.40k|#endif // _WIN32
  674|  5.40k|        break;
  675|       |
  676|      0|    case 's' : // Read/write socket
  ------------------
  |  Branch (676:5): [True: 0, False: 8.11k]
  ------------------
  677|      0|        cupsCopyString(hostname, filename, sizeof(hostname));
  678|      0|	if ((portname = strrchr(hostname, ':')) != NULL)
  ------------------
  |  Branch (678:6): [True: 0, False: 0]
  ------------------
  679|      0|	  *portname++ = '\0';
  680|      0|	else
  681|      0|	  return (NULL);
  682|       |
  683|       |        // Lookup the hostname and service...
  684|      0|        if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
  ------------------
  |  Branch (684:13): [True: 0, False: 0]
  ------------------
  685|      0|	  return (NULL);
  686|       |
  687|       |        // Connect to the server...
  688|      0|        if (!httpAddrConnect(addrlist, &fd, 30000, NULL))
  ------------------
  |  Branch (688:13): [True: 0, False: 0]
  ------------------
  689|      0|	{
  690|      0|	  httpAddrFreeList(addrlist);
  691|      0|	  return (NULL);
  692|      0|	}
  693|       |
  694|      0|	httpAddrFreeList(addrlist);
  695|      0|	break;
  696|       |
  697|      0|    default : // Remove bogus compiler warning...
  ------------------
  |  Branch (697:5): [True: 0, False: 8.11k]
  ------------------
  698|      0|        return (NULL);
  699|  8.11k|  }
  700|       |
  701|  8.11k|  if (fd < 0)
  ------------------
  |  Branch (701:7): [True: 2, False: 8.10k]
  ------------------
  702|      2|    return (NULL);
  703|       |
  704|       |  // Create the CUPS file structure...
  705|  8.10k|  if ((fp = cupsFileOpenFd(fd, mode)) == NULL)
  ------------------
  |  Branch (705:7): [True: 0, False: 8.10k]
  ------------------
  706|      0|  {
  707|      0|    if (*mode == 's')
  ------------------
  |  Branch (707:9): [True: 0, False: 0]
  ------------------
  708|      0|      httpAddrClose(NULL, fd);
  709|      0|    else
  710|      0|      close(fd);
  711|      0|  }
  712|       |
  713|       |  // Return it...
  714|  8.10k|  return (fp);
  715|  8.11k|}
cupsFileOpenFd:
  736|  8.10k|{
  737|  8.10k|  cups_file_t	*fp;			// New CUPS file
  738|       |
  739|       |
  740|       |  // Range check input...
  741|  8.10k|  if (fd < 0 || !mode || (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's') || (*mode == 'a' && isdigit(mode[1] & 255)))
  ------------------
  |  Branch (741:7): [True: 0, False: 8.10k]
  |  Branch (741:17): [True: 0, False: 8.10k]
  |  Branch (741:27): [True: 5.40k, False: 2.70k]
  |  Branch (741:43): [True: 0, False: 5.40k]
  |  Branch (741:59): [True: 0, False: 0]
  |  Branch (741:75): [True: 0, False: 0]
  |  Branch (741:93): [True: 0, False: 8.10k]
  |  Branch (741:109): [True: 0, False: 0]
  ------------------
  742|      0|    return (NULL);
  743|       |
  744|       |  // Allocate memory...
  745|  8.10k|  if ((fp = calloc(1, sizeof(cups_file_t))) == NULL)
  ------------------
  |  Branch (745:7): [True: 0, False: 8.10k]
  ------------------
  746|      0|    return (NULL);
  747|       |
  748|       |  // Open the file...
  749|  8.10k|  fp->fd = fd;
  750|       |
  751|  8.10k|  switch (*mode)
  752|  8.10k|  {
  753|      0|    case 'a' :
  ------------------
  |  Branch (753:5): [True: 0, False: 8.10k]
  ------------------
  754|  5.40k|    case 'w' :
  ------------------
  |  Branch (754:5): [True: 5.40k, False: 2.70k]
  ------------------
  755|  5.40k|        if (*mode == 'a')
  ------------------
  |  Branch (755:13): [True: 0, False: 5.40k]
  ------------------
  756|      0|          fp->pos = lseek(fd, 0, SEEK_END);
  757|       |
  758|  5.40k|	fp->mode = 'w';
  759|  5.40k|	fp->ptr  = fp->buf;
  760|  5.40k|	fp->end  = fp->buf + sizeof(fp->buf);
  761|       |
  762|  5.40k|	if (mode[1] >= '1' && mode[1] <= '9')
  ------------------
  |  Branch (762:6): [True: 0, False: 5.40k]
  |  Branch (762:24): [True: 0, False: 0]
  ------------------
  763|      0|	{
  764|       |	  // Open a compressed stream, so write the standard gzip file header...
  765|      0|          unsigned char header[10];	// gzip file header
  766|      0|	  time_t	curtime;	// Current time
  767|       |
  768|       |
  769|      0|          curtime   = time(NULL);
  770|      0|	  header[0] = 0x1f;
  771|      0|	  header[1] = 0x8b;
  772|      0|	  header[2] = Z_DEFLATED;
  773|      0|	  header[3] = 0;
  774|      0|	  header[4] = (unsigned char)curtime;
  775|      0|	  header[5] = (unsigned char)(curtime >> 8);
  776|      0|	  header[6] = (unsigned char)(curtime >> 16);
  777|      0|	  header[7] = (unsigned char)(curtime >> 24);
  778|      0|	  header[8] = 0;
  779|      0|	  header[9] = 0x03;
  780|       |
  781|      0|	  if (!cups_write(fp, (char *)header, 10))
  ------------------
  |  Branch (781:8): [True: 0, False: 0]
  ------------------
  782|      0|	  {
  783|      0|            free(fp);
  784|      0|	    return (NULL);
  785|      0|	  }
  786|       |
  787|       |          // Initialize the compressor...
  788|      0|          if (deflateInit2(&(fp->stream), mode[1] - '0', Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) < Z_OK)
  ------------------
  |  Branch (788:15): [True: 0, False: 0]
  ------------------
  789|      0|          {
  790|      0|            free(fp);
  791|      0|	    return (NULL);
  792|      0|          }
  793|       |
  794|      0|	  fp->stream.next_out  = fp->cbuf;
  795|      0|	  fp->stream.avail_out = sizeof(fp->cbuf);
  796|      0|	  fp->compressed       = true;
  797|      0|	  fp->crc              = crc32(0L, Z_NULL, 0);
  798|      0|	}
  799|  5.40k|        break;
  800|       |
  801|  5.40k|    case 'r' :
  ------------------
  |  Branch (801:5): [True: 2.70k, False: 5.40k]
  ------------------
  802|  2.70k|	fp->mode = 'r';
  803|  2.70k|	break;
  804|       |
  805|      0|    case 's' :
  ------------------
  |  Branch (805:5): [True: 0, False: 8.10k]
  ------------------
  806|      0|        fp->mode = 's';
  807|      0|	break;
  808|       |
  809|      0|    default : // Remove bogus compiler warning...
  ------------------
  |  Branch (809:5): [True: 0, False: 8.10k]
  ------------------
  810|      0|        return (NULL);
  811|  8.10k|  }
  812|       |
  813|       |  // Don't pass this file to child processes...
  814|  8.10k|#ifndef _WIN32
  815|  8.10k|  if (fcntl(fp->fd, F_SETFD, fcntl(fp->fd, F_GETFD) | FD_CLOEXEC))
  ------------------
  |  Branch (815:7): [True: 0, False: 8.10k]
  ------------------
  816|      0|    DEBUG_printf("cupsFileOpenFd: fcntl(F_SETFD, FD_CLOEXEC) failed - %s", strerror(errno));
  817|  8.10k|#endif // !_WIN32
  818|       |
  819|  8.10k|  return (fp);
  820|  8.10k|}
cupsFileRead:
 1136|  38.8M|{
 1137|  38.8M|  size_t	total;			// Total bytes read
 1138|  38.8M|  ssize_t	count;			// Bytes read
 1139|       |
 1140|       |
 1141|       |  // Range check input...
 1142|  38.8M|  if (!fp || !buf || (fp->mode != 'r' && fp->mode != 's'))
  ------------------
  |  Branch (1142:7): [True: 0, False: 38.8M]
  |  Branch (1142:14): [True: 0, False: 38.8M]
  |  Branch (1142:23): [True: 0, False: 38.8M]
  |  Branch (1142:42): [True: 0, False: 0]
  ------------------
 1143|      0|    return (-1);
 1144|       |
 1145|  38.8M|  if (bytes == 0)
  ------------------
  |  Branch (1145:7): [True: 0, False: 38.8M]
  ------------------
 1146|      0|    return (0);
 1147|       |
 1148|  38.8M|  if (fp->eof)
  ------------------
  |  Branch (1148:7): [True: 0, False: 38.8M]
  ------------------
 1149|      0|    return (-1);
 1150|       |
 1151|       |  // Loop until all bytes are read...
 1152|  38.8M|  total = 0;
 1153|  77.8M|  while (bytes > 0)
  ------------------
  |  Branch (1153:10): [True: 39.0M, False: 38.8M]
  ------------------
 1154|  39.0M|  {
 1155|  39.0M|    if (fp->ptr >= fp->end)
  ------------------
  |  Branch (1155:9): [True: 154k, False: 38.8M]
  ------------------
 1156|   154k|    {
 1157|   154k|      if (cups_fill(fp) <= 0)
  ------------------
  |  Branch (1157:11): [True: 1.99k, False: 152k]
  ------------------
 1158|  1.99k|      {
 1159|  1.99k|        if (total > 0)
  ------------------
  |  Branch (1159:13): [True: 849, False: 1.14k]
  ------------------
 1160|    849|          return ((ssize_t)total);
 1161|  1.14k|	else
 1162|  1.14k|	  return (-1);
 1163|  1.99k|      }
 1164|   154k|    }
 1165|       |
 1166|  39.0M|    count = (ssize_t)(fp->end - fp->ptr);
 1167|  39.0M|    if (count > (ssize_t)bytes)
  ------------------
  |  Branch (1167:9): [True: 38.8M, False: 152k]
  ------------------
 1168|  38.8M|      count = (ssize_t)bytes;
 1169|       |
 1170|  39.0M|    memcpy(buf, fp->ptr,(size_t) count);
 1171|  39.0M|    fp->ptr += count;
 1172|  39.0M|    fp->pos += count;
 1173|       |
 1174|       |    // Update the counts for the last read...
 1175|  39.0M|    bytes -= (size_t)count;
 1176|  39.0M|    total += (size_t)count;
 1177|  39.0M|    buf   += count;
 1178|  39.0M|  }
 1179|       |
 1180|       |  // Return the total number of bytes read...
 1181|  38.8M|  return ((ssize_t)total);
 1182|  38.8M|}
cupsFileWrite:
 1449|  3.20M|{
 1450|       |  // Range check input...
 1451|  3.20M|  if (!fp || !buf || (fp->mode != 'w' && fp->mode != 's'))
  ------------------
  |  Branch (1451:7): [True: 0, False: 3.20M]
  |  Branch (1451:14): [True: 0, False: 3.20M]
  |  Branch (1451:23): [True: 0, False: 3.20M]
  |  Branch (1451:42): [True: 0, False: 0]
  ------------------
 1452|      0|    return (false);
 1453|       |
 1454|  3.20M|  if (bytes == 0)
  ------------------
  |  Branch (1454:7): [True: 0, False: 3.20M]
  ------------------
 1455|      0|    return (true);
 1456|       |
 1457|       |  // Write the buffer...
 1458|  3.20M|  if (fp->mode == 's')
  ------------------
  |  Branch (1458:7): [True: 0, False: 3.20M]
  ------------------
 1459|      0|  {
 1460|      0|    if (!cups_write(fp, buf, bytes))
  ------------------
  |  Branch (1460:9): [True: 0, False: 0]
  ------------------
 1461|      0|      return (false);
 1462|       |
 1463|      0|    fp->pos += (off_t)bytes;
 1464|       |
 1465|      0|    return (true);
 1466|      0|  }
 1467|       |
 1468|  3.20M|  if ((fp->ptr + bytes) > fp->end)
  ------------------
  |  Branch (1468:7): [True: 138k, False: 3.06M]
  ------------------
 1469|   138k|  {
 1470|   138k|    if (!cupsFileFlush(fp))
  ------------------
  |  Branch (1470:9): [True: 0, False: 138k]
  ------------------
 1471|      0|      return (false);
 1472|   138k|  }
 1473|       |
 1474|  3.20M|  fp->pos += (off_t)bytes;
 1475|       |
 1476|  3.20M|  if (bytes > sizeof(fp->buf))
  ------------------
  |  Branch (1476:7): [True: 30.3k, False: 3.17M]
  ------------------
 1477|  30.3k|  {
 1478|  30.3k|    if (fp->compressed)
  ------------------
  |  Branch (1478:9): [True: 0, False: 30.3k]
  ------------------
 1479|      0|      return (cups_compress(fp, buf, bytes));
 1480|  30.3k|    else
 1481|  30.3k|      return (cups_write(fp, buf, bytes));
 1482|  30.3k|  }
 1483|  3.17M|  else
 1484|  3.17M|  {
 1485|  3.17M|    memcpy(fp->ptr, buf, bytes);
 1486|  3.17M|    fp->ptr += bytes;
 1487|       |    return (true);
 1488|  3.17M|  }
 1489|  3.20M|}
file.c:cups_fill:
 1537|   154k|{
 1538|   154k|  ssize_t		bytes;		// Number of bytes read
 1539|   154k|  int			status;		// Decompression status
 1540|   154k|  const unsigned char	*ptr,		// Pointer into buffer
 1541|   154k|			*end;		// End of buffer
 1542|       |
 1543|       |
 1544|   154k|  if (fp->ptr && fp->end)
  ------------------
  |  Branch (1544:7): [True: 152k, False: 2.70k]
  |  Branch (1544:18): [True: 152k, False: 0]
  ------------------
 1545|   152k|    fp->bufpos += fp->end - fp->buf;
 1546|       |
 1547|   154k|  while (!fp->ptr || fp->compressed)
  ------------------
  |  Branch (1547:10): [True: 2.70k, False: 152k]
  |  Branch (1547:22): [True: 151k, False: 743]
  ------------------
 1548|   154k|  {
 1549|       |    // Check to see if we have read any data yet; if not, see if we have a compressed file...
 1550|   154k|    if (!fp->ptr)
  ------------------
  |  Branch (1550:9): [True: 2.70k, False: 151k]
  ------------------
 1551|  2.70k|    {
 1552|       |      // Reset the file position in case we are seeking...
 1553|  2.70k|      fp->compressed = false;
 1554|       |
 1555|       |      // Read the first bytes in the file to determine if we have a gzip'd file...
 1556|  2.70k|      if ((bytes = cups_read(fp, (char *)fp->buf, sizeof(fp->buf))) < 0)
  ------------------
  |  Branch (1556:11): [True: 0, False: 2.70k]
  ------------------
 1557|      0|      {
 1558|       |        // Can't read from file!
 1559|      0|        fp->eof = true;
 1560|       |
 1561|      0|	return (-1);
 1562|      0|      }
 1563|       |
 1564|  2.70k|      if (bytes < 10 || fp->buf[0] != 0x1f || (fp->buf[1] & 255) != 0x8b || fp->buf[2] != 8 || (fp->buf[3] & 0xe0) != 0)
  ------------------
  |  Branch (1564:11): [True: 43, False: 2.66k]
  |  Branch (1564:25): [True: 824, False: 1.83k]
  |  Branch (1564:47): [True: 42, False: 1.79k]
  |  Branch (1564:77): [True: 20, False: 1.77k]
  |  Branch (1564:96): [True: 8, False: 1.76k]
  ------------------
 1565|    937|      {
 1566|       |        // Not a gzip'd file!
 1567|    937|	fp->ptr = fp->buf;
 1568|    937|	fp->end = fp->buf + bytes;
 1569|       |
 1570|    937|	return (bytes);
 1571|    937|      }
 1572|       |
 1573|       |      // Parse header junk: extra data, original name, and comment...
 1574|  1.76k|      ptr = (unsigned char *)fp->buf + 10;
 1575|  1.76k|      end = (unsigned char *)fp->buf + bytes;
 1576|       |
 1577|  1.76k|      if (fp->buf[3] & 0x04)
  ------------------
  |  Branch (1577:11): [True: 33, False: 1.73k]
  ------------------
 1578|     33|      {
 1579|       |        // Skip extra data...
 1580|     33|	if ((ptr + 2) > end)
  ------------------
  |  Branch (1580:6): [True: 4, False: 29]
  ------------------
 1581|      4|	{
 1582|       |	  // Can't read from file!
 1583|      4|          fp->eof = true;
 1584|      4|	  errno   = EIO;
 1585|       |
 1586|      4|	  return (-1);
 1587|      4|	}
 1588|       |
 1589|     29|	bytes = ((unsigned char)ptr[1] << 8) | (unsigned char)ptr[0];
 1590|     29|	ptr   += 2 + bytes;
 1591|       |
 1592|     29|	if (ptr > end)
  ------------------
  |  Branch (1592:6): [True: 25, False: 4]
  ------------------
 1593|     25|	{
 1594|       |	  // Can't read from file!
 1595|     25|          fp->eof = true;
 1596|     25|	  errno   = EIO;
 1597|       |
 1598|     25|	  return (-1);
 1599|     25|	}
 1600|     29|      }
 1601|       |
 1602|  1.73k|      if (fp->buf[3] & 0x08)
  ------------------
  |  Branch (1602:11): [True: 24, False: 1.71k]
  ------------------
 1603|     24|      {
 1604|       |        // Skip original name data...
 1605|    233|	while (ptr < end && *ptr)
  ------------------
  |  Branch (1605:9): [True: 215, False: 18]
  |  Branch (1605:22): [True: 209, False: 6]
  ------------------
 1606|    209|          ptr ++;
 1607|       |
 1608|     24|	if (ptr < end)
  ------------------
  |  Branch (1608:6): [True: 6, False: 18]
  ------------------
 1609|      6|	{
 1610|      6|          ptr ++;
 1611|      6|	}
 1612|     18|	else
 1613|     18|	{
 1614|       |	  // Can't read from file!
 1615|     18|          fp->eof = true;
 1616|     18|	  errno   = EIO;
 1617|       |
 1618|     18|	  return (-1);
 1619|     18|	}
 1620|     24|      }
 1621|       |
 1622|  1.71k|      if (fp->buf[3] & 0x10)
  ------------------
  |  Branch (1622:11): [True: 20, False: 1.69k]
  ------------------
 1623|     20|      {
 1624|       |        // Skip comment data...
 1625|  4.30k|	while (ptr < end && *ptr)
  ------------------
  |  Branch (1625:9): [True: 4.28k, False: 14]
  |  Branch (1625:22): [True: 4.28k, False: 6]
  ------------------
 1626|  4.28k|          ptr ++;
 1627|       |
 1628|     20|	if (ptr < end)
  ------------------
  |  Branch (1628:6): [True: 6, False: 14]
  ------------------
 1629|      6|	{
 1630|      6|          ptr ++;
 1631|      6|	}
 1632|     14|	else
 1633|     14|	{
 1634|       |	  // Can't read from file!
 1635|     14|          fp->eof = true;
 1636|     14|	  errno   = EIO;
 1637|       |
 1638|     14|	  return (-1);
 1639|     14|	}
 1640|     20|      }
 1641|       |
 1642|  1.70k|      if (fp->buf[3] & 0x02)
  ------------------
  |  Branch (1642:11): [True: 15, False: 1.69k]
  ------------------
 1643|     15|      {
 1644|       |        // Skip header CRC data...
 1645|     15|	ptr += 2;
 1646|       |
 1647|     15|	if (ptr > end)
  ------------------
  |  Branch (1647:6): [True: 12, False: 3]
  ------------------
 1648|     12|	{
 1649|       |	  // Can't read from file!
 1650|     12|          fp->eof = true;
 1651|     12|	  errno   = EIO;
 1652|       |
 1653|     12|	  return (-1);
 1654|     12|	}
 1655|     15|      }
 1656|       |
 1657|       |      // Copy the flate-compressed data to the compression buffer...
 1658|  1.69k|      if ((bytes = end - ptr) > 0)
  ------------------
  |  Branch (1658:11): [True: 1.69k, False: 3]
  ------------------
 1659|  1.69k|        memcpy(fp->cbuf, ptr, (size_t)bytes);
 1660|       |
 1661|       |      // Setup the decompressor data...
 1662|  1.69k|      fp->stream.zalloc    = (alloc_func)0;
 1663|  1.69k|      fp->stream.zfree     = (free_func)0;
 1664|  1.69k|      fp->stream.opaque    = (voidpf)0;
 1665|  1.69k|      fp->stream.next_in   = (Bytef *)fp->cbuf;
 1666|  1.69k|      fp->stream.next_out  = NULL;
 1667|  1.69k|      fp->stream.avail_in  = (uInt)bytes;
 1668|  1.69k|      fp->stream.avail_out = 0;
 1669|  1.69k|      fp->crc              = crc32(0L, Z_NULL, 0);
 1670|       |
 1671|  1.69k|      if (inflateInit2(&(fp->stream), -15) != Z_OK)
  ------------------
  |  Branch (1671:11): [True: 0, False: 1.69k]
  ------------------
 1672|      0|      {
 1673|      0|        fp->eof = true;
 1674|      0|        errno   = EIO;
 1675|       |
 1676|      0|	return (-1);
 1677|      0|      }
 1678|       |
 1679|  1.69k|      fp->compressed = true;
 1680|  1.69k|    }
 1681|       |
 1682|   153k|    if (fp->compressed)
  ------------------
  |  Branch (1682:9): [True: 153k, False: 0]
  ------------------
 1683|   153k|    {
 1684|       |      // If we have reached end-of-file, return immediately...
 1685|   153k|      if (fp->eof)
  ------------------
  |  Branch (1685:11): [True: 0, False: 153k]
  ------------------
 1686|      0|	return (0);
 1687|       |
 1688|       |      // Fill the decompression buffer as needed...
 1689|   153k|      if (fp->stream.avail_in == 0)
  ------------------
  |  Branch (1689:11): [True: 2.64k, False: 150k]
  ------------------
 1690|  2.64k|      {
 1691|  2.64k|	if ((bytes = cups_read(fp, (char *)fp->cbuf, sizeof(fp->cbuf))) <= 0)
  ------------------
  |  Branch (1691:6): [True: 1.15k, False: 1.49k]
  ------------------
 1692|  1.15k|	{
 1693|  1.15k|	  fp->eof = true;
 1694|       |
 1695|  1.15k|          return (bytes);
 1696|  1.15k|	}
 1697|       |
 1698|  1.49k|	fp->stream.next_in  = fp->cbuf;
 1699|  1.49k|	fp->stream.avail_in = (uInt)bytes;
 1700|  1.49k|      }
 1701|       |
 1702|       |      // Decompress data from the buffer...
 1703|   152k|      fp->stream.next_out  = (Bytef *)fp->buf;
 1704|   152k|      fp->stream.avail_out = sizeof(fp->buf);
 1705|       |
 1706|   152k|      status = inflate(&(fp->stream), Z_NO_FLUSH);
 1707|       |
 1708|   152k|      if (fp->stream.next_out > (Bytef *)fp->buf)
  ------------------
  |  Branch (1708:11): [True: 151k, False: 69]
  ------------------
 1709|   151k|        fp->crc = crc32(fp->crc, (Bytef *)fp->buf, (uInt)(fp->stream.next_out - (Bytef *)fp->buf));
 1710|       |
 1711|   152k|      if (status == Z_STREAM_END)
  ------------------
  |  Branch (1711:11): [True: 81, False: 151k]
  ------------------
 1712|     81|      {
 1713|       |        // Read the CRC and length...
 1714|     81|	unsigned char	trailer[8];	// Trailer bytes
 1715|     81|	uLong		tcrc;		// Trailer CRC
 1716|     81|	ssize_t		tbytes = 0;	// Number of bytes
 1717|       |
 1718|     81|	if (fp->stream.avail_in > 0)
  ------------------
  |  Branch (1718:6): [True: 79, False: 2]
  ------------------
 1719|     79|	{
 1720|       |	  // Get the first N trailer bytes from the inflate stream...
 1721|     79|	  if (fp->stream.avail_in > sizeof(trailer))
  ------------------
  |  Branch (1721:8): [True: 19, False: 60]
  ------------------
 1722|     19|	    tbytes = (ssize_t)sizeof(trailer);
 1723|     60|	  else
 1724|     60|	    tbytes = (ssize_t)fp->stream.avail_in;
 1725|       |
 1726|     79|	  memcpy(trailer, fp->stream.next_in, (size_t)tbytes);
 1727|     79|	  fp->stream.next_in  += tbytes;
 1728|     79|	  fp->stream.avail_in -= (size_t)tbytes;
 1729|     79|	}
 1730|       |
 1731|       |        // Reset the compressed flag so that we re-read the file header...
 1732|     81|        inflateEnd(&fp->stream);
 1733|       |
 1734|     81|	fp->compressed = false;
 1735|       |
 1736|       |        // Get any remaining trailer bytes...
 1737|     81|        if (tbytes < (ssize_t)sizeof(trailer))
  ------------------
  |  Branch (1737:13): [True: 11, False: 70]
  ------------------
 1738|     11|	{
 1739|     11|	  if (read(fp->fd, trailer + tbytes, sizeof(trailer) - (size_t)tbytes) < ((ssize_t)sizeof(trailer) - tbytes))
  ------------------
  |  Branch (1739:8): [True: 10, False: 1]
  ------------------
 1740|     10|	  {
 1741|       |	    // Can't get it, so mark end-of-file...
 1742|     10|	    fp->eof = true;
 1743|     10|	    errno   = EIO;
 1744|       |
 1745|     10|	    return (-1);
 1746|     10|	  }
 1747|     11|	}
 1748|       |
 1749|       |        // Calculate and compare the CRC...
 1750|     71|	tcrc = ((((((uLong)trailer[3] << 8) | (uLong)trailer[2]) << 8) | (uLong)trailer[1]) << 8) | (uLong)trailer[0];
 1751|       |
 1752|     71|	if (tcrc != fp->crc)
  ------------------
  |  Branch (1752:6): [True: 69, False: 2]
  ------------------
 1753|     69|	{
 1754|       |	  // Bad CRC, mark end-of-file...
 1755|     69|	  fp->eof = true;
 1756|     69|	  errno   = EIO;
 1757|       |
 1758|     69|	  return (-1);
 1759|     69|	}
 1760|     71|      }
 1761|   151k|      else if (status < Z_OK)
  ------------------
  |  Branch (1761:16): [True: 26, False: 151k]
  ------------------
 1762|     26|      {
 1763|     26|        fp->eof = true;
 1764|     26|        errno   = EIO;
 1765|       |
 1766|     26|	return (-1);
 1767|     26|      }
 1768|       |
 1769|   151k|      bytes = (ssize_t)sizeof(fp->buf) - (ssize_t)fp->stream.avail_out;
 1770|       |
 1771|       |      // Return the decompressed data...
 1772|   151k|      fp->ptr = fp->buf;
 1773|   151k|      fp->end = fp->buf + bytes;
 1774|       |
 1775|   151k|      if (bytes)
  ------------------
  |  Branch (1775:11): [True: 151k, False: 5]
  ------------------
 1776|   151k|	return (bytes);
 1777|   151k|    }
 1778|   153k|  }
 1779|       |
 1780|       |  // Read a buffer's full of data...
 1781|    743|  if ((bytes = cups_read(fp, fp->buf, sizeof(fp->buf))) <= 0)
  ------------------
  |  Branch (1781:7): [True: 665, False: 78]
  ------------------
 1782|    665|  {
 1783|       |    // Can't read from file!
 1784|    665|    fp->eof = true;
 1785|    665|    fp->ptr = fp->buf;
 1786|    665|    fp->end = fp->buf;
 1787|    665|  }
 1788|     78|  else
 1789|     78|  {
 1790|       |    // Return the bytes we read...
 1791|     78|    fp->eof = false;
 1792|     78|    fp->ptr = fp->buf;
 1793|     78|    fp->end = fp->buf + bytes;
 1794|     78|  }
 1795|       |
 1796|    743|  return (bytes);
 1797|   154k|}
file.c:cups_read:
 1888|  6.09k|{
 1889|  6.09k|  ssize_t	total;			// Total bytes read
 1890|       |
 1891|       |
 1892|       |  // Loop until we read at least 0 bytes...
 1893|  6.09k|  for (;;)
 1894|  6.09k|  {
 1895|       |#ifdef _WIN32
 1896|       |    if (fp->mode == 's')
 1897|       |      total = (ssize_t)recv(fp->fd, buf, (unsigned)bytes, 0);
 1898|       |    else
 1899|       |      total = (ssize_t)read(fp->fd, buf, (unsigned)bytes);
 1900|       |#else
 1901|  6.09k|    if (fp->mode == 's')
  ------------------
  |  Branch (1901:9): [True: 0, False: 6.09k]
  ------------------
 1902|      0|      total = recv(fp->fd, buf, bytes, 0);
 1903|  6.09k|    else
 1904|  6.09k|      total = read(fp->fd, buf, bytes);
 1905|  6.09k|#endif // _WIN32
 1906|       |
 1907|  6.09k|    if (total >= 0)
  ------------------
  |  Branch (1907:9): [True: 6.09k, False: 0]
  ------------------
 1908|  6.09k|      break;
 1909|       |
 1910|       |    // Reads can be interrupted by signals and unavailable resources...
 1911|      0|    if (errno == EAGAIN || errno == EINTR)
  ------------------
  |  Branch (1911:9): [True: 0, False: 0]
  |  Branch (1911:28): [True: 0, False: 0]
  ------------------
 1912|      0|      continue;
 1913|      0|    else
 1914|      0|      return (-1);
 1915|      0|  }
 1916|       |
 1917|       |  // Return the total number of bytes read...
 1918|  6.09k|  return (total);
 1919|  6.09k|}
file.c:cups_open:
 1811|  8.10k|{
 1812|  8.10k|  int		fd;			// File descriptor
 1813|  8.10k|  struct stat	fileinfo;		// File information
 1814|  8.10k|#ifndef _WIN32
 1815|  8.10k|  struct stat	linkinfo;		// Link information
 1816|  8.10k|#endif // !_WIN32
 1817|       |
 1818|       |
 1819|       |  // Open the file...
 1820|  8.10k|  if ((fd = open(filename, oflag, mode)) < 0)
  ------------------
  |  Branch (1820:7): [True: 2.70k, False: 5.40k]
  ------------------
 1821|  2.70k|    return (-1);
 1822|       |
 1823|       |  // Then verify that the file descriptor doesn't point to a directory or hard-linked file.
 1824|  5.40k|  if (fstat(fd, &fileinfo))
  ------------------
  |  Branch (1824:7): [True: 0, False: 5.40k]
  ------------------
 1825|      0|  {
 1826|      0|    int temp = errno;
 1827|      0|    close(fd);
 1828|      0|    errno = temp;
 1829|      0|    return (-1);
 1830|      0|  }
 1831|       |
 1832|  5.40k|  if (fileinfo.st_nlink != 1)
  ------------------
  |  Branch (1832:7): [True: 0, False: 5.40k]
  ------------------
 1833|      0|  {
 1834|      0|    close(fd);
 1835|      0|    errno = EPERM;
 1836|      0|    return (-1);
 1837|      0|  }
 1838|       |
 1839|       |#ifdef _WIN32
 1840|       |  if (fileinfo.st_mode & _S_IFDIR)
 1841|       |#else
 1842|  5.40k|  if (S_ISDIR(fileinfo.st_mode))
  ------------------
  |  Branch (1842:7): [True: 0, False: 5.40k]
  ------------------
 1843|      0|#endif // _WIN32
 1844|      0|  {
 1845|      0|    close(fd);
 1846|      0|    errno = EISDIR;
 1847|      0|    return (-1);
 1848|      0|  }
 1849|       |
 1850|  5.40k|#ifndef _WIN32
 1851|       |  // Then use lstat to determine whether the filename is a symlink...
 1852|  5.40k|  if (lstat(filename, &linkinfo))
  ------------------
  |  Branch (1852:7): [True: 0, False: 5.40k]
  ------------------
 1853|      0|  {
 1854|      0|    int temp = errno;
 1855|      0|    close(fd);
 1856|      0|    errno = temp;
 1857|      0|    return (-1);
 1858|      0|  }
 1859|       |
 1860|  5.40k|  if (S_ISLNK(linkinfo.st_mode) ||
  ------------------
  |  Branch (1860:7): [True: 0, False: 5.40k]
  ------------------
 1861|  5.40k|      fileinfo.st_dev != linkinfo.st_dev ||
  ------------------
  |  Branch (1861:7): [True: 0, False: 5.40k]
  ------------------
 1862|  5.40k|      fileinfo.st_ino != linkinfo.st_ino ||
  ------------------
  |  Branch (1862:7): [True: 0, False: 5.40k]
  ------------------
 1863|       |#ifdef HAVE_ST_GEN
 1864|       |      fileinfo.st_gen != linkinfo.st_gen ||
 1865|       |#endif // HAVE_ST_GEN
 1866|  5.40k|      fileinfo.st_nlink != linkinfo.st_nlink ||
  ------------------
  |  Branch (1866:7): [True: 0, False: 5.40k]
  ------------------
 1867|  5.40k|      fileinfo.st_mode != linkinfo.st_mode)
  ------------------
  |  Branch (1867:7): [True: 0, False: 5.40k]
  ------------------
 1868|      0|  {
 1869|       |    // Yes, don't allow!
 1870|      0|    close(fd);
 1871|      0|    errno = EPERM;
 1872|      0|    return (-1);
 1873|      0|  }
 1874|  5.40k|#endif // !_WIN32
 1875|       |
 1876|  5.40k|  return (fd);
 1877|  5.40k|}
file.c:cups_write:
 1930|   165k|{
 1931|   165k|  ssize_t	count;			// Count this time
 1932|       |
 1933|       |
 1934|       |  // Loop until all bytes are written...
 1935|   331k|  while (bytes > 0)
  ------------------
  |  Branch (1935:10): [True: 165k, False: 165k]
  ------------------
 1936|   165k|  {
 1937|       |#ifdef _WIN32
 1938|       |    if (fp->mode == 's')
 1939|       |      count = (ssize_t)send(fp->fd, buf, (unsigned)bytes, 0);
 1940|       |    else
 1941|       |      count = (ssize_t)write(fp->fd, buf, (unsigned)bytes);
 1942|       |#else
 1943|   165k|    if (fp->mode == 's')
  ------------------
  |  Branch (1943:9): [True: 0, False: 165k]
  ------------------
 1944|      0|      count = send(fp->fd, buf, bytes, 0);
 1945|   165k|    else
 1946|   165k|      count = write(fp->fd, buf, bytes);
 1947|   165k|#endif // _WIN32
 1948|       |
 1949|   165k|    if (count < 0)
  ------------------
  |  Branch (1949:9): [True: 0, False: 165k]
  ------------------
 1950|      0|    {
 1951|       |      // Writes can be interrupted by signals and unavailable resources...
 1952|      0|      if (errno == EAGAIN || errno == EINTR)
  ------------------
  |  Branch (1952:11): [True: 0, False: 0]
  |  Branch (1952:30): [True: 0, False: 0]
  ------------------
 1953|      0|        continue;
 1954|      0|      else
 1955|      0|        return (false);
 1956|      0|    }
 1957|       |
 1958|       |    // Update the counts for the last write call...
 1959|   165k|    bytes -= (size_t)count;
 1960|   165k|    buf   += count;
 1961|   165k|  }
 1962|       |
 1963|       |  // Return the total number of bytes written...
 1964|   165k|  return (true);
 1965|   165k|}

_cupsGlobals:
   67|  1.08M|{
   68|  1.08M|  _cups_globals_t *cg;			// Pointer to global data
   69|       |
   70|       |
   71|  1.08M|#ifndef _WIN32
   72|       |  // Initialize the global data exactly once...
   73|  1.08M|  pthread_once(&cups_globals_key_once, cups_globals_init);
   74|  1.08M|#endif // !_WIN32
   75|       |
   76|       |  // See if we have allocated the data yet...
   77|  1.08M|  if ((cg = (_cups_globals_t *)cupsThreadGetData(cups_globals_key)) == NULL)
  ------------------
  |  |   61|  1.08M|#    define cupsThreadGetData(k) pthread_getspecific(k)
  ------------------
  |  Branch (77:7): [True: 1, False: 1.08M]
  ------------------
   78|      1|  {
   79|       |    // No, allocate memory as set the pointer for the key...
   80|      1|    if ((cg = cups_globals_alloc()) != NULL)
  ------------------
  |  Branch (80:9): [True: 1, False: 0]
  ------------------
   81|      1|      cupsThreadSetData(cups_globals_key, cg);
  ------------------
  |  |   62|      1|#    define cupsThreadSetData(k,p) pthread_setspecific(k,p)
  ------------------
   82|      1|  }
   83|       |
   84|       |  // Return the pointer to the data...
   85|  1.08M|  return (cg);
   86|  1.08M|}
globals.c:cups_globals_alloc:
  155|      1|{
  156|      1|  const char	*cups_userconfig = getenv("CUPS_USERCONFIG");
  157|       |					// Location of user config files
  158|      1|  _cups_globals_t *cg = calloc(1, sizeof(_cups_globals_t));
  159|       |					// Pointer to global data
  160|       |#ifdef _WIN32
  161|       |  HKEY		key;			// Registry key
  162|       |  DWORD		size;			// Size of string
  163|       |  const char	*userprofile = getenv("USERPROFILE");
  164|       |					// User profile (home) directory
  165|       |  char		userconfig[1024],	// User configuration directory
  166|       |		*userptr;		// Pointer into user config
  167|       |  static char	installdir[1024] = "",	// Install directory
  168|       |		sysconfig[1024] = "";	// Server configuration directory
  169|       |#endif // _WIN32
  170|       |
  171|       |
  172|      1|  if (!cg)
  ------------------
  |  Branch (172:7): [True: 0, False: 1]
  ------------------
  173|      0|    return (NULL);
  174|       |
  175|       |  // Clear the global storage and set the default encryption and password callback values...
  176|      1|  memset(cg, 0, sizeof(_cups_globals_t));
  177|      1|  cg->encryption     = (http_encryption_t)-1;
  178|      1|  cg->password_cb    = (cups_password_cb_t)_cupsGetPassword;
  179|      1|  cg->trust_first    = -1;
  180|      1|  cg->any_root       = -1;
  181|      1|  cg->expired_certs  = -1;
  182|      1|  cg->validate_certs = -1;
  183|       |
  184|       |#ifdef DEBUG
  185|       |  // Friendly thread ID for debugging...
  186|       |  cg->thread_id = ++ cups_global_index;
  187|       |#endif // DEBUG
  188|       |
  189|       |  // Then set directories as appropriate...
  190|       |#ifdef _WIN32
  191|       |  if (!installdir[0])
  192|       |  {
  193|       |    // Open the registry...
  194|       |    cupsCopyString(installdir, "C:/Program Files/cups.org", sizeof(installdir));
  195|       |
  196|       |    if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\cups.org", 0, KEY_READ, &key))
  197|       |    {
  198|       |      // Grab the installation directory...
  199|       |      char  *ptr;			// Pointer into installdir
  200|       |
  201|       |      size = sizeof(installdir);
  202|       |      RegQueryValueExA(key, "installdir", NULL, NULL, installdir, &size);
  203|       |      RegCloseKey(key);
  204|       |
  205|       |      for (ptr = installdir; *ptr;)
  206|       |      {
  207|       |        if (*ptr == '\\')
  208|       |        {
  209|       |          if (ptr[1])
  210|       |            *ptr++ = '/';
  211|       |          else
  212|       |            *ptr = '\0';		// Strip trailing "\"
  213|       |        }
  214|       |        else if (*ptr == '/' && !ptr[1])
  215|       |        {
  216|       |          *ptr = '\0';			// Strip trailing "/"
  217|       |        }
  218|       |        else
  219|       |        {
  220|       |          ptr ++;
  221|       |	}
  222|       |      }
  223|       |    }
  224|       |
  225|       |    snprintf(sysconfig, sizeof(sysconfig), "%s/conf", installdir);
  226|       |  }
  227|       |
  228|       |  if ((cg->datadir = getenv("CUPS_DATADIR")) == NULL)
  229|       |    cg->datadir = installdir;
  230|       |
  231|       |  if ((cg->sysconfig = getenv("CUPS_SERVERROOT")) == NULL)
  232|       |    cg->sysconfig = sysconfig;
  233|       |
  234|       |  if (cups_userconfig)
  235|       |    cupsCopyString(userconfig, cups_userconfig, sizeof(userconfig));
  236|       |  else if (userprofile)
  237|       |    snprintf(userconfig, sizeof(userconfig), "%s/AppData/Local/cups", userprofile);
  238|       |  else
  239|       |    cupsCopyString(userconfig, "C:/cups", sizeof(userconfig));
  240|       |
  241|       |  for (userptr = userconfig; *userptr; userptr ++)
  242|       |  {
  243|       |    // Convert back slashes to forward slashes
  244|       |    if (*userptr == '\\')
  245|       |      *userptr = '/';
  246|       |  }
  247|       |
  248|       |  cg->userconfig = strdup(userconfig);
  249|       |
  250|       |#else
  251|      1|  const char	*home = getenv("HOME");	// HOME environment variable
  252|      1|  char		homedir[1024],		// Home directory from account
  253|      1|		temp[1024];		// Temporary directory string
  254|      1|#  ifndef __APPLE__
  255|      1|  const char	*snap_common = getenv("SNAP_COMMON"),
  256|      1|		*xdg_config_home = getenv("XDG_CONFIG_HOME");
  257|       |					// Environment variables
  258|      1|#  endif // !__APPLE__
  259|       |
  260|       |#  ifdef HAVE_GETEUID
  261|       |  if ((geteuid() != getuid() && getuid()) || getegid() != getgid())
  262|       |#  else
  263|      1|  if (!getuid())
  ------------------
  |  Branch (263:7): [True: 1, False: 0]
  ------------------
  264|      1|#  endif // HAVE_GETEUID
  265|      1|  {
  266|       |    // When running setuid/setgid, don't allow environment variables to override
  267|       |    // the system directories...
  268|      1|    cg->datadir   = CUPS_DATADIR;
  ------------------
  |  |   40|      1|#define CUPS_DATADIR "/usr/local/share/libcups3"
  ------------------
  269|      1|    cg->sysconfig = CUPS_SERVERROOT;
  ------------------
  |  |   41|      1|#define CUPS_SERVERROOT "/usr/local/etc/cups"
  ------------------
  270|       |
  271|      1|    cups_userconfig = NULL;
  272|      1|  }
  273|      0|  else
  274|      0|  {
  275|       |    // Allow directories to be overridden by environment variables.
  276|      0|    if ((cg->datadir = getenv("CUPS_DATADIR")) == NULL)
  ------------------
  |  Branch (276:9): [True: 0, False: 0]
  ------------------
  277|      0|      cg->datadir = CUPS_DATADIR;
  ------------------
  |  |   40|      0|#define CUPS_DATADIR "/usr/local/share/libcups3"
  ------------------
  278|       |
  279|      0|    if ((cg->sysconfig = getenv("CUPS_SYSCONFIG")) == NULL)
  ------------------
  |  Branch (279:9): [True: 0, False: 0]
  ------------------
  280|      0|    {
  281|      0|      if ((cg->sysconfig = getenv("CUPS_SERVERROOT")) == NULL)
  ------------------
  |  Branch (281:11): [True: 0, False: 0]
  ------------------
  282|      0|	cg->sysconfig = CUPS_SERVERROOT;
  ------------------
  |  |   41|      0|#define CUPS_SERVERROOT "/usr/local/etc/cups"
  ------------------
  283|      0|    }
  284|      0|  }
  285|       |
  286|      1|  if (!getuid())
  ------------------
  |  Branch (286:7): [True: 1, False: 0]
  ------------------
  287|      1|  {
  288|       |    // When running as root, make "userconfig" the same as "sysconfig"...
  289|      1|    cg->userconfig = strdup(cg->sysconfig);
  290|      1|    return (cg);
  291|      1|  }
  292|      0|  else if (cups_userconfig)
  ------------------
  |  Branch (292:12): [True: 0, False: 0]
  ------------------
  293|      0|  {
  294|       |    // Use the value of the CUPS_USERCONFIG environment variable...
  295|      0|    cg->userconfig = strdup(cups_userconfig);
  296|      0|    return (cg);
  297|      0|  }
  298|       |
  299|       |  // Find the user configuration directory relative to the home directory...
  300|       |#  ifdef __APPLE__
  301|       |  if (!home)
  302|       |#else
  303|      0|  if (!home && !xdg_config_home)
  ------------------
  |  Branch (303:7): [True: 0, False: 0]
  |  Branch (303:16): [True: 0, False: 0]
  ------------------
  304|      0|#  endif // __APPLE__
  305|      0|  {
  306|      0|    struct passwd	pw;		// User info
  307|      0|    struct passwd	*result;	// Auxiliary pointer
  308|       |
  309|      0|    getpwuid_r(getuid(), &pw, cg->pw_buf, PW_BUF_SIZE, &result);
  ------------------
  |  |   93|      0|#define PW_BUF_SIZE 16384		// As per glibc manual page
  ------------------
  310|      0|    if (result)
  ------------------
  |  Branch (310:9): [True: 0, False: 0]
  ------------------
  311|      0|    {
  312|      0|      cupsCopyString(homedir, pw.pw_dir, sizeof(homedir));
  313|      0|      home = homedir;
  314|      0|    }
  315|      0|  }
  316|       |
  317|       |#  ifdef __APPLE__
  318|       |  if (home)
  319|       |  {
  320|       |    // macOS uses ~/Library/Application Support/FOO
  321|       |    snprintf(temp, sizeof(temp), "%s/Library/Application Support/cups", home);
  322|       |  }
  323|       |  else
  324|       |  {
  325|       |    // Something went wrong, use temporary directory...
  326|       |    snprintf(temp, sizeof(temp), "/private/tmp/cups%u", (unsigned)getuid());
  327|       |  }
  328|       |
  329|       |#  else
  330|      0|  if (snap_common)
  ------------------
  |  Branch (330:7): [True: 0, False: 0]
  ------------------
  331|      0|  {
  332|       |    // Snaps use $SNAP_COMMON/FOO
  333|      0|    snprintf(temp, sizeof(temp), "%s/cups", snap_common);
  334|      0|  }
  335|      0|  else if (xdg_config_home)
  ------------------
  |  Branch (335:12): [True: 0, False: 0]
  ------------------
  336|      0|  {
  337|       |    // XDG uses $XDG_CONFIG_HOME/FOO
  338|      0|    snprintf(temp, sizeof(temp), "%s/cups", xdg_config_home);
  339|      0|  }
  340|      0|  else if (home)
  ------------------
  |  Branch (340:12): [True: 0, False: 0]
  ------------------
  341|      0|  {
  342|       |    // Use ~/.cups if it exists, otherwise ~/.config/cups (XDG standard)
  343|      0|    snprintf(temp, sizeof(temp), "%s/.cups", home);
  344|      0|    if (access(temp, 0))
  ------------------
  |  Branch (344:9): [True: 0, False: 0]
  ------------------
  345|      0|      snprintf(temp, sizeof(temp), "%s/.config/cups", home);
  346|      0|  }
  347|      0|  else
  348|      0|  {
  349|       |    // Something went wrong, use temporary directory...
  350|      0|    snprintf(temp, sizeof(temp), "/tmp/cups%u", (unsigned)getuid());
  351|      0|  }
  352|      0|#  endif // __APPLE__
  353|       |
  354|       |  // Can't use _cupsStrAlloc since it causes a loop with debug logging enabled
  355|      0|  cg->userconfig = strdup(temp);
  356|      0|#endif // _WIN32
  357|       |
  358|      0|  return (cg);
  359|      1|}
globals.c:cups_globals_init:
  415|      1|{
  416|       |  // Register the global data for this thread...
  417|      1|  pthread_key_create(&cups_globals_key, (void (*)(void *))cups_globals_free);
  418|      1|}

_cupsBufferGet:
   42|   689k|{
   43|   689k|  _cups_buffer_t	*buffer;	// Current buffer
   44|   689k|  _cups_globals_t	*cg = _cupsGlobals();
   45|       |					// Global data
   46|       |
   47|       |
   48|  1.37M|  for (buffer = cg->cups_buffers; buffer; buffer = buffer->next)
  ------------------
  |  Branch (48:35): [True: 1.37M, False: 11]
  ------------------
   49|  1.37M|    if (!buffer->used && buffer->size >= size)
  ------------------
  |  Branch (49:9): [True: 689k, False: 684k]
  |  Branch (49:26): [True: 689k, False: 0]
  ------------------
   50|   689k|      break;
   51|       |
   52|   689k|  if (!buffer)
  ------------------
  |  Branch (52:7): [True: 11, False: 689k]
  ------------------
   53|     11|  {
   54|     11|    if ((buffer = malloc(sizeof(_cups_buffer_t) + size - 1)) == NULL)
  ------------------
  |  Branch (54:9): [True: 0, False: 11]
  ------------------
   55|      0|      return (NULL);
   56|       |
   57|     11|    buffer->next     = cg->cups_buffers;
   58|     11|    buffer->size     = size;
   59|     11|    cg->cups_buffers = buffer;
   60|     11|  }
   61|       |
   62|   689k|  buffer->used = 1;
   63|       |
   64|   689k|  return (buffer->d);
   65|   689k|}
_cupsBufferRelease:
   74|   689k|{
   75|   689k|  _cups_buffer_t	*buffer;	// Buffer
   76|       |
   77|       |
   78|       |  // Mark this buffer as unused...
   79|       |  buffer       = (_cups_buffer_t *)(b - offsetof(_cups_buffer_t, d));
   80|   689k|  buffer->used = 0;
   81|   689k|}
ippAddSeparator:
  781|  12.6M|{
  782|  12.6M|  DEBUG_printf("ippAddSeparator(ipp=%p)", (void *)ipp);
  783|       |
  784|       |  // Range check input...
  785|  12.6M|  if (!ipp)
  ------------------
  |  Branch (785:7): [True: 0, False: 12.6M]
  ------------------
  786|      0|    return (NULL);
  787|       |
  788|       |  // Create the attribute...
  789|  12.6M|  return (ipp_add_attr(ipp, NULL, IPP_TAG_ZERO, IPP_TAG_ZERO, 0));
  790|  12.6M|}
ippAddString:
  823|  5.40k|{
  824|  5.40k|  ipp_tag_t		temp_tag;	// Temporary value tag (masked)
  825|  5.40k|  ipp_attribute_t	*attr;		// New attribute
  826|  5.40k|  char			code[IPP_MAX_LANGUAGE];
  827|       |					// Charset/language code buffer
  828|       |
  829|       |
  830|  5.40k|  DEBUG_printf("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", language=\"%s\", value=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, language, value);
  831|       |
  832|       |  // Range check input...
  833|  5.40k|  temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_CUPS_MASK);
  834|       |
  835|       |#if 0
  836|       |  if (!ipp || !name || group < IPP_TAG_ZERO ||
  837|       |      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
  838|       |      (temp_tag < IPP_TAG_TEXT && temp_tag != IPP_TAG_TEXTLANG &&
  839|       |       temp_tag != IPP_TAG_NAMELANG) || temp_tag > IPP_TAG_MIMETYPE)
  840|       |    return (NULL);
  841|       |
  842|       |  if ((temp_tag == IPP_TAG_TEXTLANG || temp_tag == IPP_TAG_NAMELANG)
  843|       |          != (language != NULL))
  844|       |    return (NULL);
  845|       |#else
  846|  5.40k|  if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
  ------------------
  |  Branch (846:7): [True: 0, False: 5.40k]
  |  Branch (846:15): [True: 0, False: 5.40k]
  |  Branch (846:24): [True: 0, False: 5.40k]
  |  Branch (846:48): [True: 0, False: 5.40k]
  |  Branch (846:72): [True: 0, False: 5.40k]
  ------------------
  847|      0|    return (NULL);
  848|  5.40k|#endif // 0
  849|       |
  850|       |  // See if we need to map charset, language, or locale values...
  851|  5.40k|  if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) && strcmp(language, ipp_lang_code(language, code, sizeof(code))))
  ------------------
  |  Branch (851:7): [True: 0, False: 5.40k]
  |  Branch (851:19): [True: 0, False: 0]
  |  Branch (851:60): [True: 0, False: 0]
  ------------------
  852|      0|    value_tag = temp_tag;		// Don't do a fast copy
  853|  5.40k|  else if (value && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST) && strcmp(value, ipp_get_code(value, code, sizeof(code))))
  ------------------
  |  Branch (853:12): [True: 5.40k, False: 0]
  |  Branch (853:21): [True: 2.70k, False: 2.70k]
  |  Branch (853:87): [True: 0, False: 2.70k]
  ------------------
  854|      0|    value_tag = temp_tag;		// Don't do a fast copy
  855|  5.40k|  else if (value && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST) && strcmp(value, ipp_lang_code(value, code, sizeof(code))))
  ------------------
  |  Branch (855:12): [True: 5.40k, False: 0]
  |  Branch (855:21): [True: 2.70k, False: 2.70k]
  |  Branch (855:88): [True: 2.70k, False: 0]
  ------------------
  856|  2.70k|    value_tag = temp_tag;		// Don't do a fast copy
  857|       |
  858|       |  // Create the attribute...
  859|  5.40k|  if ((attr = ipp_add_attr(ipp, name, group, value_tag, 1)) == NULL)
  ------------------
  |  Branch (859:7): [True: 0, False: 5.40k]
  ------------------
  860|      0|    return (NULL);
  861|       |
  862|       |  // Initialize the attribute data...
  863|  5.40k|  if ((int)value_tag & IPP_TAG_CUPS_CONST)
  ------------------
  |  Branch (863:7): [True: 2.70k, False: 2.70k]
  ------------------
  864|  2.70k|  {
  865|  2.70k|    attr->values[0].string.language = (char *)language;
  866|  2.70k|    attr->values[0].string.text     = (char *)value;
  867|  2.70k|  }
  868|  2.70k|  else
  869|  2.70k|  {
  870|  2.70k|    if (language)
  ------------------
  |  Branch (870:9): [True: 0, False: 2.70k]
  ------------------
  871|      0|      attr->values[0].string.language = _cupsStrAlloc(ipp_lang_code(language, code, sizeof(code)));
  872|       |
  873|  2.70k|    if (value)
  ------------------
  |  Branch (873:9): [True: 2.70k, False: 0]
  ------------------
  874|  2.70k|    {
  875|  2.70k|      if (value_tag == IPP_TAG_CHARSET)
  ------------------
  |  Branch (875:11): [True: 0, False: 2.70k]
  ------------------
  876|      0|	attr->values[0].string.text = _cupsStrAlloc(ipp_get_code(value, code, sizeof(code)));
  877|  2.70k|      else if (value_tag == IPP_TAG_LANGUAGE)
  ------------------
  |  Branch (877:16): [True: 2.70k, False: 0]
  ------------------
  878|  2.70k|	attr->values[0].string.text = _cupsStrAlloc(ipp_lang_code(value, code, sizeof(code)));
  879|      0|      else
  880|      0|	attr->values[0].string.text = _cupsStrAlloc(value);
  881|  2.70k|    }
  882|  2.70k|  }
  883|       |
  884|  5.40k|  return (attr);
  885|  5.40k|}
ippDelete:
 1678|   391k|{
 1679|   391k|  ipp_attribute_t	*attr,		// Current attribute
 1680|   391k|			*next;		// Next attribute
 1681|       |
 1682|       |
 1683|   391k|  DEBUG_printf("ippDelete(ipp=%p)", (void *)ipp);
 1684|       |
 1685|   391k|  if (!ipp)
  ------------------
  |  Branch (1685:7): [True: 7, False: 391k]
  ------------------
 1686|      7|    return;
 1687|       |
 1688|   391k|  ipp->use --;
 1689|   391k|  if (ipp->use > 0)
  ------------------
  |  Branch (1689:7): [True: 0, False: 391k]
  ------------------
 1690|      0|  {
 1691|      0|    DEBUG_printf("4debug_retain: %p IPP message (use=%u)", (void *)ipp, (unsigned)ipp->use);
 1692|      0|    return;
 1693|      0|  }
 1694|       |
 1695|   391k|  DEBUG_printf("4debug_free: %p IPP message", (void *)ipp);
 1696|       |
 1697|  15.6M|  for (attr = ipp->attrs; attr != NULL; attr = next)
  ------------------
  |  Branch (1697:27): [True: 15.2M, False: 391k]
  ------------------
 1698|  15.2M|  {
 1699|  15.2M|    next = attr->next;
 1700|       |
 1701|  15.2M|    DEBUG_printf("4debug_free: %p %s %s%s (%u values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), (unsigned)attr->num_values);
 1702|       |
 1703|  15.2M|    ipp_free_values(attr, 0, attr->num_values);
 1704|       |
 1705|  15.2M|    if (attr->name)
  ------------------
  |  Branch (1705:9): [True: 2.61M, False: 12.6M]
  ------------------
 1706|  2.61M|      _cupsStrFree(attr->name);
 1707|       |
 1708|  15.2M|    free(attr);
 1709|  15.2M|  }
 1710|       |
 1711|   391k|  free(ipp);
 1712|   391k|}
ippDeleteAttribute:
 1723|  1.80k|{
 1724|  1.80k|  ipp_attribute_t	*current,	// Current attribute
 1725|  1.80k|			*prev;		// Previous attribute
 1726|       |
 1727|       |
 1728|  1.80k|  DEBUG_printf("ippDeleteAttribute(ipp=%p, attr=%p(%s))", (void *)ipp, (void *)attr, attr ? attr->name : "(null)");
 1729|       |
 1730|       |  // Range check input...
 1731|  1.80k|  if (!attr)
  ------------------
  |  Branch (1731:7): [True: 0, False: 1.80k]
  ------------------
 1732|      0|    return;
 1733|       |
 1734|  1.80k|  DEBUG_printf("4debug_free: %p %s %s%s (%u values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), (unsigned)attr->num_values);
 1735|       |
 1736|       |  // Find the attribute in the list...
 1737|  1.80k|  if (ipp)
  ------------------
  |  Branch (1737:7): [True: 1.80k, False: 0]
  ------------------
 1738|  1.80k|  {
 1739|  7.86M|    for (current = ipp->attrs, prev = NULL; current; prev = current, current = current->next)
  ------------------
  |  Branch (1739:45): [True: 7.86M, False: 0]
  ------------------
 1740|  7.86M|    {
 1741|  7.86M|      if (current == attr)
  ------------------
  |  Branch (1741:11): [True: 1.80k, False: 7.85M]
  ------------------
 1742|  1.80k|      {
 1743|       |	// Found it, remove the attribute from the list...
 1744|  1.80k|	if (prev)
  ------------------
  |  Branch (1744:6): [True: 1.03k, False: 764]
  ------------------
 1745|  1.03k|	  prev->next = current->next;
 1746|    764|	else
 1747|    764|	  ipp->attrs = current->next;
 1748|       |
 1749|  1.80k|	if (current == ipp->last)
  ------------------
  |  Branch (1749:6): [True: 1.80k, False: 0]
  ------------------
 1750|  1.80k|	  ipp->last = prev;
 1751|       |
 1752|  1.80k|        break;
 1753|  1.80k|      }
 1754|  7.86M|    }
 1755|       |
 1756|  1.80k|    if (!current)
  ------------------
  |  Branch (1756:9): [True: 0, False: 1.80k]
  ------------------
 1757|      0|      return;
 1758|  1.80k|  }
 1759|       |
 1760|       |  // Free memory used by the attribute...
 1761|  1.80k|  ipp_free_values(attr, 0, attr->num_values);
 1762|       |
 1763|  1.80k|  if (attr->name)
  ------------------
  |  Branch (1763:7): [True: 1.75k, False: 48]
  ------------------
 1764|  1.75k|    _cupsStrFree(attr->name);
 1765|       |
 1766|  1.80k|  free(attr);
 1767|  1.80k|}
ippNew:
 2377|   391k|{
 2378|   391k|  ipp_t			*temp;		// New IPP message
 2379|   391k|  _cups_globals_t	*cg = _cupsGlobals();
 2380|       |					// Global data
 2381|       |
 2382|       |
 2383|   391k|  DEBUG_puts("ippNew()");
 2384|       |
 2385|   391k|  if ((temp = (ipp_t *)calloc(1, sizeof(ipp_t))) != NULL)
  ------------------
  |  Branch (2385:7): [True: 391k, False: 0]
  ------------------
 2386|   391k|  {
 2387|       |    // Set default version - usually 2.0...
 2388|   391k|    DEBUG_printf("4debug_alloc: %p IPP message", (void *)temp);
 2389|       |
 2390|   391k|    if (!cg->client_conf_loaded)
  ------------------
  |  Branch (2390:9): [True: 1, False: 391k]
  ------------------
 2391|      1|      _cupsSetDefaults();
 2392|       |
 2393|   391k|    temp->request.version[0] = (ipp_uchar_t)(cg->server_version / 10);
 2394|   391k|    temp->request.version[1] = (ipp_uchar_t)(cg->server_version % 10);
 2395|   391k|    temp->use                = 1;
 2396|   391k|    temp->find               = temp->fstack;
 2397|   391k|  }
 2398|       |
 2399|   391k|  DEBUG_printf("1ippNew: Returning %p", (void *)temp);
 2400|       |
 2401|   391k|  return (temp);
 2402|   391k|}
ippNewRequest:
 2415|  2.70k|{
 2416|  2.70k|  ipp_t		*request;		// IPP request message
 2417|  2.70k|  cups_lang_t	*language;		// Current language localization
 2418|  2.70k|  static int	request_id = 0;		// Current request ID
 2419|  2.70k|  static cups_mutex_t request_mutex = CUPS_MUTEX_INITIALIZER;
  ------------------
  |  |   58|  2.70k|#    define CUPS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  ------------------
 2420|       |					// Mutex for request ID
 2421|       |
 2422|       |
 2423|  2.70k|  DEBUG_printf("ippNewRequest(op=%02x(%s))", op, ippOpString(op));
 2424|       |
 2425|       |  // Create a new IPP message...
 2426|  2.70k|  if ((request = ippNew()) == NULL)
  ------------------
  |  Branch (2426:7): [True: 0, False: 2.70k]
  ------------------
 2427|      0|    return (NULL);
 2428|       |
 2429|       |  // Set the operation and request ID...
 2430|  2.70k|  cupsMutexLock(&request_mutex);
 2431|       |
 2432|  2.70k|  request->request.op_status  = (short)op;
 2433|  2.70k|  request->request.request_id = ++request_id;
 2434|       |
 2435|  2.70k|  cupsMutexUnlock(&request_mutex);
 2436|       |
 2437|       |  // Use UTF-8 as the character set...
 2438|  2.70k|  ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_CHARSET), "attributes-charset", NULL, "utf-8");
  ------------------
  |  |   25|  2.70k|#  define IPP_CONST_TAG(x) (ipp_tag_t)(IPP_TAG_CUPS_CONST | (x))
  ------------------
 2439|       |
 2440|       |  // Get the language from the current locale...
 2441|  2.70k|  language = cupsLangDefault();
 2442|       |
 2443|  2.70k|  ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_LANGUAGE), "attributes-natural-language", NULL, cupsLangGetName(language));
  ------------------
  |  |   25|  2.70k|#  define IPP_CONST_TAG(x) (ipp_tag_t)(IPP_TAG_CUPS_CONST | (x))
  ------------------
 2444|       |
 2445|       |  // Return the new request...
 2446|  2.70k|  return (request);
 2447|  2.70k|}
ippReadIO:
 2563|  2.70k|{
 2564|  2.70k|  DEBUG_printf("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)src, (void *)cb, blocking, (void *)parent, (void *)ipp);
 2565|       |
 2566|  2.70k|  if (!src || !ipp)
  ------------------
  |  Branch (2566:7): [True: 0, False: 2.70k]
  |  Branch (2566:15): [True: 0, False: 2.70k]
  ------------------
 2567|      0|    return (IPP_STATE_ERROR);
 2568|       |
 2569|  2.70k|  return (ipp_read_io(src, cb, blocking, parent, ipp, /*depth*/0));
 2570|  2.70k|}
ippSetState:
 3025|  2.70k|{
 3026|       |  // Range check input...
 3027|  2.70k|  if (!ipp)
  ------------------
  |  Branch (3027:7): [True: 0, False: 2.70k]
  ------------------
 3028|      0|    return (false);
 3029|       |
 3030|       |  // Set the state and return...
 3031|  2.70k|  ipp->state   = state;
 3032|  2.70k|  ipp->current = NULL;
 3033|       |
 3034|       |  return (true);
 3035|  2.70k|}
ippSetValueTag:
 3311|   280k|{
 3312|   280k|  size_t	i;			// Looping var
 3313|   280k|  _ipp_value_t	*value;			// Current value
 3314|   280k|  int		integer;		// Current integer value
 3315|   280k|  cups_lang_t	*language;		// Current language
 3316|   280k|  char		code[32];		// Language code
 3317|   280k|  ipp_tag_t	temp_tag;		// Temporary value tag
 3318|       |
 3319|       |
 3320|   280k|  DEBUG_printf("ippSetValueTag(ipp=%p, attr=%p(%p), value_tag=0x%x(%s))", ipp, attr, attr ? *attr : NULL, value_tag, ippTagString(value_tag));
 3321|       |
 3322|       |  // Range check input...
 3323|   280k|  if (!ipp || !attr || !*attr)
  ------------------
  |  Branch (3323:7): [True: 0, False: 280k]
  |  Branch (3323:15): [True: 0, False: 280k]
  |  Branch (3323:24): [True: 0, False: 280k]
  ------------------
 3324|      0|    return (false);
 3325|       |
 3326|       |  // If there is no change, return immediately...
 3327|   280k|  temp_tag = (ipp_tag_t)((int)((*attr)->value_tag) & IPP_TAG_CUPS_MASK);
 3328|       |
 3329|   280k|  if (value_tag == temp_tag)
  ------------------
  |  Branch (3329:7): [True: 0, False: 280k]
  ------------------
 3330|      0|  {
 3331|      0|    DEBUG_puts("2ippSetValueTag: No change.");
 3332|      0|    return (true);
 3333|      0|  }
 3334|       |
 3335|       |  // Otherwise implement changes as needed...
 3336|   280k|  switch (value_tag)
 3337|   280k|  {
 3338|      0|    case IPP_TAG_UNSUPPORTED_VALUE :
  ------------------
  |  Branch (3338:5): [True: 0, False: 280k]
  ------------------
 3339|      0|    case IPP_TAG_DEFAULT :
  ------------------
  |  Branch (3339:5): [True: 0, False: 280k]
  ------------------
 3340|      0|    case IPP_TAG_UNKNOWN :
  ------------------
  |  Branch (3340:5): [True: 0, False: 280k]
  ------------------
 3341|  3.51k|    case IPP_TAG_NOVALUE :
  ------------------
  |  Branch (3341:5): [True: 3.51k, False: 276k]
  ------------------
 3342|  3.51k|    case IPP_TAG_NOTSETTABLE :
  ------------------
  |  Branch (3342:5): [True: 0, False: 280k]
  ------------------
 3343|  3.51k|    case IPP_TAG_DELETEATTR :
  ------------------
  |  Branch (3343:5): [True: 0, False: 280k]
  ------------------
 3344|  3.51k|    case IPP_TAG_ADMINDEFINE :
  ------------------
  |  Branch (3344:5): [True: 0, False: 280k]
  ------------------
 3345|       |        // Free any existing values...
 3346|  3.51k|        if ((*attr)->num_values > 0)
  ------------------
  |  Branch (3346:13): [True: 3.51k, False: 0]
  ------------------
 3347|  3.51k|          ipp_free_values(*attr, 0, (*attr)->num_values);
 3348|       |
 3349|       |        // Set out-of-band value...
 3350|  3.51k|        (*attr)->value_tag = value_tag;
 3351|  3.51k|        break;
 3352|       |
 3353|    273|    case IPP_TAG_RANGE :
  ------------------
  |  Branch (3353:5): [True: 273, False: 279k]
  ------------------
 3354|    273|        if (temp_tag != IPP_TAG_INTEGER)
  ------------------
  |  Branch (3354:13): [True: 0, False: 273]
  ------------------
 3355|      0|        {
 3356|      0|          DEBUG_printf("2ippSetValueTag: Unable to convert %s to rangeOfInteger.", ippTagString(temp_tag));
 3357|      0|          return (false);
 3358|      0|        }
 3359|       |
 3360|   305k|        for (i = (*attr)->num_values, value = (*attr)->values; i > 0; i --, value ++)
  ------------------
  |  Branch (3360:64): [True: 304k, False: 273]
  ------------------
 3361|   304k|        {
 3362|   304k|          integer            = value->integer;
 3363|   304k|          value->range.lower = value->range.upper = integer;
 3364|   304k|          DEBUG_printf("2ippSetValueTag: values[%u].lower=%d, .upper=%d", (unsigned)((*attr)->num_values - i), value->range.lower, value->range.upper);
 3365|   304k|        }
 3366|       |
 3367|    273|        (*attr)->value_tag = IPP_TAG_RANGE;
 3368|    273|        break;
 3369|       |
 3370|    217|    case IPP_TAG_NAME :
  ------------------
  |  Branch (3370:5): [True: 217, False: 279k]
  ------------------
 3371|    217|        if (temp_tag != IPP_TAG_KEYWORD)
  ------------------
  |  Branch (3371:13): [True: 4, False: 213]
  ------------------
 3372|      4|        {
 3373|      4|          DEBUG_printf("2ippSetValueTag: Unable to convert %s to name.", ippTagString(temp_tag));
 3374|      4|          return (false);
 3375|      4|        }
 3376|       |
 3377|    213|        (*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_CUPS_CONST));
 3378|    213|        break;
 3379|       |
 3380|    607|    case IPP_TAG_NAMELANG :
  ------------------
  |  Branch (3380:5): [True: 607, False: 279k]
  ------------------
 3381|  2.79k|    case IPP_TAG_TEXTLANG :
  ------------------
  |  Branch (3381:5): [True: 2.18k, False: 277k]
  ------------------
 3382|  2.79k|        if (value_tag == IPP_TAG_NAMELANG && (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD))
  ------------------
  |  Branch (3382:13): [True: 607, False: 2.18k]
  |  Branch (3382:47): [True: 335, False: 272]
  |  Branch (3382:75): [True: 6, False: 329]
  ------------------
 3383|      6|        {
 3384|      6|          DEBUG_printf("2ippSetValueTag: Unable to convert %s to nameWithLanguage.", ippTagString(temp_tag));
 3385|      6|          return (false);
 3386|      6|        }
 3387|       |
 3388|  2.78k|        if (value_tag == IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_TEXT)
  ------------------
  |  Branch (3388:13): [True: 2.18k, False: 601]
  |  Branch (3388:46): [True: 5, False: 2.18k]
  ------------------
 3389|      5|        {
 3390|      5|          DEBUG_printf("2ippSetValueTag: Unable to convert %s to textWithLanguage.", ippTagString(temp_tag));
 3391|      5|          return (false);
 3392|      5|        }
 3393|       |
 3394|  2.78k|        if (ipp->attrs && ipp->attrs->next && ipp->attrs->next->name && !strcmp(ipp->attrs->next->name, "attributes-natural-language") && (ipp->attrs->next->value_tag & IPP_TAG_CUPS_MASK) == IPP_TAG_LANGUAGE)
  ------------------
  |  Branch (3394:13): [True: 2.78k, False: 0]
  |  Branch (3394:27): [True: 2.56k, False: 216]
  |  Branch (3394:47): [True: 735, False: 1.83k]
  |  Branch (3394:73): [True: 399, False: 336]
  |  Branch (3394:139): [True: 196, False: 203]
  ------------------
 3395|    196|        {
 3396|       |          // Use the language code from the IPP message...
 3397|    196|	  (*attr)->values[0].string.language = _cupsStrAlloc(ipp->attrs->next->values[0].string.text);
 3398|    196|        }
 3399|  2.58k|        else
 3400|  2.58k|        {
 3401|       |          // Otherwise, use the language code corresponding to the locale...
 3402|  2.58k|	  language = cupsLangDefault();
 3403|  2.58k|	  (*attr)->values[0].string.language = _cupsStrAlloc(ipp_lang_code(cupsLangGetName(language), code, sizeof(code)));
 3404|  2.58k|        }
 3405|       |
 3406|  2.78k|	DEBUG_printf("2ippSetValueTag: values[0].string.language=\"%s\"(%p)", (*attr)->values[0].string.language, (*attr)->values[0].string.language);
 3407|       |
 3408|   371k|        for (i = (*attr)->num_values - 1, value = (*attr)->values + 1; i > 0; i --, value ++)
  ------------------
  |  Branch (3408:72): [True: 368k, False: 2.78k]
  ------------------
 3409|   368k|        {
 3410|   368k|          value->string.language = (*attr)->values[0].string.language;
 3411|   368k|          DEBUG_printf("2ippSetValueTag: values[%u].string.language=\"%s\"(%s)", (unsigned)((*attr)->num_values - i), value->string.language, value->string.language);
 3412|   368k|        }
 3413|       |
 3414|  2.78k|        if ((int)(*attr)->value_tag & IPP_TAG_CUPS_CONST)
  ------------------
  |  Branch (3414:13): [True: 0, False: 2.78k]
  ------------------
 3415|      0|        {
 3416|       |          // Make copies of all values...
 3417|      0|	  for (i = (*attr)->num_values, value = (*attr)->values; i > 0; i --, value ++)
  ------------------
  |  Branch (3417:59): [True: 0, False: 0]
  ------------------
 3418|      0|	  {
 3419|      0|	    value->string.text = _cupsStrAlloc(value->string.text);
 3420|      0|	    DEBUG_printf("2ippSetValueTag: values[%u].string.text=\"%s\"(%s)", (unsigned)((*attr)->num_values - i), value->string.text, value->string.text);
 3421|      0|	  }
 3422|      0|        }
 3423|       |
 3424|  2.78k|        (*attr)->value_tag = IPP_TAG_NAMELANG;
 3425|  2.78k|        break;
 3426|       |
 3427|   273k|    case IPP_TAG_KEYWORD :
  ------------------
  |  Branch (3427:5): [True: 273k, False: 6.79k]
  ------------------
 3428|   273k|        if (temp_tag == IPP_TAG_NAME || temp_tag == IPP_TAG_NAMELANG)
  ------------------
  |  Branch (3428:13): [True: 98.0k, False: 175k]
  |  Branch (3428:41): [True: 175k, False: 8]
  ------------------
 3429|   273k|        {
 3430|   273k|          DEBUG_printf("2ippSetValueTag: Ignoring change of %s to keyword.", ippTagString(temp_tag));
 3431|   273k|          break;			// Silently "allow" name -> keyword
 3432|   273k|        }
 3433|       |
 3434|      8|        DEBUG_printf("2ippSetValueTag: Unable to convert %s to keyword.", ippTagString(temp_tag));
 3435|      8|        return (false);
 3436|       |
 3437|      0|    case IPP_TAG_EXTENSION :
  ------------------
  |  Branch (3437:5): [True: 0, False: 280k]
  ------------------
 3438|      0|        if (temp_tag == IPP_TAG_STRING && value_tag == IPP_TAG_EXTENSION)
  ------------------
  |  Branch (3438:13): [True: 0, False: 0]
  |  Branch (3438:43): [True: 0, False: 0]
  ------------------
 3439|      0|        {
 3440|       |          // Allow octetString -> extension
 3441|      0|          (*attr)->value_tag = value_tag;
 3442|      0|          DEBUG_puts("2ippSetValueTag: Changing octetString to extension.");
 3443|      0|          break;
 3444|      0|        }
 3445|       |
 3446|      3|    default :
  ------------------
  |  Branch (3446:5): [True: 3, False: 280k]
  ------------------
 3447|      3|        DEBUG_printf("2ippSetValueTag: Unable to convert %s to %s.", ippTagString(temp_tag), ippTagString(value_tag));
 3448|      3|        return (false);
 3449|   280k|  }
 3450|       |
 3451|   280k|  DEBUG_puts("2ippSetValueTag: Successful.");
 3452|       |  return (true);
 3453|   280k|}
ippWriteIO:
 4099|   300k|{
 4100|   300k|  size_t		i;		// Looping var
 4101|   300k|  int			n;		// Length of data
 4102|   300k|  unsigned char		*buffer,	// Data buffer
 4103|   300k|			*bufptr;	// Pointer into buffer
 4104|   300k|  ipp_attribute_t	*attr;		// Current attribute
 4105|   300k|  _ipp_value_t		*value;		// Current value
 4106|       |
 4107|       |
 4108|   300k|  DEBUG_printf("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)dst, (void *)cb, blocking, (void *)parent, (void *)ipp);
 4109|       |
 4110|   300k|  if (!dst || !ipp)
  ------------------
  |  Branch (4110:7): [True: 0, False: 300k]
  |  Branch (4110:15): [True: 0, False: 300k]
  ------------------
 4111|      0|    return (IPP_STATE_ERROR);
 4112|       |
 4113|   300k|  if ((buffer = (unsigned char *)_cupsBufferGet(IPP_BUF_SIZE)) == NULL)
  ------------------
  |  |   24|   300k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   300k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4113:7): [True: 0, False: 300k]
  ------------------
 4114|      0|  {
 4115|      0|    DEBUG_puts("1ippWriteIO: Unable to get write buffer");
 4116|      0|    return (IPP_STATE_ERROR);
 4117|      0|  }
 4118|       |
 4119|   300k|  switch (ipp->state)
 4120|   300k|  {
 4121|   300k|    case IPP_STATE_IDLE :
  ------------------
  |  Branch (4121:5): [True: 300k, False: 0]
  ------------------
 4122|   300k|        ipp->state ++; // Avoid common problem...
 4123|       |
 4124|   300k|    case IPP_STATE_HEADER :
  ------------------
  |  Branch (4124:5): [True: 0, False: 300k]
  ------------------
 4125|   300k|        if (parent == NULL)
  ------------------
  |  Branch (4125:13): [True: 5.40k, False: 294k]
  ------------------
 4126|  5.40k|	{
 4127|       |	  // Send the request header:
 4128|       |	  //
 4129|       |	  //                 Version = 2 bytes
 4130|       |	  //   Operation/Status Code = 2 bytes
 4131|       |	  //              Request ID = 4 bytes
 4132|       |	  //                   Total = 8 bytes
 4133|  5.40k|          bufptr = buffer;
 4134|       |
 4135|  5.40k|	  *bufptr++ = ipp->request.version[0];
 4136|  5.40k|	  *bufptr++ = ipp->request.version[1];
 4137|  5.40k|	  *bufptr++ = (ipp_uchar_t)(ipp->request.op_status >> 8);
 4138|  5.40k|	  *bufptr++ = (ipp_uchar_t)ipp->request.op_status;
 4139|  5.40k|	  *bufptr++ = (ipp_uchar_t)(ipp->request.request_id >> 24);
 4140|  5.40k|	  *bufptr++ = (ipp_uchar_t)(ipp->request.request_id >> 16);
 4141|  5.40k|	  *bufptr++ = (ipp_uchar_t)(ipp->request.request_id >> 8);
 4142|  5.40k|	  *bufptr++ = (ipp_uchar_t)ipp->request.request_id;
 4143|       |
 4144|  5.40k|	  DEBUG_printf("2ippWriteIO: version=%d.%d", buffer[0], buffer[1]);
 4145|  5.40k|	  DEBUG_printf("2ippWriteIO: op_status=%04x", ipp->request.op_status);
 4146|  5.40k|	  DEBUG_printf("2ippWriteIO: request_id=%d", ipp->request.request_id);
 4147|       |
 4148|  5.40k|          if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4148:15): [True: 0, False: 5.40k]
  ------------------
 4149|      0|	  {
 4150|      0|	    DEBUG_puts("1ippWriteIO: Could not write IPP header...");
 4151|      0|	    _cupsBufferRelease((char *)buffer);
 4152|      0|	    return (IPP_STATE_ERROR);
 4153|      0|	  }
 4154|  5.40k|	}
 4155|       |
 4156|       |	// Reset the state engine to point to the first attribute
 4157|       |	// in the request/response, with no current group.
 4158|   300k|        ipp->state   = IPP_STATE_ATTRIBUTE;
 4159|   300k|	ipp->current = ipp->attrs;
 4160|   300k|	ipp->curtag  = IPP_TAG_ZERO;
 4161|       |
 4162|   300k|	DEBUG_printf("1ippWriteIO: ipp->current=%p", (void *)ipp->current);
 4163|       |
 4164|       |        // If blocking is disabled, stop here...
 4165|   300k|        if (!blocking)
  ------------------
  |  Branch (4165:13): [True: 0, False: 300k]
  ------------------
 4166|      0|	  break;
 4167|       |
 4168|   300k|    case IPP_STATE_ATTRIBUTE :
  ------------------
  |  Branch (4168:5): [True: 0, False: 300k]
  ------------------
 4169|  15.5M|        while (ipp->current != NULL)
  ------------------
  |  Branch (4169:16): [True: 15.2M, False: 300k]
  ------------------
 4170|  15.2M|	{
 4171|       |	  // Write this attribute...
 4172|  15.2M|	  bufptr = buffer;
 4173|  15.2M|	  attr   = ipp->current;
 4174|       |
 4175|  15.2M|	  ipp->current = ipp->current->next;
 4176|       |
 4177|  15.2M|          if (!parent)
  ------------------
  |  Branch (4177:15): [True: 15.2M, False: 557]
  ------------------
 4178|  15.2M|	  {
 4179|  15.2M|	    if (ipp->curtag != attr->group_tag)
  ------------------
  |  Branch (4179:10): [True: 668k, False: 14.5M]
  ------------------
 4180|   668k|	    {
 4181|       |	      // Send a group tag byte...
 4182|   668k|	      ipp->curtag = attr->group_tag;
 4183|       |
 4184|   668k|	      if (attr->group_tag == IPP_TAG_ZERO)
  ------------------
  |  Branch (4184:12): [True: 332k, False: 336k]
  ------------------
 4185|   332k|		continue;
 4186|       |
 4187|   336k|	      DEBUG_printf("2ippWriteIO: wrote group tag=%x(%s)", attr->group_tag, ippTagString(attr->group_tag));
 4188|   336k|	      *bufptr++ = (ipp_uchar_t)attr->group_tag;
 4189|   336k|	    }
 4190|  14.5M|	    else if (attr->group_tag == IPP_TAG_ZERO)
  ------------------
  |  Branch (4190:15): [True: 12.2M, False: 2.27M]
  ------------------
 4191|  12.2M|	    {
 4192|  12.2M|	      continue;
 4193|  12.2M|	    }
 4194|  15.2M|	  }
 4195|       |
 4196|  2.61M|	  DEBUG_printf("1ippWriteIO: %s (%s%s)", attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag));
 4197|       |
 4198|       |	  // Write the attribute tag and name.
 4199|       |	  //
 4200|       |	  // The attribute name length does not include the trailing nul
 4201|       |	  // character in the source string.
 4202|       |	  //
 4203|       |	  // Collection values (parent != NULL) are written differently...
 4204|  2.61M|          if (parent == NULL)
  ------------------
  |  Branch (4204:15): [True: 2.61M, False: 557]
  ------------------
 4205|  2.61M|	  {
 4206|       |	    // Get the length of the attribute name, and make sure it won't overflow the buffer...
 4207|  2.61M|            if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 8))
  ------------------
  |  |   24|  2.61M|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|  2.61M|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4207:17): [True: 1, False: 2.61M]
  ------------------
 4208|      1|	    {
 4209|      1|	      DEBUG_printf("1ippWriteIO: Attribute name too long (%d)", n);
 4210|      1|	      _cupsBufferRelease((char *)buffer);
 4211|      1|	      return (IPP_STATE_ERROR);
 4212|      1|	    }
 4213|       |
 4214|       |	    // Write the value tag, name length, and name string...
 4215|  2.61M|	    DEBUG_printf("2ippWriteIO: writing value tag=%x(%s)", attr->value_tag, ippTagString(attr->value_tag));
 4216|  2.61M|            DEBUG_printf("2ippWriteIO: writing name=%d,\"%s\"", n, attr->name);
 4217|       |
 4218|  2.61M|	    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4219|  2.61M|	    *bufptr++ = (ipp_uchar_t)(n >> 8);
 4220|  2.61M|	    *bufptr++ = (ipp_uchar_t)n;
 4221|  2.61M|	    memcpy(bufptr, attr->name, (size_t)n);
 4222|  2.61M|	    bufptr += n;
 4223|  2.61M|          }
 4224|    557|	  else
 4225|    557|	  {
 4226|       |	    // Get the length of the attribute name, and make sure it won't overflow the buffer...
 4227|    557|            if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 12))
  ------------------
  |  |   24|    557|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|    557|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4227:17): [True: 1, False: 556]
  ------------------
 4228|      1|	    {
 4229|      1|	      DEBUG_printf("1ippWriteIO: Attribute name too long (%d)", n);
 4230|      1|	      _cupsBufferRelease((char *)buffer);
 4231|      1|	      return (IPP_STATE_ERROR);
 4232|      1|	    }
 4233|       |
 4234|       |	    // Write the member name tag, name length, name string, value tag,
 4235|       |	    // and empty name for the collection member attribute...
 4236|    556|            DEBUG_printf("2ippWriteIO: writing value tag=%x(memberName)", IPP_TAG_MEMBERNAME);
 4237|    556|            DEBUG_printf("2ippWriteIO: writing name=%d,\"%s\"", n, attr->name);
 4238|    556|            DEBUG_printf("2ippWriteIO: writing value tag=%x(%s)", attr->value_tag, ippTagString(attr->value_tag));
 4239|    556|            DEBUG_puts("2ippWriteIO: writing name=0,\"\"");
 4240|       |
 4241|    556|            *bufptr++ = IPP_TAG_MEMBERNAME;
 4242|    556|	    *bufptr++ = 0;
 4243|    556|	    *bufptr++ = 0;
 4244|    556|	    *bufptr++ = (ipp_uchar_t)(n >> 8);
 4245|    556|	    *bufptr++ = (ipp_uchar_t)n;
 4246|    556|	    memcpy(bufptr, attr->name, (size_t)n);
 4247|    556|	    bufptr += n;
 4248|       |
 4249|    556|            if (attr->value_tag > 0xff)
  ------------------
  |  Branch (4249:17): [True: 0, False: 556]
  ------------------
 4250|      0|            {
 4251|      0|              *bufptr++ = IPP_TAG_EXTENSION;
 4252|      0|	      *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 24);
 4253|      0|	      *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 16);
 4254|      0|	      *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 8);
 4255|      0|	      *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4256|      0|            }
 4257|    556|            else
 4258|    556|            {
 4259|    556|	      *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4260|    556|	    }
 4261|       |
 4262|    556|            *bufptr++ = 0;
 4263|    556|            *bufptr++ = 0;
 4264|    556|	  }
 4265|       |
 4266|       |	  // Now write the attribute value(s)...
 4267|  2.61M|	  switch (attr->value_tag & ~IPP_TAG_CUPS_CONST)
 4268|  2.61M|	  {
 4269|    216|	    case IPP_TAG_UNSUPPORTED_VALUE :
  ------------------
  |  Branch (4269:6): [True: 216, False: 2.61M]
  ------------------
 4270|    432|	    case IPP_TAG_DEFAULT :
  ------------------
  |  Branch (4270:6): [True: 216, False: 2.61M]
  ------------------
 4271|    657|	    case IPP_TAG_UNKNOWN :
  ------------------
  |  Branch (4271:6): [True: 225, False: 2.61M]
  ------------------
 4272|  1.02k|	    case IPP_TAG_NOVALUE :
  ------------------
  |  Branch (4272:6): [True: 371, False: 2.61M]
  ------------------
 4273|  1.40k|	    case IPP_TAG_NOTSETTABLE :
  ------------------
  |  Branch (4273:6): [True: 374, False: 2.61M]
  ------------------
 4274|  1.61k|	    case IPP_TAG_DELETEATTR :
  ------------------
  |  Branch (4274:6): [True: 215, False: 2.61M]
  ------------------
 4275|  1.83k|	    case IPP_TAG_ADMINDEFINE :
  ------------------
  |  Branch (4275:6): [True: 217, False: 2.61M]
  ------------------
 4276|  1.83k|		*bufptr++ = 0;
 4277|  1.83k|		*bufptr++ = 0;
 4278|  1.83k|	        break;
 4279|       |
 4280|    546|	    case IPP_TAG_INTEGER :
  ------------------
  |  Branch (4280:6): [True: 546, False: 2.61M]
  ------------------
 4281|    799|	    case IPP_TAG_ENUM :
  ------------------
  |  Branch (4281:6): [True: 253, False: 2.61M]
  ------------------
 4282|   314k|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4282:44): [True: 313k, False: 799]
  ------------------
 4283|   313k|		{
 4284|   313k|                  if ((IPP_BUF_SIZE - (bufptr - buffer)) < 9)
  ------------------
  |  |   24|   313k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   313k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4284:23): [True: 78, False: 313k]
  ------------------
 4285|     78|		  {
 4286|     78|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4286:25): [True: 0, False: 78]
  ------------------
 4287|      0|	            {
 4288|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4289|      0|		      _cupsBufferRelease((char *)buffer);
 4290|      0|	              return (IPP_STATE_ERROR);
 4291|      0|	            }
 4292|       |
 4293|     78|		    bufptr = buffer;
 4294|     78|		  }
 4295|       |
 4296|   313k|		  if (i)
  ------------------
  |  Branch (4296:9): [True: 312k, False: 799]
  ------------------
 4297|   312k|		  {
 4298|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4299|   312k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4300|   312k|		    *bufptr++ = 0;
 4301|   312k|		    *bufptr++ = 0;
 4302|   312k|		  }
 4303|       |
 4304|       |	          // Integers and enumerations are both 4-byte signed
 4305|       |		  // (twos-complement) values.
 4306|       |		  //
 4307|       |		  // Put the 2-byte length and 4-byte value into the buffer...
 4308|   313k|	          *bufptr++ = 0;
 4309|   313k|		  *bufptr++ = 4;
 4310|   313k|		  *bufptr++ = (ipp_uchar_t)(value->integer >> 24);
 4311|   313k|		  *bufptr++ = (ipp_uchar_t)(value->integer >> 16);
 4312|   313k|		  *bufptr++ = (ipp_uchar_t)(value->integer >> 8);
 4313|   313k|		  *bufptr++ = (ipp_uchar_t)value->integer;
 4314|   313k|		}
 4315|    799|		break;
 4316|       |
 4317|    799|	    case IPP_TAG_BOOLEAN :
  ------------------
  |  Branch (4317:6): [True: 370, False: 2.61M]
  ------------------
 4318|   379k|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4318:44): [True: 378k, False: 370]
  ------------------
 4319|   378k|		{
 4320|   378k|                  if ((IPP_BUF_SIZE - (bufptr - buffer)) < 6)
  ------------------
  |  |   24|   378k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   378k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4320:23): [True: 57, False: 378k]
  ------------------
 4321|     57|		  {
 4322|     57|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4322:25): [True: 0, False: 57]
  ------------------
 4323|      0|	            {
 4324|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4325|      0|		      _cupsBufferRelease((char *)buffer);
 4326|      0|	              return (IPP_STATE_ERROR);
 4327|      0|	            }
 4328|       |
 4329|     57|		    bufptr = buffer;
 4330|     57|		  }
 4331|       |
 4332|   378k|		  if (i)
  ------------------
  |  Branch (4332:9): [True: 378k, False: 370]
  ------------------
 4333|   378k|		  {
 4334|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4335|   378k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4336|   378k|		    *bufptr++ = 0;
 4337|   378k|		    *bufptr++ = 0;
 4338|   378k|		  }
 4339|       |
 4340|       |		  // Boolean values are 1-byte; 0 = false, 1 = true.
 4341|       |		  //
 4342|       |		  // Put the 2-byte length and 1-byte value into the buffer...
 4343|   378k|	          *bufptr++ = 0;
 4344|   378k|		  *bufptr++ = 1;
 4345|   378k|		  *bufptr++ = (ipp_uchar_t)value->boolean;
 4346|   378k|		}
 4347|    370|		break;
 4348|       |
 4349|   355k|	    case IPP_TAG_TEXT :
  ------------------
  |  Branch (4349:6): [True: 355k, False: 2.25M]
  ------------------
 4350|   356k|	    case IPP_TAG_NAME :
  ------------------
  |  Branch (4350:6): [True: 954, False: 2.61M]
  ------------------
 4351|   357k|	    case IPP_TAG_KEYWORD :
  ------------------
  |  Branch (4351:6): [True: 758, False: 2.61M]
  ------------------
 4352|   357k|	    case IPP_TAG_URI :
  ------------------
  |  Branch (4352:6): [True: 696, False: 2.61M]
  ------------------
 4353|   360k|	    case IPP_TAG_URISCHEME :
  ------------------
  |  Branch (4353:6): [True: 2.55k, False: 2.61M]
  ------------------
 4354|   363k|	    case IPP_TAG_CHARSET :
  ------------------
  |  Branch (4354:6): [True: 3.59k, False: 2.60M]
  ------------------
 4355|   366k|	    case IPP_TAG_LANGUAGE :
  ------------------
  |  Branch (4355:6): [True: 2.93k, False: 2.60M]
  ------------------
 4356|   367k|	    case IPP_TAG_MIMETYPE :
  ------------------
  |  Branch (4356:6): [True: 691, False: 2.61M]
  ------------------
 4357|  1.24M|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4357:44): [True: 877k, False: 367k]
  ------------------
 4358|   877k|		{
 4359|   877k|		  if (i)
  ------------------
  |  Branch (4359:9): [True: 509k, False: 367k]
  ------------------
 4360|   509k|		  {
 4361|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4362|   509k|        	    DEBUG_printf("2ippWriteIO: writing value tag=%x(%s)", attr->value_tag, ippTagString(attr->value_tag));
 4363|   509k|        	    DEBUG_printf("2ippWriteIO: writing name=0,\"\"");
 4364|       |
 4365|   509k|                    if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
  ------------------
  |  |   24|   509k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   509k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4365:25): [True: 38, False: 509k]
  ------------------
 4366|     38|		    {
 4367|     38|                      if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4367:27): [True: 0, False: 38]
  ------------------
 4368|      0|	              {
 4369|      0|			DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4370|      0|			_cupsBufferRelease((char *)buffer);
 4371|      0|	        	return (IPP_STATE_ERROR);
 4372|      0|	              }
 4373|       |
 4374|     38|		      bufptr = buffer;
 4375|     38|		    }
 4376|       |
 4377|   509k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4378|   509k|		    *bufptr++ = 0;
 4379|   509k|		    *bufptr++ = 0;
 4380|   509k|		  }
 4381|       |
 4382|   877k|                  if (value->string.text != NULL)
  ------------------
  |  Branch (4382:23): [True: 876k, False: 459]
  ------------------
 4383|   876k|                    n = (int)strlen(value->string.text);
 4384|    459|		  else
 4385|    459|		    n = 0;
 4386|       |
 4387|   877k|                  if (n > (IPP_BUF_SIZE - 2))
  ------------------
  |  |   24|   877k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   877k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4387:23): [True: 1, False: 877k]
  ------------------
 4388|      1|		  {
 4389|      1|		    DEBUG_printf("1ippWriteIO: String too long (%d)", n);
 4390|      1|		    _cupsBufferRelease((char *)buffer);
 4391|      1|		    return (IPP_STATE_ERROR);
 4392|      1|		  }
 4393|       |
 4394|   877k|                  DEBUG_printf("2ippWriteIO: writing string=%d,\"%s\"", n, value->string.text);
 4395|       |
 4396|   877k|                  if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
  ------------------
  |  |   24|   877k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   877k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4396:23): [True: 383, False: 876k]
  ------------------
 4397|    383|		  {
 4398|    383|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4398:25): [True: 0, False: 383]
  ------------------
 4399|      0|	            {
 4400|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4401|      0|		      _cupsBufferRelease((char *)buffer);
 4402|      0|	              return (IPP_STATE_ERROR);
 4403|      0|	            }
 4404|       |
 4405|    383|		    bufptr = buffer;
 4406|    383|		  }
 4407|       |
 4408|       |		  // All simple strings consist of the 2-byte length and
 4409|       |		  // character data without the trailing nul normally found
 4410|       |		  // in C strings.  Also, strings cannot be longer than IPP_MAX_LENGTH
 4411|       |		  // bytes since the 2-byte length is a signed (twos-complement)
 4412|       |		  // value.
 4413|       |		  //
 4414|       |		  // Put the 2-byte length and string characters in the buffer.
 4415|   877k|	          *bufptr++ = (ipp_uchar_t)(n >> 8);
 4416|   877k|		  *bufptr++ = (ipp_uchar_t)n;
 4417|       |
 4418|   877k|		  if (n > 0)
  ------------------
  |  Branch (4418:9): [True: 578k, False: 298k]
  ------------------
 4419|   578k|		  {
 4420|   578k|		    memcpy(bufptr, value->string.text, (size_t)n);
 4421|   578k|		    bufptr += n;
 4422|   578k|		  }
 4423|   877k|		}
 4424|   367k|		break;
 4425|       |
 4426|   367k|	    case IPP_TAG_DATE :
  ------------------
  |  Branch (4426:6): [True: 350, False: 2.61M]
  ------------------
 4427|   288k|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4427:44): [True: 287k, False: 350]
  ------------------
 4428|   287k|		{
 4429|   287k|                  if ((IPP_BUF_SIZE - (bufptr - buffer)) < 16)
  ------------------
  |  |   24|   287k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   287k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4429:23): [True: 126, False: 287k]
  ------------------
 4430|    126|		  {
 4431|    126|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4431:25): [True: 0, False: 126]
  ------------------
 4432|      0|	            {
 4433|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4434|      0|		      _cupsBufferRelease((char *)buffer);
 4435|      0|	              return (IPP_STATE_ERROR);
 4436|      0|	            }
 4437|       |
 4438|    126|		    bufptr = buffer;
 4439|    126|		  }
 4440|       |
 4441|   287k|		  if (i)
  ------------------
  |  Branch (4441:9): [True: 287k, False: 350]
  ------------------
 4442|   287k|		  {
 4443|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4444|   287k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4445|   287k|		    *bufptr++ = 0;
 4446|   287k|		    *bufptr++ = 0;
 4447|   287k|		  }
 4448|       |
 4449|       |		  // Date values consist of a 2-byte length and an
 4450|       |		  // 11-byte date/time structure defined by RFC 1903.
 4451|       |		  //
 4452|       |		  // Put the 2-byte length and 11-byte date/time
 4453|       |		  // structure in the buffer.
 4454|   287k|	          *bufptr++ = 0;
 4455|   287k|		  *bufptr++ = 11;
 4456|   287k|		  memcpy(bufptr, value->date, 11);
 4457|   287k|		  bufptr += 11;
 4458|   287k|		}
 4459|    350|		break;
 4460|       |
 4461|    640|	    case IPP_TAG_RESOLUTION :
  ------------------
  |  Branch (4461:6): [True: 640, False: 2.61M]
  ------------------
 4462|   311k|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4462:44): [True: 310k, False: 640]
  ------------------
 4463|   310k|		{
 4464|   310k|                  if ((IPP_BUF_SIZE - (bufptr - buffer)) < 14)
  ------------------
  |  |   24|   310k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   310k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4464:23): [True: 123, False: 310k]
  ------------------
 4465|    123|		  {
 4466|    123|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4466:25): [True: 0, False: 123]
  ------------------
 4467|      0|	            {
 4468|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4469|      0|		      _cupsBufferRelease((char *)buffer);
 4470|      0|		      return (IPP_STATE_ERROR);
 4471|      0|	            }
 4472|       |
 4473|    123|		    bufptr = buffer;
 4474|    123|		  }
 4475|       |
 4476|   310k|		  if (i)
  ------------------
  |  Branch (4476:9): [True: 309k, False: 640]
  ------------------
 4477|   309k|		  {
 4478|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4479|   309k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4480|   309k|		    *bufptr++ = 0;
 4481|   309k|		    *bufptr++ = 0;
 4482|   309k|		  }
 4483|       |
 4484|       |		  // Resolution values consist of a 2-byte length,
 4485|       |		  // 4-byte horizontal resolution value, 4-byte vertical
 4486|       |		  // resolution value, and a 1-byte units value.
 4487|       |		  //
 4488|       |		  // Put the 2-byte length and resolution value data
 4489|       |		  // into the buffer.
 4490|   310k|	          *bufptr++ = 0;
 4491|   310k|		  *bufptr++ = 9;
 4492|   310k|		  *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 24);
 4493|   310k|		  *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 16);
 4494|   310k|		  *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 8);
 4495|   310k|		  *bufptr++ = (ipp_uchar_t)value->resolution.xres;
 4496|   310k|		  *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 24);
 4497|   310k|		  *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 16);
 4498|   310k|		  *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 8);
 4499|   310k|		  *bufptr++ = (ipp_uchar_t)value->resolution.yres;
 4500|   310k|		  *bufptr++ = (ipp_uchar_t)value->resolution.units;
 4501|   310k|		}
 4502|    640|		break;
 4503|       |
 4504|    640|	    case IPP_TAG_RANGE :
  ------------------
  |  Branch (4504:6): [True: 484, False: 2.61M]
  ------------------
 4505|   364k|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4505:44): [True: 363k, False: 484]
  ------------------
 4506|   363k|		{
 4507|   363k|                  if ((IPP_BUF_SIZE - (bufptr - buffer)) < 13)
  ------------------
  |  |   24|   363k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   363k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4507:23): [True: 130, False: 363k]
  ------------------
 4508|    130|		  {
 4509|    130|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4509:25): [True: 0, False: 130]
  ------------------
 4510|      0|	            {
 4511|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4512|      0|		      _cupsBufferRelease((char *)buffer);
 4513|      0|	              return (IPP_STATE_ERROR);
 4514|      0|	            }
 4515|       |
 4516|    130|		    bufptr = buffer;
 4517|    130|		  }
 4518|       |
 4519|   363k|		  if (i)
  ------------------
  |  Branch (4519:9): [True: 363k, False: 484]
  ------------------
 4520|   363k|		  {
 4521|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4522|   363k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4523|   363k|		    *bufptr++ = 0;
 4524|   363k|		    *bufptr++ = 0;
 4525|   363k|		  }
 4526|       |
 4527|       |		  // Range values consist of a 2-byte length,
 4528|       |		  // 4-byte lower value, and 4-byte upper value.
 4529|       |		  //
 4530|       |		  // Put the 2-byte length and range value data
 4531|       |		  // into the buffer.
 4532|   363k|	          *bufptr++ = 0;
 4533|   363k|		  *bufptr++ = 8;
 4534|   363k|		  *bufptr++ = (ipp_uchar_t)(value->range.lower >> 24);
 4535|   363k|		  *bufptr++ = (ipp_uchar_t)(value->range.lower >> 16);
 4536|   363k|		  *bufptr++ = (ipp_uchar_t)(value->range.lower >> 8);
 4537|   363k|		  *bufptr++ = (ipp_uchar_t)value->range.lower;
 4538|   363k|		  *bufptr++ = (ipp_uchar_t)(value->range.upper >> 24);
 4539|   363k|		  *bufptr++ = (ipp_uchar_t)(value->range.upper >> 16);
 4540|   363k|		  *bufptr++ = (ipp_uchar_t)(value->range.upper >> 8);
 4541|   363k|		  *bufptr++ = (ipp_uchar_t)value->range.upper;
 4542|   363k|		}
 4543|    484|		break;
 4544|       |
 4545|    484|	    case IPP_TAG_TEXTLANG :
  ------------------
  |  Branch (4545:6): [True: 343, False: 2.61M]
  ------------------
 4546|  1.31k|	    case IPP_TAG_NAMELANG :
  ------------------
  |  Branch (4546:6): [True: 973, False: 2.61M]
  ------------------
 4547|   532k|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4547:44): [True: 531k, False: 1.31k]
  ------------------
 4548|   531k|		{
 4549|   531k|		  if (i)
  ------------------
  |  Branch (4549:9): [True: 530k, False: 1.31k]
  ------------------
 4550|   530k|		  {
 4551|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4552|   530k|                    if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
  ------------------
  |  |   24|   530k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   530k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4552:25): [True: 41, False: 530k]
  ------------------
 4553|     41|		    {
 4554|     41|                      if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4554:27): [True: 0, False: 41]
  ------------------
 4555|      0|	              {
 4556|      0|			DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4557|      0|			_cupsBufferRelease((char *)buffer);
 4558|      0|	        	return (IPP_STATE_ERROR);
 4559|      0|	              }
 4560|       |
 4561|     41|		      bufptr = buffer;
 4562|     41|		    }
 4563|       |
 4564|   530k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4565|   530k|		    *bufptr++ = 0;
 4566|   530k|		    *bufptr++ = 0;
 4567|   530k|		  }
 4568|       |
 4569|       |		  // textWithLanguage and nameWithLanguage values consist
 4570|       |		  // of a 2-byte length for both strings and their
 4571|       |		  // individual lengths, a 2-byte length for the
 4572|       |		  // character string, the character string without the
 4573|       |		  // trailing nul, a 2-byte length for the character
 4574|       |		  // set string, and the character set string without
 4575|       |		  // the trailing nul.
 4576|   531k|                  n = 4;
 4577|       |
 4578|   531k|		  if (value->string.language != NULL)
  ------------------
  |  Branch (4578:9): [True: 356k, False: 174k]
  ------------------
 4579|   356k|                    n += (int)strlen(value->string.language);
 4580|       |
 4581|   531k|		  if (value->string.text != NULL)
  ------------------
  |  Branch (4581:9): [True: 531k, False: 328]
  ------------------
 4582|   531k|                    n += (int)strlen(value->string.text);
 4583|       |
 4584|   531k|                  if (n > (IPP_BUF_SIZE - 2))
  ------------------
  |  |   24|   531k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   531k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4584:23): [True: 2, False: 531k]
  ------------------
 4585|      2|		  {
 4586|      2|		    DEBUG_printf("1ippWriteIO: text/nameWithLanguage value too long (%d)", n);
 4587|      2|		    _cupsBufferRelease((char *)buffer);
 4588|      2|		    return (IPP_STATE_ERROR);
 4589|      2|                  }
 4590|       |
 4591|   531k|                  if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
  ------------------
  |  |   24|   531k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   531k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4591:23): [True: 174, False: 531k]
  ------------------
 4592|    174|		  {
 4593|    174|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4593:25): [True: 0, False: 174]
  ------------------
 4594|      0|	            {
 4595|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4596|      0|		      _cupsBufferRelease((char *)buffer);
 4597|      0|	              return (IPP_STATE_ERROR);
 4598|      0|	            }
 4599|       |
 4600|    174|		    bufptr = buffer;
 4601|    174|		  }
 4602|       |
 4603|       |		  // Length of entire value
 4604|   531k|	          *bufptr++ = (ipp_uchar_t)(n >> 8);
 4605|   531k|		  *bufptr++ = (ipp_uchar_t)n;
 4606|       |
 4607|       |		  // Length of language
 4608|   531k|		  if (value->string.language != NULL)
  ------------------
  |  Branch (4608:9): [True: 356k, False: 174k]
  ------------------
 4609|   356k|		    n = (int)strlen(value->string.language);
 4610|   174k|		  else
 4611|   174k|		    n = 0;
 4612|       |
 4613|   531k|	          *bufptr++ = (ipp_uchar_t)(n >> 8);
 4614|   531k|		  *bufptr++ = (ipp_uchar_t)n;
 4615|       |
 4616|       |		  // Language
 4617|   531k|		  if (n > 0)
  ------------------
  |  Branch (4617:9): [True: 355k, False: 176k]
  ------------------
 4618|   355k|		  {
 4619|   355k|		    memcpy(bufptr, value->string.language, (size_t)n);
 4620|   355k|		    bufptr += n;
 4621|   355k|		  }
 4622|       |
 4623|       |		  // Length of text
 4624|   531k|                  if (value->string.text != NULL)
  ------------------
  |  Branch (4624:23): [True: 531k, False: 328]
  ------------------
 4625|   531k|		    n = (int)strlen(value->string.text);
 4626|    328|		  else
 4627|    328|		    n = 0;
 4628|       |
 4629|   531k|	          *bufptr++ = (ipp_uchar_t)(n >> 8);
 4630|   531k|		  *bufptr++ = (ipp_uchar_t)n;
 4631|       |
 4632|       |		  // Text
 4633|   531k|		  if (n > 0)
  ------------------
  |  Branch (4633:9): [True: 42.0k, False: 489k]
  ------------------
 4634|  42.0k|		  {
 4635|  42.0k|		    memcpy(bufptr, value->string.text, (size_t)n);
 4636|  42.0k|		    bufptr += n;
 4637|  42.0k|		  }
 4638|   531k|		}
 4639|  1.31k|		break;
 4640|       |
 4641|  1.31k|            case IPP_TAG_BEGIN_COLLECTION :
  ------------------
  |  Branch (4641:13): [True: 611, False: 2.61M]
  ------------------
 4642|   295k|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4642:44): [True: 294k, False: 610]
  ------------------
 4643|   294k|		{
 4644|       |		  // Collections are written with the begin-collection
 4645|       |		  // tag first with a value of 0 length, followed by the
 4646|       |		  // attributes in the collection, then the end-collection
 4647|       |		  // value...
 4648|   294k|                  if ((IPP_BUF_SIZE - (bufptr - buffer)) < 5)
  ------------------
  |  |   24|   294k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   294k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4648:23): [True: 0, False: 294k]
  ------------------
 4649|      0|		  {
 4650|      0|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4650:25): [True: 0, False: 0]
  ------------------
 4651|      0|	            {
 4652|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4653|      0|		      _cupsBufferRelease((char *)buffer);
 4654|      0|	              return (IPP_STATE_ERROR);
 4655|      0|	            }
 4656|       |
 4657|      0|		    bufptr = buffer;
 4658|      0|		  }
 4659|       |
 4660|   294k|		  if (i)
  ------------------
  |  Branch (4660:9): [True: 294k, False: 611]
  ------------------
 4661|   294k|		  {
 4662|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4663|   294k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4664|   294k|		    *bufptr++ = 0;
 4665|   294k|		    *bufptr++ = 0;
 4666|   294k|		  }
 4667|       |
 4668|       |		  // Write a data length of 0 and flush the buffer...
 4669|   294k|	          *bufptr++ = 0;
 4670|   294k|		  *bufptr++ = 0;
 4671|       |
 4672|   294k|                  if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4672:23): [True: 0, False: 294k]
  ------------------
 4673|      0|	          {
 4674|      0|		    DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4675|      0|		    _cupsBufferRelease((char *)buffer);
 4676|      0|	            return (IPP_STATE_ERROR);
 4677|      0|	          }
 4678|       |
 4679|   294k|		  bufptr = buffer;
 4680|       |
 4681|       |		  // Then write the collection attribute...
 4682|   294k|                  value->collection->state = IPP_STATE_IDLE;
 4683|       |
 4684|   294k|		  if (ippWriteIO(dst, cb, 1, ipp, value->collection) == IPP_STATE_ERROR)
  ------------------
  |  Branch (4684:9): [True: 1, False: 294k]
  ------------------
 4685|      1|		  {
 4686|      1|		    DEBUG_puts("1ippWriteIO: Unable to write collection value");
 4687|      1|		    _cupsBufferRelease((char *)buffer);
 4688|      1|		    return (IPP_STATE_ERROR);
 4689|      1|		  }
 4690|   294k|		}
 4691|    610|		break;
 4692|       |
 4693|  2.23M|            default :
  ------------------
  |  Branch (4693:13): [True: 2.23M, False: 373k]
  ------------------
 4694|  4.95M|	        for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
  ------------------
  |  Branch (4694:44): [True: 2.71M, False: 2.23M]
  ------------------
 4695|  2.71M|		{
 4696|  2.71M|		  if (i)
  ------------------
  |  Branch (4696:9): [True: 474k, False: 2.23M]
  ------------------
 4697|   474k|		  {
 4698|       |		    // Arrays and sets are done by sending additional values with a zero-length name...
 4699|   474k|                    if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
  ------------------
  |  |   24|   474k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   474k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4699:25): [True: 60, False: 474k]
  ------------------
 4700|     60|		    {
 4701|     60|                      if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4701:27): [True: 0, False: 60]
  ------------------
 4702|      0|	              {
 4703|      0|			DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4704|      0|			_cupsBufferRelease((char *)buffer);
 4705|      0|	        	return (IPP_STATE_ERROR);
 4706|      0|	              }
 4707|       |
 4708|     60|		      bufptr = buffer;
 4709|     60|		    }
 4710|       |
 4711|   474k|                    *bufptr++ = (ipp_uchar_t)attr->value_tag;
 4712|   474k|		    *bufptr++ = 0;
 4713|   474k|		    *bufptr++ = 0;
 4714|   474k|		  }
 4715|       |
 4716|       |		  // An unknown value might some new value that a
 4717|       |		  // vendor has come up with. It consists of a
 4718|       |		  // 2-byte length and the bytes in the unknown
 4719|       |		  // value buffer.
 4720|  2.71M|                  n = value->unknown.length;
 4721|       |
 4722|  2.71M|                  if (n > (IPP_BUF_SIZE - 2))
  ------------------
  |  |   24|  2.71M|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|  2.71M|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4722:23): [True: 1, False: 2.71M]
  ------------------
 4723|      1|		  {
 4724|      1|		    DEBUG_printf("1ippWriteIO: Data length too long (%d)", n);
 4725|      1|		    _cupsBufferRelease((char *)buffer);
 4726|      1|		    return (IPP_STATE_ERROR);
 4727|      1|		  }
 4728|       |
 4729|  2.71M|                  if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
  ------------------
  |  |   24|  2.71M|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|  2.71M|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (4729:23): [True: 515, False: 2.71M]
  ------------------
 4730|    515|		  {
 4731|    515|                    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4731:25): [True: 0, False: 515]
  ------------------
 4732|      0|	            {
 4733|      0|		      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4734|      0|		      _cupsBufferRelease((char *)buffer);
 4735|      0|	              return (IPP_STATE_ERROR);
 4736|      0|	            }
 4737|       |
 4738|    515|		    bufptr = buffer;
 4739|    515|		  }
 4740|       |
 4741|       |		  // Length of unknown value
 4742|  2.71M|	          *bufptr++ = (ipp_uchar_t)(n >> 8);
 4743|  2.71M|		  *bufptr++ = (ipp_uchar_t)n;
 4744|       |
 4745|       |		  // Value
 4746|  2.71M|		  if (n > 0)
  ------------------
  |  Branch (4746:9): [True: 256k, False: 2.45M]
  ------------------
 4747|   256k|		  {
 4748|   256k|		    memcpy(bufptr, value->unknown.data, (size_t)n);
 4749|   256k|		    bufptr += n;
 4750|   256k|		  }
 4751|  2.71M|		}
 4752|  2.23M|		break;
 4753|  2.61M|	  }
 4754|       |
 4755|       |	  // Write the data out...
 4756|  2.61M|	  if (bufptr > buffer)
  ------------------
  |  Branch (4756:8): [True: 2.61M, False: 610]
  ------------------
 4757|  2.61M|	  {
 4758|  2.61M|	    if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
  ------------------
  |  Branch (4758:10): [True: 0, False: 2.61M]
  ------------------
 4759|      0|	    {
 4760|      0|	      DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
 4761|      0|	      _cupsBufferRelease((char *)buffer);
 4762|      0|	      return (IPP_STATE_ERROR);
 4763|      0|	    }
 4764|       |
 4765|  2.61M|	    DEBUG_printf("2ippWriteIO: wrote %d bytes", (int)(bufptr - buffer));
 4766|  2.61M|	  }
 4767|       |
 4768|       |          // If blocking is disabled and we aren't at the end of the attribute
 4769|       |          // list, stop here...
 4770|  2.61M|          if (!blocking && ipp->current)
  ------------------
  |  Branch (4770:15): [True: 0, False: 2.61M]
  |  Branch (4770:28): [True: 0, False: 0]
  ------------------
 4771|      0|	    break;
 4772|  2.61M|	}
 4773|       |
 4774|   300k|	if (ipp->current == NULL)
  ------------------
  |  Branch (4774:6): [True: 300k, False: 0]
  ------------------
 4775|   300k|	{
 4776|       |	  // Done with all of the attributes; add the end-of-attributes
 4777|       |	  // tag or end-collection attribute...
 4778|   300k|          if (parent == NULL)
  ------------------
  |  Branch (4778:15): [True: 5.40k, False: 294k]
  ------------------
 4779|  5.40k|	  {
 4780|  5.40k|            buffer[0] = IPP_TAG_END;
 4781|  5.40k|	    n         = 1;
 4782|  5.40k|	  }
 4783|   294k|	  else
 4784|   294k|	  {
 4785|   294k|            buffer[0] = IPP_TAG_END_COLLECTION;
 4786|   294k|	    buffer[1] = 0; // empty name
 4787|   294k|	    buffer[2] = 0;
 4788|   294k|	    buffer[3] = 0; // empty value
 4789|   294k|	    buffer[4] = 0;
 4790|   294k|	    n         = 5;
 4791|   294k|	  }
 4792|       |
 4793|   300k|	  if ((*cb)(dst, buffer, (size_t)n) < 0)
  ------------------
  |  Branch (4793:8): [True: 0, False: 300k]
  ------------------
 4794|      0|	  {
 4795|      0|	    DEBUG_puts("1ippWriteIO: Could not write IPP end-tag...");
 4796|      0|	    _cupsBufferRelease((char *)buffer);
 4797|      0|	    return (IPP_STATE_ERROR);
 4798|      0|	  }
 4799|       |
 4800|   300k|	  ipp->state = IPP_STATE_DATA;
 4801|   300k|	}
 4802|   300k|        break;
 4803|       |
 4804|   300k|    case IPP_STATE_DATA :
  ------------------
  |  Branch (4804:5): [True: 0, False: 300k]
  ------------------
 4805|      0|        break;
 4806|       |
 4807|      0|    default :
  ------------------
  |  Branch (4807:5): [True: 0, False: 300k]
  ------------------
 4808|      0|        break; // anti-compiler-warning-code
 4809|   300k|  }
 4810|       |
 4811|   300k|  _cupsBufferRelease((char *)buffer);
 4812|       |
 4813|   300k|  return (ipp->state);
 4814|   300k|}
ipp.c:ipp_add_attr:
 4827|  15.2M|{
 4828|  15.2M|  size_t		alloc_values;	// Number of values to allocate
 4829|  15.2M|  ipp_attribute_t	*attr;		// New attribute
 4830|       |
 4831|       |
 4832|  15.2M|  DEBUG_printf("4ipp_add_attr(ipp=%p, name=\"%s\", group_tag=0x%x, value_tag=0x%x, num_values=%u)", (void *)ipp, name, group_tag, value_tag, (unsigned)num_values);
 4833|       |
 4834|       |  // Range check input...
 4835|  15.2M|  if (!ipp)
  ------------------
  |  Branch (4835:7): [True: 0, False: 15.2M]
  ------------------
 4836|      0|    return (NULL);
 4837|       |
 4838|       |  // Allocate memory, rounding the allocation up as needed...
 4839|  15.2M|  if (num_values <= 1)
  ------------------
  |  Branch (4839:7): [True: 15.2M, False: 0]
  ------------------
 4840|  15.2M|    alloc_values = 1;
 4841|      0|  else
 4842|      0|    alloc_values = (num_values + IPP_MAX_VALUES - 1) & (size_t)~(IPP_MAX_VALUES - 1);
  ------------------
  |  |   37|      0|#  define IPP_MAX_VALUES	8	// Power-of-2 allocation increment
  ------------------
                  alloc_values = (num_values + IPP_MAX_VALUES - 1) & (size_t)~(IPP_MAX_VALUES - 1);
  ------------------
  |  |   37|      0|#  define IPP_MAX_VALUES	8	// Power-of-2 allocation increment
  ------------------
 4843|       |
 4844|  15.2M|  attr = calloc(1, sizeof(ipp_attribute_t) + (size_t)(alloc_values - 1) * sizeof(_ipp_value_t));
 4845|       |
 4846|  15.2M|  if (attr)
  ------------------
  |  Branch (4846:7): [True: 15.2M, False: 0]
  ------------------
 4847|  15.2M|  {
 4848|       |    // Initialize attribute...
 4849|  15.2M|    DEBUG_printf("4debug_alloc: %p %s %s%s (%u values)", (void *)attr, name, num_values > 1 ? "1setOf " : "", ippTagString(value_tag), (unsigned)num_values);
 4850|       |
 4851|  15.2M|    if (name)
  ------------------
  |  Branch (4851:9): [True: 2.61M, False: 12.6M]
  ------------------
 4852|  2.61M|      attr->name = _cupsStrAlloc(name);
 4853|       |
 4854|  15.2M|    attr->group_tag  = group_tag;
 4855|  15.2M|    attr->value_tag  = value_tag;
 4856|  15.2M|    attr->num_values = num_values;
 4857|       |
 4858|       |    // Add it to the end of the linked list...
 4859|  15.2M|    if (ipp->last)
  ------------------
  |  Branch (4859:9): [True: 15.2M, False: 5.58k]
  ------------------
 4860|  15.2M|      ipp->last->next = attr;
 4861|  5.58k|    else
 4862|  5.58k|      ipp->attrs = attr;
 4863|       |
 4864|  15.2M|    ipp->prev = ipp->last;
 4865|  15.2M|    ipp->last = ipp->current = attr;
 4866|  15.2M|  }
 4867|       |
 4868|  15.2M|  DEBUG_printf("5ipp_add_attr: Returning %p", (void *)attr);
 4869|       |
 4870|  15.2M|  return (attr);
 4871|  15.2M|}
ipp.c:ipp_free_values:
 4882|  15.2M|{
 4883|  15.2M|  size_t	i;			// Looping var
 4884|  15.2M|  _ipp_value_t	*value;			// Current value
 4885|       |
 4886|       |
 4887|  15.2M|  DEBUG_printf("4ipp_free_values(attr=%p, element=%u, count=%u)", (void *)attr, (unsigned)element, (unsigned)count);
 4888|       |
 4889|  15.2M|  if (!(attr->value_tag & IPP_TAG_CUPS_CONST))
  ------------------
  |  Branch (4889:7): [True: 15.2M, False: 2.70k]
  ------------------
 4890|  15.2M|  {
 4891|       |    // Free values as needed...
 4892|  15.2M|    switch (attr->value_tag)
 4893|  15.2M|    {
 4894|    542|      case IPP_TAG_TEXTLANG :
  ------------------
  |  Branch (4894:7): [True: 542, False: 15.2M]
  ------------------
 4895|  3.89k|      case IPP_TAG_NAMELANG :
  ------------------
  |  Branch (4895:7): [True: 3.35k, False: 15.2M]
  ------------------
 4896|  3.89k|	  if (element == 0 && count == attr->num_values && attr->values[0].string.language)
  ------------------
  |  Branch (4896:8): [True: 3.89k, False: 0]
  |  Branch (4896:24): [True: 3.89k, False: 0]
  |  Branch (4896:53): [True: 3.80k, False: 94]
  ------------------
 4897|  3.80k|	  {
 4898|  3.80k|	    _cupsStrFree(attr->values[0].string.language);
 4899|  3.80k|	    attr->values[0].string.language = NULL;
 4900|  3.80k|	  }
 4901|       |	  // Fall through to other string values
 4902|       |
 4903|   360k|      case IPP_TAG_TEXT :
  ------------------
  |  Branch (4903:7): [True: 357k, False: 14.8M]
  ------------------
 4904|   361k|      case IPP_TAG_NAME :
  ------------------
  |  Branch (4904:7): [True: 1.00k, False: 15.2M]
  ------------------
 4905|  2.58M|      case IPP_TAG_RESERVED_STRING :
  ------------------
  |  Branch (4905:7): [True: 2.22M, False: 13.0M]
  ------------------
 4906|  2.58M|      case IPP_TAG_KEYWORD :
  ------------------
  |  Branch (4906:7): [True: 816, False: 15.2M]
  ------------------
 4907|  2.59M|      case IPP_TAG_URI :
  ------------------
  |  Branch (4907:7): [True: 735, False: 15.2M]
  ------------------
 4908|  2.59M|      case IPP_TAG_URISCHEME :
  ------------------
  |  Branch (4908:7): [True: 2.58k, False: 15.2M]
  ------------------
 4909|  2.59M|      case IPP_TAG_CHARSET :
  ------------------
  |  Branch (4909:7): [True: 928, False: 15.2M]
  ------------------
 4910|  2.59M|      case IPP_TAG_LANGUAGE :
  ------------------
  |  Branch (4910:7): [True: 2.97k, False: 15.2M]
  ------------------
 4911|  2.59M|      case IPP_TAG_MIMETYPE :
  ------------------
  |  Branch (4911:7): [True: 720, False: 15.2M]
  ------------------
 4912|  6.48M|	  for (i = count, value = attr->values + element; i > 0; i --, value ++)
  ------------------
  |  Branch (4912:52): [True: 3.88M, False: 2.59M]
  ------------------
 4913|  3.88M|	  {
 4914|  3.88M|	    _cupsStrFree(value->string.text);
 4915|  3.88M|	    value->string.text = NULL;
 4916|  3.88M|	  }
 4917|  2.59M|	  break;
 4918|       |
 4919|    251|      case IPP_TAG_UNSUPPORTED_VALUE :
  ------------------
  |  Branch (4919:7): [True: 251, False: 15.2M]
  ------------------
 4920|    601|      case IPP_TAG_DEFAULT :
  ------------------
  |  Branch (4920:7): [True: 350, False: 15.2M]
  ------------------
 4921|    837|      case IPP_TAG_UNKNOWN :
  ------------------
  |  Branch (4921:7): [True: 236, False: 15.2M]
  ------------------
 4922|  1.25k|      case IPP_TAG_NOVALUE :
  ------------------
  |  Branch (4922:7): [True: 414, False: 15.2M]
  ------------------
 4923|  1.65k|      case IPP_TAG_NOTSETTABLE :
  ------------------
  |  Branch (4923:7): [True: 405, False: 15.2M]
  ------------------
 4924|  1.88k|      case IPP_TAG_DELETEATTR :
  ------------------
  |  Branch (4924:7): [True: 231, False: 15.2M]
  ------------------
 4925|  2.13k|      case IPP_TAG_ADMINDEFINE :
  ------------------
  |  Branch (4925:7): [True: 250, False: 15.2M]
  ------------------
 4926|  2.72k|      case IPP_TAG_INTEGER :
  ------------------
  |  Branch (4926:7): [True: 592, False: 15.2M]
  ------------------
 4927|  3.00k|      case IPP_TAG_ENUM :
  ------------------
  |  Branch (4927:7): [True: 275, False: 15.2M]
  ------------------
 4928|  3.45k|      case IPP_TAG_BOOLEAN :
  ------------------
  |  Branch (4928:7): [True: 453, False: 15.2M]
  ------------------
 4929|  3.84k|      case IPP_TAG_DATE :
  ------------------
  |  Branch (4929:7): [True: 390, False: 15.2M]
  ------------------
 4930|  4.53k|      case IPP_TAG_RESOLUTION :
  ------------------
  |  Branch (4930:7): [True: 685, False: 15.2M]
  ------------------
 4931|  5.10k|      case IPP_TAG_RANGE :
  ------------------
  |  Branch (4931:7): [True: 577, False: 15.2M]
  ------------------
 4932|  5.10k|	  break;
 4933|       |
 4934|  1.00k|      case IPP_TAG_BEGIN_COLLECTION :
  ------------------
  |  Branch (4934:7): [True: 1.00k, False: 15.2M]
  ------------------
 4935|   387k|	  for (i = count, value = attr->values + element; i > 0; i --, value ++)
  ------------------
  |  Branch (4935:52): [True: 386k, False: 1.00k]
  ------------------
 4936|   386k|	  {
 4937|   386k|	    ippDelete(value->collection);
 4938|   386k|	    value->collection = NULL;
 4939|   386k|	  }
 4940|  1.00k|	  break;
 4941|       |
 4942|    120|      case IPP_TAG_STRING :
  ------------------
  |  Branch (4942:7): [True: 120, False: 15.2M]
  ------------------
 4943|  12.6M|      default :
  ------------------
  |  Branch (4943:7): [True: 12.6M, False: 2.60M]
  ------------------
 4944|  13.1M|	  for (i = count, value = attr->values + element; i > 0; i --, value ++)
  ------------------
  |  Branch (4944:52): [True: 488k, False: 12.6M]
  ------------------
 4945|   488k|	  {
 4946|   488k|	    if (value->unknown.data)
  ------------------
  |  Branch (4946:10): [True: 256k, False: 232k]
  ------------------
 4947|   256k|	    {
 4948|   256k|	      free(value->unknown.data);
 4949|   256k|	      value->unknown.data = NULL;
 4950|   256k|	    }
 4951|   488k|	  }
 4952|  12.6M|	  break;
 4953|  15.2M|    }
 4954|  15.2M|  }
 4955|       |
 4956|       |  // If we are not freeing values from the end, move the remaining values up...
 4957|  15.2M|  if ((element + count) < attr->num_values)
  ------------------
  |  Branch (4957:7): [True: 0, False: 15.2M]
  ------------------
 4958|      0|    memmove(attr->values + element, attr->values + element + count, (size_t)(attr->num_values - count - element) * sizeof(_ipp_value_t));
 4959|       |
 4960|  15.2M|  attr->num_values -= count;
 4961|  15.2M|}
ipp.c:ipp_get_code:
 4975|  10.6k|{
 4976|  10.6k|  char	*bufptr,			// Pointer into buffer
 4977|  10.6k|	*bufend;			// End of buffer
 4978|       |
 4979|       |
 4980|       |  // Convert values to lowercase and change _ to - as needed...
 4981|  64.1k|  for (bufptr = buffer, bufend = buffer + bufsize - 1; *value && bufptr < bufend; value ++)
  ------------------
  |  Branch (4981:56): [True: 53.4k, False: 10.6k]
  |  Branch (4981:66): [True: 53.4k, False: 0]
  ------------------
 4982|  53.4k|  {
 4983|  53.4k|    if (*value == '_')
  ------------------
  |  Branch (4983:9): [True: 7.99k, False: 45.4k]
  ------------------
 4984|  7.99k|      *bufptr++ = '-';
 4985|  45.4k|    else
 4986|  45.4k|      *bufptr++ = (char)_cups_tolower(*value);
 4987|  53.4k|  }
 4988|  10.6k|  *bufptr = '\0';
 4989|       |
 4990|       |  // Return the converted string...
 4991|  10.6k|  return (buffer);
 4992|  10.6k|}
ipp.c:ipp_lang_code:
 5006|  7.99k|{
 5007|       |  // Map POSIX ("C") locale to generic English, otherwise convert the locale string as-is.
 5008|  7.99k|  if (!_cups_strcasecmp(locale, "c"))
  ------------------
  |  Branch (5008:7): [True: 0, False: 7.99k]
  ------------------
 5009|      0|  {
 5010|      0|    cupsCopyString(buffer, "en", bufsize);
 5011|      0|    return (buffer);
 5012|      0|  }
 5013|  7.99k|  else
 5014|  7.99k|  {
 5015|  7.99k|    return (ipp_get_code(locale, buffer, bufsize));
 5016|  7.99k|  }
 5017|  7.99k|}
ipp.c:ipp_read_io:
 5264|   388k|{
 5265|   388k|  int			n;		// Length of data
 5266|   388k|  unsigned char		*buffer,	// Data buffer
 5267|   388k|			string[IPP_MAX_TEXT],
 5268|       |					// Small string buffer
 5269|   388k|			*bufptr,	// Pointer into buffer
 5270|   388k|			*bufend;	// End of buffer
 5271|   388k|  ipp_attribute_t	*attr = NULL;	// Current attribute
 5272|   388k|  ipp_tag_t		tag;		// Current tag
 5273|   388k|  ipp_tag_t		value_tag;	// Current value tag
 5274|   388k|  _ipp_value_t		*value;		// Current value
 5275|       |
 5276|       |
 5277|   388k|  DEBUG_printf("ipp_read_io(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p, depth=%d)", (void *)src, (void *)cb, blocking, (void *)parent, (void *)ipp, depth);
 5278|   388k|  DEBUG_printf("2ipp_read_io: ipp->state=%d", ipp->state);
 5279|       |
 5280|   388k|  if (depth > 10)
  ------------------
  |  Branch (5280:7): [True: 4, False: 388k]
  ------------------
 5281|      4|  {
 5282|      4|    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP message nested too deeply."), true);
  ------------------
  |  |   40|      4|#  define _(x) x
  ------------------
 5283|      4|    return (IPP_STATE_ERROR);
 5284|      4|  }
 5285|       |
 5286|   388k|  if ((buffer = (unsigned char *)_cupsBufferGet(IPP_BUF_SIZE)) == NULL)
  ------------------
  |  |   24|   388k|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|   388k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (5286:7): [True: 0, False: 388k]
  ------------------
 5287|      0|  {
 5288|      0|    DEBUG_puts("1ipp_read_io: Unable to get read buffer.");
 5289|      0|    return (IPP_STATE_ERROR);
 5290|      0|  }
 5291|       |
 5292|   388k|  switch (ipp->state)
 5293|   388k|  {
 5294|   388k|    case IPP_STATE_IDLE :
  ------------------
  |  Branch (5294:5): [True: 388k, False: 0]
  ------------------
 5295|   388k|        ipp->state ++; // Avoid common problem...
 5296|       |
 5297|   388k|    case IPP_STATE_HEADER :
  ------------------
  |  Branch (5297:5): [True: 0, False: 388k]
  ------------------
 5298|   388k|        if (parent == NULL)
  ------------------
  |  Branch (5298:13): [True: 2.70k, False: 386k]
  ------------------
 5299|  2.70k|	{
 5300|       |          // Get the request header...
 5301|  2.70k|          if ((*cb)(src, buffer, 8) < 8)
  ------------------
  |  Branch (5301:15): [True: 169, False: 2.53k]
  ------------------
 5302|    169|	  {
 5303|    169|	    DEBUG_puts("1ipp_read_io: Unable to read header.");
 5304|    169|	    goto rollback;
 5305|    169|	  }
 5306|       |
 5307|       |          // Then copy the request header over...
 5308|  2.53k|          ipp->request.version[0]  = buffer[0];
 5309|  2.53k|          ipp->request.version[1]  = buffer[1];
 5310|  2.53k|          ipp->request.op_status   = (short)((buffer[2] << 8) | buffer[3]);
 5311|  2.53k|          ipp->request.request_id  = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
 5312|       |
 5313|  2.53k|          DEBUG_printf("2ipp_read_io: version=%d.%d", buffer[0], buffer[1]);
 5314|  2.53k|	  DEBUG_printf("2ipp_read_io: op_status=%04x", ipp->request.op_status);
 5315|  2.53k|	  DEBUG_printf("2ipp_read_io: request_id=%d", ipp->request.request_id);
 5316|  2.53k|        }
 5317|       |
 5318|   388k|        ipp->state   = IPP_STATE_ATTRIBUTE;
 5319|   388k|	ipp->current = NULL;
 5320|   388k|	ipp->curtag  = IPP_TAG_ZERO;
 5321|   388k|	ipp->prev    = ipp->last;
 5322|       |
 5323|       |        // If blocking is disabled, stop here...
 5324|   388k|        if (!blocking)
  ------------------
  |  Branch (5324:13): [True: 0, False: 388k]
  ------------------
 5325|      0|	  break;
 5326|       |
 5327|   388k|    case IPP_STATE_ATTRIBUTE :
  ------------------
  |  Branch (5327:5): [True: 0, False: 388k]
  ------------------
 5328|   388k|        for (;;)
 5329|  20.7M|	{
 5330|  20.7M|	  if ((*cb)(src, buffer, 1) < 1)
  ------------------
  |  Branch (5330:8): [True: 367, False: 20.7M]
  ------------------
 5331|    367|	  {
 5332|    367|	    DEBUG_puts("1ipp_read_io: Callback returned EOF/error");
 5333|    367|	    goto rollback;
 5334|    367|	  }
 5335|       |
 5336|  20.7M|	  DEBUG_printf("2ipp_read_io: ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev);
 5337|       |
 5338|       |	  // Read this attribute...
 5339|  20.7M|          tag = (ipp_tag_t)buffer[0];
 5340|       |
 5341|  20.7M|	  if (tag == IPP_TAG_END)
  ------------------
  |  Branch (5341:8): [True: 385k, False: 20.4M]
  ------------------
 5342|   385k|	  {
 5343|       |	    // No more attributes left...
 5344|   385k|            DEBUG_puts("2ipp_read_io: IPP_TAG_END.");
 5345|       |
 5346|   385k|	    ipp->state = IPP_STATE_DATA;
 5347|   385k|	    break;
 5348|   385k|	  }
 5349|  20.4M|	  else if (tag == IPP_TAG_ZERO || (tag == IPP_TAG_OPERATION && ipp->curtag != IPP_TAG_ZERO))
  ------------------
  |  Branch (5349:13): [True: 79, False: 20.4M]
  |  Branch (5349:37): [True: 38, False: 20.4M]
  |  Branch (5349:65): [True: 16, False: 22]
  ------------------
 5350|     95|	  {
 5351|     95|	    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid group tag."), true);
  ------------------
  |  |   40|     95|#  define _(x) x
  ------------------
 5352|     95|	    DEBUG_printf("1ipp_read_io: bad tag 0x%02x.", tag);
 5353|     95|	    goto rollback;
 5354|     95|	  }
 5355|  20.4M|          else if (tag < IPP_TAG_UNSUPPORTED_VALUE)
  ------------------
  |  Branch (5355:20): [True: 13.9M, False: 6.44M]
  ------------------
 5356|  13.9M|	  {
 5357|       |	    // Group tag...  Set the current group and continue...
 5358|  13.9M|            if (parent)
  ------------------
  |  Branch (5358:17): [True: 2, False: 13.9M]
  ------------------
 5359|      2|            {
 5360|      2|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid group tag."), true);
  ------------------
  |  |   40|      2|#  define _(x) x
  ------------------
 5361|      2|	      DEBUG_printf("1ipp_read_io: bad tag 0x%02x.", tag);
 5362|      2|	      goto rollback;
 5363|      2|            }
 5364|  13.9M|            else if (ipp->curtag == tag)
  ------------------
  |  Branch (5364:22): [True: 12.6M, False: 1.34M]
  ------------------
 5365|  12.6M|            {
 5366|  12.6M|	      ipp->prev = ippAddSeparator(ipp);
 5367|  12.6M|            }
 5368|  1.34M|            else if (ipp->current)
  ------------------
  |  Branch (5368:22): [True: 15.6k, False: 1.32M]
  ------------------
 5369|  15.6k|	    {
 5370|  15.6k|	      ipp->prev = ipp->current;
 5371|  15.6k|	    }
 5372|       |
 5373|  13.9M|	    ipp->curtag  = tag;
 5374|  13.9M|	    ipp->current = NULL;
 5375|  13.9M|	    attr         = NULL;
 5376|  13.9M|	    DEBUG_printf("2ipp_read_io: group tag=%x(%s), ipp->prev=%p", tag, ippTagString(tag), (void *)ipp->prev);
 5377|  13.9M|	    continue;
 5378|  13.9M|	  }
 5379|       |
 5380|  6.44M|          DEBUG_printf("2ipp_read_io: value tag=%x(%s)", tag, ippTagString(tag));
 5381|       |
 5382|       |	  // Get the name...
 5383|  6.44M|          if ((*cb)(src, buffer, 2) < 2)
  ------------------
  |  Branch (5383:15): [True: 155, False: 6.44M]
  ------------------
 5384|    155|	  {
 5385|    155|	    DEBUG_puts("1ipp_read_io: unable to read name length.");
 5386|    155|	    goto rollback;
 5387|    155|	  }
 5388|       |
 5389|  6.44M|          n = (buffer[0] << 8) | buffer[1];
 5390|       |
 5391|  6.44M|          if (n >= IPP_BUF_SIZE)
  ------------------
  |  |   24|  6.44M|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|  6.44M|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (5391:15): [True: 38, False: 6.44M]
  ------------------
 5392|     38|	  {
 5393|     38|	    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP name larger than 32767 bytes."), true);
  ------------------
  |  |   40|     38|#  define _(x) x
  ------------------
 5394|     38|	    DEBUG_printf("1ipp_read_io: bad name length %d.", n);
 5395|     38|	    goto rollback;
 5396|     38|	  }
 5397|       |
 5398|  6.44M|          DEBUG_printf("2ipp_read_io: name length=%d", n);
 5399|       |
 5400|  6.44M|          if (n && parent)
  ------------------
  |  Branch (5400:15): [True: 2.60M, False: 3.83M]
  |  Branch (5400:20): [True: 1, False: 2.60M]
  ------------------
 5401|      1|          {
 5402|      1|            _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid named IPP attribute in collection."), true);
  ------------------
  |  |   40|      1|#  define _(x) x
  ------------------
 5403|      1|            DEBUG_puts("1ipp_read_io: bad attribute name in collection.");
 5404|      1|	    goto rollback;
 5405|      1|          }
 5406|  6.44M|          else if (n == 0 && tag != IPP_TAG_MEMBERNAME && tag != IPP_TAG_END_COLLECTION)
  ------------------
  |  Branch (5406:20): [True: 3.83M, False: 2.60M]
  |  Branch (5406:30): [True: 3.83M, False: 1.54k]
  |  Branch (5406:59): [True: 3.83M, False: 211]
  ------------------
 5407|  3.83M|	  {
 5408|       |	    // More values for current attribute...
 5409|  3.83M|            if (ipp->current == NULL)
  ------------------
  |  Branch (5409:17): [True: 109, False: 3.83M]
  ------------------
 5410|    109|	    {
 5411|    109|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP attribute has no name."), true);
  ------------------
  |  |   40|    109|#  define _(x) x
  ------------------
 5412|    109|	      DEBUG_puts("1ipp_read_io: Attribute without name and no current.");
 5413|    109|	      goto rollback;
 5414|    109|	    }
 5415|       |
 5416|  3.83M|            attr      = ipp->current;
 5417|  3.83M|	    value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_CUPS_MASK);
 5418|       |
 5419|       |	    // Make sure we aren't adding a new value of a different type...
 5420|  3.83M|	    if (value_tag == IPP_TAG_ZERO)
  ------------------
  |  Branch (5420:10): [True: 545, False: 3.83M]
  ------------------
 5421|    545|	    {
 5422|       |	      // Setting the value of a collection member...
 5423|    545|	      attr->value_tag = tag;
 5424|    545|	    }
 5425|  3.83M|	    else if (value_tag == IPP_TAG_TEXTLANG || value_tag == IPP_TAG_NAMELANG || (value_tag >= IPP_TAG_TEXT && value_tag <= IPP_TAG_MIMETYPE))
  ------------------
  |  Branch (5425:15): [True: 210, False: 3.83M]
  |  Branch (5425:48): [True: 177k, False: 3.65M]
  |  Branch (5425:82): [True: 1.22M, False: 2.43M]
  |  Branch (5425:111): [True: 1.10M, False: 110k]
  ------------------
 5426|  1.28M|            {
 5427|       |	      // String values can sometimes come across in different forms; accept sets of differing values...
 5428|  1.28M|	      if (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG && (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE) && tag != IPP_TAG_NOVALUE)
  ------------------
  |  Branch (5428:12): [True: 1.28M, False: 2.25k]
  |  Branch (5428:39): [True: 1.28M, False: 800]
  |  Branch (5428:67): [True: 3.52k, False: 1.28M]
  |  Branch (5428:89): [True: 9, False: 1.28M]
  |  Branch (5428:116): [True: 25, False: 3.51k]
  ------------------
 5429|     25|	      {
 5430|     25|		_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP 1setOf attribute with incompatible value tags."), true);
  ------------------
  |  |   40|     25|#  define _(x) x
  ------------------
 5431|     25|		DEBUG_printf("1ipp_read_io: 1setOf value tag %x(%s) != %x(%s)", value_tag, ippTagString(value_tag), tag, ippTagString(tag));
 5432|     25|		goto rollback;
 5433|     25|	      }
 5434|       |
 5435|  1.28M|              if (value_tag != tag)
  ------------------
  |  Branch (5435:19): [True: 279k, False: 1.00M]
  ------------------
 5436|   279k|              {
 5437|   279k|                DEBUG_printf("1ipp_read_io: Converting %s attribute from %s to %s.", attr->name, ippTagString(value_tag), ippTagString(tag));
 5438|   279k|		if (!ippSetValueTag(ipp, &attr, tag))
  ------------------
  |  Branch (5438:7): [True: 26, False: 279k]
  ------------------
 5439|     26|		  goto rollback;
 5440|   279k|	      }
 5441|  1.28M|            }
 5442|  2.54M|	    else if (value_tag == IPP_TAG_INTEGER || value_tag == IPP_TAG_RANGE)
  ------------------
  |  Branch (5442:15): [True: 603k, False: 1.94M]
  |  Branch (5442:47): [True: 83.6k, False: 1.86M]
  ------------------
 5443|   687k|            {
 5444|       |	      // Integer and rangeOfInteger values can sometimes be mixed; accept sets of differing values...
 5445|   687k|	      if (tag != IPP_TAG_INTEGER && tag != IPP_TAG_RANGE)
  ------------------
  |  Branch (5445:12): [True: 82.9k, False: 604k]
  |  Branch (5445:38): [True: 16, False: 82.9k]
  ------------------
 5446|     16|	      {
 5447|     16|		_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP 1setOf attribute with incompatible value tags."), true);
  ------------------
  |  |   40|     16|#  define _(x) x
  ------------------
 5448|     16|		DEBUG_printf("1ipp_read_io: 1setOf value tag %x(%s) != %x(%s)", value_tag, ippTagString(value_tag), tag, ippTagString(tag));
 5449|     16|		goto rollback;
 5450|     16|	      }
 5451|       |
 5452|   687k|              if (value_tag == IPP_TAG_INTEGER && tag == IPP_TAG_RANGE)
  ------------------
  |  Branch (5452:19): [True: 603k, False: 83.6k]
  |  Branch (5452:51): [True: 273, False: 603k]
  ------------------
 5453|    273|              {
 5454|       |                // Convert integer values to rangeOfInteger values...
 5455|    273|		DEBUG_printf("1ipp_read_io: Converting %s attribute to rangeOfInteger.", attr->name);
 5456|    273|                ippSetValueTag(ipp, &attr, IPP_TAG_RANGE);
 5457|    273|              }
 5458|   687k|            }
 5459|  1.86M|	    else if (value_tag != tag)
  ------------------
  |  Branch (5459:15): [True: 22, False: 1.86M]
  ------------------
 5460|     22|	    {
 5461|     22|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP 1setOf attribute with incompatible value tags."), true);
  ------------------
  |  |   40|     22|#  define _(x) x
  ------------------
 5462|     22|	      DEBUG_printf("1ipp_read_io: value tag %x(%s) != %x(%s)", value_tag, ippTagString(value_tag), tag, ippTagString(tag));
 5463|     22|	      goto rollback;
 5464|     22|            }
 5465|       |
 5466|       |	    // Finally, reallocate the attribute array as needed...
 5467|  3.83M|	    if ((value = ipp_set_value(ipp, &attr, attr->num_values)) == NULL)
  ------------------
  |  Branch (5467:10): [True: 0, False: 3.83M]
  ------------------
 5468|      0|	      goto rollback;
 5469|  3.83M|	  }
 5470|  2.61M|	  else if (tag == IPP_TAG_MEMBERNAME)
  ------------------
  |  Branch (5470:13): [True: 1.54k, False: 2.60M]
  ------------------
 5471|  1.54k|	  {
 5472|       |	    // Name must be length 0!
 5473|  1.54k|	    if (n)
  ------------------
  |  Branch (5473:10): [True: 2, False: 1.54k]
  ------------------
 5474|      2|	    {
 5475|      2|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP member name is not empty."), true);
  ------------------
  |  |   40|      2|#  define _(x) x
  ------------------
 5476|      2|	      DEBUG_puts("1ipp_read_io: member name not empty.");
 5477|      2|	      goto rollback;
 5478|      2|	    }
 5479|  1.54k|	    else if (!parent)
  ------------------
  |  Branch (5479:15): [True: 1, False: 1.54k]
  ------------------
 5480|      1|	    {
 5481|      1|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP member attribute outside of collection."), true);
  ------------------
  |  |   40|      1|#  define _(x) x
  ------------------
 5482|      1|	      DEBUG_puts("1ipp_read_io: member attribute outside of collection.");
 5483|      1|	      goto rollback;
 5484|      1|	    }
 5485|       |
 5486|  1.54k|            if (ipp->current)
  ------------------
  |  Branch (5486:17): [True: 1.00k, False: 537]
  ------------------
 5487|  1.00k|	      ipp->prev = ipp->current;
 5488|       |
 5489|  1.54k|	    attr = ipp->current = ipp_add_attr(ipp, NULL, ipp->curtag, IPP_TAG_ZERO, 1);
 5490|  1.54k|	    if (!attr)
  ------------------
  |  Branch (5490:10): [True: 0, False: 1.54k]
  ------------------
 5491|      0|	    {
 5492|      0|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), false);
 5493|      0|	      DEBUG_puts("1ipp_read_io: unable to allocate attribute.");
 5494|      0|	      goto rollback;
 5495|      0|	    }
 5496|       |
 5497|  1.54k|	    DEBUG_printf("2ipp_read_io: membername, ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev);
 5498|       |
 5499|  1.54k|	    value = attr->values;
 5500|  1.54k|	  }
 5501|  2.60M|	  else if (tag != IPP_TAG_END_COLLECTION)
  ------------------
  |  Branch (5501:13): [True: 2.60M, False: 238]
  ------------------
 5502|  2.60M|	  {
 5503|       |	    // New attribute; read the name and add it...
 5504|  2.60M|	    if ((*cb)(src, buffer, (size_t)n) < n)
  ------------------
  |  Branch (5504:10): [True: 385, False: 2.60M]
  ------------------
 5505|    385|	    {
 5506|    385|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to read IPP attribute name."), true);
  ------------------
  |  |   40|    385|#  define _(x) x
  ------------------
 5507|    385|	      DEBUG_puts("1ipp_read_io: unable to read name.");
 5508|    385|	      goto rollback;
 5509|    385|	    }
 5510|       |
 5511|  2.60M|	    buffer[n] = '\0';
 5512|       |
 5513|  2.60M|            if (ipp->current)
  ------------------
  |  Branch (5513:17): [True: 2.27M, False: 337k]
  ------------------
 5514|  2.27M|	      ipp->prev = ipp->current;
 5515|       |
 5516|  2.60M|	    if ((attr = ipp->current = ipp_add_attr(ipp, (char *)buffer, ipp->curtag, tag, 1)) == NULL)
  ------------------
  |  Branch (5516:10): [True: 0, False: 2.60M]
  ------------------
 5517|      0|	    {
 5518|      0|	      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), false);
 5519|      0|	      DEBUG_puts("1ipp_read_io: unable to allocate attribute.");
 5520|      0|	      goto rollback;
 5521|      0|	    }
 5522|       |
 5523|  2.60M|	    DEBUG_printf("2ipp_read_io: name=\"%s\", ipp->current=%p, ipp->prev=%p", buffer, (void *)ipp->current, (void *)ipp->prev);
 5524|       |
 5525|  2.60M|	    value = attr->values;
 5526|  2.60M|	  }
 5527|    238|	  else
 5528|    238|	  {
 5529|    238|	    attr  = NULL;
 5530|    238|	    value = NULL;
 5531|    238|	  }
 5532|       |
 5533|  6.44M|	  if ((*cb)(src, buffer, 2) < 2)
  ------------------
  |  Branch (5533:8): [True: 395, False: 6.44M]
  ------------------
 5534|    395|	  {
 5535|    395|	    DEBUG_puts("1ipp_read_io: unable to read value length.");
 5536|    395|	    goto rollback;
 5537|    395|	  }
 5538|       |
 5539|  6.44M|	  n = (buffer[0] << 8) | buffer[1];
 5540|  6.44M|          DEBUG_printf("2ipp_read_io: value length=%d", n);
 5541|       |
 5542|  6.44M|	  if (n >= IPP_BUF_SIZE)
  ------------------
  |  |   24|  6.44M|#  define IPP_BUF_SIZE	(IPP_MAX_LENGTH + 2)
  |  |  ------------------
  |  |  |  |   30|  6.44M|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  |  |  ------------------
  ------------------
  |  Branch (5542:8): [True: 15, False: 6.44M]
  ------------------
 5543|     15|	  {
 5544|     15|	    _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
 5545|     15|			  _("IPP value larger than 32767 bytes."), true);
  ------------------
  |  |   40|     15|#  define _(x) x
  ------------------
 5546|     15|	    DEBUG_printf("1ipp_read_io: bad value length %d.", n);
 5547|     15|	    goto rollback;
 5548|     15|	  }
 5549|       |
 5550|  6.44M|	  switch (tag)
 5551|  6.44M|	  {
 5552|   605k|	    case IPP_TAG_INTEGER :
  ------------------
  |  Branch (5552:6): [True: 605k, False: 5.84M]
  ------------------
 5553|   619k|	    case IPP_TAG_ENUM :
  ------------------
  |  Branch (5553:6): [True: 14.3k, False: 6.43M]
  ------------------
 5554|   619k|		if (n != 4)
  ------------------
  |  Branch (5554:7): [True: 24, False: 619k]
  ------------------
 5555|     24|		{
 5556|     24|		  if (tag == IPP_TAG_INTEGER)
  ------------------
  |  Branch (5556:9): [True: 18, False: 6]
  ------------------
 5557|     18|		    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP integer value not 4 bytes."), true);
  ------------------
  |  |   40|     18|#  define _(x) x
  ------------------
 5558|      6|		  else
 5559|      6|		    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP enum value not 4 bytes."), true);
  ------------------
  |  |   40|      6|#  define _(x) x
  ------------------
 5560|     24|		  DEBUG_printf("1ipp_read_io: bad integer value length %d.", n);
 5561|     24|		  goto rollback;
 5562|     24|		}
 5563|       |
 5564|   619k|	        if ((*cb)(src, buffer, 4) < 4)
  ------------------
  |  Branch (5564:14): [True: 21, False: 619k]
  ------------------
 5565|     21|		{
 5566|     21|	          DEBUG_puts("1ipp_read_io: Unable to read integer value.");
 5567|     21|		  goto rollback;
 5568|     21|		}
 5569|       |
 5570|   619k|		n = (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
 5571|       |
 5572|   619k|                if (attr->value_tag == IPP_TAG_RANGE)
  ------------------
  |  Branch (5572:21): [True: 999, False: 618k]
  ------------------
 5573|    999|                  value->range.lower = value->range.upper = n;
 5574|   618k|                else
 5575|   618k|		  value->integer = n;
 5576|   619k|	        break;
 5577|       |
 5578|   379k|	    case IPP_TAG_BOOLEAN :
  ------------------
  |  Branch (5578:6): [True: 379k, False: 6.06M]
  ------------------
 5579|   379k|		if (n != 1)
  ------------------
  |  Branch (5579:7): [True: 49, False: 378k]
  ------------------
 5580|     49|		{
 5581|     49|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP boolean value not 1 byte."),
  ------------------
  |  |   40|     49|#  define _(x) x
  ------------------
 5582|     49|		                1);
 5583|     49|		  DEBUG_printf("1ipp_read_io: bad boolean value length %d.", n);
 5584|     49|		  goto rollback;
 5585|     49|		}
 5586|       |
 5587|   378k|	        if ((*cb)(src, buffer, 1) < 1)
  ------------------
  |  Branch (5587:14): [True: 3, False: 378k]
  ------------------
 5588|      3|		{
 5589|      3|	          DEBUG_puts("1ipp_read_io: Unable to read boolean value.");
 5590|      3|		  goto rollback;
 5591|      3|		}
 5592|       |
 5593|   378k|                value->boolean = (char)buffer[0];
 5594|   378k|	        break;
 5595|       |
 5596|  4.42k|	    case IPP_TAG_UNSUPPORTED_VALUE :
  ------------------
  |  Branch (5596:6): [True: 4.42k, False: 6.44M]
  ------------------
 5597|   301k|	    case IPP_TAG_DEFAULT :
  ------------------
  |  Branch (5597:6): [True: 296k, False: 6.14M]
  ------------------
 5598|   302k|	    case IPP_TAG_UNKNOWN :
  ------------------
  |  Branch (5598:6): [True: 1.02k, False: 6.44M]
  ------------------
 5599|   312k|	    case IPP_TAG_NOVALUE :
  ------------------
  |  Branch (5599:6): [True: 10.5k, False: 6.43M]
  ------------------
 5600|   313k|	    case IPP_TAG_NOTSETTABLE :
  ------------------
  |  Branch (5600:6): [True: 703, False: 6.44M]
  ------------------
 5601|   368k|	    case IPP_TAG_DELETEATTR :
  ------------------
  |  Branch (5601:6): [True: 54.4k, False: 6.39M]
  ------------------
 5602|   368k|	    case IPP_TAG_ADMINDEFINE :
  ------------------
  |  Branch (5602:6): [True: 949, False: 6.44M]
  ------------------
 5603|       |	        // These value types are not supposed to have values, however
 5604|       |		// some vendors (Brother) do not implement IPP correctly and so
 5605|       |		// we need to map non-empty values to text...
 5606|   368k|	        if (attr->value_tag == tag)
  ------------------
  |  Branch (5606:14): [True: 368k, False: 0]
  ------------------
 5607|   368k|		{
 5608|   368k|		  if (n == 0)
  ------------------
  |  Branch (5608:9): [True: 11.2k, False: 357k]
  ------------------
 5609|  11.2k|		    break;
 5610|       |
 5611|   357k|		  attr->value_tag = IPP_TAG_TEXT;
 5612|   357k|		}
 5613|       |
 5614|   427k|	    case IPP_TAG_TEXT :
  ------------------
  |  Branch (5614:6): [True: 69.6k, False: 6.37M]
  ------------------
 5615|   563k|	    case IPP_TAG_NAME :
  ------------------
  |  Branch (5615:6): [True: 136k, False: 6.30M]
  ------------------
 5616|  2.85M|	    case IPP_TAG_RESERVED_STRING :
  ------------------
  |  Branch (5616:6): [True: 2.29M, False: 4.15M]
  ------------------
 5617|  3.69M|	    case IPP_TAG_KEYWORD :
  ------------------
  |  Branch (5617:6): [True: 836k, False: 5.61M]
  ------------------
 5618|  3.72M|	    case IPP_TAG_URI :
  ------------------
  |  Branch (5618:6): [True: 35.4k, False: 6.41M]
  ------------------
 5619|  3.80M|	    case IPP_TAG_URISCHEME :
  ------------------
  |  Branch (5619:6): [True: 72.0k, False: 6.37M]
  ------------------
 5620|  3.81M|	    case IPP_TAG_CHARSET :
  ------------------
  |  Branch (5620:6): [True: 9.27k, False: 6.43M]
  ------------------
 5621|  3.86M|	    case IPP_TAG_LANGUAGE :
  ------------------
  |  Branch (5621:6): [True: 55.6k, False: 6.39M]
  ------------------
 5622|  3.87M|	    case IPP_TAG_MIMETYPE :
  ------------------
  |  Branch (5622:6): [True: 8.94k, False: 6.43M]
  ------------------
 5623|  3.87M|	        if (n > 0)
  ------------------
  |  Branch (5623:14): [True: 619k, False: 3.25M]
  ------------------
 5624|   619k|	        {
 5625|   619k|		  if ((*cb)(src, buffer, (size_t)n) < n)
  ------------------
  |  Branch (5625:9): [True: 184, False: 619k]
  ------------------
 5626|    184|		  {
 5627|    184|		    DEBUG_puts("1ipp_read_io: unable to read string value.");
 5628|    184|		    goto rollback;
 5629|    184|		  }
 5630|   619k|		}
 5631|       |
 5632|  3.87M|		buffer[n] = '\0';
 5633|  3.87M|		value->string.text = _cupsStrAlloc((char *)buffer);
 5634|  3.87M|		DEBUG_printf("2ipp_read_io: value=\"%s\"(%p)", value->string.text, value->string.text);
 5635|  3.87M|	        break;
 5636|       |
 5637|   287k|	    case IPP_TAG_DATE :
  ------------------
  |  Branch (5637:6): [True: 287k, False: 6.15M]
  ------------------
 5638|   287k|		if (n != 11)
  ------------------
  |  Branch (5638:7): [True: 19, False: 287k]
  ------------------
 5639|     19|		{
 5640|     19|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP date value not 11 bytes."), true);
  ------------------
  |  |   40|     19|#  define _(x) x
  ------------------
 5641|     19|		  DEBUG_printf("1ipp_read_io: bad date value length %d.", n);
 5642|     19|		  goto rollback;
 5643|     19|		}
 5644|       |
 5645|   287k|	        if ((*cb)(src, value->date, 11) < 11)
  ------------------
  |  Branch (5645:14): [True: 9, False: 287k]
  ------------------
 5646|      9|		{
 5647|      9|	          DEBUG_puts("1ipp_read_io: Unable to read date value.");
 5648|      9|		  goto rollback;
 5649|      9|		}
 5650|   287k|	        break;
 5651|       |
 5652|   310k|	    case IPP_TAG_RESOLUTION :
  ------------------
  |  Branch (5652:6): [True: 310k, False: 6.13M]
  ------------------
 5653|   310k|		if (n != 9)
  ------------------
  |  Branch (5653:7): [True: 21, False: 310k]
  ------------------
 5654|     21|		{
 5655|     21|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP resolution value not 9 bytes."), true);
  ------------------
  |  |   40|     21|#  define _(x) x
  ------------------
 5656|     21|		  DEBUG_printf("1ipp_read_io: bad resolution value length %d.", n);
 5657|     21|		  goto rollback;
 5658|     21|		}
 5659|       |
 5660|   310k|	        if ((*cb)(src, buffer, 9) < 9)
  ------------------
  |  Branch (5660:14): [True: 13, False: 310k]
  ------------------
 5661|     13|		{
 5662|     13|	          DEBUG_puts("1ipp_read_io: Unable to read resolution value.");
 5663|     13|		  goto rollback;
 5664|     13|		}
 5665|       |
 5666|   310k|                value->resolution.xres  = (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
 5667|   310k|                value->resolution.yres  = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
 5668|   310k|                value->resolution.units =
 5669|   310k|		    (ipp_res_t)buffer[8];
 5670|   310k|	        break;
 5671|       |
 5672|  83.2k|	    case IPP_TAG_RANGE :
  ------------------
  |  Branch (5672:6): [True: 83.2k, False: 6.36M]
  ------------------
 5673|  83.2k|		if (n != 8)
  ------------------
  |  Branch (5673:7): [True: 30, False: 83.1k]
  ------------------
 5674|     30|		{
 5675|     30|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP rangeOfInteger value not 8 bytes."), true);
  ------------------
  |  |   40|     30|#  define _(x) x
  ------------------
 5676|     30|		  DEBUG_printf("1ipp_read_io: bad rangeOfInteger value length %d.", n);
 5677|     30|		  goto rollback;
 5678|     30|		}
 5679|       |
 5680|  83.1k|	        if ((*cb)(src, buffer, 8) < 8)
  ------------------
  |  Branch (5680:14): [True: 17, False: 83.1k]
  ------------------
 5681|     17|		{
 5682|     17|	          DEBUG_puts("1ipp_read_io: Unable to read range value.");
 5683|     17|		  goto rollback;
 5684|     17|		}
 5685|       |
 5686|  83.1k|                value->range.lower = (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
 5687|  83.1k|                value->range.upper = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
 5688|  83.1k|	        break;
 5689|       |
 5690|  2.73k|	    case IPP_TAG_TEXTLANG :
  ------------------
  |  Branch (5690:6): [True: 2.73k, False: 6.44M]
  ------------------
 5691|  3.98k|	    case IPP_TAG_NAMELANG :
  ------------------
  |  Branch (5691:6): [True: 1.25k, False: 6.44M]
  ------------------
 5692|  3.98k|	        if (n < 4)
  ------------------
  |  Branch (5692:14): [True: 10, False: 3.97k]
  ------------------
 5693|     10|		{
 5694|     10|		  if (tag == IPP_TAG_TEXTLANG)
  ------------------
  |  Branch (5694:9): [True: 4, False: 6]
  ------------------
 5695|      4|		    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP textWithLanguage value less than minimum 4 bytes."), true);
  ------------------
  |  |   40|      4|#  define _(x) x
  ------------------
 5696|      6|		  else
 5697|      6|		    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP nameWithLanguage value less than minimum 4 bytes."), true);
  ------------------
  |  |   40|      6|#  define _(x) x
  ------------------
 5698|     10|		  DEBUG_printf("1ipp_read_io: bad stringWithLanguage value length %d.", n);
 5699|     10|		  goto rollback;
 5700|     10|		}
 5701|       |
 5702|  3.97k|	        if ((*cb)(src, buffer, (size_t)n) < n)
  ------------------
  |  Branch (5702:14): [True: 97, False: 3.87k]
  ------------------
 5703|     97|		{
 5704|     97|	          DEBUG_puts("1ipp_read_io: Unable to read string w/language value.");
 5705|     97|		  goto rollback;
 5706|     97|		}
 5707|       |
 5708|  3.87k|                bufptr = buffer;
 5709|  3.87k|                bufend = buffer + n;
 5710|       |
 5711|       |	        // textWithLanguage and nameWithLanguage are composite values:
 5712|       |		//
 5713|       |		//   language-length
 5714|       |		//   language
 5715|       |		//   text-length
 5716|       |		//   text
 5717|  3.87k|		n = (bufptr[0] << 8) | bufptr[1];
 5718|       |
 5719|  3.87k|		if ((bufptr + 2 + n + 2) > bufend || n >= (int)sizeof(string))
  ------------------
  |  Branch (5719:7): [True: 27, False: 3.85k]
  |  Branch (5719:40): [True: 5, False: 3.84k]
  ------------------
 5720|     32|		{
 5721|     32|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP language length overflows value."), true);
  ------------------
  |  |   40|     32|#  define _(x) x
  ------------------
 5722|     32|		  DEBUG_printf("1ipp_read_io: bad language value length %d.", n);
 5723|     32|		  goto rollback;
 5724|     32|		}
 5725|  3.84k|		else if (n >= IPP_MAX_LANGUAGE)
  ------------------
  |  |   29|  3.84k|#  define IPP_MAX_LANGUAGE	64	// Maximum length of naturalLanguage values w/nul
  ------------------
  |  Branch (5725:12): [True: 5, False: 3.84k]
  ------------------
 5726|      5|		{
 5727|      5|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP language length too large."), true);
  ------------------
  |  |   40|      5|#  define _(x) x
  ------------------
 5728|      5|		  DEBUG_printf("1ipp_read_io: bad language value length %d.", n);
 5729|      5|		  goto rollback;
 5730|      5|		}
 5731|       |
 5732|  3.84k|		memcpy(string, bufptr + 2, (size_t)n);
 5733|  3.84k|		string[n] = '\0';
 5734|       |
 5735|  3.84k|		value->string.language = _cupsStrAlloc((char *)string);
 5736|       |
 5737|  3.84k|                bufptr += 2 + n;
 5738|  3.84k|		n = (bufptr[0] << 8) | bufptr[1];
 5739|       |
 5740|  3.84k|		if ((bufptr + 2 + n) > bufend)
  ------------------
  |  Branch (5740:7): [True: 28, False: 3.81k]
  ------------------
 5741|     28|		{
 5742|     28|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP string length overflows value."), true);
  ------------------
  |  |   40|     28|#  define _(x) x
  ------------------
 5743|     28|		  DEBUG_printf("1ipp_read_io: bad string value length %d.", n);
 5744|     28|		  goto rollback;
 5745|     28|		}
 5746|       |
 5747|  3.81k|		bufptr[2 + n] = '\0';
 5748|  3.81k|                value->string.text = _cupsStrAlloc((char *)bufptr + 2);
 5749|  3.81k|	        break;
 5750|       |
 5751|   386k|            case IPP_TAG_BEGIN_COLLECTION :
  ------------------
  |  Branch (5751:13): [True: 386k, False: 6.06M]
  ------------------
 5752|       |	        // Oh boy, here comes a collection value, so read it...
 5753|   386k|                value->collection = ippNew();
 5754|       |
 5755|   386k|                if (n > 0)
  ------------------
  |  Branch (5755:21): [True: 21, False: 386k]
  ------------------
 5756|     21|		{
 5757|     21|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP begCollection value not 0 bytes."), true);
  ------------------
  |  |   40|     21|#  define _(x) x
  ------------------
 5758|     21|	          DEBUG_puts("1ipp_read_io: begCollection tag with value length > 0.");
 5759|     21|		  goto rollback;
 5760|     21|		}
 5761|       |
 5762|   386k|		if (ipp_read_io(src, cb, 1, ipp, value->collection, depth + 1) == IPP_STATE_ERROR)
  ------------------
  |  Branch (5762:7): [True: 147, False: 386k]
  ------------------
 5763|    147|		{
 5764|    147|	          DEBUG_puts("1ipp_read_io: Unable to read collection value.");
 5765|    147|		  goto rollback;
 5766|    147|		}
 5767|   386k|                break;
 5768|       |
 5769|   386k|            case IPP_TAG_END_COLLECTION :
  ------------------
  |  Branch (5769:13): [True: 232, False: 6.44M]
  ------------------
 5770|    232|                if (n > 0)
  ------------------
  |  Branch (5770:21): [True: 26, False: 206]
  ------------------
 5771|     26|		{
 5772|     26|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP endCollection value not 0 bytes."), true);
  ------------------
  |  |   40|     26|#  define _(x) x
  ------------------
 5773|     26|	          DEBUG_puts("1ipp_read_io: endCollection tag with value length > 0.");
 5774|     26|		  goto rollback;
 5775|     26|		}
 5776|       |
 5777|    206|		_cupsBufferRelease((char *)buffer);
 5778|       |
 5779|    206|	        DEBUG_puts("1ipp_read_io: endCollection tag...");
 5780|    206|		return (ipp->state = IPP_STATE_DATA);
 5781|       |
 5782|  1.54k|            case IPP_TAG_MEMBERNAME :
  ------------------
  |  Branch (5782:13): [True: 1.54k, False: 6.44M]
  ------------------
 5783|       |	        // The value is the name of the member in the collection, which
 5784|       |		// we need to carry over...
 5785|  1.54k|		if (n == 0)
  ------------------
  |  Branch (5785:7): [True: 2, False: 1.53k]
  ------------------
 5786|      2|		{
 5787|      2|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP memberName value is empty."), true);
  ------------------
  |  |   40|      2|#  define _(x) x
  ------------------
 5788|      2|	          DEBUG_puts("1ipp_read_io: Empty member name value.");
 5789|      2|		  goto rollback;
 5790|      2|		}
 5791|  1.53k|		else if ((*cb)(src, buffer, (size_t)n) < n)
  ------------------
  |  Branch (5791:12): [True: 43, False: 1.49k]
  ------------------
 5792|     43|		{
 5793|     43|	          DEBUG_puts("1ipp_read_io: Unable to read member name value.");
 5794|     43|		  goto rollback;
 5795|     43|		}
 5796|       |
 5797|  1.49k|		buffer[n] = '\0';
 5798|  1.49k|		attr->name = _cupsStrAlloc((char *)buffer);
 5799|       |
 5800|       |	        // Since collection members are encoded differently than
 5801|       |		// regular attributes, make sure we don't start with an
 5802|       |		// empty value...
 5803|  1.49k|                attr->num_values --;
 5804|       |
 5805|  1.49k|		DEBUG_printf("2ipp_read_io: member name=\"%s\"", attr->name);
 5806|  1.49k|		break;
 5807|       |
 5808|  2.22k|            case IPP_TAG_STRING :
  ------------------
  |  Branch (5808:13): [True: 2.22k, False: 6.44M]
  ------------------
 5809|   488k|            default : // Other unsupported values
  ------------------
  |  Branch (5809:13): [True: 486k, False: 5.96M]
  ------------------
 5810|   488k|                if (tag == IPP_TAG_STRING && n > IPP_MAX_LENGTH)
  ------------------
  |  |   30|  2.22k|#  define IPP_MAX_LENGTH	32767	// Maximum size of any single value
  ------------------
  |  Branch (5810:21): [True: 2.22k, False: 486k]
  |  Branch (5810:46): [True: 1, False: 2.22k]
  ------------------
 5811|      1|		{
 5812|      1|		  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP octetString length too large."), true);
  ------------------
  |  |   40|      1|#  define _(x) x
  ------------------
 5813|      1|		  DEBUG_printf("1ipp_read_io: bad octetString value length %d.", n);
 5814|      1|		  goto rollback;
 5815|      1|		}
 5816|       |
 5817|   488k|                value->unknown.length = (size_t)n;
 5818|       |
 5819|   488k|	        if (n > 0)
  ------------------
  |  Branch (5819:14): [True: 256k, False: 231k]
  ------------------
 5820|   256k|		{
 5821|   256k|		  if ((value->unknown.data = malloc((size_t)n)) == NULL)
  ------------------
  |  Branch (5821:9): [True: 0, False: 256k]
  ------------------
 5822|      0|		  {
 5823|      0|		    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), false);
 5824|      0|		    DEBUG_puts("1ipp_read_io: Unable to allocate value");
 5825|      0|		    goto rollback;
 5826|      0|		  }
 5827|       |
 5828|   256k|	          if ((*cb)(src, value->unknown.data, (size_t)n) < n)
  ------------------
  |  Branch (5828:16): [True: 137, False: 256k]
  ------------------
 5829|    137|		  {
 5830|    137|	            DEBUG_puts("1ipp_read_io: Unable to read unsupported value.");
 5831|    137|		    goto rollback;
 5832|    137|		  }
 5833|   256k|		}
 5834|   231k|		else
 5835|   231k|		{
 5836|   231k|		  value->unknown.data = NULL;
 5837|   231k|		}
 5838|   488k|	        break;
 5839|  6.44M|	  }
 5840|       |
 5841|       |          // If blocking is disabled, stop here...
 5842|  6.44M|          if (!blocking)
  ------------------
  |  Branch (5842:15): [True: 0, False: 6.44M]
  ------------------
 5843|      0|	    break;
 5844|  6.44M|	}
 5845|   385k|        break;
 5846|       |
 5847|   385k|    case IPP_STATE_DATA :
  ------------------
  |  Branch (5847:5): [True: 0, False: 388k]
  ------------------
 5848|      0|        break;
 5849|       |
 5850|      0|    default :
  ------------------
  |  Branch (5850:5): [True: 0, False: 388k]
  ------------------
 5851|      0|        break; // anti-compiler-warning-code
 5852|   388k|  }
 5853|       |
 5854|   385k|  DEBUG_printf("1ipp_read_io: returning ipp->state=%d.", ipp->state);
 5855|   385k|  _cupsBufferRelease((char *)buffer);
 5856|       |
 5857|   385k|  return (ipp->state);
 5858|       |
 5859|       |  // If we get here, there was an error that required us to roll back the last
 5860|       |  // attribute read in order to keep the IPP message valid...
 5861|  2.76k|  rollback:
 5862|       |
 5863|  2.76k|  DEBUG_puts("1ipp_read_io: <<rollback>>");
 5864|       |
 5865|  2.76k|  _cupsBufferRelease((char *)buffer);
 5866|       |
 5867|  2.76k|  if (attr)
  ------------------
  |  Branch (5867:7): [True: 1.80k, False: 962]
  ------------------
 5868|  1.80k|    ippDeleteAttribute(ipp, attr);
 5869|       |
 5870|  2.76k|  return (IPP_STATE_ERROR);
 5871|   388k|}
ipp.c:ipp_set_value:
 5906|  3.83M|{
 5907|  3.83M|  ipp_attribute_t	*temp,		// New attribute pointer
 5908|  3.83M|			*current,	// Current attribute in list
 5909|  3.83M|			*prev;		// Previous attribute in list
 5910|  3.83M|  size_t		alloc_values;	// Allocated values
 5911|       |
 5912|       |
 5913|       |  // If we are setting an existing value element, return it...
 5914|  3.83M|  temp = *attr;
 5915|       |
 5916|  3.83M|  if (temp->num_values <= 1)
  ------------------
  |  Branch (5916:7): [True: 9.16k, False: 3.82M]
  ------------------
 5917|  9.16k|    alloc_values = 1;
 5918|  3.82M|  else
 5919|  3.82M|    alloc_values = (temp->num_values + IPP_MAX_VALUES - 1) & (size_t)~(IPP_MAX_VALUES - 1);
  ------------------
  |  |   37|  3.82M|#  define IPP_MAX_VALUES	8	// Power-of-2 allocation increment
  ------------------
                  alloc_values = (temp->num_values + IPP_MAX_VALUES - 1) & (size_t)~(IPP_MAX_VALUES - 1);
  ------------------
  |  |   37|  3.82M|#  define IPP_MAX_VALUES	8	// Power-of-2 allocation increment
  ------------------
 5920|       |
 5921|  3.83M|  if (element < alloc_values)
  ------------------
  |  Branch (5921:7): [True: 3.35M, False: 483k]
  ------------------
 5922|  3.35M|  {
 5923|  3.35M|    if (element >= temp->num_values)
  ------------------
  |  Branch (5923:9): [True: 3.35M, False: 0]
  ------------------
 5924|  3.35M|      temp->num_values = element + 1;
 5925|       |
 5926|  3.35M|    return (temp->values + element);
 5927|  3.35M|  }
 5928|       |
 5929|       |  // Otherwise re-allocate the attribute - we allocate in groups of
 5930|       |  // IPP_MAX_VALUE values when num_values > 1.
 5931|   483k|  if (alloc_values < IPP_MAX_VALUES)
  ------------------
  |  |   37|   483k|#  define IPP_MAX_VALUES	8	// Power-of-2 allocation increment
  ------------------
  |  Branch (5931:7): [True: 5.10k, False: 477k]
  ------------------
 5932|  5.10k|    alloc_values = IPP_MAX_VALUES;
  ------------------
  |  |   37|  5.10k|#  define IPP_MAX_VALUES	8	// Power-of-2 allocation increment
  ------------------
 5933|   477k|  else
 5934|   477k|    alloc_values += IPP_MAX_VALUES;
  ------------------
  |  |   37|   477k|#  define IPP_MAX_VALUES	8	// Power-of-2 allocation increment
  ------------------
 5935|       |
 5936|   483k|  DEBUG_printf("4ipp_set_value: Reallocating for up to %u values.", (unsigned)alloc_values);
 5937|       |
 5938|       |  // Reallocate memory...
 5939|   483k|  if ((temp = realloc(temp, sizeof(ipp_attribute_t) + (size_t)(alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
  ------------------
  |  Branch (5939:7): [True: 0, False: 483k]
  ------------------
 5940|      0|  {
 5941|      0|    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), false);
 5942|      0|    DEBUG_puts("4ipp_set_value: Unable to resize attribute.");
 5943|      0|    return (NULL);
 5944|      0|  }
 5945|       |
 5946|       |  // Zero the new memory...
 5947|   483k|  memset(temp->values + temp->num_values, 0, (size_t)(alloc_values - temp->num_values) * sizeof(_ipp_value_t));
 5948|       |
 5949|   483k|  if (temp != *attr)
  ------------------
  |  Branch (5949:7): [True: 7.56k, False: 475k]
  ------------------
 5950|  7.56k|  {
 5951|       |    // Reset pointers in the list...
 5952|  7.56k|#ifndef __clang_analyzer__
 5953|  7.56k|    DEBUG_printf("4debug_free: %p %s", (void *)*attr, temp->name);
 5954|  7.56k|#endif // !__clang_analyzer__
 5955|  7.56k|    DEBUG_printf("4debug_alloc: %p %s %s%s (%u)", (void *)temp, temp->name, temp->num_values > 1 ? "1setOf " : "", ippTagString(temp->value_tag), (unsigned)temp->num_values);
 5956|       |
 5957|  7.56k|    if (ipp->current == *attr && ipp->prev && ipp->prev->next == *attr)
  ------------------
  |  Branch (5957:9): [True: 7.56k, False: 0]
  |  Branch (5957:34): [True: 7.28k, False: 278]
  |  Branch (5957:47): [True: 7.28k, False: 0]
  ------------------
 5958|  7.28k|    {
 5959|       |      // Use current "previous" pointer...
 5960|  7.28k|      prev = ipp->prev;
 5961|  7.28k|    }
 5962|    278|    else
 5963|    278|    {
 5964|       |      // Find this attribute in the linked list...
 5965|    278|      for (prev = NULL, current = ipp->attrs; current && current != *attr; prev = current, current = current->next)
  ------------------
  |  Branch (5965:47): [True: 278, False: 0]
  |  Branch (5965:58): [True: 0, False: 278]
  ------------------
 5966|      0|        ;				// Loop until we find the attribute
 5967|       |
 5968|    278|      if (!current)
  ------------------
  |  Branch (5968:11): [True: 0, False: 278]
  ------------------
 5969|      0|      {
 5970|       |	// This is a serious error!
 5971|      0|	*attr = temp;
 5972|      0|	_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP attribute is not a member of the message."), true);
  ------------------
  |  |   40|      0|#  define _(x) x
  ------------------
 5973|      0|	DEBUG_puts("4ipp_set_value: Unable to find attribute in message.");
 5974|      0|	return (NULL);
 5975|      0|      }
 5976|    278|    }
 5977|       |
 5978|  7.56k|    if (prev)
  ------------------
  |  Branch (5978:9): [True: 7.28k, False: 278]
  ------------------
 5979|  7.28k|      prev->next = temp;
 5980|    278|    else
 5981|    278|      ipp->attrs = temp;
 5982|       |
 5983|  7.56k|    ipp->current = temp;
 5984|  7.56k|    ipp->prev    = prev;
 5985|       |
 5986|  7.56k|    if (ipp->last == *attr)
  ------------------
  |  Branch (5986:9): [True: 7.56k, False: 0]
  ------------------
 5987|  7.56k|      ipp->last = temp;
 5988|       |
 5989|  7.56k|    *attr = temp;
 5990|  7.56k|  }
 5991|       |
 5992|       |  // Return the value element...
 5993|   483k|  if (element >= temp->num_values)
  ------------------
  |  Branch (5993:7): [True: 483k, False: 0]
  ------------------
 5994|   483k|    temp->num_values = element + 1;
 5995|       |
 5996|   483k|  return (temp->values + element);
 5997|   483k|}

cupsLangDefault:
   34|  5.28k|{
   35|  5.28k|  _cups_globals_t *cg = _cupsGlobals();	// Global data
   36|       |
   37|       |
   38|       |  // Load the default language as needed...
   39|  5.28k|  if (!cg->lang_default)
  ------------------
  |  Branch (39:7): [True: 1, False: 5.28k]
  ------------------
   40|      1|    cg->lang_default = cupsLangFind(cups_lang_default());
   41|       |
   42|  5.28k|  return (cg->lang_default);
   43|  5.28k|}
langprintf.c:cups_lang_default:
  209|      1|{
  210|      1|  _cups_globals_t	*cg = _cupsGlobals();
  211|       |  					// Pointer to library globals
  212|      1|#ifndef __APPLE__
  213|      1|  static const char * const locale_encodings[] =
  214|      1|  {					// Locale charset names
  215|      1|    "ASCII",	"ISO88591",	"ISO88592",	"ISO88593",
  216|      1|    "ISO88594",	"ISO88595",	"ISO88596",	"ISO88597",
  217|      1|    "ISO88598",	"ISO88599",	"ISO885910",	"UTF8",
  218|      1|    "ISO885913",	"ISO885914",	"ISO885915",	"CP874",
  219|      1|    "CP1250",	"CP1251",	"CP1252",	"CP1253",
  220|      1|    "CP1254",	"CP1255",	"CP1256",	"CP1257",
  221|      1|    "CP1258",	"KOI8R",	"KOI8U",	"ISO885911",
  222|      1|    "ISO885916",	"MACROMAN",	"",		"",
  223|       |
  224|      1|    "",		"",		"",		"",
  225|      1|    "",		"",		"",		"",
  226|      1|    "",		"",		"",		"",
  227|      1|    "",		"",		"",		"",
  228|      1|    "",		"",		"",		"",
  229|      1|    "",		"",		"",		"",
  230|      1|    "",		"",		"",		"",
  231|      1|    "",		"",		"",		"",
  232|       |
  233|      1|    "CP932",	"CP936",	"CP949",	"CP950",
  234|      1|    "CP1361",	"GB18030",	"",		"",
  235|      1|    "",		"",		"",		"",
  236|      1|    "",		"",		"",		"",
  237|      1|    "",		"",		"",		"",
  238|      1|    "",		"",		"",		"",
  239|      1|    "",		"",		"",		"",
  240|      1|    "",		"",		"",		"",
  241|       |
  242|      1|    "",		"",		"",		"",
  243|      1|    "",		"",		"",		"",
  244|      1|    "",		"",		"",		"",
  245|      1|    "",		"",		"",		"",
  246|      1|    "",		"",		"",		"",
  247|      1|    "",		"",		"",		"",
  248|      1|    "",		"",		"",		"",
  249|      1|    "",		"",		"",		"",
  250|       |
  251|      1|    "EUCCN",	"EUCJP",	"EUCKR",	"EUCTW",
  252|      1|    "SHIFT_JISX0213"
  253|      1|  };
  254|      1|#endif // !__APPLE__
  255|       |
  256|       |
  257|      1|  DEBUG_puts("2cups_lang_default()");
  258|       |
  259|       |  // Only lookup the locale the first time.
  260|      1|  if (!cg->lang_name[0])
  ------------------
  |  Branch (260:7): [True: 1, False: 0]
  ------------------
  261|      1|  {
  262|      1|    const char		*lang;		// LANG environment variable
  263|       |#ifdef __APPLE__
  264|       |    CFBundleRef		bundle;		// Main bundle (if any)
  265|       |    CFArrayRef		bundleList;	// List of localizations in bundle
  266|       |    CFPropertyListRef 	localizationList = NULL;
  267|       |					// List of localization data
  268|       |    CFStringRef		languageName,	// Current language name
  269|       |			localeName;	// Current locale name
  270|       |
  271|       |    if (getenv("SOFTWARE") != NULL && (lang = getenv("LANG")) != NULL)
  272|       |    {
  273|       |      DEBUG_printf("3cups_lang_default: Using LANG=%s", lang);
  274|       |      cupsCopyString(cg->lang_name, lang, sizeof(cg->lang_name));
  275|       |      return (cg->lang_name);
  276|       |    }
  277|       |    else if ((bundle = CFBundleGetMainBundle()) != NULL && (bundleList = CFBundleCopyBundleLocalizations(bundle)) != NULL)
  278|       |    {
  279|       |      CFURLRef resources = CFBundleCopyResourcesDirectoryURL(bundle);
  280|       |					// Resource directory for program
  281|       |
  282|       |      DEBUG_puts("3cups_lang_default: Getting localizationList from bundle.");
  283|       |
  284|       |      if (resources)
  285|       |      {
  286|       |        CFStringRef	cfpath = CFURLCopyPath(resources);
  287|       |					// Directory path of bundle
  288|       |	char		path[1024];	// C string with path
  289|       |
  290|       |        if (cfpath)
  291|       |	{
  292|       |	  // See if we have an Info.plist file in the bundle...
  293|       |	  CFStringGetCString(cfpath, path, sizeof(path), kCFStringEncodingUTF8);
  294|       |	  DEBUG_printf("3cups_lang_default: Got a resource URL (\"%s\")", path);
  295|       |	  cupsConcatString(path, "Contents/Info.plist", sizeof(path));
  296|       |
  297|       |          if (!access(path, R_OK))
  298|       |	    localizationList = CFBundleCopyPreferredLocalizationsFromArray(bundleList);
  299|       |	  else
  300|       |	    DEBUG_puts("3cups_lang_default: No Info.plist, ignoring resource URL...");
  301|       |
  302|       |	  CFRelease(cfpath);
  303|       |	}
  304|       |
  305|       |	CFRelease(resources);
  306|       |      }
  307|       |      else
  308|       |      {
  309|       |        DEBUG_puts("3cups_lang_default: No resource URL.");
  310|       |      }
  311|       |
  312|       |      CFRelease(bundleList);
  313|       |    }
  314|       |
  315|       |    if (!localizationList)
  316|       |    {
  317|       |      DEBUG_puts("3cups_lang_default: Getting localizationList from preferences.");
  318|       |
  319|       |      localizationList = CFPreferencesCopyAppValue(CFSTR("AppleLanguages"), kCFPreferencesCurrentApplication);
  320|       |    }
  321|       |
  322|       |    if (localizationList)
  323|       |    {
  324|       |#  ifdef DEBUG
  325|       |      if (CFGetTypeID(localizationList) == CFArrayGetTypeID())
  326|       |        DEBUG_printf("3cups_lang_default: Got localizationList, %d entries.", (int)CFArrayGetCount(localizationList));
  327|       |      else
  328|       |        DEBUG_puts("3cups_lang_default: Got localizationList but not an array.");
  329|       |#  endif // DEBUG
  330|       |
  331|       |      // Make sure the localization list is an array...
  332|       |      if (CFGetTypeID(localizationList) == CFArrayGetTypeID() && CFArrayGetCount(localizationList) > 0)
  333|       |      {
  334|       |        // Make sure the first element is a string...
  335|       |	languageName = CFArrayGetValueAtIndex(localizationList, 0);
  336|       |
  337|       |	if (languageName && CFGetTypeID(languageName) == CFStringGetTypeID())
  338|       |	{
  339|       |	  // Get the locale identifier for the given language...
  340|       |	  if ((localeName = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, languageName)) != NULL)
  341|       |	  {
  342|       |	    // Use the locale name...
  343|       |	    if (!CFStringGetCString(localeName, cg->lang_name, (CFIndex)sizeof(cg->lang_name), kCFStringEncodingASCII))
  344|       |	    {
  345|       |	      // Use default locale...
  346|       |	      cg->lang_name[0] = '\0';
  347|       |	    }
  348|       |
  349|       |            CFRelease(localeName);
  350|       |	  }
  351|       |	  else if (!CFStringGetCString(languageName, cg->lang_name, (CFIndex)sizeof(cg->lang_name), kCFStringEncodingASCII))
  352|       |	  {
  353|       |	    // Use default locale...
  354|       |	    cg->lang_name[0] = '\0';
  355|       |	  }
  356|       |	}
  357|       |      }
  358|       |
  359|       |      CFRelease(localizationList);
  360|       |    }
  361|       |
  362|       |    // Always use UTF-8 on macOS...
  363|       |    cg->lang_encoding = CUPS_ENCODING_UTF_8;
  364|       |
  365|       |#else // !__APPLE__
  366|      1|    size_t		i;		// Looping var
  367|      1|    const char		*lptr;		// Pointer into the language
  368|      1|    char		charset[32],	// Character set name
  369|      1|			*csptr;		// Pointer into character set
  370|       |
  371|       |    // See if the locale has been set; if it is still "C" or "POSIX", use the
  372|       |    // environment to get the default...
  373|       |#  ifdef _WIN32
  374|       |    WCHAR	wlocname[32];		// Locale name as wide chars
  375|       |    char	locname[32];		// Locale name
  376|       |
  377|       |    if (GetUserDefaultLocaleName(wlocname, sizeof(wlocname)) > 0)
  378|       |    {
  379|       |      size_t  i;			// Looping var
  380|       |
  381|       |      for (i = 0; i < (sizeof(locname) / sizeof(locname[0]) - 1); i ++)
  382|       |        locname[i] = (char)wlocname[i];
  383|       |
  384|       |      locname[i] = '\0';
  385|       |      lang       = locname;
  386|       |    }
  387|       |    else
  388|       |    {
  389|       |      lang = "en";
  390|       |    }
  391|       |
  392|       |#  elif defined(LC_MESSAGES)
  393|      1|    lang = setlocale(LC_MESSAGES, NULL);
  394|       |#  else
  395|       |    lang = setlocale(LC_ALL, NULL);
  396|       |#  endif // LC_MESSAGES
  397|       |
  398|      1|    DEBUG_printf("3cups_lang_default: Current locale is \"%s\".", lang);
  399|       |
  400|      1|    charset[0] = '\0';
  401|       |
  402|      1|    if (!lang || !strcmp(lang, "C") || !strcmp(lang, "POSIX"))
  ------------------
  |  Branch (402:9): [True: 0, False: 1]
  |  Branch (402:18): [True: 1, False: 0]
  |  Branch (402:40): [True: 0, False: 0]
  ------------------
  403|      1|    {
  404|       |      // Get the character set from the LC_xxx locale setting...
  405|      1|      if ((lang = getenv("LC_CTYPE")) == NULL)
  ------------------
  |  Branch (405:11): [True: 1, False: 0]
  ------------------
  406|      1|      {
  407|      1|        if ((lang = getenv("LC_ALL")) == NULL)
  ------------------
  |  Branch (407:13): [True: 1, False: 0]
  ------------------
  408|      1|	{
  409|      1|	  if ((lang = getenv("LANG")) == NULL)
  ------------------
  |  Branch (409:8): [True: 1, False: 0]
  ------------------
  410|      1|	    lang = "en_US";
  411|      1|	}
  412|      1|      }
  413|       |
  414|      1|      if ((lptr = strchr(lang, '.')) != NULL)
  ------------------
  |  Branch (414:11): [True: 0, False: 1]
  ------------------
  415|      0|      {
  416|       |        // Extract the character set from the environment...
  417|      0|	for (csptr = charset, lptr ++; *lptr; lptr ++)
  ------------------
  |  Branch (417:33): [True: 0, False: 0]
  ------------------
  418|      0|	{
  419|      0|	  if (csptr < (charset + sizeof(charset) - 1) && _cups_isalnum(*lptr))
  ------------------
  |  Branch (419:8): [True: 0, False: 0]
  |  Branch (419:51): [True: 0, False: 0]
  ------------------
  420|      0|	    *csptr++ = *lptr;
  421|      0|	}
  422|       |
  423|      0|        *csptr = '\0';
  424|      0|        DEBUG_printf("3cups_lang_default: Charset set to \"%s\" via environment.", charset);
  425|      0|      }
  426|       |
  427|       |      // Get the locale for messages from the LC_MESSAGES locale setting...
  428|      1|      if ((lang = getenv("LC_MESSAGES")) == NULL)
  ------------------
  |  Branch (428:11): [True: 1, False: 0]
  ------------------
  429|      1|      {
  430|      1|        if ((lang = getenv("LC_ALL")) == NULL)
  ------------------
  |  Branch (430:13): [True: 1, False: 0]
  ------------------
  431|      1|        {
  432|      1|	  if ((lang = getenv("LANG")) == NULL)
  ------------------
  |  Branch (432:8): [True: 1, False: 0]
  ------------------
  433|      1|	    lang = "en_US";
  434|      1|	}
  435|      1|      }
  436|      1|    }
  437|       |
  438|      1|    if (lang)
  ------------------
  |  Branch (438:9): [True: 1, False: 0]
  ------------------
  439|      1|    {
  440|       |      // Copy the language over...
  441|      1|      cupsCopyString(cg->lang_name, lang, sizeof(cg->lang_name));
  442|       |
  443|      1|      if ((lptr = strchr(lang, '.')) != NULL)
  ------------------
  |  Branch (443:11): [True: 0, False: 1]
  ------------------
  444|      0|      {
  445|       |        // Extract the character set from the environment...
  446|      0|	for (csptr = charset, lptr ++; *lptr; lptr ++)
  ------------------
  |  Branch (446:33): [True: 0, False: 0]
  ------------------
  447|      0|	{
  448|      0|	  if (csptr < (charset + sizeof(charset) - 1) && _cups_isalnum(*lptr))
  ------------------
  |  Branch (448:8): [True: 0, False: 0]
  |  Branch (448:51): [True: 0, False: 0]
  ------------------
  449|      0|	    *csptr++ = *lptr;
  450|      0|	}
  451|       |
  452|      0|        *csptr = '\0';
  453|       |
  454|      0|        DEBUG_printf("3cups_lang_default: Charset set to \"%s\" via setlocale().", charset);
  455|       |
  456|      0|        if ((csptr = strchr(cg->lang_name, '.')) != NULL)
  ------------------
  |  Branch (456:13): [True: 0, False: 0]
  ------------------
  457|      0|          *csptr = '\0';		// Strip charset from locale name...
  458|      0|      }
  459|      1|    }
  460|       |
  461|      1|#ifdef CODESET
  462|       |    // On systems that support the nl_langinfo(CODESET) call, use this value as
  463|       |    // the character set...
  464|      1|    if (!charset[0] && (lptr = nl_langinfo(CODESET)) != NULL)
  ------------------
  |  Branch (464:9): [True: 1, False: 0]
  |  Branch (464:24): [True: 1, False: 0]
  ------------------
  465|      1|    {
  466|       |      // Copy all of the letters and numbers in the CODESET string...
  467|     15|      for (csptr = charset; *lptr; lptr ++)
  ------------------
  |  Branch (467:29): [True: 14, False: 1]
  ------------------
  468|     14|      {
  469|     14|	if (_cups_isalnum(*lptr) && csptr < (charset + sizeof(charset) - 1))
  ------------------
  |  Branch (469:6): [True: 11, False: 3]
  |  Branch (469:30): [True: 11, False: 0]
  ------------------
  470|     11|	  *csptr++ = *lptr;
  471|     14|      }
  472|      1|      *csptr = '\0';
  473|       |
  474|      1|      DEBUG_printf("3cups_lang_default: Charset set to \"%s\" via nl_langinfo(CODESET).", charset);
  475|      1|    }
  476|      1|#endif // CODESET
  477|       |
  478|       |    // Set the encoding, defaulting to UTF-8...
  479|      1|    cg->lang_encoding = CUPS_ENCODING_AUTO;
  480|       |
  481|    134|    for (i = 0; i < (sizeof(locale_encodings) / sizeof(locale_encodings[0])); i ++)
  ------------------
  |  Branch (481:17): [True: 133, False: 1]
  ------------------
  482|    133|    {
  483|    133|      if (!_cups_strcasecmp(charset, locale_encodings[i]))
  ------------------
  |  Branch (483:11): [True: 0, False: 133]
  ------------------
  484|      0|      {
  485|      0|        cg->lang_encoding = (cups_encoding_t)i;
  486|      0|        break;
  487|      0|      }
  488|    133|    }
  489|       |
  490|      1|    if (cg->lang_encoding == CUPS_ENCODING_AUTO)
  ------------------
  |  Branch (490:9): [True: 1, False: 0]
  ------------------
  491|      1|    {
  492|       |      // Map alternate names for various character sets...
  493|      1|      if (!_cups_strcasecmp(charset, "iso-2022-jp") || !_cups_strcasecmp(charset, "sjis"))
  ------------------
  |  Branch (493:11): [True: 0, False: 1]
  |  Branch (493:56): [True: 0, False: 1]
  ------------------
  494|      0|	cg->lang_encoding = CUPS_ENCODING_WINDOWS_932;
  495|      1|      else if (!_cups_strcasecmp(charset, "iso-2022-cn"))
  ------------------
  |  Branch (495:16): [True: 0, False: 1]
  ------------------
  496|      0|	cg->lang_encoding = CUPS_ENCODING_WINDOWS_936;
  497|      1|      else if (!_cups_strcasecmp(charset, "iso-2022-kr"))
  ------------------
  |  Branch (497:16): [True: 0, False: 1]
  ------------------
  498|      0|	cg->lang_encoding = CUPS_ENCODING_WINDOWS_949;
  499|      1|      else if (!_cups_strcasecmp(charset, "big5"))
  ------------------
  |  Branch (499:16): [True: 0, False: 1]
  ------------------
  500|      0|	cg->lang_encoding = CUPS_ENCODING_WINDOWS_950;
  501|      1|      else
  502|      1|        cg->lang_encoding = CUPS_ENCODING_UTF_8;
  503|      1|    }
  504|      1|#endif // __APPLE__
  505|       |
  506|       |    // Map default/new locales to their legacy counterparts...
  507|      1|    if (!cg->lang_name[0] || !strcmp(cg->lang_name, "en"))
  ------------------
  |  Branch (507:9): [True: 0, False: 1]
  |  Branch (507:30): [True: 0, False: 1]
  ------------------
  508|      0|    {
  509|       |      // Default to en_US...
  510|      0|      cupsCopyString(cg->lang_name, "en_US", sizeof(cg->lang_name));
  511|      0|    }
  512|      1|    else if (!strncmp(cg->lang_name, "nb", 2))
  ------------------
  |  Branch (512:14): [True: 0, False: 1]
  ------------------
  513|      0|    {
  514|       |      // "nb" == Norwegian Bokmal, "no" is the legacy name...
  515|      0|      cupsCopyString(cg->lang_name, "no", sizeof(cg->lang_name));
  516|      0|    }
  517|      1|    else if (!strncmp(cg->lang_name, "zh-Hans", 7) || !strncmp(cg->lang_name, "zh_HANS", 7))
  ------------------
  |  Branch (517:14): [True: 0, False: 1]
  |  Branch (517:55): [True: 0, False: 1]
  ------------------
  518|      0|    {
  519|       |      // Simplified Chinese (China)
  520|      0|      cupsCopyString(cg->lang_name, "zh_CN", sizeof(cg->lang_name));
  521|      0|    }
  522|      1|    else if (!strncmp(cg->lang_name, "zh-Hant", 7) || !strncmp(cg->lang_name, "zh_HANT", 7))
  ------------------
  |  Branch (522:14): [True: 0, False: 1]
  |  Branch (522:55): [True: 0, False: 1]
  ------------------
  523|      0|    {
  524|       |      // Traditional Chinese (Taiwan)
  525|      0|      cupsCopyString(cg->lang_name, "zh_TW", sizeof(cg->lang_name));
  526|      0|    }
  527|       |
  528|      1|    DEBUG_printf("3cups_lang_default: Using locale \"%s\".", cg->lang_name);
  529|      1|  }
  530|      0|  else
  531|      0|  {
  532|      0|    DEBUG_printf("3cups_lang_default: Using previous locale \"%s\".", cg->lang_name);
  533|      0|  }
  534|       |
  535|       |  // Return the cached locale...
  536|      1|  return (cg->lang_name);
  537|      1|}

cupsLangFind:
  106|      1|{
  107|      1|  char		langname[16];		// Requested language name
  108|      1|  cups_lang_t	*lang;			// Current language...
  109|       |
  110|       |
  111|      1|  DEBUG_printf("2cupsLangFind(language=\"%s\")", language);
  112|       |
  113|      1|  if (!language)
  ------------------
  |  Branch (113:7): [True: 0, False: 1]
  ------------------
  114|      0|    return (cupsLangDefault());
  115|       |
  116|      1|  cupsMutexLock(&lang_mutex);
  117|       |
  118|      1|  cupsCopyString(langname, language, sizeof(langname));
  119|      1|  if (langname[2] == '-')
  ------------------
  |  Branch (119:7): [True: 0, False: 1]
  ------------------
  120|      0|    langname[2] = '_';
  121|       |
  122|      1|  for (lang = lang_cache; lang; lang = lang->next)
  ------------------
  |  Branch (122:27): [True: 0, False: 1]
  ------------------
  123|      0|  {
  124|      0|    if (!_cups_strcasecmp(lang->language, langname))
  ------------------
  |  Branch (124:9): [True: 0, False: 0]
  ------------------
  125|      0|      break;
  126|      0|  }
  127|       |
  128|      1|  if (!lang)
  ------------------
  |  Branch (128:7): [True: 1, False: 0]
  ------------------
  129|      1|  {
  130|       |    // Create the language if it doesn't exist...
  131|      1|    lang = cups_lang_new(langname);
  132|      1|  }
  133|       |
  134|      1|  cupsMutexUnlock(&lang_mutex);
  135|       |
  136|      1|  return (lang);
  137|      1|}
cupsLangGetName:
  172|  5.28k|{
  173|  5.28k|  return (lang ? lang->language : NULL);
  ------------------
  |  Branch (173:11): [True: 5.28k, False: 0]
  ------------------
  174|  5.28k|}
cupsLangGetString:
  188|    983|{
  189|    983|  _cups_message_t	key,		// Search key
  190|    983|			*match;		// Matching message
  191|    983|  const char		*text;		// Localized message text
  192|       |
  193|       |
  194|    983|  DEBUG_printf("cupsLangGetString(lang=%p(%s), message=\"%s\")", (void *)lang, lang ? lang->language : "null", message);
  195|       |
  196|       |  // Range check input...
  197|    983|  if (!lang || !lang->num_messages || !message || !*message)
  ------------------
  |  Branch (197:7): [True: 0, False: 983]
  |  Branch (197:16): [True: 0, False: 983]
  |  Branch (197:39): [True: 0, False: 983]
  |  Branch (197:51): [True: 0, False: 983]
  ------------------
  198|      0|    return (message);
  199|       |
  200|    983|  cupsRWLockRead(&lang->rwlock);
  201|       |
  202|    983|  key.key = (char *)message;
  203|    983|  match   = bsearch(&key, lang->messages, lang->num_messages, sizeof(_cups_message_t), (int (*)(const void *, const void *))cups_message_compare);
  204|    983|  text    = match ? match->text : message;
  ------------------
  |  Branch (204:13): [True: 983, False: 0]
  ------------------
  205|       |
  206|    983|  cupsRWUnlock(&lang->rwlock);
  207|       |
  208|    983|  return (text);
  209|    983|}
cupsLangLoadStrings:
  251|      1|{
  252|      1|  bool		ret = true;		// Return value
  253|      1|  int		linenum;		// Current line number in data
  254|      1|  const char	*data,			// Pointer to strings data
  255|      1|		*dataptr;		// Pointer into string data
  256|      1|  char		key[1024],		// Key string
  257|      1|		text[1024],		// Localized text string
  258|      1|		*ptr;			// Pointer into strings
  259|      1|  _cups_message_t *m,			// Pointer to message
  260|      1|		mkey;			// Search key
  261|      1|  size_t	num_messages;		// New number of messages
  262|       |
  263|       |
  264|      1|  if (filename)
  ------------------
  |  Branch (264:7): [True: 0, False: 1]
  ------------------
  265|      0|  {
  266|       |    // Load the strings file...
  267|      0|    int		fd;			// File descriptor
  268|      0|    struct stat	fileinfo;		// File information
  269|      0|    ssize_t	bytes;			// Bytes read
  270|       |
  271|      0|    if ((fd = open(filename, O_RDONLY)) < 0)
  ------------------
  |  Branch (271:9): [True: 0, False: 0]
  ------------------
  272|      0|    {
  273|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
  274|      0|      return (false);
  275|      0|    }
  276|       |
  277|      0|    if (fstat(fd, &fileinfo))
  ------------------
  |  Branch (277:9): [True: 0, False: 0]
  ------------------
  278|      0|    {
  279|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
  280|      0|      close(fd);
  281|      0|      return (false);
  282|      0|    }
  283|       |
  284|      0|    if ((ptr = malloc((size_t)(fileinfo.st_size + 1))) == NULL)
  ------------------
  |  Branch (284:9): [True: 0, False: 0]
  ------------------
  285|      0|    {
  286|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
  287|      0|      close(fd);
  288|      0|      return (false);
  289|      0|    }
  290|       |
  291|      0|    if ((bytes = read(fd, ptr, (size_t)fileinfo.st_size)) < 0)
  ------------------
  |  Branch (291:9): [True: 0, False: 0]
  ------------------
  292|      0|    {
  293|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
  294|      0|      close(fd);
  295|      0|      free(ptr);
  296|      0|      return (false);
  297|      0|    }
  298|       |
  299|      0|    close(fd);
  300|       |
  301|      0|    ptr[bytes] = '\0';
  302|      0|    data       = ptr;
  303|      0|  }
  304|      1|  else
  305|      1|  {
  306|       |    // Use in-memory strings data...
  307|      1|    data = (const char *)strings;
  308|      1|  }
  309|       |
  310|      1|  if (!data)
  ------------------
  |  Branch (310:7): [True: 0, False: 1]
  ------------------
  311|      0|  {
  312|      0|    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
  313|      0|    return (false);
  314|      0|  }
  315|       |
  316|       |  // Scan the in-memory strings data and add key/text pairs...
  317|       |  //
  318|       |  // Format of strings files is:
  319|       |  //
  320|       |  // "key" = "text";
  321|      1|  cupsRWLockWrite(&lang->rwlock);
  322|       |
  323|      1|  num_messages = lang->num_messages;
  324|      1|  mkey.key     = key;
  325|       |
  326|  2.49k|  for (dataptr = data, linenum = 1; *dataptr; dataptr ++)
  ------------------
  |  Branch (326:37): [True: 2.49k, False: 1]
  ------------------
  327|  2.49k|  {
  328|       |    // Skip leading whitespace...
  329|  2.49k|    while (*dataptr && isspace(*dataptr & 255))
  ------------------
  |  Branch (329:12): [True: 2.49k, False: 0]
  |  Branch (329:24): [True: 0, False: 2.49k]
  ------------------
  330|      0|    {
  331|      0|      if (*dataptr == '\n')
  ------------------
  |  Branch (331:11): [True: 0, False: 0]
  ------------------
  332|      0|        linenum ++;
  333|       |
  334|      0|      dataptr ++;
  335|      0|    }
  336|       |
  337|  2.49k|    if (!*dataptr)
  ------------------
  |  Branch (337:9): [True: 0, False: 2.49k]
  ------------------
  338|      0|    {
  339|       |      // End of string...
  340|      0|      break;
  341|      0|    }
  342|  2.49k|    else if (*dataptr == '/' && dataptr[1] == '*')
  ------------------
  |  Branch (342:14): [True: 0, False: 2.49k]
  |  Branch (342:33): [True: 0, False: 0]
  ------------------
  343|      0|    {
  344|       |      // Start of C-style comment...
  345|      0|      for (dataptr += 2; *dataptr; dataptr ++)
  ------------------
  |  Branch (345:26): [True: 0, False: 0]
  ------------------
  346|      0|      {
  347|      0|        if (*dataptr == '*' && dataptr[1] == '/')
  ------------------
  |  Branch (347:13): [True: 0, False: 0]
  |  Branch (347:32): [True: 0, False: 0]
  ------------------
  348|      0|	{
  349|      0|	  dataptr += 2;
  350|      0|	  break;
  351|      0|	}
  352|      0|	else if (*dataptr == '\n')
  ------------------
  |  Branch (352:11): [True: 0, False: 0]
  ------------------
  353|      0|	  linenum ++;
  354|      0|      }
  355|       |
  356|      0|      if (!*dataptr)
  ------------------
  |  Branch (356:11): [True: 0, False: 0]
  ------------------
  357|      0|        break;
  358|      0|    }
  359|  2.49k|    else if (*dataptr != '\"')
  ------------------
  |  Branch (359:14): [True: 0, False: 2.49k]
  ------------------
  360|      0|    {
  361|       |      // Something else we don't recognize...
  362|      0|      snprintf(text, sizeof(text), "Syntax error on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (362:7): [True: 0, False: 0]
  ------------------
  363|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  364|      0|      ret = false;
  365|      0|      break;
  366|      0|    }
  367|       |
  368|       |    // Parse key string...
  369|  2.49k|    dataptr ++;
  370|  89.7k|    for (ptr = key; *dataptr && *dataptr != '\"'; dataptr ++)
  ------------------
  |  Branch (370:21): [True: 89.7k, False: 0]
  |  Branch (370:33): [True: 87.2k, False: 2.49k]
  ------------------
  371|  87.2k|    {
  372|  87.2k|      if (*dataptr == '\\' && dataptr[1])
  ------------------
  |  Branch (372:11): [True: 149, False: 87.1k]
  |  Branch (372:31): [True: 149, False: 0]
  ------------------
  373|    149|      {
  374|       |        // Escaped character...
  375|    149|        int	ch;			// Character
  376|       |
  377|    149|        dataptr ++;
  378|    149|        if (*dataptr == '\\' || *dataptr == '\'' || *dataptr == '\"')
  ------------------
  |  Branch (378:13): [True: 0, False: 149]
  |  Branch (378:33): [True: 0, False: 149]
  |  Branch (378:53): [True: 133, False: 16]
  ------------------
  379|    133|        {
  380|    133|          ch = *dataptr;
  381|    133|	}
  382|     16|	else if (*dataptr == 'n')
  ------------------
  |  Branch (382:11): [True: 16, False: 0]
  ------------------
  383|     16|	{
  384|     16|	  ch = '\n';
  385|     16|	}
  386|      0|	else if (*dataptr == 'r')
  ------------------
  |  Branch (386:11): [True: 0, False: 0]
  ------------------
  387|      0|	{
  388|      0|	  ch = '\r';
  389|      0|	}
  390|      0|	else if (*dataptr == 't')
  ------------------
  |  Branch (390:11): [True: 0, False: 0]
  ------------------
  391|      0|	{
  392|      0|	  ch = '\t';
  393|      0|	}
  394|      0|	else if (*dataptr >= '0' && *dataptr <= '3' && dataptr[1] >= '0' && dataptr[1] <= '7' && dataptr[2] >= '0' && dataptr[2] <= '7')
  ------------------
  |  Branch (394:11): [True: 0, False: 0]
  |  Branch (394:30): [True: 0, False: 0]
  |  Branch (394:49): [True: 0, False: 0]
  |  Branch (394:70): [True: 0, False: 0]
  |  Branch (394:91): [True: 0, False: 0]
  |  Branch (394:112): [True: 0, False: 0]
  ------------------
  395|      0|	{
  396|       |	  // Octal escape
  397|      0|	  ch = ((*dataptr - '0') << 6) | ((dataptr[1] - '0') << 3) | (dataptr[2] - '0');
  398|      0|	  dataptr += 2;
  399|      0|	}
  400|      0|	else
  401|      0|	{
  402|      0|	  snprintf(text, sizeof(text), "Invalid escape in key string on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (402:4): [True: 0, False: 0]
  ------------------
  403|      0|	  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  404|      0|	  ret = false;
  405|      0|	  break;
  406|      0|	}
  407|       |
  408|    149|        if (ptr < (key + sizeof(key) - 1))
  ------------------
  |  Branch (408:13): [True: 149, False: 0]
  ------------------
  409|    149|          *ptr++ = (char)ch;
  410|    149|      }
  411|  87.1k|      else if (ptr < (key + sizeof(key) - 1))
  ------------------
  |  Branch (411:16): [True: 87.1k, False: 0]
  ------------------
  412|  87.1k|      {
  413|  87.1k|        *ptr++ = *dataptr;
  414|  87.1k|      }
  415|  87.2k|    }
  416|       |
  417|  2.49k|    if (!*dataptr)
  ------------------
  |  Branch (417:9): [True: 0, False: 2.49k]
  ------------------
  418|      0|    {
  419|      0|      snprintf(text, sizeof(text), "Unterminated key string on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (419:7): [True: 0, False: 0]
  ------------------
  420|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  421|      0|      ret = false;
  422|      0|      break;
  423|      0|    }
  424|       |
  425|  2.49k|    dataptr ++;
  426|  2.49k|    *ptr = '\0';
  427|       |
  428|       |    // Parse separator...
  429|  4.99k|    while (*dataptr && isspace(*dataptr & 255))
  ------------------
  |  Branch (429:12): [True: 4.99k, False: 0]
  |  Branch (429:24): [True: 2.49k, False: 2.49k]
  ------------------
  430|  2.49k|    {
  431|  2.49k|      if (*dataptr == '\n')
  ------------------
  |  Branch (431:11): [True: 0, False: 2.49k]
  ------------------
  432|      0|        linenum ++;
  433|       |
  434|  2.49k|      dataptr ++;
  435|  2.49k|    }
  436|       |
  437|  2.49k|    if (*dataptr != '=')
  ------------------
  |  Branch (437:9): [True: 0, False: 2.49k]
  ------------------
  438|      0|    {
  439|      0|      snprintf(text, sizeof(text), "Missing separator on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (439:7): [True: 0, False: 0]
  ------------------
  440|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  441|      0|      ret = false;
  442|      0|      break;
  443|      0|    }
  444|       |
  445|  2.49k|    dataptr ++;
  446|  4.99k|    while (*dataptr && isspace(*dataptr & 255))
  ------------------
  |  Branch (446:12): [True: 4.99k, False: 0]
  |  Branch (446:24): [True: 2.49k, False: 2.49k]
  ------------------
  447|  2.49k|    {
  448|  2.49k|      if (*dataptr == '\n')
  ------------------
  |  Branch (448:11): [True: 0, False: 2.49k]
  ------------------
  449|      0|        linenum ++;
  450|       |
  451|  2.49k|      dataptr ++;
  452|  2.49k|    }
  453|       |
  454|  2.49k|    if (*dataptr != '\"')
  ------------------
  |  Branch (454:9): [True: 0, False: 2.49k]
  ------------------
  455|      0|    {
  456|      0|      snprintf(text, sizeof(text), "Missing text string on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (456:7): [True: 0, False: 0]
  ------------------
  457|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  458|      0|      ret = false;
  459|      0|      break;
  460|      0|    }
  461|       |
  462|       |    // Parse text string...
  463|  2.49k|    dataptr ++;
  464|  57.6k|    for (ptr = text; *dataptr && *dataptr != '\"'; dataptr ++)
  ------------------
  |  Branch (464:22): [True: 57.6k, False: 0]
  |  Branch (464:34): [True: 55.1k, False: 2.49k]
  ------------------
  465|  55.1k|    {
  466|  55.1k|      if (*dataptr == '\\')
  ------------------
  |  Branch (466:11): [True: 151, False: 54.9k]
  ------------------
  467|    151|      {
  468|       |        // Escaped character...
  469|    151|        int	ch;			// Character
  470|       |
  471|    151|        dataptr ++;
  472|    151|        if (*dataptr == '\\' || *dataptr == '\'' || *dataptr == '\"')
  ------------------
  |  Branch (472:13): [True: 0, False: 151]
  |  Branch (472:33): [True: 0, False: 151]
  |  Branch (472:53): [True: 135, False: 16]
  ------------------
  473|    135|        {
  474|    135|          ch = *dataptr;
  475|    135|	}
  476|     16|	else if (*dataptr == 'n')
  ------------------
  |  Branch (476:11): [True: 16, False: 0]
  ------------------
  477|     16|	{
  478|     16|	  ch = '\n';
  479|     16|	}
  480|      0|	else if (*dataptr == 'r')
  ------------------
  |  Branch (480:11): [True: 0, False: 0]
  ------------------
  481|      0|	{
  482|      0|	  ch = '\r';
  483|      0|	}
  484|      0|	else if (*dataptr == 't')
  ------------------
  |  Branch (484:11): [True: 0, False: 0]
  ------------------
  485|      0|	{
  486|      0|	  ch = '\t';
  487|      0|	}
  488|      0|	else if (*dataptr >= '0' && *dataptr <= '3' && dataptr[1] >= '0' && dataptr[1] <= '7' && dataptr[2] >= '0' && dataptr[2] <= '7')
  ------------------
  |  Branch (488:11): [True: 0, False: 0]
  |  Branch (488:30): [True: 0, False: 0]
  |  Branch (488:49): [True: 0, False: 0]
  |  Branch (488:70): [True: 0, False: 0]
  |  Branch (488:91): [True: 0, False: 0]
  |  Branch (488:112): [True: 0, False: 0]
  ------------------
  489|      0|	{
  490|       |	  // Octal escape
  491|      0|	  ch = ((*dataptr - '0') << 6) | ((dataptr[1] - '0') << 3) | (dataptr[2] - '0');
  492|      0|	  dataptr += 2;
  493|      0|	}
  494|      0|	else
  495|      0|	{
  496|      0|	  snprintf(text, sizeof(text), "Invalid escape in text string on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (496:4): [True: 0, False: 0]
  ------------------
  497|      0|	  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  498|      0|	  ret = false;
  499|      0|	  break;
  500|      0|	}
  501|       |
  502|    151|        if (ptr < (text + sizeof(text) - 1))
  ------------------
  |  Branch (502:13): [True: 151, False: 0]
  ------------------
  503|    151|          *ptr++ = (char)ch;
  504|    151|      }
  505|  54.9k|      else if (ptr < (text + sizeof(text) - 1))
  ------------------
  |  Branch (505:16): [True: 54.9k, False: 0]
  ------------------
  506|  54.9k|      {
  507|  54.9k|        *ptr++ = *dataptr;
  508|  54.9k|      }
  509|  55.1k|    }
  510|       |
  511|  2.49k|    if (!*dataptr)
  ------------------
  |  Branch (511:9): [True: 0, False: 2.49k]
  ------------------
  512|      0|    {
  513|      0|      snprintf(text, sizeof(text), "Unterminated text string on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (513:7): [True: 0, False: 0]
  ------------------
  514|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  515|      0|      ret = false;
  516|      0|      break;
  517|      0|    }
  518|       |
  519|  2.49k|    dataptr ++;
  520|  2.49k|    *ptr = '\0';
  521|       |
  522|       |    // Look for terminator, then add the pair...
  523|  2.49k|    if (*dataptr != ';')
  ------------------
  |  Branch (523:9): [True: 0, False: 2.49k]
  ------------------
  524|      0|    {
  525|      0|      snprintf(text, sizeof(text), "Missing terminator on line %d of '%s'.", linenum, filename ? filename : "in-memory");
  ------------------
  |  Branch (525:7): [True: 0, False: 0]
  ------------------
  526|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, text, 0);
  527|      0|      ret = false;
  528|      0|      break;
  529|      0|    }
  530|       |
  531|  2.49k|    dataptr ++;
  532|       |
  533|       |    // Add the message if it doesn't already exist...
  534|  2.49k|    if (lang->num_messages > 0 && bsearch(&mkey, lang->messages, lang->num_messages, sizeof(_cups_message_t), (int (*)(const void *, const void *))cups_message_compare))
  ------------------
  |  Branch (534:9): [True: 0, False: 2.49k]
  |  Branch (534:35): [True: 0, False: 0]
  ------------------
  535|      0|      continue;
  536|       |
  537|  2.49k|    if (num_messages >= lang->alloc_messages)
  ------------------
  |  Branch (537:9): [True: 3, False: 2.49k]
  ------------------
  538|      3|    {
  539|      3|      if ((m = realloc(lang->messages, (lang->alloc_messages + 1024) * sizeof(_cups_message_t))) == NULL)
  ------------------
  |  Branch (539:11): [True: 0, False: 3]
  ------------------
  540|      0|      {
  541|      0|        _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
  542|      0|        ret = false;
  543|      0|        break;
  544|      0|      }
  545|       |
  546|      3|      lang->messages       = m;
  547|      3|      lang->alloc_messages += 1024;
  548|      3|    }
  549|       |
  550|  2.49k|    m = lang->messages + num_messages;
  551|       |
  552|  2.49k|    if ((m->key = _cupsStrAlloc(key)) == NULL || (m->text = _cupsStrAlloc(text)) == NULL)
  ------------------
  |  Branch (552:9): [True: 0, False: 2.49k]
  |  Branch (552:50): [True: 0, False: 2.49k]
  ------------------
  553|      0|    {
  554|      0|      _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
  555|      0|      _cupsStrFree(m->key);
  556|      0|      _cupsStrFree(m->text);
  557|      0|      ret = false;
  558|      0|      break;
  559|      0|    }
  560|       |
  561|  2.49k|    num_messages ++;
  562|  2.49k|  }
  563|       |
  564|       |  // Re-sort messages as needed...
  565|      1|  if (num_messages > lang->num_messages)
  ------------------
  |  Branch (565:7): [True: 1, False: 0]
  ------------------
  566|      1|  {
  567|      1|    lang->num_messages = num_messages;
  568|      1|    qsort(lang->messages, lang->num_messages, sizeof(_cups_message_t), (int (*)(const void *, const void *))cups_message_compare);
  569|      1|  }
  570|       |
  571|      1|  cupsRWUnlock(&lang->rwlock);
  572|       |
  573|       |  // Free temporary storage and return...
  574|      1|  if (data != strings)
  ------------------
  |  Branch (574:7): [True: 0, False: 1]
  ------------------
  575|      0|    free((void *)data);
  576|       |
  577|      1|  return (ret);
  578|      1|}
language.c:cups_lang_new:
  610|      1|{
  611|      1|  cups_lang_t	*lang;			// Language data
  612|      1|  char		filename[1024];		// Strings file...
  613|      1|  bool		status;			// Load status
  614|       |
  615|       |
  616|       |  // Create an empty language data structure...
  617|      1|  if ((lang = calloc(1, sizeof(cups_lang_t))) == NULL)
  ------------------
  |  Branch (617:7): [True: 0, False: 1]
  ------------------
  618|      0|    return (NULL);
  619|       |
  620|      1|  cupsRWInit(&lang->rwlock);
  621|      1|  cupsCopyString(lang->language, language, sizeof(lang->language));
  622|       |
  623|       |  // Add strings...
  624|      1|  if (!_cups_strncasecmp(language, "ca", 2))
  ------------------
  |  Branch (624:7): [True: 0, False: 1]
  ------------------
  625|      0|    status = cupsLangLoadStrings(lang, NULL, ca_strings);
  626|      1|  else if (!_cups_strncasecmp(language, "cs", 2))
  ------------------
  |  Branch (626:12): [True: 0, False: 1]
  ------------------
  627|      0|    status = cupsLangLoadStrings(lang, NULL, cs_strings);
  628|      1|  else if (!_cups_strncasecmp(language, "da", 2))
  ------------------
  |  Branch (628:12): [True: 0, False: 1]
  ------------------
  629|      0|    status = cupsLangLoadStrings(lang, NULL, da_strings);
  630|      1|  else if (!_cups_strncasecmp(language, "de", 2))
  ------------------
  |  Branch (630:12): [True: 0, False: 1]
  ------------------
  631|      0|    status = cupsLangLoadStrings(lang, NULL, de_strings);
  632|      1|  else if (!_cups_strncasecmp(language, "es", 2))
  ------------------
  |  Branch (632:12): [True: 0, False: 1]
  ------------------
  633|      0|    status = cupsLangLoadStrings(lang, NULL, es_strings);
  634|      1|  else if (!_cups_strncasecmp(language, "fr", 2))
  ------------------
  |  Branch (634:12): [True: 0, False: 1]
  ------------------
  635|      0|    status = cupsLangLoadStrings(lang, NULL, fr_strings);
  636|      1|  else if (!_cups_strncasecmp(language, "it", 2))
  ------------------
  |  Branch (636:12): [True: 0, False: 1]
  ------------------
  637|      0|    status = cupsLangLoadStrings(lang, NULL, it_strings);
  638|      1|  else if (!_cups_strncasecmp(language, "ja", 2))
  ------------------
  |  Branch (638:12): [True: 0, False: 1]
  ------------------
  639|      0|    status = cupsLangLoadStrings(lang, NULL, ja_strings);
  640|      1|  else if (!_cups_strncasecmp(language, "pt", 2))
  ------------------
  |  Branch (640:12): [True: 0, False: 1]
  ------------------
  641|      0|    status = cupsLangLoadStrings(lang, NULL, pt_BR_strings);
  642|      1|  else if (!_cups_strncasecmp(language, "ru", 2))
  ------------------
  |  Branch (642:12): [True: 0, False: 1]
  ------------------
  643|      0|    status = cupsLangLoadStrings(lang, NULL, ru_strings);
  644|      1|  else if (!_cups_strncasecmp(language, "zh", 2))
  ------------------
  |  Branch (644:12): [True: 0, False: 1]
  ------------------
  645|      0|    status = cupsLangLoadStrings(lang, NULL, zh_CN_strings);
  646|      1|  else
  647|      1|    status = cupsLangLoadStrings(lang, NULL, en_strings);
  648|       |
  649|      1|  if (status && lang_directory)
  ------------------
  |  Branch (649:7): [True: 1, False: 0]
  |  Branch (649:17): [True: 0, False: 1]
  ------------------
  650|      0|  {
  651|      0|    snprintf(filename, sizeof(filename), "%s/%s.strings", lang_directory, language);
  652|      0|    if (access(filename, 0) && language[2])
  ------------------
  |  Branch (652:9): [True: 0, False: 0]
  |  Branch (652:32): [True: 0, False: 0]
  ------------------
  653|      0|    {
  654|      0|      char	baselang[3];		// Base language name
  655|       |
  656|      0|      cupsCopyString(baselang, language, sizeof(baselang));
  657|      0|      snprintf(filename, sizeof(filename), "%s/%s.strings", lang_directory, baselang);
  658|      0|    }
  659|       |
  660|      0|    if (!access(filename, 0))
  ------------------
  |  Branch (660:9): [True: 0, False: 0]
  ------------------
  661|      0|      status = cupsLangLoadStrings(lang, filename, NULL);
  662|      0|  }
  663|       |
  664|      1|  if (!status)
  ------------------
  |  Branch (664:7): [True: 0, False: 1]
  ------------------
  665|      0|  {
  666|       |    // Free memory if the load failed...
  667|      0|    size_t	i;			// Looping var
  668|       |
  669|      0|    for (i = 0; i < lang->num_messages; i ++)
  ------------------
  |  Branch (669:17): [True: 0, False: 0]
  ------------------
  670|      0|    {
  671|      0|      _cupsStrFree(lang->messages[i].key);
  672|      0|      _cupsStrFree(lang->messages[i].text);
  673|      0|    }
  674|       |
  675|      0|    free(lang->messages);
  676|      0|    free(lang);
  677|       |
  678|      0|    return (NULL);
  679|      0|  }
  680|       |
  681|       |  // Add this language to the front of the list...
  682|      1|  lang->next = lang_cache;
  683|      1|  lang_cache = lang;
  684|       |
  685|      1|  return (lang);
  686|      1|}
language.c:cups_message_compare:
  697|  24.2k|{
  698|  24.2k|  return (strcmp(m1->key, m2->key));
  699|  24.2k|}

_cupsSetError:
  861|    983|{
  862|    983|  _cups_globals_t	*cg;		// Global data
  863|       |
  864|       |
  865|    983|  if (!message && errno)
  ------------------
  |  Branch (865:7): [True: 0, False: 983]
  |  Branch (865:19): [True: 0, False: 0]
  ------------------
  866|      0|  {
  867|      0|    message  = strerror(errno);
  868|      0|    localize = 0;
  869|      0|  }
  870|       |
  871|    983|  cg             = _cupsGlobals();
  872|    983|  cg->last_error = status;
  873|       |
  874|    983|  if (cg->last_status_message)
  ------------------
  |  Branch (874:7): [True: 982, False: 1]
  ------------------
  875|    982|  {
  876|    982|    _cupsStrFree(cg->last_status_message);
  877|       |
  878|    982|    cg->last_status_message = NULL;
  879|    982|  }
  880|       |
  881|    983|  if (message)
  ------------------
  |  Branch (881:7): [True: 983, False: 0]
  ------------------
  882|    983|  {
  883|    983|    if (localize)
  ------------------
  |  Branch (883:9): [True: 983, False: 0]
  ------------------
  884|    983|    {
  885|       |      // Get the message catalog...
  886|    983|      if (!cg->lang_default)
  ------------------
  |  Branch (886:11): [True: 0, False: 983]
  ------------------
  887|      0|	cg->lang_default = cupsLangDefault();
  888|       |
  889|    983|      cg->last_status_message = _cupsStrAlloc(cupsLangGetString(cg->lang_default, message));
  890|    983|    }
  891|      0|    else
  892|      0|    {
  893|      0|      cg->last_status_message = _cupsStrAlloc(message);
  894|      0|    }
  895|    983|  }
  896|       |
  897|    983|  DEBUG_printf("4_cupsSetError: last_error=%s, last_status_message=\"%s\"", ippErrorString(cg->last_error), cg->last_status_message);
  898|    983|}

ipp.c:_cups_tolower:
   94|  45.4k|{
   95|  45.4k|  return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch);
  ------------------
  |  Branch (95:11): [True: 15.9k, False: 29.4k]
  ------------------
   96|  45.4k|}
ipp.c:_cups_isupper:
   88|  45.4k|{
   89|  45.4k|  return (ch >= 'A' && ch <= 'Z');
  ------------------
  |  Branch (89:11): [True: 40.0k, False: 5.40k]
  |  Branch (89:24): [True: 15.9k, False: 24.0k]
  ------------------
   90|  45.4k|}
string.c:_cups_tolower:
   94|  32.0k|{
   95|  32.0k|  return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch);
  ------------------
  |  Branch (95:11): [True: 91, False: 32.0k]
  ------------------
   96|  32.0k|}
string.c:_cups_isupper:
   88|  32.0k|{
   89|  32.0k|  return (ch >= 'A' && ch <= 'Z');
  ------------------
  |  Branch (89:11): [True: 32.0k, False: 0]
  |  Branch (89:24): [True: 91, False: 32.0k]
  ------------------
   90|  32.0k|}
langprintf.c:_cups_isalnum:
   64|     14|{
   65|     14|  return ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'));
  ------------------
  |  Branch (65:12): [True: 12, False: 2]
  |  Branch (65:25): [True: 6, False: 6]
  |  Branch (65:40): [True: 6, False: 2]
  |  Branch (65:53): [True: 5, False: 1]
  |  Branch (65:68): [True: 0, False: 3]
  |  Branch (65:81): [True: 0, False: 0]
  ------------------
   66|     14|}

cupsCopyString:
   92|      8|{
   93|      8|  size_t	srclen;			// Length of source string
   94|       |
   95|       |
   96|       |  // Range check input...
   97|      8|  if (!dst || !src || dstsize == 0)
  ------------------
  |  Branch (97:7): [True: 0, False: 8]
  |  Branch (97:15): [True: 0, False: 8]
  |  Branch (97:23): [True: 0, False: 8]
  ------------------
   98|      0|  {
   99|      0|    if (dst)
  ------------------
  |  Branch (99:9): [True: 0, False: 0]
  ------------------
  100|      0|      *dst = '\0';
  101|      0|    return (0);
  102|      0|  }
  103|       |
  104|       |  // Figure out how much room is needed...
  105|      8|  dstsize --;
  106|       |
  107|      8|  srclen = strlen(src);
  108|       |
  109|       |  // Copy the appropriate amount...
  110|      8|  if (srclen <= dstsize)
  ------------------
  |  Branch (110:7): [True: 8, False: 0]
  ------------------
  111|      8|  {
  112|       |    // Source string will fit...
  113|      8|    memmove(dst, src, srclen);
  114|      8|    dst[srclen] = '\0';
  115|      8|  }
  116|      0|  else
  117|      0|  {
  118|       |    // Source string too big, copy what we can and clean up the end...
  119|      0|    memmove(dst, src, dstsize);
  120|      0|    dst[dstsize] = '\0';
  121|       |
  122|      0|    validate_end(dst, dst + dstsize);
  123|      0|  }
  124|       |
  125|      8|  return (srclen);
  126|      8|}
_cupsStrAlloc:
  503|  6.50M|{
  504|  6.50M|  size_t		slen;		// Length of string
  505|  6.50M|  _cups_sp_item_t	*item,		// String pool item
  506|  6.50M|			*key;		// Search key
  507|       |
  508|       |
  509|       |  // Range check input...
  510|  6.50M|  if (!s)
  ------------------
  |  Branch (510:7): [True: 0, False: 6.50M]
  ------------------
  511|      0|    return (NULL);
  512|       |
  513|       |  // Get the string pool...
  514|  6.50M|  cupsMutexLock(&sp_mutex);
  515|       |
  516|  6.50M|  if (!stringpool)
  ------------------
  |  Branch (516:7): [True: 1, False: 6.50M]
  ------------------
  517|      1|    stringpool = cupsArrayNew((cups_array_cb_t)compare_sp_items, NULL, NULL, 0, NULL, NULL);
  518|       |
  519|  6.50M|  if (!stringpool)
  ------------------
  |  Branch (519:7): [True: 0, False: 6.50M]
  ------------------
  520|      0|  {
  521|      0|    cupsMutexUnlock(&sp_mutex);
  522|       |
  523|      0|    return (NULL);
  524|      0|  }
  525|       |
  526|       |  // See if the string is already in the pool...
  527|  6.50M|  key = (_cups_sp_item_t *)(s - offsetof(_cups_sp_item_t, str));
  528|       |
  529|  6.50M|  if ((item = (_cups_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL)
  ------------------
  |  Branch (529:7): [True: 5.83M, False: 677k]
  ------------------
  530|  5.83M|  {
  531|       |    // Found it, return the cached string...
  532|  5.83M|    item->ref_count ++;
  533|       |
  534|       |#ifdef DEBUG_GUARDS
  535|       |    DEBUG_printf("5_cupsStrAlloc: Using string %p(%s) for \"%s\", guard=%08x, ref_count=%d", item, item->str, s, item->guard, item->ref_count);
  536|       |
  537|       |    if (item->guard != _CUPS_STR_GUARD)
  538|       |      abort();
  539|       |#endif // DEBUG_GUARDS
  540|       |
  541|  5.83M|    cupsMutexUnlock(&sp_mutex);
  542|       |
  543|  5.83M|    return (item->str);
  544|  5.83M|  }
  545|       |
  546|       |  // Not found, so allocate a new one...
  547|   677k|  slen = strlen(s);
  548|   677k|  item = (_cups_sp_item_t *)calloc(1, sizeof(_cups_sp_item_t) + slen);
  549|   677k|  if (!item)
  ------------------
  |  Branch (549:7): [True: 0, False: 677k]
  ------------------
  550|      0|  {
  551|      0|    cupsMutexUnlock(&sp_mutex);
  552|       |
  553|      0|    return (NULL);
  554|      0|  }
  555|       |
  556|   677k|  item->ref_count = 1;
  557|   677k|  memcpy(item->str, s, slen + 1);
  558|       |
  559|       |#ifdef DEBUG_GUARDS
  560|       |  item->guard = _CUPS_STR_GUARD;
  561|       |
  562|       |  DEBUG_printf("5_cupsStrAlloc: Created string %p(%s) for \"%s\", guard=%08x, ref_count=%d", item, item->str, s, item->guard, item->ref_count);
  563|       |#endif // DEBUG_GUARDS
  564|       |
  565|       |  // Add the string to the pool and return it...
  566|   677k|  cupsArrayAdd(stringpool, item);
  567|       |
  568|   677k|  cupsMutexUnlock(&sp_mutex);
  569|       |
  570|   677k|  return (item->str);
  571|   677k|}
_cupsStrFree:
  677|  6.50M|{
  678|  6.50M|  _cups_sp_item_t	*item,		// String pool item
  679|  6.50M|			*key;		// Search key
  680|       |
  681|       |
  682|       |  // Range check input...
  683|  6.50M|  if (!s)
  ------------------
  |  Branch (683:7): [True: 7.67k, False: 6.50M]
  ------------------
  684|  7.67k|    return;
  685|       |
  686|       |  // See if the string is already in the pool...
  687|  6.50M|  cupsMutexLock(&sp_mutex);
  688|       |
  689|  6.50M|  key = (_cups_sp_item_t *)(s - offsetof(_cups_sp_item_t, str));
  690|       |
  691|  6.50M|  if ((item = (_cups_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL && item == key)
  ------------------
  |  Branch (691:7): [True: 6.50M, False: 0]
  |  Branch (691:77): [True: 6.50M, False: 0]
  ------------------
  692|  6.50M|  {
  693|       |    // Found it, dereference...
  694|       |#ifdef DEBUG_GUARDS
  695|       |    if (key->guard != _CUPS_STR_GUARD)
  696|       |    {
  697|       |      DEBUG_printf("5_cupsStrFree: Freeing string %p(%s), guard=%08x, ref_count=%d", key, key->str, key->guard, key->ref_count);
  698|       |      abort();
  699|       |    }
  700|       |#endif // DEBUG_GUARDS
  701|       |
  702|  6.50M|    item->ref_count --;
  703|       |
  704|  6.50M|    if (!item->ref_count)
  ------------------
  |  Branch (704:9): [True: 673k, False: 5.82M]
  ------------------
  705|   673k|    {
  706|       |      // Remove and free...
  707|   673k|      cupsArrayRemove(stringpool, item);
  708|       |
  709|   673k|      free(item);
  710|   673k|    }
  711|  6.50M|  }
  712|       |
  713|  6.50M|  cupsMutexUnlock(&sp_mutex);
  714|  6.50M|}
_cups_strcasecmp:
  954|  8.13k|{
  955|  8.13k|  while (*s != '\0' && *t != '\0')
  ------------------
  |  Branch (955:10): [True: 8.13k, False: 0]
  |  Branch (955:24): [True: 8.03k, False: 92]
  ------------------
  956|  8.03k|  {
  957|  8.03k|    if (_cups_tolower(*s) < _cups_tolower(*t))
  ------------------
  |  Branch (957:9): [True: 46, False: 7.99k]
  ------------------
  958|     46|      return (-1);
  959|  7.99k|    else if (_cups_tolower(*s) > _cups_tolower(*t))
  ------------------
  |  Branch (959:14): [True: 7.99k, False: 1]
  ------------------
  960|  7.99k|      return (1);
  961|       |
  962|      1|    s ++;
  963|      1|    t ++;
  964|      1|  }
  965|       |
  966|     92|  if (*s == '\0' && *t == '\0')
  ------------------
  |  Branch (966:7): [True: 0, False: 92]
  |  Branch (966:21): [True: 0, False: 0]
  ------------------
  967|      0|    return (0);
  968|     92|  else if (*s != '\0')
  ------------------
  |  Branch (968:12): [True: 92, False: 0]
  ------------------
  969|     92|    return (1);
  970|      0|  else
  971|      0|    return (-1);
  972|     92|}
_cups_strncasecmp:
  982|     11|{
  983|     12|  while (*s != '\0' && *t != '\0' && n > 0)
  ------------------
  |  Branch (983:10): [True: 12, False: 0]
  |  Branch (983:24): [True: 12, False: 0]
  |  Branch (983:38): [True: 12, False: 0]
  ------------------
  984|     12|  {
  985|     12|    if (_cups_tolower(*s) < _cups_tolower(*t))
  ------------------
  |  Branch (985:9): [True: 7, False: 5]
  ------------------
  986|      7|      return (-1);
  987|      5|    else if (_cups_tolower(*s) > _cups_tolower(*t))
  ------------------
  |  Branch (987:14): [True: 4, False: 1]
  ------------------
  988|      4|      return (1);
  989|       |
  990|      1|    s ++;
  991|      1|    t ++;
  992|      1|    n --;
  993|      1|  }
  994|       |
  995|      0|  if (n == 0)
  ------------------
  |  Branch (995:7): [True: 0, False: 0]
  ------------------
  996|      0|    return (0);
  997|      0|  else if (*s == '\0' && *t == '\0')
  ------------------
  |  Branch (997:12): [True: 0, False: 0]
  |  Branch (997:26): [True: 0, False: 0]
  ------------------
  998|      0|    return (0);
  999|      0|  else if (*s != '\0')
  ------------------
  |  Branch (999:12): [True: 0, False: 0]
  ------------------
 1000|      0|    return (1);
 1001|      0|  else
 1002|      0|    return (-1);
 1003|      0|}
string.c:compare_sp_items:
 1013|  45.6M|{
 1014|  45.6M|  return (strcmp(a->str, b->str));
 1015|  45.6M|}

cupsMutexLock:
  505|  13.0M|{
  506|  13.0M|  pthread_mutex_lock(mutex);
  507|  13.0M|}
cupsMutexUnlock:
  516|  13.0M|{
  517|  13.0M|  pthread_mutex_unlock(mutex);
  518|  13.0M|}
cupsRWInit:
  538|      1|{
  539|       |  pthread_rwlock_init(rwlock, NULL);
  540|      1|}
cupsRWLockRead:
  549|    983|{
  550|    983|  pthread_rwlock_rdlock(rwlock);
  551|    983|}
cupsRWLockWrite:
  560|      1|{
  561|      1|  pthread_rwlock_wrlock(rwlock);
  562|      1|}
cupsRWUnlock:
  571|    984|{
  572|    984|  pthread_rwlock_unlock(rwlock);
  573|    984|}

_httpTLSSetOptions:
  295|      1|{
  296|      1|  if (!(options & _HTTP_TLS_SET_DEFAULT) || tls_options < 0)
  ------------------
  |  |   62|      1|#  define _HTTP_TLS_SET_DEFAULT 128     // Setting the default TLS options
  ------------------
  |  Branch (296:7): [True: 0, False: 1]
  |  Branch (296:45): [True: 1, False: 0]
  ------------------
  297|      1|  {
  298|      1|    tls_options     = options;
  299|      1|    tls_min_version = min_version;
  300|      1|    tls_max_version = max_version;
  301|      1|  }
  302|      1|}

cupsSetServer:
  356|      1|{
  357|      1|  char		*options,		// Options
  358|      1|		*port;			// Pointer to port
  359|      1|  _cups_globals_t *cg = _cupsGlobals();	// Pointer to library globals
  360|       |
  361|       |
  362|      1|  if (server)
  ------------------
  |  Branch (362:7): [True: 1, False: 0]
  ------------------
  363|      1|  {
  364|      1|    cupsCopyString(cg->server, server, sizeof(cg->server));
  365|       |
  366|      1|    if (cg->server[0] != '/' && (options = strrchr(cg->server, '/')) != NULL)
  ------------------
  |  Branch (366:9): [True: 1, False: 0]
  |  Branch (366:33): [True: 0, False: 1]
  ------------------
  367|      0|    {
  368|      0|      *options++ = '\0';
  369|       |
  370|      0|      if (!strcmp(options, "version=1.0"))
  ------------------
  |  Branch (370:11): [True: 0, False: 0]
  ------------------
  371|      0|        cg->server_version = 10;
  372|      0|      else if (!strcmp(options, "version=1.1"))
  ------------------
  |  Branch (372:16): [True: 0, False: 0]
  ------------------
  373|      0|        cg->server_version = 11;
  374|      0|      else if (!strcmp(options, "version=2.0"))
  ------------------
  |  Branch (374:16): [True: 0, False: 0]
  ------------------
  375|      0|        cg->server_version = 20;
  376|      0|      else if (!strcmp(options, "version=2.1"))
  ------------------
  |  Branch (376:16): [True: 0, False: 0]
  ------------------
  377|      0|        cg->server_version = 21;
  378|      0|      else if (!strcmp(options, "version=2.2"))
  ------------------
  |  Branch (378:16): [True: 0, False: 0]
  ------------------
  379|      0|        cg->server_version = 22;
  380|      0|    }
  381|      1|    else
  382|      1|      cg->server_version = 20;
  383|       |
  384|      1|    if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL &&
  ------------------
  |  Branch (384:9): [True: 1, False: 0]
  |  Branch (384:33): [True: 0, False: 1]
  ------------------
  385|      1|        !strchr(port, ']') && isdigit(port[1] & 255))
  ------------------
  |  Branch (385:9): [True: 0, False: 0]
  |  Branch (385:31): [True: 0, False: 0]
  ------------------
  386|      0|    {
  387|      0|      int	portnum;		// Port number
  388|       |
  389|      0|      *port++ = '\0';
  390|      0|      portnum = atoi(port);
  391|       |
  392|      0|      if (portnum > 0 && portnum < 65536)
  ------------------
  |  Branch (392:11): [True: 0, False: 0]
  |  Branch (392:26): [True: 0, False: 0]
  ------------------
  393|      0|        cg->ipp_port = portnum;
  394|      0|    }
  395|       |
  396|      1|    if (!cg->ipp_port)
  ------------------
  |  Branch (396:9): [True: 1, False: 0]
  ------------------
  397|      1|      cups_set_default_ipp_port(cg);
  398|       |
  399|      1|    if (cg->server[0] == '/')
  ------------------
  |  Branch (399:9): [True: 0, False: 1]
  ------------------
  400|      0|      cupsCopyString(cg->servername, "localhost", sizeof(cg->servername));
  401|      1|    else
  402|      1|      cupsCopyString(cg->servername, cg->server, sizeof(cg->servername));
  403|      1|  }
  404|      0|  else
  405|      0|  {
  406|      0|    cg->server[0]      = '\0';
  407|      0|    cg->servername[0]  = '\0';
  408|      0|    cg->server_version = 20;
  409|      0|    cg->ipp_port       = 0;
  410|      0|  }
  411|       |
  412|      1|  if (cg->http)
  ------------------
  |  Branch (412:7): [True: 0, False: 1]
  ------------------
  413|      0|  {
  414|      0|    httpClose(cg->http);
  415|       |    cg->http = NULL;
  416|      0|  }
  417|      1|}
_cupsSetDefaults:
  868|      1|{
  869|      1|  cups_file_t	*fp;			// File
  870|      1|  char		filename[1024];		// Filename
  871|      1|  _cups_client_conf_t cc;		// client.conf values
  872|      1|  _cups_globals_t *cg = _cupsGlobals();	// Pointer to library globals
  873|       |#ifdef DEBUG
  874|       |  static const char * const encryptions[] =
  875|       |  {					// Encryption values
  876|       |    "IfRequested",
  877|       |    "Never",
  878|       |    "Required",
  879|       |    "Always"
  880|       |  };
  881|       |#endif // DEBUG
  882|       |
  883|       |
  884|      1|  DEBUG_puts("_cupsSetDefaults()");
  885|       |
  886|       |  // Load initial client.conf values...
  887|      1|  cups_init_client_conf(&cc);
  888|       |
  889|       |  // Read the /etc/cups/client.conf and ~/.cups/client.conf files, if present.
  890|      1|  snprintf(filename, sizeof(filename), "%s/client.conf", cg->sysconfig);
  891|      1|  if ((fp = cupsFileOpen(filename, "r")) != NULL)
  ------------------
  |  Branch (891:7): [True: 0, False: 1]
  ------------------
  892|      0|  {
  893|      0|    cups_read_client_conf(fp, &cc);
  894|      0|    cupsFileClose(fp);
  895|      0|  }
  896|       |
  897|      1|  if (cg->userconfig)
  ------------------
  |  Branch (897:7): [True: 1, False: 0]
  ------------------
  898|      1|  {
  899|       |    // Look for client.conf...
  900|      1|    snprintf(filename, sizeof(filename), "%s/client.conf", cg->userconfig);
  901|       |
  902|      1|    if ((fp = cupsFileOpen(filename, "r")) != NULL)
  ------------------
  |  Branch (902:9): [True: 0, False: 1]
  ------------------
  903|      0|    {
  904|      0|      cups_read_client_conf(fp, &cc);
  905|      0|      cupsFileClose(fp);
  906|      0|    }
  907|      1|  }
  908|       |
  909|       |  // Finalize things so every client.conf value is set...
  910|      1|  cups_finalize_client_conf(&cc);
  911|       |
  912|      1|  cg->uatokens = cc.uatokens;
  913|       |
  914|      1|  if (cg->encryption == (http_encryption_t)-1)
  ------------------
  |  Branch (914:7): [True: 1, False: 0]
  ------------------
  915|      1|    cg->encryption = cc.encryption;
  916|       |
  917|      1|  if (!cg->server[0] || !cg->ipp_port)
  ------------------
  |  Branch (917:7): [True: 1, False: 0]
  |  Branch (917:25): [True: 0, False: 0]
  ------------------
  918|      1|    cupsSetServer(cc.server_name);
  919|       |
  920|      1|  if (!cg->ipp_port)
  ------------------
  |  Branch (920:7): [True: 0, False: 1]
  ------------------
  921|      0|    cups_set_default_ipp_port(cg);
  922|       |
  923|      1|  if (!cg->user[0])
  ------------------
  |  Branch (923:7): [True: 1, False: 0]
  ------------------
  924|      1|    cupsCopyString(cg->user, cc.user, sizeof(cg->user));
  925|       |
  926|      1|  if (cg->trust_first < 0)
  ------------------
  |  Branch (926:7): [True: 1, False: 0]
  ------------------
  927|      1|    cg->trust_first = cc.trust_first;
  928|       |
  929|      1|  if (cg->any_root < 0)
  ------------------
  |  Branch (929:7): [True: 1, False: 0]
  ------------------
  930|      1|    cg->any_root = cc.any_root;
  931|       |
  932|      1|  if (cg->expired_certs < 0)
  ------------------
  |  Branch (932:7): [True: 1, False: 0]
  ------------------
  933|      1|    cg->expired_certs = cc.expired_certs;
  934|       |
  935|      1|  if (cg->validate_certs < 0)
  ------------------
  |  Branch (935:7): [True: 1, False: 0]
  ------------------
  936|      1|    cg->validate_certs = cc.validate_certs;
  937|       |
  938|      1|  DEBUG_printf("1_cupsSetDefaults: BrowseDomains %s", cc.browse_domains);
  939|       |
  940|      1|  if (!strcmp(cc.browse_domains, "none"))
  ------------------
  |  Branch (940:7): [True: 0, False: 1]
  ------------------
  941|      0|    cg->browse_domains = cupsArrayNewStrings(/*s*/NULL, /*delim*/'\0');
  942|      1|  else if (strcmp(cc.browse_domains, "all") && cc.browse_domains[0])
  ------------------
  |  Branch (942:12): [True: 1, False: 0]
  |  Branch (942:48): [True: 0, False: 1]
  ------------------
  943|      0|    cg->browse_domains = cupsArrayNewStrings(cc.browse_domains, /*delim*/',');
  944|       |
  945|      1|  DEBUG_printf("1_cupsSetDefaults: FilterLocation %s", cc.filter_location);
  946|       |
  947|      1|  if (cc.filter_location[0] == '/')
  ------------------
  |  Branch (947:7): [True: 0, False: 1]
  ------------------
  948|      0|  {
  949|       |    // FilterLocation /regex/
  950|      0|    if ((cg->filter_location_regex = (regex_t *)calloc(1, sizeof(regex_t))) != NULL)
  ------------------
  |  Branch (950:9): [True: 0, False: 0]
  ------------------
  951|      0|    {
  952|      0|      char	*ptr = cc.filter_location + strlen(cc.filter_location) - 1;
  953|       |					// Pointer into FilterLocation value
  954|       |
  955|      0|      if (*ptr == '/')
  ------------------
  |  Branch (955:11): [True: 0, False: 0]
  ------------------
  956|      0|        *ptr = '\0';			// Strip trailing '/'
  957|       |
  958|      0|      if (regcomp(cg->filter_location_regex, cc.filter_location + 1, REG_EXTENDED | REG_ICASE))
  ------------------
  |  Branch (958:11): [True: 0, False: 0]
  ------------------
  959|      0|      {
  960|      0|        DEBUG_puts("1_cupsSetDefaults: Bad regular expression in FilterLocation - results not filtered.");
  961|      0|        free(cg->filter_location_regex);
  962|      0|        cg->filter_location_regex = NULL;
  963|      0|      }
  964|      0|    }
  965|      0|  }
  966|      1|  else if (cc.filter_location[0])
  ------------------
  |  Branch (966:12): [True: 0, False: 1]
  ------------------
  967|      0|  {
  968|       |    // FilterLocation "string"[,...,"string"]
  969|       |    // FilterLocation 'string'[,...,'string']
  970|       |    // FilterLocation string[,...,string]
  971|      0|    char	quote,			// Quote character, if any
  972|      0|		*start,			// Start of value
  973|      0|	        *ptr;			// Pointer into string
  974|       |
  975|      0|    cg->filter_location_array = cupsArrayNewStrings(/*s*/NULL, /*delim*/'\0');
  976|       |
  977|       |    // Scan for strings...
  978|      0|    for (ptr = cc.filter_location; *ptr;)
  ------------------
  |  Branch (978:36): [True: 0, False: 0]
  ------------------
  979|      0|    {
  980|       |      // Handle quotes...
  981|      0|      if (*ptr == '\'' || *ptr == '\"')
  ------------------
  |  Branch (981:11): [True: 0, False: 0]
  |  Branch (981:27): [True: 0, False: 0]
  ------------------
  982|      0|        quote = *ptr++;
  983|      0|      else
  984|      0|        quote = '\0';
  985|       |
  986|       |      // Find the end of the string...
  987|      0|      for (start = ptr; *ptr; ptr ++)
  ------------------
  |  Branch (987:25): [True: 0, False: 0]
  ------------------
  988|      0|      {
  989|      0|        if (quote && *ptr == quote)
  ------------------
  |  Branch (989:13): [True: 0, False: 0]
  |  Branch (989:22): [True: 0, False: 0]
  ------------------
  990|      0|        {
  991|      0|          *ptr++ = '\0';
  992|      0|          if (*ptr == ',')
  ------------------
  |  Branch (992:15): [True: 0, False: 0]
  ------------------
  993|      0|            *ptr++ = '\0';
  994|      0|          break;
  995|      0|	}
  996|      0|	else if (!quote && *ptr == ',')
  ------------------
  |  Branch (996:11): [True: 0, False: 0]
  |  Branch (996:21): [True: 0, False: 0]
  ------------------
  997|      0|	{
  998|      0|	  *ptr++ = '\0';
  999|      0|	  break;
 1000|      0|	}
 1001|      0|      }
 1002|       |
 1003|      0|      if (*start)
  ------------------
  |  Branch (1003:11): [True: 0, False: 0]
  ------------------
 1004|      0|        cupsArrayAdd(cg->filter_location_array, start);
 1005|      0|    }
 1006|      0|  }
 1007|       |
 1008|      1|  DEBUG_printf("1_cupsSetDefaults: FilterType %s", cc.filter_type);
 1009|      1|  if (cc.filter_type[0] && strcmp(cc.filter_type, "any"))
  ------------------
  |  Branch (1009:7): [True: 0, False: 1]
  |  Branch (1009:28): [True: 0, False: 0]
  ------------------
 1010|      0|  {
 1011|      0|    char	*ptr,			// Pointer into type value
 1012|      0|		*next;			// Pointer to next value
 1013|       |
 1014|      0|    for (ptr = cc.filter_type; ptr && *ptr; ptr = next)
  ------------------
  |  Branch (1014:32): [True: 0, False: 0]
  |  Branch (1014:39): [True: 0, False: 0]
  ------------------
 1015|      0|    {
 1016|      0|      if ((next = strchr(ptr, ',')) != NULL)
  ------------------
  |  Branch (1016:11): [True: 0, False: 0]
  ------------------
 1017|      0|        *next++ = '\0';
 1018|       |
 1019|      0|      if (!_cups_strcasecmp(ptr, "mono"))
  ------------------
  |  Branch (1019:11): [True: 0, False: 0]
  ------------------
 1020|      0|      {
 1021|      0|        cg->filter_type      |= CUPS_PTYPE_BW;
 1022|      0|        cg->filter_type_mask |= CUPS_PTYPE_BW;
 1023|      0|      }
 1024|      0|      else if (!_cups_strcasecmp(ptr, "color"))
  ------------------
  |  Branch (1024:16): [True: 0, False: 0]
  ------------------
 1025|      0|      {
 1026|      0|        cg->filter_type      |= CUPS_PTYPE_COLOR;
 1027|      0|        cg->filter_type_mask |= CUPS_PTYPE_COLOR;
 1028|      0|      }
 1029|      0|      else if (!_cups_strcasecmp(ptr, "duplex"))
  ------------------
  |  Branch (1029:16): [True: 0, False: 0]
  ------------------
 1030|      0|      {
 1031|      0|        if (cg->filter_type_mask & CUPS_PTYPE_DUPLEX)
  ------------------
  |  Branch (1031:13): [True: 0, False: 0]
  ------------------
 1032|      0|        {
 1033|       |          // Both simplex and duplex
 1034|      0|          cg->filter_type_mask &= (cups_ptype_t)~CUPS_PTYPE_DUPLEX;
 1035|      0|	}
 1036|      0|	else
 1037|      0|	{
 1038|       |	  // Just duplex
 1039|      0|	  cg->filter_type      |= CUPS_PTYPE_DUPLEX;
 1040|      0|	  cg->filter_type_mask |= CUPS_PTYPE_DUPLEX;
 1041|      0|	}
 1042|      0|      }
 1043|      0|      else if (!_cups_strcasecmp(ptr, "simplex"))
  ------------------
  |  Branch (1043:16): [True: 0, False: 0]
  ------------------
 1044|      0|      {
 1045|      0|        if (cg->filter_type & CUPS_PTYPE_DUPLEX)
  ------------------
  |  Branch (1045:13): [True: 0, False: 0]
  ------------------
 1046|      0|        {
 1047|       |          // Both simplex and duplex
 1048|      0|          cg->filter_type_mask &= (cups_ptype_t)~CUPS_PTYPE_DUPLEX;
 1049|      0|        }
 1050|      0|        else
 1051|      0|        {
 1052|       |          // Just simplex
 1053|      0|          cg->filter_type_mask |= CUPS_PTYPE_DUPLEX;
 1054|      0|	}
 1055|      0|      }
 1056|      0|      else if (!_cups_strcasecmp(ptr, "staple"))
  ------------------
  |  Branch (1056:16): [True: 0, False: 0]
  ------------------
 1057|      0|      {
 1058|      0|        cg->filter_type      |= CUPS_PTYPE_STAPLE;
 1059|      0|        cg->filter_type_mask |= CUPS_PTYPE_STAPLE;
 1060|      0|      }
 1061|      0|      else if (!_cups_strcasecmp(ptr, "punch"))
  ------------------
  |  Branch (1061:16): [True: 0, False: 0]
  ------------------
 1062|      0|      {
 1063|      0|        cg->filter_type      |= CUPS_PTYPE_PUNCH;
 1064|      0|        cg->filter_type_mask |= CUPS_PTYPE_PUNCH;
 1065|      0|      }
 1066|      0|      else if (!_cups_strcasecmp(ptr, "cover"))
  ------------------
  |  Branch (1066:16): [True: 0, False: 0]
  ------------------
 1067|      0|      {
 1068|      0|        cg->filter_type      |= CUPS_PTYPE_COVER;
 1069|      0|        cg->filter_type_mask |= CUPS_PTYPE_COVER;
 1070|      0|      }
 1071|      0|      else if (!_cups_strcasecmp(ptr, "bind"))
  ------------------
  |  Branch (1071:16): [True: 0, False: 0]
  ------------------
 1072|      0|      {
 1073|      0|        cg->filter_type      |= CUPS_PTYPE_BIND;
 1074|      0|        cg->filter_type_mask |= CUPS_PTYPE_BIND;
 1075|      0|      }
 1076|      0|      else if (!_cups_strcasecmp(ptr, "sort"))
  ------------------
  |  Branch (1076:16): [True: 0, False: 0]
  ------------------
 1077|      0|      {
 1078|      0|        cg->filter_type      |= CUPS_PTYPE_SORT;
 1079|      0|        cg->filter_type_mask |= CUPS_PTYPE_SORT;
 1080|      0|      }
 1081|      0|      else if (!_cups_strcasecmp(ptr, "small"))
  ------------------
  |  Branch (1081:16): [True: 0, False: 0]
  ------------------
 1082|      0|      {
 1083|      0|        cg->filter_type      |= CUPS_PTYPE_SMALL;
 1084|      0|        cg->filter_type_mask |= CUPS_PTYPE_SMALL;
 1085|      0|      }
 1086|      0|      else if (!_cups_strcasecmp(ptr, "medium"))
  ------------------
  |  Branch (1086:16): [True: 0, False: 0]
  ------------------
 1087|      0|      {
 1088|      0|        cg->filter_type      |= CUPS_PTYPE_MEDIUM;
 1089|      0|        cg->filter_type_mask |= CUPS_PTYPE_MEDIUM;
 1090|      0|      }
 1091|      0|      else if (!_cups_strcasecmp(ptr, "large"))
  ------------------
  |  Branch (1091:16): [True: 0, False: 0]
  ------------------
 1092|      0|      {
 1093|      0|        cg->filter_type      |= CUPS_PTYPE_LARGE;
 1094|      0|        cg->filter_type_mask |= CUPS_PTYPE_LARGE;
 1095|      0|      }
 1096|      0|      else if (!_cups_strcasecmp(ptr, "variable"))
  ------------------
  |  Branch (1096:16): [True: 0, False: 0]
  ------------------
 1097|      0|      {
 1098|      0|        cg->filter_type      |= CUPS_PTYPE_VARIABLE;
 1099|      0|        cg->filter_type_mask |= CUPS_PTYPE_VARIABLE;
 1100|      0|      }
 1101|      0|      else
 1102|      0|      {
 1103|       |        // Something we don't understand...
 1104|      0|        DEBUG_printf("2_cupsSetDefaults: Unknown FilterType '%s'.", ptr);
 1105|      0|      }
 1106|      0|    }
 1107|      0|  }
 1108|       |
 1109|      1|  DEBUG_printf("1_cupsSetDefaults: FilterType value 0x%x mask 0x%x", cg->filter_type, cg->filter_type_mask);
 1110|       |
 1111|      1|  DEBUG_printf("1_cupsSetDefaults: AllowAnyRoot %s", cg->any_root ? "Yes" : "No");
 1112|      1|  DEBUG_printf("1_cupsSetDefaults: AllowExpiredCerts %s", cg->expired_certs ? "Yes" : "No");
 1113|      1|  DEBUG_printf("1_cupsSetDefaults: DigestOptions %s", cg->digestoptions == _CUPS_DIGESTOPTIONS_DENYMD5 ? "DenyMD5" : "None");
 1114|      1|  DEBUG_printf("1_cupsSetDefaults: Encryption %s", encryptions[cg->encryption]);
 1115|      1|  DEBUG_printf("1_cupsSetDefaults: ServerName %s", cg->servername);
 1116|      1|  DEBUG_printf("1_cupsSetDefaults: SSLOptions%s%s%s%s Min%s Max%s", cc.ssl_options == _HTTP_TLS_NONE ? " none" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_RC4) ? " AllowRC4" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_DH) ? " AllowDH" : "", (cc.ssl_options & _HTTP_TLS_DENY_CBC) ? " DenyCBC" : "", tls_versions[cc.ssl_min_version], tls_versions[cc.ssl_max_version]);
 1117|      1|  DEBUG_printf("1_cupsSetDefaults: TrustOnFirstUse %s", cg->trust_first ? "Yes" : "No");
 1118|      1|  DEBUG_printf("1_cupsSetDefaults: User %s", cg->user);
 1119|      1|  DEBUG_printf("1_cupsSetDefaults: UserAgentTokens %s", uatokens[cg->uatokens]);
 1120|      1|  DEBUG_printf("1_cupsSetDefaults: ValidateCerts %s", cg->validate_certs ? "Yes" : "No");
 1121|       |
 1122|      1|  _httpTLSSetOptions(cc.ssl_options | _HTTP_TLS_SET_DEFAULT, cc.ssl_min_version, cc.ssl_max_version);
  ------------------
  |  |   62|      1|#  define _HTTP_TLS_SET_DEFAULT 128     // Setting the default TLS options
  ------------------
 1123|       |
 1124|       |  cg->client_conf_loaded = true;
 1125|      1|}
usersys.c:cups_finalize_client_conf:
 1197|      1|{
 1198|      1|  const char	*value;			// Environment variable
 1199|       |
 1200|       |
 1201|      1|  if ((value = getenv("CUPS_BROWSE_DOMAINS")) != NULL)
  ------------------
  |  Branch (1201:7): [True: 0, False: 1]
  ------------------
 1202|      0|    cups_set_browse_domains(cc, value);
 1203|       |
 1204|      1|  if ((value = getenv("CUPS_FILTER_LOCATION")) != NULL)
  ------------------
  |  Branch (1204:7): [True: 0, False: 1]
  ------------------
 1205|      0|    cups_set_filter_location(cc, value);
 1206|       |
 1207|      1|  if ((value = getenv("CUPS_FILTER_TYPE")) != NULL)
  ------------------
  |  Branch (1207:7): [True: 0, False: 1]
  ------------------
 1208|      0|    cups_set_filter_type(cc, value);
 1209|       |
 1210|      1|  if ((value = getenv("CUPS_TRUSTFIRST")) != NULL)
  ------------------
  |  Branch (1210:7): [True: 0, False: 1]
  ------------------
 1211|      0|    cc->trust_first = cups_boolean_value(value);
 1212|       |
 1213|      1|  if ((value = getenv("CUPS_ANYROOT")) != NULL)
  ------------------
  |  Branch (1213:7): [True: 0, False: 1]
  ------------------
 1214|      0|    cc->any_root = cups_boolean_value(value);
 1215|       |
 1216|      1|  if ((value = getenv("CUPS_ENCRYPTION")) != NULL)
  ------------------
  |  Branch (1216:7): [True: 0, False: 1]
  ------------------
 1217|      0|    cups_set_encryption(cc, value);
 1218|       |
 1219|      1|  if ((value = getenv("CUPS_EXPIREDCERTS")) != NULL)
  ------------------
  |  Branch (1219:7): [True: 0, False: 1]
  ------------------
 1220|      0|    cc->expired_certs = cups_boolean_value(value);
 1221|       |
 1222|      1|  if ((value = getenv("CUPS_SERVER")) != NULL)
  ------------------
  |  Branch (1222:7): [True: 0, False: 1]
  ------------------
 1223|      0|    cups_set_server_name(cc, value);
 1224|       |
 1225|      1|  if ((value = getenv("CUPS_USER")) != NULL)
  ------------------
  |  Branch (1225:7): [True: 0, False: 1]
  ------------------
 1226|      0|    cups_set_user(cc, value);
 1227|       |
 1228|      1|  if ((value = getenv("CUPS_VALIDATECERTS")) != NULL)
  ------------------
  |  Branch (1228:7): [True: 0, False: 1]
  ------------------
 1229|      0|    cc->validate_certs = cups_boolean_value(value);
 1230|       |
 1231|       |  // Then apply defaults for those values that haven't been set...
 1232|      1|  if (cc->trust_first < 0)
  ------------------
  |  Branch (1232:7): [True: 1, False: 0]
  ------------------
 1233|      1|    cc->trust_first = 1;
 1234|       |
 1235|      1|  if (cc->any_root < 0)
  ------------------
  |  Branch (1235:7): [True: 1, False: 0]
  ------------------
 1236|      1|    cc->any_root = 1;
 1237|       |
 1238|      1|  if (cc->encryption == (http_encryption_t)-1)
  ------------------
  |  Branch (1238:7): [True: 1, False: 0]
  ------------------
 1239|      1|    cc->encryption = HTTP_ENCRYPTION_IF_REQUESTED;
 1240|       |
 1241|      1|  if (cc->expired_certs < 0)
  ------------------
  |  Branch (1241:7): [True: 1, False: 0]
  ------------------
 1242|      1|    cc->expired_certs = 0;
 1243|       |
 1244|      1|#ifdef HAVE_DBUS
 1245|      1|  if (!cc->server_name[0])
  ------------------
  |  Branch (1245:7): [True: 1, False: 0]
  ------------------
 1246|      1|  {
 1247|      1|    DBusConnection *dbus;		// D-Bus connection
 1248|      1|    DBusError	error;			// Last error
 1249|      1|    DBusMessage	*request = NULL,	// D-Bus request message
 1250|      1|		*response = NULL;	// D-Bus response message
 1251|       |
 1252|       |    // Connect to the session bus...
 1253|      1|    dbus_error_init(&error);
 1254|       |
 1255|      1|    if ((dbus = dbus_bus_get(DBUS_BUS_SESSION, &error)) == NULL)
  ------------------
  |  Branch (1255:9): [True: 1, False: 0]
  ------------------
 1256|      1|    {
 1257|       |      // Error
 1258|      1|      DEBUG_printf("4cups_finalize_client_conf: Unable to get session bus for cups-locald (%s %s)", error.name, error.message);
 1259|      1|      dbus_error_free(&error);
 1260|      1|    }
 1261|      0|    else
 1262|      0|    {
 1263|       |      // Try sending a GetSocket method call...
 1264|      0|      if ((request = dbus_message_new_method_call(NULL, "/org/openprinting/cupslocald", "org.openprinting.cupslocald", "GetSocket")) == NULL)
  ------------------
  |  Branch (1264:11): [True: 0, False: 0]
  ------------------
 1265|      0|      {
 1266|      0|	DEBUG_printf("4cups_finalize_client_conf: Unable to create D-Bus method call: %s", strerror(errno));
 1267|      0|      }
 1268|      0|      else if ((response = dbus_connection_send_with_reply_and_block(dbus, request, 2000, &error)) == NULL)
  ------------------
  |  Branch (1268:16): [True: 0, False: 0]
  ------------------
 1269|      0|      {
 1270|      0|	DEBUG_printf("4cups_finalize_client_conf: Unable to get response from cups-locald (%s %s)", error.name, error.message);
 1271|      0|	dbus_error_free(&error);
 1272|      0|      }
 1273|      0|      else
 1274|      0|      {
 1275|      0|	DBusMessageIter iter;		// Iterator
 1276|       |
 1277|      0|	dbus_message_iter_init(response, &iter);
 1278|       |
 1279|      0|	if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
  ------------------
  |  |  102|      0|#define DBUS_TYPE_STRING        ((int) 's')
  ------------------
  |  Branch (1279:6): [True: 0, False: 0]
  ------------------
 1280|      0|	{
 1281|       |	  // Copy socket path to server name field...
 1282|      0|	  const char *path = NULL;	// Socket path
 1283|       |
 1284|      0|	  dbus_message_iter_get_basic(&iter, &path);
 1285|       |
 1286|      0|	  if (path)
  ------------------
  |  Branch (1286:8): [True: 0, False: 0]
  ------------------
 1287|      0|	    cups_set_server_name(cc, path);
 1288|      0|	}
 1289|      0|      }
 1290|       |
 1291|       |      // Free D-Bus messages as needed...
 1292|      0|      if (request)
  ------------------
  |  Branch (1292:11): [True: 0, False: 0]
  ------------------
 1293|      0|	dbus_message_unref(request);
 1294|       |
 1295|      0|      if (response)
  ------------------
  |  Branch (1295:11): [True: 0, False: 0]
  ------------------
 1296|      0|	dbus_message_unref(response);
 1297|      0|    }
 1298|      1|  }
 1299|      1|#endif // HAVE_DBUS
 1300|       |
 1301|      1|  if (!cc->server_name[0])
  ------------------
  |  Branch (1301:7): [True: 1, False: 0]
  ------------------
 1302|      1|  {
 1303|       |    // If we are compiled with domain socket support, only use the
 1304|       |    // domain socket if it exists and has the right permissions...
 1305|       |#if defined(__APPLE__) && !TARGET_OS_OSX
 1306|       |    cups_set_server_name(cc, "/private/var/run/printd");
 1307|       |
 1308|       |#elif defined(CUPS_DEFAULT_DOMAINSOCKET)
 1309|      1|    if (!access(CUPS_DEFAULT_DOMAINSOCKET, R_OK))
  ------------------
  |  |   30|      1|#define CUPS_DEFAULT_DOMAINSOCKET "/var/run/cups.sock"
  ------------------
  |  Branch (1309:9): [True: 0, False: 1]
  ------------------
 1310|      0|      cups_set_server_name(cc, CUPS_DEFAULT_DOMAINSOCKET);
  ------------------
  |  |   30|      0|#define CUPS_DEFAULT_DOMAINSOCKET "/var/run/cups.sock"
  ------------------
 1311|      1|    else
 1312|      1|      cups_set_server_name(cc, "localhost");
 1313|       |
 1314|       |#else
 1315|       |    cups_set_server_name(cc, "localhost");
 1316|       |#endif // __APPLE__ && !TARGET_OS_OSX
 1317|      1|  }
 1318|       |
 1319|      1|  if (!cc->user[0])
  ------------------
  |  Branch (1319:7): [True: 1, False: 0]
  ------------------
 1320|      1|  {
 1321|       |#ifdef _WIN32
 1322|       |    // Get the current user name from the OS...
 1323|       |    DWORD	size;			// Size of string
 1324|       |
 1325|       |    size = sizeof(cc->user);
 1326|       |    if (!GetUserNameA(cc->user, &size))
 1327|       |#else
 1328|       |    // Try the USER environment variable as the default username...
 1329|      1|    const char *envuser = getenv("USER");	// Default username
 1330|      1|    struct passwd pw;				// Account information
 1331|      1|    struct passwd *result = NULL;		// Auxiliary pointer
 1332|      1|    _cups_globals_t *cg = _cupsGlobals();	// Pointer to library globals
 1333|       |
 1334|      1|    if (envuser)
  ------------------
  |  Branch (1334:9): [True: 0, False: 1]
  ------------------
 1335|      0|    {
 1336|       |      // Validate USER matches the current UID, otherwise don't allow it to
 1337|       |      // override things.  This makes sure that printing after doing su or sudo
 1338|       |      // records the correct username.
 1339|      0|      getpwnam_r(envuser, &pw, cg->pw_buf, PW_BUF_SIZE, &result);
  ------------------
  |  |   93|      0|#define PW_BUF_SIZE 16384		// As per glibc manual page
  ------------------
 1340|      0|      if (result && pw.pw_uid != getuid())
  ------------------
  |  Branch (1340:11): [True: 0, False: 0]
  |  Branch (1340:21): [True: 0, False: 0]
  ------------------
 1341|      0|        result = NULL;
 1342|      0|    }
 1343|       |
 1344|      1|    if (!result)
  ------------------
  |  Branch (1344:9): [True: 1, False: 0]
  ------------------
 1345|      1|      getpwuid_r(getuid(), &pw, cg->pw_buf, PW_BUF_SIZE, &result);
  ------------------
  |  |   93|      1|#define PW_BUF_SIZE 16384		// As per glibc manual page
  ------------------
 1346|       |
 1347|      1|    if (result)
  ------------------
  |  Branch (1347:9): [True: 1, False: 0]
  ------------------
 1348|      1|    {
 1349|      1|      cupsCopyString(cc->user, pw.pw_name, sizeof(cc->user));
 1350|      1|    }
 1351|      0|    else
 1352|      0|#endif // _WIN32
 1353|      0|    {
 1354|       |      // Use the default "unknown" user name...
 1355|      0|      cupsCopyString(cc->user, "unknown", sizeof(cc->user));
 1356|      0|    }
 1357|      1|  }
 1358|       |
 1359|      1|  if (cc->validate_certs < 0)
  ------------------
  |  Branch (1359:7): [True: 1, False: 0]
  ------------------
 1360|      1|    cc->validate_certs = 0;
 1361|      1|}
usersys.c:cups_set_server_name:
 1610|      1|{
 1611|      1|  cupsCopyString(cc->server_name, value, sizeof(cc->server_name));
 1612|      1|}
usersys.c:cups_init_client_conf:
 1371|      1|{
 1372|       |  // Clear all values to "not set"...
 1373|      1|  memset(cc, 0, sizeof(_cups_client_conf_t));
 1374|       |
 1375|      1|  cc->uatokens = _CUPS_UATOKENS_MINIMAL;
 1376|       |
 1377|       |#if defined(__APPLE__) && !TARGET_OS_OSX
 1378|       |  cups_set_user(cc, "mobile");
 1379|       |#endif // __APPLE__ && !TARGET_OS_OSX
 1380|       |
 1381|      1|  cc->ssl_min_version = _HTTP_TLS_1_2;
  ------------------
  |  |   67|      1|#  define _HTTP_TLS_1_2		3	// Min/max version is TLS/1.2
  ------------------
 1382|      1|  cc->ssl_max_version = _HTTP_TLS_MAX;
  ------------------
  |  |   69|      1|#  define _HTTP_TLS_MAX		5	// Highest known TLS version
  ------------------
 1383|      1|  cc->encryption      = (http_encryption_t)-1;
 1384|      1|  cc->trust_first     = -1;
 1385|      1|  cc->any_root        = -1;
 1386|      1|  cc->expired_certs   = -1;
 1387|      1|  cc->validate_certs  = -1;
 1388|       |
 1389|       |#if defined(__APPLE__)
 1390|       |  // Load settings from the org.cups.PrintingPrefs plist (which trump everything...)
 1391|       |  char	sval[1024];			// String value
 1392|       |  int	bval;				// Boolean value
 1393|       |
 1394|       |  if (cups_apple_get_boolean(kAllowAnyRootKey, &bval))
 1395|       |    cc->any_root = bval;
 1396|       |
 1397|       |  if (cups_apple_get_boolean(kAllowExpiredCertsKey, &bval))
 1398|       |    cc->expired_certs = bval;
 1399|       |
 1400|       |  if (cups_apple_get_string(kEncryptionKey, sval, sizeof(sval)))
 1401|       |    cups_set_encryption(cc, sval);
 1402|       |
 1403|       |  if (cups_apple_get_string(kSSLOptionsKey, sval, sizeof(sval)))
 1404|       |  {
 1405|       |    cups_set_ssl_options(cc, sval);
 1406|       |  }
 1407|       |  else
 1408|       |  {
 1409|       |    sval[0] = '\0';
 1410|       |
 1411|       |    if (cups_apple_get_boolean(kAllowRC4, &bval) && bval)
 1412|       |      cupsConcatString(sval, " AllowRC4", sizeof(sval));
 1413|       |    if (cups_apple_get_boolean(kAllowSSL3, &bval) && bval)
 1414|       |      cupsConcatString(sval, " AllowSSL3", sizeof(sval));
 1415|       |    if (cups_apple_get_boolean(kAllowDH, &bval) && bval)
 1416|       |      cupsConcatString(sval, " AllowDH", sizeof(sval));
 1417|       |
 1418|       |    if (sval[0])
 1419|       |      cups_set_ssl_options(cc, sval);
 1420|       |  }
 1421|       |
 1422|       |  if (cups_apple_get_boolean(kTrustOnFirstUseKey, &bval))
 1423|       |    cc->trust_first = bval;
 1424|       |
 1425|       |  if (cups_apple_get_boolean(kValidateCertsKey, &bval))
 1426|       |    cc->validate_certs = bval;
 1427|       |
 1428|       |  if (cups_apple_get_string(kDigestOptionsKey, sval, sizeof(sval)))
 1429|       |    cups_set_digestoptions(cc, sval);
 1430|       |
 1431|       |  if (cups_apple_get_string(kUserKey, sval, sizeof(sval)))
 1432|       |    cupsCopyString(cc->user, sval, sizeof(cc->user));
 1433|       |
 1434|       |  if (cups_apple_get_string(kUserAgentTokensKey, sval, sizeof(sval)))
 1435|       |    cups_set_uatokens(cc, sval);
 1436|       |#endif // __APPLE__
 1437|      1|}
usersys.c:cups_set_default_ipp_port:
 1516|      1|{
 1517|      1|  const char	*ipp_port;		// IPP_PORT environment variable
 1518|       |
 1519|       |
 1520|      1|  if ((ipp_port = getenv("IPP_PORT")) != NULL)
  ------------------
  |  Branch (1520:7): [True: 0, False: 1]
  ------------------
 1521|      0|  {
 1522|      0|    int port = atoi(ipp_port);		// IPP_PORT value
 1523|       |
 1524|      0|    if (port > 0 && port < 65536)
  ------------------
  |  Branch (1524:9): [True: 0, False: 0]
  |  Branch (1524:21): [True: 0, False: 0]
  ------------------
 1525|      0|      cg->ipp_port = port;
 1526|      0|    else
 1527|      0|      cg->ipp_port = 631;
 1528|      0|  }
 1529|      1|  else
 1530|      1|    cg->ipp_port = 631;
 1531|      1|}

write_cb:
   36|  10.8k|{
   37|  10.8k|  size_t	count;			// Number of bytes
   38|       |
   39|       |  // Loop until all bytes are written...
   40|  10.8k|  if ((count = data->wsize - data->wused) > bytes)
  ------------------
  |  Branch (40:7): [True: 10.8k, False: 0]
  ------------------
   41|  10.8k|    count = bytes;
   42|       |
   43|  10.8k|  memcpy(data->wbuffer + data->wused, buffer, count);
   44|  10.8k|  data->wused += count;
   45|       |
   46|       |  // Return the number of bytes written...
   47|  10.8k|  return ((ssize_t)count);
   48|  10.8k|}
LLVMFuzzerTestOneInput:
   50|  2.70k|extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size){
   51|       |
   52|  2.70k|    if (Size == 0 || Size > 262144) {
  ------------------
  |  Branch (52:9): [True: 0, False: 2.70k]
  |  Branch (52:22): [True: 6, False: 2.70k]
  ------------------
   53|      6|      return 0;  // Handle empty input gracefully
   54|      6|    } // Handle large input gracefully (limiting to 262144 bytes for now
   55|       |
   56|  2.70k|    int status = 0;
   57|  2.70k|    cups_file_t	*fp;
   58|  2.70k|    ipp_state_t	state;
   59|  2.70k|    ipp_t *request;
   60|  2.70k|    ipp_uchar_t buffer[262144];
   61|       |
   62|  2.70k|    request = ippNewRequest(IPP_OP_PRINT_JOB);  // Create a new IPP request (operation type is IPP_OP_PRINT_JOB
   63|  2.70k|    _ippdata_t	ippdata;
   64|  2.70k|    ippdata.wused = 0;
   65|  2.70k|    ippdata.wsize = sizeof(buffer);
   66|  2.70k|    ippdata.wbuffer = buffer;
   67|       |
   68|       |    // create new ipp
   69|       |
   70|  2.70k|    while ((state = ippWriteIO(&ippdata, (ipp_io_cb_t)write_cb, 1, NULL,
  ------------------
  |  Branch (70:12): [True: 0, False: 2.70k]
  ------------------
   71|  2.70k|                               request)) != IPP_STATE_DATA)
   72|      0|    {
   73|      0|      if (state == IPP_STATE_ERROR)
  ------------------
  |  Branch (73:11): [True: 0, False: 0]
  ------------------
   74|      0|	break;
   75|      0|    }
   76|  2.70k|    if (state != IPP_STATE_DATA)
  ------------------
  |  Branch (76:9): [True: 0, False: 2.70k]
  ------------------
   77|      0|    {
   78|      0|      status = 1;
   79|      0|    }
   80|       |    
   81|  2.70k|    ippDelete(request);
   82|       |
   83|       |    // testing writing
   84|  2.70k|    memcpy((char *)ippdata.wbuffer, (char *)Data, Size);
   85|  2.70k|    ippdata.wused = Size;
   86|       |
   87|  2.70k|    const char *filename = "/tmp/tmp.ipp";
   88|       |
   89|  2.70k|    if ((fp = cupsFileOpen(filename, "w")) == NULL)
  ------------------
  |  Branch (89:9): [True: 0, False: 2.70k]
  ------------------
   90|      0|      {
   91|      0|        return 1;
   92|      0|      }
   93|       |
   94|  2.70k|    cupsFileWrite(fp, (char *)buffer, ippdata.wused);
   95|  2.70k|    cupsFileClose(fp);
   96|       |
   97|       |    // Testing Reading
   98|  2.70k|    if ((fp = cupsFileOpen(filename, "r")) == NULL)
  ------------------
  |  Branch (98:9): [True: 0, False: 2.70k]
  ------------------
   99|      0|    {
  100|      0|      return 1;
  101|      0|    }
  102|       |
  103|  2.70k|    request = ippNew();
  104|       |
  105|  2.70k|    do
  106|  2.70k|    {
  107|  2.70k|      state = ippReadIO(fp, (ipp_io_cb_t)cupsFileRead, 1, NULL, request);
  108|  2.70k|    }
  109|  2.70k|    while (state == IPP_STATE_ATTRIBUTE);
  ------------------
  |  Branch (109:12): [True: 0, False: 2.70k]
  ------------------
  110|       |
  111|  2.70k|    cupsFileClose(fp);
  112|       |
  113|  2.70k|    fp = cupsFileOpen("/dev/null", "w");
  114|       |
  115|  2.70k|    ippSetState(request, IPP_STATE_IDLE);
  116|       |
  117|  2.70k|    do
  118|  2.70k|    {
  119|  2.70k|      state = ippWriteIO(fp, (ipp_io_cb_t)cupsFileWrite, 1, NULL, request);
  120|  2.70k|    }
  121|  2.70k|    while (state == IPP_STATE_ATTRIBUTE);
  ------------------
  |  Branch (121:12): [True: 0, False: 2.70k]
  ------------------
  122|       |
  123|  2.70k|    cupsFileClose(fp);
  124|  2.70k|    ippDelete(request);
  125|       |
  126|       |    // clean up file
  127|  2.70k|    unlink(filename);
  128|  2.70k|    return status;
  129|  2.70k|}

