c_api_infolib_test.C 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: c_api_infolib_test.C /main/5 1996/08/21 15:53:07 drk $ */
  24. #include "oliasdb/DtMmdb.h"
  25. #include <stdio.h>
  26. extern "C" void showBookCaseInfo(int i);
  27. extern "C"
  28. int showInfoLibInfo(int i)
  29. {
  30. int n = 0;
  31. DtMmdbInfoLibInfo* info = DtMmdbInfoLibGetInfo(i);
  32. if ( info ) {
  33. if ( info -> path )
  34. fprintf(stderr, "infolibInfo: path= %s\n", info -> path);
  35. if ( info -> name )
  36. fprintf(stderr, "infolibInfo: name= %s\n", info -> name);
  37. fprintf(stderr, "infolibInfo: num_bookcases= %d\n", info -> num_bookcases);
  38. n = info -> num_bookcases;
  39. DtMmdbInfoLibFreeInfo(info);
  40. } else
  41. fprintf(stderr, "no infolibInfo\n");
  42. return n;
  43. }
  44. extern "C"
  45. int test0(int argc, char** argv)
  46. {
  47. int j = 0;
  48. int n = 0;
  49. int i = -1;
  50. switch ( argc ) {
  51. case 4:
  52. i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
  53. n = showInfoLibInfo(i);
  54. for ( j=0; j<n; j++ )
  55. showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
  56. break;
  57. case 3:
  58. i = DtMmdbOpenInfoLib(argv[2], 0, DtMmdbFalse);
  59. showInfoLibInfo(i);
  60. n = showInfoLibInfo(i);
  61. for ( j=0; j<n; j++ )
  62. showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
  63. break;
  64. default:
  65. fprintf(stderr, "bad argument list\n");
  66. }
  67. fprintf(stderr, "infolib desc=%d\n", i);
  68. return 0;
  69. }
  70. extern "C"
  71. int test1(int argc, char** argv)
  72. {
  73. int j = 0;
  74. int n = 0;
  75. int i = -1;
  76. switch ( argc ) {
  77. case 5:
  78. i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
  79. n = showInfoLibInfo(i);
  80. for ( j=0; j<n; j++ )
  81. showBookCaseInfo(DtMmdbGetBookCaseByLoc(i, argv[4]));
  82. break;
  83. default:
  84. fprintf(stderr, "bad argument list\n");
  85. }
  86. fprintf(stderr, "infolib desc=%d\n", i);
  87. return 0;
  88. }