pkg.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * dpkg - main program for package management
  3. * pkg-array.c - primitives for pkg handling
  4. *
  5. * Copyright © 1995, 1996 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2009 Guillem Jover <guillem@debian.org>
  7. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2,
  11. * or (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <config.h>
  22. #include <compat.h>
  23. #include <string.h>
  24. #include <dpkg/dpkg-db.h>
  25. #include <dpkg/pkg.h>
  26. /**
  27. * Compare a package to be sorted by name.
  28. *
  29. * @param a A pointer of a pointer to a struct pkginfo.
  30. * @param b A pointer of a pointer to a struct pkginfo.
  31. *
  32. * @return An integer with the result of the comparison.
  33. * @retval -1 a is smaller than b.
  34. * @retval 0 a is equal to b.
  35. * @retval 1 a is greater than b.
  36. */
  37. int
  38. pkg_sorter_by_name(const void *a, const void *b)
  39. {
  40. const struct pkginfo *pa = *(const struct pkginfo **)a;
  41. const struct pkginfo *pb = *(const struct pkginfo **)b;
  42. return strcmp(pa->name, pb->name);
  43. }