FindPane.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenuFindPane - Find the first menu pane who's label matches a
  7. * particular string.
  8. *
  9. * Author: Tony Della Fera, DEC
  10. * January 22, 1986
  11. *
  12. */
  13. #include "XMenuInt.h"
  14. #include <string.h>
  15. int
  16. XMenuFindPane(register XMenu *menu, register char *label)
  17. {
  18. register XMPane *p_ptr;
  19. register int i = 0;
  20. /*
  21. * Check for NULL pointers!
  22. */
  23. if (label == NULL) {
  24. _XMErrorCode = XME_ARG_BOUNDS;
  25. return(XM_FAILURE);
  26. }
  27. /*
  28. * Find the pane who's label matches the given label.
  29. */
  30. for (
  31. p_ptr = menu->p_list->next;
  32. p_ptr != menu->p_list;
  33. p_ptr = p_ptr->next
  34. ){
  35. if (p_ptr->label_length == 0) {
  36. if (*label == '\0') {
  37. _XMErrorCode = XME_NO_ERROR;
  38. return (i);
  39. }
  40. }
  41. else {
  42. if (strncmp (label, p_ptr->label, p_ptr->label_length) == 0) {
  43. _XMErrorCode = XME_NO_ERROR;
  44. return (i);
  45. }
  46. }
  47. i++;
  48. }
  49. /*
  50. * If we get here then we have not found
  51. * a match.
  52. */
  53. _XMErrorCode = XME_P_NOT_FOUND;
  54. return (XM_FAILURE);
  55. }