root/oldXMenu/FindPane.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. XMenuFindPane

     1 /* Copyright    Massachusetts Institute of Technology    1985   */
     2 
     3 /*
     4 
     5 Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
     6 
     7 Permission to use, copy, modify, and distribute this
     8 software and its documentation for any purpose and without
     9 fee is hereby granted, provided that the above copyright
    10 notice appear in all copies and that both that copyright
    11 notice and this permission notice appear in supporting
    12 documentation, and that the name of M.I.T. not be used in
    13 advertising or publicity pertaining to distribution of the
    14 software without specific, written prior permission.
    15 M.I.T. makes no representations about the suitability of
    16 this software for any purpose.  It is provided "as is"
    17 without express or implied warranty.
    18 
    19 */
    20 
    21 
    22 
    23 
    24 /*
    25  * XMenu:       MIT Project Athena, X Window system menu package
    26  *
    27  *      XMenuFindPane - Find the first menu pane who's label matches a
    28  *                      particular string.
    29  *
    30  *      Author:         Tony Della Fera, DEC
    31  *                      January 22, 1986
    32  *
    33  */
    34 
    35 #include "XMenuInt.h"
    36 #include <string.h>
    37 
    38 int
    39 XMenuFindPane(register XMenu *menu, register char *label)
    40 {
    41     register XMPane *p_ptr;
    42     register int i = 0;
    43 
    44     /*
    45      * Check for NULL pointers!
    46      */
    47     if (label == NULL) {
    48         _XMErrorCode = XME_ARG_BOUNDS;
    49         return(XM_FAILURE);
    50     }
    51 
    52     /*
    53      * Find the pane who's label matches the given label.
    54      */
    55     for (
    56         p_ptr = menu->p_list->next;
    57         p_ptr != menu->p_list;
    58         p_ptr = p_ptr->next
    59     ){
    60         if (p_ptr->label_length == 0) {
    61             if (*label == '\0') {
    62                 _XMErrorCode = XME_NO_ERROR;
    63                 return (i);
    64             }
    65         }
    66         else {
    67             if (strncmp (label, p_ptr->label, p_ptr->label_length) == 0) {
    68                 _XMErrorCode = XME_NO_ERROR;
    69                 return (i);
    70             }
    71         }
    72         i++;
    73     }
    74 
    75     /*
    76      * If we get here then we have not found
    77      * a match.
    78      */
    79     _XMErrorCode = XME_P_NOT_FOUND;
    80     return (XM_FAILURE);
    81 }

/* [<][>][^][v][top][bottom][index][help] */