startup.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * dpkg - main program for package management
  3. * main.c - main program
  4. *
  5. * Copyright (C) 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2,
  10. * or (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with dpkg; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <stdlib.h>
  24. #include <signal.h>
  25. #include <sys/stat.h>
  26. #include <sys/types.h>
  27. #include <sys/wait.h>
  28. #include <errno.h>
  29. #include <unistd.h>
  30. #include <dirent.h>
  31. #include <limits.h>
  32. #include <ctype.h>
  33. #include <config.h>
  34. #include <dpkg.h>
  35. #include <dpkg-db.h>
  36. #include <version.h>
  37. #include <myopt.h>
  38. void standard_startup(jmp_buf *ejbuf, int argc, const char *const **argv, const char *prog, int loadcfg, const struct cmdinfo cmdinfos[]) {
  39. setlocale(LC_ALL, "");
  40. bindtextdomain(PACKAGE, LOCALEDIR);
  41. textdomain(PACKAGE);
  42. if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */
  43. error_unwind(ehflag_bombout); exit(2);
  44. }
  45. push_error_handler(ejbuf,print_error_fatal,0);
  46. umask(022); /* Make sure all our status databases are readable. */
  47. if (loadcfg)
  48. loadcfgfile(prog, cmdinfos);
  49. myopt(argv,cmdinfos);
  50. }
  51. void standard_shutdown(void) {
  52. set_error_display(0,0);
  53. error_unwind(ehflag_normaltidy);
  54. }