print.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (c) 2002-2004 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@mvista.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <stdio.h>
  35. #include <string.h>
  36. #include <stdarg.h>
  37. #include "print.h"
  38. #include "parse.h"
  39. #include "../include/ais_types.h"
  40. /*
  41. * logging printf
  42. */
  43. void
  44. internal_log_printf (int level, char *string, ...)
  45. {
  46. va_list ap;
  47. char newstring[1024];
  48. va_start(ap, string);
  49. sprintf (newstring, "L(%x): %s", level, string);
  50. vfprintf(stderr, newstring, ap);
  51. va_end(ap);
  52. }
  53. extern char *getSaClmNodeAddressT (SaClmNodeAddressT *nodeAddress) {
  54. int i;
  55. static char node_address[300];
  56. int pos;
  57. for (i = 0, pos = 0; i < nodeAddress->length; i++) {
  58. pos += sprintf (&node_address[pos], "%d.", nodeAddress->value[i]);
  59. }
  60. return (node_address);
  61. }
  62. void printSaClmClusterNodeT (char *description, SaClmClusterNodeT *clusterNode) {
  63. log_printf (LOG_LEVEL_NOTICE, "Node Information for %s:\n", description);
  64. log_printf (LOG_LEVEL_NOTICE, "\tnode id is %x\n", (int)clusterNode->nodeId);
  65. log_printf (LOG_LEVEL_NOTICE, "\tnode address is %s\n", getSaClmNodeAddressT (&clusterNode->nodeAddress));
  66. log_printf (LOG_LEVEL_NOTICE, "\tnode name is %s.\n", getSaNameT (&clusterNode->nodeName));
  67. log_printf (LOG_LEVEL_NOTICE, "\tcluster name is %s.\n", getSaNameT (&clusterNode->clusterName));
  68. log_printf (LOG_LEVEL_NOTICE, "\tMember is %d\n", clusterNode->member);
  69. log_printf (LOG_LEVEL_NOTICE, "\tTimestamp is %llx nanoseconds\n", clusterNode->bootTimestamp);
  70. }
  71. char *getSaNameT (SaNameT *name)
  72. {
  73. static char ret_name[300];
  74. memset (ret_name, 0, sizeof (ret_name));
  75. if (name->length > 299) {
  76. memcpy (ret_name, name->value, 299);
  77. } else {
  78. memcpy (ret_name, name->value, name->length);
  79. }
  80. return (ret_name);
  81. }
  82. void saAmfPrintGroups (void)
  83. {
  84. struct list_head *AmfGroupList;
  85. struct list_head *AmfUnitList;
  86. struct list_head *AmfComponentList;
  87. struct list_head *AmfProtectionGroupList;
  88. struct saAmfGroup *saAmfGroup;
  89. struct saAmfUnit *AmfUnit;
  90. struct saAmfComponent *AmfComponent;
  91. struct saAmfProtectionGroup *AmfProtectionGroup;
  92. for (AmfGroupList = saAmfGroupHead.next;
  93. AmfGroupList != &saAmfGroupHead;
  94. AmfGroupList = AmfGroupList->next) {
  95. saAmfGroup = list_entry (AmfGroupList,
  96. struct saAmfGroup, saAmfGroupList);
  97. log_printf (LOG_LEVEL_DEBUG, "group {\n");
  98. log_printf (LOG_LEVEL_DEBUG, "\tname = ", getSaNameT (&saAmfGroup->name));
  99. log_printf (LOG_LEVEL_DEBUG, "\tmodel = %d\n", saAmfGroup->model);
  100. log_printf (LOG_LEVEL_DEBUG, "\tactive-units = %d\n", (int)saAmfGroup->saAmfActiveUnitsDesired);
  101. log_printf (LOG_LEVEL_DEBUG, "\tbackup-units = %d\n", (int)saAmfGroup->saAmfStandbyUnitsDesired);
  102. for (AmfUnitList = saAmfGroup->saAmfUnitHead.next;
  103. AmfUnitList != &saAmfGroup->saAmfUnitHead;
  104. AmfUnitList = AmfUnitList->next) {
  105. AmfUnit = list_entry (AmfUnitList,
  106. struct saAmfUnit, saAmfUnitList);
  107. log_printf (LOG_LEVEL_DEBUG, "\tunit {\n");
  108. log_printf (LOG_LEVEL_DEBUG, "\t\tname = ", getSaNameT (&AmfUnit->name));
  109. for (AmfComponentList = AmfUnit->saAmfComponentHead.next;
  110. AmfComponentList != &AmfUnit->saAmfComponentHead;
  111. AmfComponentList = AmfComponentList->next) {
  112. AmfComponent = list_entry (AmfComponentList,
  113. struct saAmfComponent, saAmfComponentList);
  114. log_printf (LOG_LEVEL_DEBUG, "\t\tcomponent {\n");
  115. log_printf (LOG_LEVEL_DEBUG, "\t\t\tname = ", getSaNameT (&AmfComponent->name));
  116. log_printf (LOG_LEVEL_DEBUG, "\t\t\tmodel = %d\n", AmfComponent->componentCapabilityModel);
  117. log_printf (LOG_LEVEL_DEBUG, "\t\t}\n");
  118. }
  119. log_printf (LOG_LEVEL_DEBUG, "\t}\n");
  120. }
  121. for (AmfProtectionGroupList = saAmfGroup->saAmfProtectionGroupHead.next;
  122. AmfProtectionGroupList != &saAmfGroup->saAmfProtectionGroupHead;
  123. AmfProtectionGroupList = AmfProtectionGroupList->next) {
  124. AmfProtectionGroup = list_entry (AmfProtectionGroupList,
  125. struct saAmfProtectionGroup, saAmfProtectionGroupList);
  126. log_printf (LOG_LEVEL_DEBUG, "\tprotection {\n");
  127. log_printf (LOG_LEVEL_DEBUG, "\t\tname = ", getSaNameT (&AmfProtectionGroup->name));
  128. for (AmfComponentList = AmfProtectionGroup->saAmfMembersHead.next;
  129. AmfComponentList != &AmfProtectionGroup->saAmfMembersHead;
  130. AmfComponentList = AmfComponentList->next) {
  131. AmfComponent = list_entry (AmfComponentList,
  132. struct saAmfComponent, saAmfProtectionGroupList);
  133. log_printf (LOG_LEVEL_DEBUG, "\t\tmember = ", getSaNameT (&AmfComponent->name));
  134. }
  135. log_printf (LOG_LEVEL_DEBUG, "\t}\n");
  136. }
  137. log_printf (LOG_LEVEL_DEBUG, "}\n");
  138. }
  139. }