| 1050 | */ |
| 1051 | |
| 1052 | cups_dest_t * /* O - Destination pointer or @code NULL@ */ |
| 1053 | cupsGetDest(const char *name, /* I - Destination name or @code NULL@ for the default destination */ |
| 1054 | const char *instance, /* I - Instance name or @code NULL@ */ |
| 1055 | int num_dests, /* I - Number of destinations */ |
| 1056 | cups_dest_t *dests) /* I - Destinations */ |
| 1057 | { |
| 1058 | int diff, /* Result of comparison */ |
| 1059 | match; /* Matching index */ |
| 1060 | |
| 1061 | |
| 1062 | if (num_dests <= 0 || !dests) |
| 1063 | return (NULL); |
| 1064 | |
| 1065 | if (!name) |
| 1066 | { |
| 1067 | /* |
| 1068 | * NULL name for default printer. |
| 1069 | */ |
| 1070 | |
| 1071 | while (num_dests > 0) |
| 1072 | { |
| 1073 | if (dests->is_default) |
| 1074 | return (dests); |
| 1075 | |
| 1076 | num_dests --; |
| 1077 | dests ++; |
| 1078 | } |
| 1079 | } |
| 1080 | else |
| 1081 | { |
| 1082 | /* |
| 1083 | * Lookup name and optionally the instance... |
| 1084 | */ |
| 1085 | |
| 1086 | match = cups_find_dest(name, instance, num_dests, dests, -1, &diff); |
| 1087 | |
| 1088 | if (!diff) |
| 1089 | return (dests + match); |
| 1090 | } |
| 1091 | |
| 1092 | return (NULL); |
| 1093 | } |
| 1094 | |
| 1095 | |
| 1096 | /* |