Add Commentary section, minor cleanup of file header.
[emacs.git] / oldXMenu / FindSel.c
blobaf3ce1324a6a33224bb2f9bda1fbe65a7e2da494
1 #include "copyright.h"
3 /* $Header: /cvsroot/emacs/emacs/oldXMenu/FindSel.c,v 1.1 1999/10/03 19:35:03 fx Exp $ */
4 /* Copyright Massachusetts Institute of Technology 1985 */
6 /*
7 * XMenu: MIT Project Athena, X Window system menu package
9 * XMenuFindSelection - Find the first selection in a pane who's
10 * label matches a particular string.
12 * Author: Tony Della Fera, DEC
13 * January 22, 1986
17 #include "XMenuInt.h"
19 int
20 XMenuFindSelection(menu, p_num, label)
21 register XMenu *menu;
22 int p_num;
23 register char *label;
25 register XMPane *p_ptr;
26 register XMSelect *s_ptr;
27 register int i = 0;
30 * Check for NULL pointers!
32 if (label == NULL) {
33 _XMErrorCode = XME_ARG_BOUNDS;
34 return(XM_FAILURE);
38 * Find the right pane.
40 p_ptr = _XMGetPanePtr(menu, p_num);
41 if (p_ptr == NULL) return(XM_FAILURE);
44 * Find the right selection.
46 for (
47 s_ptr = p_ptr->s_list->next;
48 s_ptr != p_ptr->s_list;
49 s_ptr = s_ptr->next
51 if (s_ptr->label_length == 0) {
52 if (*label == '\0') {
53 _XMErrorCode = XME_NO_ERROR;
54 return (i);
57 else {
58 if (strncmp (label, s_ptr->label, s_ptr->label_length) == 0) {
59 _XMErrorCode = XME_NO_ERROR;
60 return (i);
63 i++;
67 * If we get here then we have not found
68 * a match.
70 _XMErrorCode = XME_S_NOT_FOUND;
71 return (XM_FAILURE);
74 /* arch-tag: 564a4a95-9ab0-4580-b05f-6970c4b25dd4
75 (do not change this comment) */