Example #1
0
void
lostpeer(int ignore)
{
	(void)ignore;

	if (connected) {
		if (cout != NULL) {
			shutdown(fileno(cout), 1+1);
			fclose(cout);
			cout = NULL;
		}
		if (data >= 0) {
			shutdown(data, 1+1);
			close(data);
			data = -1;
		}
		connected = 0;
	}
	pswitch(1);
	if (connected) {
		if (cout != NULL) {
			shutdown(fileno(cout), 1+1);
			fclose(cout);
			cout = NULL;
		}
		connected = 0;
	}
	proxflag = 0;
	pswitch(0);
}
Example #2
0
void
lostpeer(void)
{
	int save_errno = errno;

	alarmtimer(0);
	if (connected) {
		if (cout != NULL) {
			(void)shutdown(fileno(cout), SHUT_RDWR);
			(void)fclose(cout);
			cout = NULL;
		}
		if (data >= 0) {
			(void)shutdown(data, SHUT_RDWR);
			(void)close(data);
			data = -1;
		}
		connected = 0;
	}
	pswitch(1);
	if (connected) {
		if (cout != NULL) {
			(void)shutdown(fileno(cout), SHUT_RDWR);
			(void)fclose(cout);
			cout = NULL;
		}
		connected = 0;
	}
	proxflag = 0;
	pswitch(0);
	errno = save_errno;
}
Example #3
0
File: main.c Project: 274914765/C
RETSIGTYPE lostpeer (int sig ARG_UNUSED)
{
    if (connected)
    {
        if (cout != NULL)
        {
            shutdown (fileno (cout), 1 + 1);
            fclose (cout);
            cout = NULL;
        }
        if (data >= 0)
        {
            shutdown (data, 1 + 1);
            close (data);
            data = -1;
        }
        connected = 0;
    }
    pswitch (1);
    if (connected)
    {
        if (cout != NULL)
        {
            shutdown (fileno (cout), 1 + 1);
            fclose (cout);
            cout = NULL;
        }
        connected = 0;
    }
    proxflag = 0;
    pswitch (0);
}
Example #4
0
void Connection::doproxy(int argc, char *argv[])
{
	PROC(("doproxy","%d [%s,%s,%s]",argc,(argc>=1)?argv[0]:"nil",(argc>=2)?argv[1]:"nil",(argc>=3)?argv[2]:"nil"));
	struct cmd *c;

	if(argc < 2)
	{
		code = -1;
		return;
	}

	c = getcmd(argv[1]);

	//Not found
	if(c == (cmd*)-1 || c == 0)
	{
		WINPORT(SetLastError)(ERROR_BAD_DRIVER_LEVEL);
		code = -1;
		return;
	}

	//Unsupported in proxy mode
	if(!c->c_proxy)
	{
		WINPORT(SetLastError)(ERROR_BAD_NET_RESP);
		code = -1;
		return;
	}

	//Allready in proxy mode
	if(proxy > 0)
		ExecCmdTab(c, argc-1, argv+1);
	else
	{
		//Temp switch to proxy mode
		pswitch(1);

		if(c->c_conn && !connected)
		{
			pswitch(0);
			code = -1;
			return;
		}

		ExecCmdTab(c, argc-1, argv+1);
		proxflag = (connected) ? 1 : 0;
		pswitch(0);
	}
}
Example #5
0
static int pkeyh(struct wdgt *w, int key)
{
        int ret = KEY_HANDLED;
	int ctrl = key&KBD_MASK;
	static int pkey;
	
	/* hide or unhide wdgt */
	if(key == 't' || key == KBD_ENTER) { 
		pswitch(w, key, pkey);
		pkey = key;
		return KEY_HANDLED;
	}
	/* must be visible to process keys below */
	if(WIN_HIDDEN(w)) return KEY_SKIPPED;
	if(ctrl == 'K') {
		signal_keys(w, key);
		return ret;
	}
        switch(key) {
		case 'o': show_owner ^= 1; WNEED_REDRAW(w); break;
		case 'r': ptree_periodic(w); WNEED_REDRAW(w); break;
		case 'l': show_linenr ^=1 ; WNEED_REDRAW(w); break;
        /*        case KBD_UP:
		case KBD_DOWN:
		case KBD_PAGE_UP:
		case KBD_PAGE_DOWN: */
		default:	 ret = scr_keyh(w, key);
	}
        return ret;
}
Example #6
0
/*VARARGS*/
void Connection::quit()
{
	PROC(("quit",NULL));

	if(connected)
		disconnect();

	pswitch(1);

	if(connected)
		disconnect();
}
Example #7
0
static void
print_union (const rpc_union *s)
{
  bool ns = will_need_sep(s);
  aout <<
    "const strbuf &\n"
    "rpc_print (const strbuf &sb, const " << s->id << " &obj, "
    "int recdepth,\n"
    "           const char *name, const char *prefix)\n"
    "{\n"
    "  if (name) {\n"
    "    if (prefix)\n"
    "      sb << prefix;\n"
    "    sb << \"" << s->id << " \" << name << \" = \";\n"
    "  };\n"
    << ((ns) ? "  const char *sep;\n" : "") <<
    "  str npref;\n"
    "  if (prefix) {\n"
    "    npref = strbuf (\"%s  \", prefix);\n" 
    << ((ns) ? "    sep = \"\";\n" : "") <<
    "    sb << \"{\\n\";\n"
    "  }\n"
    "  else {\n"
    << ((ns) ? "    sep = \", \";\n" : "") <<
    "    sb << \"{ \";\n"
    "  }\n"
    "  rpc_print (sb, obj." << s->tagid << ", recdepth, "
    "\"" << s->tagid << "\", npref.cstr());\n";
  pswitch ("  ", s, "obj." << s->tagid, print_case, "\n", print_break);
  aout <<
    "  if (prefix)\n"
    "    sb << prefix << \"};\\n\";\n"
    "  else\n"
    "    sb << \" }\";\n"
    "  return sb;\n"
    "}\n";
  print_print (s->id);
}
Example #8
0
static void
dumpunion (const rpc_sym *s)
{
  bool hasdefault = false;

  const rpc_union *rs = s->sunion.addr ();
  aout << "\nstruct " << rs->id << " {\n"
       << "  const " << rs->tagtype << " " << rs->tagid << ";\n"
       << "  union {\n"
       << "    union_entry_base _base;\n";
  for (const rpc_utag *rt = rs->cases.base (); rt < rs->cases.lim (); rt++) {
    if (!rt->swval)
      hasdefault = true;
    if (rt->tagvalid && rt->tag.type != "void") {
      str type = rpc_decltype (&rt->tag);
      if (type[type.len ()-1] == '>')
	type = type << " ";
      aout << "    union_entry<" << type << "> "
	   << rt->tag.id << ";\n";
    }
  }
  aout << "  };\n\n";

  aout << "#define rpcunion_tag_" << rs->id << " " << rs->tagid << "\n";
  aout << "#define rpcunion_switch_" << rs->id
       << "(swarg, action, voidaction, defaction) \\\n";
  pswitch ("  ", rs, "swarg", punionmacro, " \\\n", punionmacrodefault);

  aout << "\n"
       << "  " << rs->id << " (" << rs->tagtype << " _tag = ("
       << rs->tagtype << ") 0) : " << rs->tagid << " (_tag)\n"
       << "    { _base.init (); set_" << rs->tagid << " (_tag); }\n"

       << "  " << rs->id << " (" << "const " << rs->id << " &_s)\n"
       << "    : " << rs->tagid << " (_s." << rs->tagid << ")\n"
       << "    { _base.init (_s._base); }\n"
       << "  ~" << rs->id << " () { _base.destroy (); }\n"
       << "  " << rs->id << " &operator= (const " << rs->id << " &_s) {\n"
       << "    const_cast<" << rs->tagtype << " &> ("
       << rs->tagid << ") = _s." << rs->tagid << ";\n"
       << "    _base.assign (_s._base);\n"
       << "    return *this;\n"
       << "  }\n\n";

  aout << "  void set_" << rs->tagid << " (" << rs->tagtype << " _tag) {\n"
       << "    const_cast<" << rs->tagtype << " &> (" << rs->tagid
       << ") = _tag;\n"
       << "    rpcunion_switch_" << rs->id << "\n"
       << "      (_tag, RPCUNION_SET, _base.destroy (), _base.destroy ());\n"
       << "  }\n";

#if 0
  aout << "  void Xstompcast () {\n"
       << "    rpcunion_switch_" << rs->id << "\n"
       << "      (" << rs->tagid << ", RPCUNION_STOMPCAST,\n"
       << "       _base.destroy (), _base.destroy ());\n"
       << "  }\n";
#endif
  aout << "};\n";

  aout << "\ntemplate<class T> bool\n"
       << "rpc_traverse (T &t, " << rs->id << " &obj)\n"
       << "{\n"
       << "  " << rs->tagtype << " tag = obj." << rs->tagid << ";\n"
       << "  if (!rpc_traverse (t, tag))\n"
       << "    return false;\n"
       << "  if (tag != obj." << rs->tagid << ")\n"
       << "    obj.set_" << rs->tagid << " (tag);\n\n"
       << "  rpcunion_switch_" << rs->id << "\n"
       << "    (obj." << rs->tagid << ", RPCUNION_TRAVERSE, "
       << "return true, return false);\n"
       << "  /* gcc 4.0.3 makes buggy warnings without the following line */\n"
       << "  return false;\n"
       << "}\n"
       << "inline bool\n"
       << "rpc_traverse (const stompcast_t &s, " << rs->id << " &obj)\n"
       << "{\n"
       << "  rpcunion_switch_" << rs->id << "\n"
       << "    (obj." << rs->tagid << ", RPCUNION_REC_STOMPCAST,\n"
       << "     obj._base.destroy (); return true, "
       << "obj._base.destroy (); return true;);\n"
       << "  /* gcc 4.0.3 makes buggy warnings without the following line */\n"
       << "  return false;\n"
       << "}\n";
  pmshl (rs->id);
  // aout << "RPC_TYPE_DECL (" << rs->id << ")\n";
  aout << "RPC_UNION_DECL (" << rs->id << ")\n";

  aout << "\n";
}