c_api_stylesheet.C 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_stylesheet.cc /main/3 1996/06/11 17:28:03 cde-hal $
  24. #include "oliasdb/c_api_common.h"
  25. static stylesheet_smart_ptr*
  26. getStylesheetUsingLocAndProid(DtMmdbInfoRequest* request, Boolean checkPIDOnly = false)
  27. {
  28. mtry {
  29. info_base* x = getBookCase(request -> bookcase_descriptor);
  30. if ( x == 0 ) return 0;
  31. oid_t * id = getPrimiaryOid(request);
  32. if ( id )
  33. return new stylesheet_smart_ptr(x, *id);
  34. if ( checkPIDOnly == true ) return 0;
  35. const char* str = getLocator(request);
  36. if ( str ) {
  37. return new stylesheet_smart_ptr(x, str);
  38. } else
  39. return 0;
  40. }
  41. mcatch (mmdbException &,e)
  42. {
  43. return 0;
  44. } end_try;
  45. return 0;
  46. }
  47. const char*
  48. DtMmdbStylesheetGetName(DtMmdbInfoRequest* request)
  49. {
  50. mtry {
  51. stylesheet_smart_ptr* x = getStylesheetUsingLocAndProid(request, true);
  52. if ( x == 0 ) return 0;
  53. const char* y = x -> name();
  54. delete x;
  55. return y;
  56. }
  57. mcatch (mmdbException &,e)
  58. {
  59. return 0;
  60. } end_try;
  61. return 0;
  62. }
  63. const char*
  64. DtMmdbStylesheetGetata(DtMmdbInfoRequest* request, unsigned int* data_length)
  65. {
  66. mtry {
  67. stylesheet_smart_ptr* x = getStylesheetUsingLocAndProid(request, false);
  68. if ( x == 0 ) return 0;
  69. #ifdef DEBUG
  70. fprintf(stderr, " stylesheetInfo: mmdb_oid = %d.%d\n", (int)(*x).its_oid().ccode()
  71. , (int)(*x).its_oid().icode());
  72. #endif
  73. const char* y = x -> online_data();
  74. if ( data_length ) *data_length = strlen(y);
  75. delete x;
  76. return y;
  77. }
  78. mcatch (mmdbException &,e)
  79. {
  80. return 0;
  81. } end_try;
  82. return 0;
  83. }