2 do_gpent(which,gimme,arglast)
7 register ARRAY *ary = stack;
8 register int sp = arglast[0];
11 struct protoent *getprotobyname();
12 struct protoent *getprotobynumber();
13 struct protoent *getprotoent();
14 struct protoent *pent;
16 if (which == O_GPBYNAME) {
17 char *name = str_get(ary->ary_array[sp+1]);
19 pent = getprotobyname(name);
21 else if (which == O_GPBYNUMBER) {
22 int proto = (int)str_gnum(ary->ary_array[sp+1]);
24 pent = getprotobynumber(proto);
29 if (gimme != G_ARRAY) {
30 astore(ary, ++sp, TARG = str_mortal(&str_undef));
32 if (which == O_GPBYNAME)
33 str_numset(TARG, (double)pent->p_proto);
35 str_set(TARG, pent->p_name);
42 (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
43 str_set(TARG, pent->p_name);
44 (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
45 for (elem = pent->p_aliases; *elem; elem++) {
50 (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
51 str_numset(TARG, (double)pent->p_proto);
55 (void)astore(ary, ++sp, str_mortal(&str_no));