2 do_gsent(which,gimme,arglast)
7 register ARRAY *ary = stack;
8 register int sp = arglast[0];
11 struct servent *getservbyname();
12 struct servent *getservbynumber();
13 struct servent *getservent();
16 if (which == O_GSBYNAME) {
17 char *name = str_get(ary->ary_array[sp+1]);
18 char *proto = str_get(ary->ary_array[sp+2]);
23 sent = getservbyname(name,proto);
25 else if (which == O_GSBYPORT) {
26 int port = (int)str_gnum(ary->ary_array[sp+1]);
27 char *proto = str_get(ary->ary_array[sp+2]);
29 sent = getservbyport(port,proto);
34 if (gimme != G_ARRAY) {
35 astore(ary, ++sp, TARG = str_mortal(&str_undef));
37 if (which == O_GSBYNAME) {
39 str_numset(TARG, (double)ntohs(sent->s_port));
41 str_numset(TARG, (double)(sent->s_port));
45 str_set(TARG, sent->s_name);
52 (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
53 str_set(TARG, sent->s_name);
54 (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
55 for (elem = sent->s_aliases; *elem; elem++) {
60 (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
62 str_numset(TARG, (double)ntohs(sent->s_port));
64 str_numset(TARG, (double)(sent->s_port));
66 (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
67 str_set(TARG, sent->s_proto);
71 (void)astore(ary, ++sp, str_mortal(&str_no));