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

Function cupsCopyDest

cups/dest.c:800–864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798 */
799
800int /* O - New number of destinations */
801cupsCopyDest(cups_dest_t *dest, /* I - Destination to copy */
802 int num_dests, /* I - Number of destinations */
803 cups_dest_t **dests) /* IO - Destination array */
804{
805 int i; /* Looping var */
806 cups_dest_t *new_dest; /* New destination pointer */
807 cups_option_t *new_option, /* Current destination option */
808 *option; /* Current parent option */
809
810
811 /*
812 * Range check input...
813 */
814
815 if (!dest || num_dests < 0 || !dests)
816 return (num_dests);
817
818 /*
819 * See if the destination already exists...
820 */
821
822 if ((new_dest = cupsGetDest(dest->name, dest->instance, num_dests,
823 *dests)) != NULL)
824 {
825 /*
826 * Protect against copying destination to itself...
827 */
828
829 if (new_dest == dest)
830 return (num_dests);
831
832 /*
833 * Otherwise, free the options...
834 */
835
836 cupsFreeOptions(new_dest->num_options, new_dest->options);
837
838 new_dest->num_options = 0;
839 new_dest->options = NULL;
840 }
841 else
842 new_dest = cups_add_dest(dest->name, dest->instance, &num_dests, dests);
843
844 if (new_dest)
845 {
846 new_dest->is_default = dest->is_default;
847
848 if ((new_dest->options = calloc((size_t)dest->num_options, sizeof(cups_option_t))) == NULL)
849 return (cupsRemoveDest(dest->name, dest->instance, num_dests, dests));
850
851 new_dest->num_options = dest->num_options;
852
853 for (i = dest->num_options, option = dest->options,
854 new_option = new_dest->options;
855 i > 0;
856 i --, option ++, new_option ++)
857 {

Callers 3

cups_get_cbFunction · 0.85
cups_name_cbFunction · 0.85
enum_dests_cbFunction · 0.85

Calls 5

cupsGetDestFunction · 0.85
cupsFreeOptionsFunction · 0.85
cups_add_destFunction · 0.85
cupsRemoveDestFunction · 0.85
_cupsStrRetainFunction · 0.85

Tested by 1

enum_dests_cbFunction · 0.68