1 /* ***********************************************************
  2    *                                                         *
  3    * Copyright, (C) Honeywell Bull Inc., 1987                *
  4    *                                                         *
  5    * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6    *                                                         *
  7    *********************************************************** */
  8 
  9 /* HISTORY COMMENTS:
 10   1) change(86-05-09,Lee), approve(87-07-13,MCR7580), audit(87-07-13,Leskiw),
 11      install(87-08-07,MR12.1-1072):
 12      Created.
 13                                                    END HISTORY COMMENTS */
 14 
 15 /* : PROCEDURE FUNCTION (i_fndcnu):
 16 
 17 Interrupt routine to find a major capability number from the local and remote
 18 CAT in mowse's memory space given a capability name.
 19 */
 20 
 21 /* : NOTES
 22 
 23 MOWSE looks for the capability name in its capability table in the following
 24 fashion:
 25 
 26      1) If the provided major capability number is 0, MOWSE will search the
 27         specified system from the top of the CAT.
 28      2) If the major capability number is valid and not 0, MOWSE will search
 29         the specified system from the NEXT position in the CAT.
 30      3) If the provided system_id is invalid, MOWSE will search the local
 31         system CAT.
 32 
 33 If MOWSE does not find the name between its starting point and the end of the
 34 CAT, an error code will be returned.
 35 
 36 param points to a structure containing
 37    char capability_name [CAPABILITY_NAME_LENGTH]; /* Name to be searchedfor */
 38    int  major_capability_number;                  /* Return value of name */
 39 */
 40 
 41 #include <dos.h>
 42 #include <ws.h>
 43 #include <cat.h>
 44 #include <ws_dcls.h>
 45 #include <ws_error.h>
 46 
 47 #define NULL 0
 48 
 49 extern local_cat  l_CAT[];
 50 extern remote_cat r_CAT[];
 51 extern char mysystem;
 52 
 53 i_fndcnu (param)
 54 
 55 struct findnumb_param_struct *param;  /* Parameter structure */
 56 {
 57 int  sysid;              /* system ID specified by caller */
 58 int  cap_num;            /* capability number specified by caller */
 59 int  cap_index;          /* temporary count of cat entries examined */
 60 int  entry_number;       /* major capability number found        */
 61 char entry_name[CAPABILITY_NAME_LENGTH];  /* major name found */
 62 int  code;               /* return codes */
 63 
 64 /* : if invalid major capability number, start at top of CAT */
 65 
 66    if (code = c_unpack (&sysid, &cap_num, param->major_capability_number))
 67       cap_num = 0;
 68 
 69 /* : if index specified is not 0, search next entry */
 70 
 71    cap_num = (cap_num < MIN_CAPABILITY_NUMBER)
 72       ? 0
 73       : cap_num + 1 - MIN_CAPABILITY_NUMBER;
 74 
 75 /* : If searching local table */
 76 
 77     if ((sysid == mysystem) || (sysid == WSLOCAL))
 78     {  for (cap_index = cap_num; cap_index < NUMBER_OF_CAT_ENTRIES; cap_index++)
 79        {  if (l_CAT[cap_index].mcb_ptr != NULL)
 80           {  if (code = get_mcb_values (&l_CAT[cap_index],entry_name,&entry_number))
 81                 return (code);
 82              if (!strncmp (entry_name,param->capability_name,CAPABILITY_NAME_LENGTH))
 83              {  c_pack (mysystem,cap_index + MIN_CAPABILITY_NUMBER,&param->major_capability_number);
 84                 return(0);
 85              }
 86          }
 87       }
 88       return (WSINVNAM);
 89    }
 90 
 91 /* : Else search remote CAT */
 92 
 93    for (cap_index = cap_num, sysid = WSMULTICS; cap_index < NUMBER_OF_CAT_ENTRIES; cap_index++)
 94    {  if (strncmp(param->capability_name,r_CAT[cap_index].capability_name,CAPABILITY_NAME_LENGTH) == 0)
 95       {  c_pack(sysid,cap_index + MIN_CAPABILITY_NUMBER,&param->major_capability_number);
 96          return(0);
 97       }
 98    }
 99 
100 /* : Nothing found, set code to indicate this */
101 
102    return (WSINVNAM);
103 }
104 ^Z