MCPcopy Create free account
hub / github.com/OpenPrinting/cups / ppd_get_group

Function ppd_get_group

cups/ppd.c:2758–2811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2756 */
2757
2758static ppd_group_t * /* O - Named group */
2759ppd_get_group(ppd_file_t *ppd, /* I - PPD file */
2760 const char *name, /* I - Name of group */
2761 const char *text, /* I - Text for group */
2762 _ppd_globals_t *pg, /* I - Global data */
2763 cups_encoding_t encoding) /* I - Encoding of text */
2764{
2765 int i; /* Looping var */
2766 ppd_group_t *group; /* Group */
2767
2768
2769 DEBUG_printf(("7ppd_get_group(ppd=%p, name=\"%s\", text=\"%s\", cg=%p)",
2770 ppd, name, text, pg));
2771
2772 for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
2773 if (!strcmp(group->name, name))
2774 break;
2775
2776 if (i == 0)
2777 {
2778 DEBUG_printf(("8ppd_get_group: Adding group %s...", name));
2779
2780 if (pg->ppd_conform == PPD_CONFORM_STRICT && strlen(text) >= sizeof(group->text))
2781 {
2782 pg->ppd_status = PPD_ILLEGAL_TRANSLATION;
2783
2784 return (NULL);
2785 }
2786
2787 if (ppd->num_groups == 0)
2788 group = malloc(sizeof(ppd_group_t));
2789 else
2790 group = realloc(ppd->groups, (size_t)(ppd->num_groups + 1) * sizeof(ppd_group_t));
2791
2792 if (group == NULL)
2793 {
2794 pg->ppd_status = PPD_ALLOC_ERROR;
2795
2796 return (NULL);
2797 }
2798
2799 ppd->groups = group;
2800 group += ppd->num_groups;
2801 ppd->num_groups ++;
2802
2803 memset(group, 0, sizeof(ppd_group_t));
2804 strlcpy(group->name, name, sizeof(group->name));
2805
2806 cupsCharsetToUTF8((cups_utf8_t *)group->text, text,
2807 sizeof(group->text), encoding);
2808 }
2809
2810 return (group);
2811}
2812
2813
2814/*

Callers 1

_ppdOpenFunction · 0.85

Calls 1

cupsCharsetToUTF8Function · 0.85

Tested by

no test coverage detected