• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ do_action函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中do_action函数的典型用法代码示例。如果您正苦于以下问题:C++ do_action函数的具体用法?C++ do_action怎么用?C++ do_action使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了do_action函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: l_siplua_moduleFunc

static int l_siplua_moduleFunc(lua_State *L)
{
  struct sipapi_object *o;
  const char *func;
  int n, nargs;
  cmd_export_t *exp_func_struct;
  action_elem_t elems[MAX_ACTION_ELEMS];
  const char *s, *msg;
  char *str;
  int i;
  struct action *act;
  int retval;

  o = luaL_checkudata(L, 1, "siplua.api");
  func = luaL_checkstring(L, 2);
  n = lua_gettop(L);
  nargs = n - 2;
  if (n - 1 > MAX_ACTION_ELEMS)
    return luaL_error(L, "function '%s' called with too many arguments [%d > %d]",
	       func, nargs, MAX_ACTION_ELEMS - 1);
  exp_func_struct = find_cmd_export_t((char *)func, nargs, 0);
  if (!exp_func_struct)
    {
      return luaL_error(L, "function '%s' called, but not available.");
    }
  elems[0].type = CMD_ST;
  elems[0].u.data = exp_func_struct;
  memset(&elems[1], '\0', nargs * sizeof(action_elem_t));
  for (i = 0; i < nargs; ++i)
    {
      s = lua_tostring(L, 3 + i);
      if (!s)
	{
	  siplua_moduleFunc_free(func, exp_func_struct, elems, nargs);
	  msg = lua_pushfstring(L, "%s expected, got %s",
				lua_typename(L, LUA_TSTRING), luaL_typename(L, 3 + i));
	  return luaL_argerror(L, 3 + i, msg);
	}
      str = pkg_malloc(strlen(s) + 1);
      if (!str)
	{
	  siplua_moduleFunc_free(func, exp_func_struct, elems, nargs);
	  return luaL_error(L, "Not enough memory");
	}
      strcpy(str, s);
      /* We should maybe try STR_ST and elems[].u.str.{s,len} */
      elems[i + 1].type = STRING_ST;
      elems[i + 1].u.data = str; /* elems[].u.string */
    }
  act = mk_action(MODULE_T, n - 2 + 1, elems, 0);
  if (!act)
    {
      siplua_moduleFunc_free(func, exp_func_struct, elems, nargs);
      return luaL_error(L, "action structure could not be created. Error.");
    }
/*   siplua_log(L_DBG, "fixup/%p free_fixup/%p", */
/* 	     exp_func_struct->fixup, */
/* 	     exp_func_struct->free_fixup); */
  if (exp_func_struct->fixup)
    {
      if (!siplua_unsafemodfnc && !exp_func_struct->free_fixup)
	{
	  siplua_moduleFunc_free(func, exp_func_struct, act->elem, nargs);
	  return luaL_error(L, "Module function '%s' is unsafe. Call is refused.\n", func);
	}
      if (nargs == 0)
	{
	  retval = exp_func_struct->fixup(0, 0);
	  if (retval < 0)
	    {
	      siplua_moduleFunc_free(func, exp_func_struct, act->elem, nargs);
	      return luaL_error(L, "Error in fixup (0)\n");
	    }
	}
      for (i = 0; i < nargs; ++i)
	{
	  retval = exp_func_struct->fixup(&act->elem[i + 1].u.data, i + 1);
	  if (retval < 0)
	    {
	      siplua_moduleFunc_free(func, exp_func_struct, act->elem, nargs);
	      return luaL_error(L, "Error in fixup (%d)\n", i + 1);
	    }
	  act->elem[i + 1].type = MODFIXUP_ST;
	}
    }
  retval = do_action(act, o->msg);
  siplua_moduleFunc_free(func, exp_func_struct, act->elem, nargs);
  pkg_free(act);
  lua_pushinteger(L, retval);
  return 1;
}
开发者ID:UIKit0,项目名称:OpenSIPS,代码行数:91,代码来源:sipapi.c


示例2: process_event

/* State machine to do the calling and hangup procedure */
static void process_event(struct cardstate *cs, struct event_t *ev)
{
	struct bc_state *bcs;
	char *p_command = NULL;
	struct reply_t *rep;
	int rcode;
	int genresp = 0;
	int resp_code = RSP_ERROR;
	int sendcid;
	struct at_state_t *at_state;
	int index;
	int curact;
	unsigned long flags;

	if (ev->cid >= 0) {
		at_state = at_state_from_cid(cs, ev->cid);
		if (!at_state) {
			gig_dbg(DEBUG_EVENT, "event %d for invalid cid %d",
				ev->type, ev->cid);
			gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID,
					  NULL, 0, NULL);
			return;
		}
	} else {
		at_state = ev->at_state;
		if (at_state_invalid(cs, at_state)) {
			gig_dbg(DEBUG_EVENT, "event for invalid at_state %p",
				at_state);
			return;
		}
	}

	gig_dbg(DEBUG_EVENT, "connection state %d, event %d",
		at_state->ConState, ev->type);

	bcs = at_state->bcs;
	sendcid = at_state->cid;

	/* Setting the pointer to the dial array */
	rep = at_state->replystruct;

	spin_lock_irqsave(&cs->lock, flags);
	if (ev->type == EV_TIMEOUT) {
		if (ev->parameter != at_state->timer_index
		    || !at_state->timer_active) {
			ev->type = RSP_NONE; /* old timeout */
			gig_dbg(DEBUG_EVENT, "old timeout");
		} else if (!at_state->waiting)
			gig_dbg(DEBUG_EVENT, "timeout occurred");
		else
			gig_dbg(DEBUG_EVENT, "stopped waiting");
	}
	spin_unlock_irqrestore(&cs->lock, flags);

	/* if the response belongs to a variable in at_state->int_var[VAR_XXXX]
	   or at_state->str_var[STR_XXXX], set it */
	if (ev->type >= RSP_VAR && ev->type < RSP_VAR + VAR_NUM) {
		index = ev->type - RSP_VAR;
		at_state->int_var[index] = ev->parameter;
	} else if (ev->type >= RSP_STR && ev->type < RSP_STR + STR_NUM) {
		index = ev->type - RSP_STR;
		kfree(at_state->str_var[index]);
		at_state->str_var[index] = ev->ptr;
		ev->ptr = NULL; /* prevent process_events() from
				   deallocating ptr */
	}

	if (ev->type == EV_TIMEOUT || ev->type == RSP_STRING)
		at_state->getstring = 0;

	/* Search row in dial array which matches modem response and current
	   constate */
	for (;; rep++) {
		rcode = rep->resp_code;
		if (rcode == RSP_LAST) {
			/* found nothing...*/
			dev_warn(cs->dev, "%s: rcode=RSP_LAST: "
				 "resp_code %d in ConState %d!\n",
				 __func__, ev->type, at_state->ConState);
			return;
		}
		if ((rcode == RSP_ANY || rcode == ev->type)
		    && ((int) at_state->ConState >= rep->min_ConState)
		    && (rep->max_ConState < 0
			|| (int) at_state->ConState <= rep->max_ConState)
		    && (rep->parameter < 0 || rep->parameter == ev->parameter))
			break;
	}

	p_command = rep->command;

	at_state->waiting = 0;
	for (curact = 0; curact < MAXACT; ++curact) {
		/* The row tells us what we should do  ..
		 */
		do_action(rep->action[curact], cs, bcs, &at_state, &p_command,
			  &genresp, &resp_code, ev);
		if (!at_state)
			break; /* may be freed after disconnect */
//.........这里部分代码省略.........
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:101,代码来源:ev-layer.c


示例3: process_command


//.........这里部分代码省略.........
		/* remember command for programs */
		strcpyn(match_args, sizeof(match_args), full_command);
		strcpyn(match_cmdname, sizeof(match_cmdname), command);

		/* move over spaces */
		while (*arg1 && isspace(*arg1))
			arg1++;

		/* find end of arg1, start of arg2 */
		for (arg2 = arg1; *arg2 && *arg2 != ARG_DELIMITER; arg2++) ;

		/* truncate arg1 */
		for (p = arg2 - 1; p >= arg1 && isspace(*p); p--)
			*p = '\0';

		/* go past delimiter if present */
		if (*arg2)
			*arg2++ = '\0';
		while (*arg2 && isspace(*arg2))
			arg2++;

		switch (command[0]) {
		case '@':
			switch (command[1]) {
			case 'a':
			case 'A':
				/* @action, @armageddon, @attach */
				switch (command[2]) {
				case 'c':
				case 'C':
					Matched("@action");
					NOGUEST("@action", player);
					BUILDERONLY("@action", player);
					do_action(descr, player, arg1, arg2);
					break;
				case 'r':
				case 'R':
					if (strcmp(command, "@armageddon"))
						goto bad;
/*
					WIZARDONLY("@armageddon", player);
					PLAYERONLY("@armageddon", player);
*/
					do_armageddon(player, full_command);
					break;
				case 't':
				case 'T':
					Matched("@attach");
					NOGUEST("@attach", player);
					BUILDERONLY("@attach", player);
					do_attach(descr, player, arg1, arg2);
					break;
				default:
					goto bad;
				}
				break;
			case 'b':
			case 'B':
				/* @bless, @boot */
				switch (command[2]) {
				case 'l':
				case 'L':
					Matched("@bless");
					WIZARDONLY("@bless", player);
					PLAYERONLY("@bless", player);
					NOFORCE("@bless", force_level, player);
开发者ID:revarbat,项目名称:fuzzball,代码行数:67,代码来源:game.c


示例4: catch_sigusr2

static void
catch_sigusr2(int s) {
	(void)s;
	do_action(sigusr2);
}
开发者ID:itdaniher,项目名称:SucklessDebXO,代码行数:5,代码来源:main.c


示例5: main


//.........这里部分代码省略.........
			if(++i < argc) dzen.line_height= atoi(argv[i]);
		}
		else if(!strncmp(argv[i], "-tw", 4)) {
			if(++i < argc) dzen.title_win.width = atoi(argv[i]);
		}
#ifdef DZEN_XINERAMA
		else if(!strncmp(argv[i], "-xs", 4)) {
			if(++i < argc) dzen.xinescreen = atoi(argv[i]);
		}
#endif
		else if(!strncmp(argv[i], "-v", 3)) 
			eprint("dzen-"VERSION", (C)opyright 2007 Robert Manea\n");
		else
			eprint("usage: dzen2 [-v] [-p [seconds]] [-m [v|h]] [-ta <l|c|r>] [-sa <l|c|r>]\n"
                   "             [-x <pixel>] [-y <pixel>] [-w <pixel>] [-tw <pixel>] [-u] \n"
				   "             [-e <string>] [-l <lines>]  [-fn <font>] [-bg <color>] [-fg <color>]\n"
#ifdef DZEN_XINERAMA
				   "             [-xs <screen>]\n"
#endif
				  );

	if(dzen.tsupdate && !dzen.slave_win.max_lines)
		dzen.tsupdate = False;

	if(!dzen.title_win.width)
		dzen.title_win.width = dzen.slave_win.width;

	if(!setlocale(LC_ALL, "") || !XSupportsLocale())
		puts("dzen: locale not available, expect problems with fonts.\n");

	if(action_string) 
		fill_ev_table(action_string);
	else {
		if(!dzen.slave_win.max_lines) {
			char edef[] = "button3=exit:13";
			fill_ev_table(edef);
		}
		else if(dzen.slave_win.ishmenu) {
			char edef[] = "enterslave=grabkeys;leaveslave=ungrabkeys;"
				"button4=scrollup;button5=scrolldown;"
				"key_Left=scrollup;key_Right=scrolldown;"
				"button1=menuexec;button3=exit:13;"
				"key_Escape=ungrabkeys,exit";
			fill_ev_table(edef);
		}
		else {
			char edef[]  = "entertitle=uncollapse,grabkeys;"
				"enterslave=grabkeys;leaveslave=collapse,ungrabkeys;"
				"button1=menuexec;button2=togglestick;button3=exit:13;"
				"button4=scrollup;button5=scrolldown;"
				"key_Up=scrollup;key_Down=scrolldown;"
				"key_Escape=ungrabkeys,exit";
			fill_ev_table(edef);
		}
	}

	if((find_event(onexit) != -1) 
			&& (setup_signal(SIGTERM, catch_sigterm) == SIG_ERR))
		fprintf(stderr, "dzen: error hooking SIGTERM\n");

	if((find_event(sigusr1) != -1) 
			&& (setup_signal(SIGUSR1, catch_sigusr1) == SIG_ERR))
		fprintf(stderr, "dzen: error hooking SIGUSR1\n");
	
	if((find_event(sigusr2) != -1) 
		&& (setup_signal(SIGUSR2, catch_sigusr2) == SIG_ERR))
		fprintf(stderr, "dzen: error hooking SIGUSR2\n");
	
	if(setup_signal(SIGALRM, catch_alrm) == SIG_ERR)
		fprintf(stderr, "dzen: error hooking SIGALARM\n");

	set_alignment();
	
	if(dzen.slave_win.ishmenu &&
			!dzen.slave_win.max_lines)
		dzen.slave_win.max_lines = 1;

	x_create_windows();
	
	if(!dzen.slave_win.ishmenu)
		x_map_window(dzen.title_win.win);
	else {
		XMapRaised(dzen.dpy, dzen.slave_win.win);
		for(i=0; i < dzen.slave_win.max_lines; i++)
			XMapWindow(dzen.dpy, dzen.slave_win.line[i]);
	}

	do_action(onstart);

	/* main loop */
	event_loop();

	do_action(onexit);
	clean_up();

	if(dzen.ret_val)
		return dzen.ret_val;

	return EXIT_SUCCESS;
}
开发者ID:itdaniher,项目名称:SucklessDebXO,代码行数:101,代码来源:main.c


示例6: msg_call_function

static PyObject *
msg_call_function(msgobject *self, PyObject *args)
{
/* TODO: adapt to new cmd_export and params interface */
#if 0
    int i, rval;
    char *fname, *arg1, *arg2;
    cmd_export_t *fexport;
    struct action *act;
    action_elem_t elems[MAX_ACTION_ELEMS];

    if (self->msg == NULL) {
        PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
        Py_INCREF(Py_None);
        return Py_None;
    }

    i = PySequence_Size(args);
    if (i < 1 || i > 3) {
        PyErr_SetString(PyExc_RuntimeError, "call_function() should " \
          "have from 1 to 3 arguments");
        Py_INCREF(Py_None);
        return Py_None;
    }

    if(!PyArg_ParseTuple(args, "s|ss:call_function", &fname, &arg1, &arg2))
        return NULL;

    fexport = find_cmd_export_t(fname, 0);
    if (fexport == NULL) {
        PyErr_SetString(PyExc_RuntimeError, "no such function");
        Py_INCREF(Py_None);
        return Py_None;
    }

    elems[0].type = CMD_ST;
    elems[0].u.data = fexport;
    elems[1].type = STRING_ST;
    elems[1].u.data = arg1;
    elems[2].type = STRING_ST;
    elems[2].u.data = arg2;
    act = mk_action(MODULE_T, 3, elems, 0, "python");

    if (act == NULL) {
        PyErr_SetString(PyExc_RuntimeError,
          "action structure could not be created");
        Py_INCREF(Py_None);
        return Py_None;
    }

    if (fexport->fixup != NULL) {
        if (i >= 3) {
            rval = fexport->fixup(&(act->elem[2].u.data), 2);
            if (rval < 0) {
                PyErr_SetString(PyExc_RuntimeError, "Error in fixup (2)");
                Py_INCREF(Py_None);
                return Py_None;
            }
            act->elem[2].type = MODFIXUP_ST;
        }
        if (i >= 2) {
            rval = fexport->fixup(&(act->elem[1].u.data), 1);
            if (rval < 0) {
                PyErr_SetString(PyExc_RuntimeError, "Error in fixup (1)");
                Py_INCREF(Py_None);
                return Py_None;
            }
            act->elem[1].type = MODFIXUP_ST;
        }
        if (i == 1) {
            rval = fexport->fixup(0, 0);
            if (rval < 0) {
                PyErr_SetString(PyExc_RuntimeError, "Error in fixup (0)");
                Py_INCREF(Py_None);
                return Py_None;
            }
        }
    }

    rval = do_action(act, self->msg);

    if ((act->elem[2].type == MODFIXUP_ST) && (act->elem[2].u.data) &&
      (act->elem[2].u.data != arg2)) {
       pkg_free(act->elem[2].u.data);
    }

    if ((act->elem[1].type == MODFIXUP_ST) && (act->elem[1].u.data)) {
        pkg_free(act->elem[1].u.data);
    }

    pkg_free(act);

    return PyInt_FromLong(rval);
#endif

    return NULL;
}
开发者ID:rrb3942,项目名称:opensips,代码行数:97,代码来源:python_msgobj.c


示例7: moduleFunc

int moduleFunc(struct sip_msg *m, char *func,
	       char *param1, char *param2,
	       int *retval) {

	cmd_export_t *exp_func_struct;
	struct action *act;
	char *argv[2];
	int argc = 0;
	action_elem_t elems[MAX_ACTION_ELEMS];

	if (!func) {
		LM_ERR("moduleFunc called with null function name. Error.");
		return -1;
	}

	if ((!param1) && param2) {
		LM_ERR("moduleFunc called with parameter 1 UNSET and"
			   " parameter 2 SET. Error.");
		return -1;
	}


	if (param1) {
		argv[0] = (char *)pkg_malloc(strlen(param1)+1);
		strcpy(argv[0], param1);
		argc++;
	} else {
		argv[0] = NULL;
	}

	if (param2) {
		argv[1] = (char *)pkg_malloc(strlen(param2)+1);
		strcpy(argv[1], param2);
		argc++;
	} else {
		argv[1] = NULL;
	}

	exp_func_struct = find_cmd_export_t(func, argc, 0);
	if (!exp_func_struct) {
		LM_ERR("function '%s' called, but not available.", func);
		*retval = -1;
		if (argv[0]) pkg_free(argv[0]);
		if (argv[1]) pkg_free(argv[1]);
		return -1;
	}

	elems[0].type = CMD_ST;
	elems[0].u.data = exp_func_struct;
	elems[1].type = STRING_ST;
	elems[1].u.data = argv[0];
	elems[2].type = STRING_ST;
	elems[2].u.data = argv[1];
	act = mk_action(	MODULE_T,
				3,
				elems,
				0);


	if (!act) {
		LM_ERR("action structure could not be created. Error.");
		if (argv[0]) pkg_free(argv[0]);
		if (argv[1]) pkg_free(argv[1]);
		return -1;
	}


	if (exp_func_struct->fixup) {
		if (!unsafemodfnc) {
			LM_ERR("Module function '%s' is unsafe. Call is refused.\n", func);
			if (argv[0]) pkg_free(argv[0]);
			if (argv[1]) pkg_free(argv[1]);
			*retval = -1;
			return -1;
		}

		if (argc>=2) {
			*retval = exp_func_struct->fixup(&(act->elem[2].u.data), 2);
			if (*retval < 0) {
				LM_ERR("Error in fixup (2)\n");
				return -1;
			}
			act->elem[2].type = MODFIXUP_ST;
		}
		if (argc>=1) {
			*retval = exp_func_struct->fixup(&(act->elem[1].u.data), 1);
			if (*retval < 0) {
				LM_ERR("Error in fixup (1)\n");
				return -1;
			}
			act->elem[1].type = MODFIXUP_ST;
		}
		if (argc==0) {
			*retval = exp_func_struct->fixup(0, 0);
			if (*retval < 0) {
				LM_ERR("Error in fixup (0)\n");
				return -1;
			}
		}
	}
//.........这里部分代码省略.........
开发者ID:ryzhov,项目名称:ATS0,代码行数:101,代码来源:opensipsxs.c


示例8: right

unsigned long right(unsigned long exe_t,  unsigned long const initial_exe_t, cbuf_t cbt, int len)
{
	return do_action(exe_t,initial_exe_t, cbt, len);
}
开发者ID:asweeney86,项目名称:Composite,代码行数:4,代码来源:exe_cbuf_synth_hier.c


示例9: exec_str

int exec_str(struct sip_msg *msg, char *cmd, char *param, int param_len) {

    struct action act;
    struct run_act_ctx ra_ctx;
    int cmd_len;
    FILE *pipe;
    char *cmd_line;
    int ret;
    int l1;
    static char uri_line[MAX_URI_SIZE+1];
    int uri_cnt;
    str uri;
    int exit_status;

    /* pessimist: assume error by default */
    ret=-1;

    l1=strlen(cmd);
    if(param_len>0)
        cmd_len=l1+param_len+4;
    else
        cmd_len=l1+1;
    cmd_line=pkg_malloc(cmd_len);
    if (cmd_line==0) {
        ret=ser_error=E_OUT_OF_MEM;
        LM_ERR("no pkg mem for command\n");
        goto error00;
    }

    /* 'command parameter \0' */
    memcpy(cmd_line, cmd, l1);
    if(param_len>0)
    {
        cmd_line[l1]=' ';
        cmd_line[l1+1]='\'';
        memcpy(cmd_line+l1+2, param, param_len);
        cmd_line[l1+param_len+2]='\'';
        cmd_line[l1+param_len+3]=0;
    } else {
        cmd_line[l1] = 0;
    }

    pipe=popen( cmd_line, "r" );
    if (pipe==NULL) {
        LM_ERR("cannot open pipe: %s\n", cmd_line);
        ser_error=E_EXEC;
        goto error01;
    }

    /* read now line by line */
    uri_cnt=0;
    while( fgets(uri_line, MAX_URI_SIZE, pipe)!=NULL) {
        uri.s = uri_line;
        uri.len=strlen(uri.s);
        /* trim from right */
        while(uri.len && (uri.s[uri.len-1]=='\r'
                          || uri.s[uri.len-1]=='\n'
                          || uri.s[uri.len-1]=='\t'
                          || uri.s[uri.len-1]==' ' )) {
            LM_DBG("rtrim\n");
            uri.len--;
        }
        /* skip empty line */
        if (uri.len==0) continue;
        /* ZT */
        uri.s[uri.len]=0;
        if (uri_cnt==0) {
            memset(&act, 0, sizeof(act));
            act.type = SET_URI_T;
            act.val[0].type = STRING_ST;
            act.val[0].u.string = uri.s;
            init_run_actions_ctx(&ra_ctx);
            if (do_action(&ra_ctx, &act, msg)<0) {
                LM_ERR("the action for has failed\n");
                ser_error=E_OUT_OF_MEM;
                goto error02;
            }
        } else {
            if (append_branch(msg, &uri, 0, 0, Q_UNSPECIFIED, 0, 0)==-1) {
                LM_ERR("append_branch failed; too many or too long URIs?\n");
                goto error02;
            }
        }
        uri_cnt++;
    }
    if (uri_cnt==0) {
        LM_ERR("no uri from %s\n", cmd_line );
        goto error02;
    }
    /* success */
    ret=1;

error02:
    if (ferror(pipe)) {
        LM_ERR("in pipe: %s\n", strerror(errno));
        ser_error=E_EXEC;
        ret=-1;
    }
    exit_status=pclose(pipe);
    if (WIFEXITED(exit_status)) { /* exited properly .... */
//.........这里部分代码省略.........
开发者ID:kiryu,项目名称:kamailio,代码行数:101,代码来源:exec.c


示例10: do_action

const unsigned char*
do_action( const unsigned char* action, CIStream* args, COStream out) {
    const unsigned char* as;
    unsigned char ac;
    int argn = 0;

    as = action;
    if ( as != NULL )
        for ( ; ; ) {
            ac = *as++;
            switch (ac) {
            case PT_END:
                return as-1;
            case PT_SEPARATOR:
                return as;
            case PT_PUT_ARG: {
                CIStream arg = args[ (*as++) - 1 ];
                cis_rewind(arg);
                cos_copy_input_stream(out,arg);
                break;
            }
            case PT_ONE_OPT:
                cos_putch(out,arg_char);
                break;

            case PT_DOMAIN: {
                CIStream inbuf;
                Pattern save_rule = current_rule;
#if MAX_DOMAINS < 256
                int domain = *as++ - 1;
#else
                /* Get domain index as 14 bit little endian number */
                int domain = ((unsigned char)*as++)&0x7f;
                domain = ((((unsigned char)*as++)&0x7f)<<7) | domain;
#endif
                if ( as[0] == PT_VAR1 ||
                        ( as[0] == PT_OP &&
                          ( as[1] == OP_VAR || as[1] == OP_VAR_DFLT ) ) ) {
                    /* for safety, copy the variable's value in case it is
                       changed during translation.  */
                    COStream outbuf;
                    outbuf = make_buffer_output_stream();
                    as = do_action( as, args, outbuf );
                    inbuf = convert_output_to_input( outbuf );
                }
                else /* optimized operand access */
                    inbuf = function_operand( &as, args );
#ifdef TRACE
                if ( trace_switch ) {
                    int n;
                    fprintf( stderr, "%12ld,%2d ",
                             cis_line(input_stream), cis_column(input_stream));
                    for ( n = trace_indent ; n > 0 ; n-- )
                        fputc(' ',stderr);
                    if ( cis_is_file(inbuf) ) {
                        const char* inpath = cis_pathname(inbuf);
                        if ( inpath == NULL )
                            inpath = "-";
                        fprintf( stderr, "@%s{@read{%s}}\n",
                                 domains[domain]->name, inpath);
                    }
                    else
                        fprintf( stderr, "@%s{%.60s}\n",
                                 domains[domain]->name, cis_whole_string(inbuf));
                    ++trace_indent;
                }
#endif
                if ( !translate( inbuf, domains[domain], out, NULL ) &&
                        cis_is_file(inbuf) && exit_status < EXS_FAIL )
                    exit_status = EXS_FAIL;
#ifdef TRACE
                if ( trace_switch ) {
                    --trace_indent;
                }
#endif
                current_rule = save_rule;
                cis_close(inbuf);
                break;
            }

            case PT_VAR1: {
                char vname[2];
                vname[0] = *as++;
                vname[1] = '\0';
                put_var(out, vname, FALSE);
                break;
            }

            case PT_LINE:
                cos_freshline(out);
                break;

            case PT_MATCHED_TEXT:
                do_action( current_rule->pattern, args, out );
                break;

            case PT_SPECIAL_ARG:
#if MAX_DOMAINS >= 256 /* advance one more since  2 bytes for domain index */
            case PT_RECUR:
#endif
//.........这里部分代码省略.........
开发者ID:NeonMan,项目名称:gema,代码行数:101,代码来源:action.c


示例11: mouse_ll_proc

static
LRESULT CALLBACK mouse_ll_proc(int code, WPARAM wparam, LPARAM lparam)
{
    MSLLHOOKSTRUCT *msll;

    if(code < 0) {
        goto norm_end;
    }

    msll = (MSLLHOOKSTRUCT *)lparam;

    if(msll->flags & LLMHF_INJECTED) {
        goto norm_end;
    }

    if(ctx.mode_data.cur_conf == NULL) {
        goto norm_end;
    }

    {
        int motion, btn;

        motion = msg_to_motion(wparam);
        btn = msg_to_button(wparam, msll->mouseData);

        if(ctx.hook_data.pressed) {
            struct mouse_action *cmb_d_act, *cmb_u_act;

            ctx.hook_data.pressed = 0;
            KillTimer(NULL, comb_timer_id);

            cmb_d_act = &ctx.mode_data.cur_conf->
                        button[ctx.hook_data.pressed_btn].comb_d_act[btn];
            cmb_u_act = &ctx.mode_data.cur_conf->
                        button[ctx.hook_data.pressed_btn].comb_u_act[btn];

            if(motion == MOTION_DOWN &&
               (cmb_d_act->code != MOUSE_ACT_NOTHING ||
                cmb_u_act->code != MOUSE_ACT_NOTHING)) {
                /* combination press */
                do_action(cmb_d_act, msll);

                ctx.hook_data.
                    combination[ctx.hook_data.combinated * 2] =
                    ctx.hook_data.pressed_btn;
                ctx.hook_data.
                    combination[ctx.hook_data.combinated * 2 + 1] = btn;
                ctx.hook_data.combinated += 1;

                return 1;
            }

            do_action(&ctx.mode_data.cur_conf->
                      button[ctx.hook_data.pressed_btn].d_act,
                      &ctx.hook_data.pressed_btn_data);
        }

        if(btn >= 0) {
            /* check ignore mask */
            if(ctx.hook_data.ignore_btn_mask & MOUSE_BTN_BIT(btn)) {
                ctx.hook_data.ignore_btn_mask &= ~MOUSE_BTN_BIT(btn);
                return 1;
            }

            if(motion == MOTION_DOWN) {
                /* try combination */
                if(ctx.mode_data.cur_conf->button[btn].flags &
                   MOUSE_BTN_CONF_ENABLE_COMB) {
                    ctx.hook_data.pressed = 1;
                    ctx.hook_data.pressed_btn = btn;
                    memcpy(&ctx.hook_data.pressed_btn_data, msll,
                           sizeof(MSLLHOOKSTRUCT));
                    comb_timer_id = SetTimer(NULL, 0,
                                             ctx.app_conf.comb_time,
                                             comb_timer);
                    return 1;
                }
            }

            if(motion == MOTION_UP) {
                if(ctx.hook_data.combinated) {
                    int i;

                    for(i = 0; i < ctx.hook_data.combinated; i++) {
                        /* combination release */
                        if(ctx.hook_data.combination[i * 2] == btn ||
                           ctx.hook_data.combination[i * 2 + 1] == btn) {
                            do_action(
                                &ctx.mode_data.cur_conf->
                                button[ctx.hook_data.combination[i * 2]].
                                comb_u_act[
                                    ctx.hook_data.combination[i * 2 + 1]],
                                msll);

                            ctx.hook_data.ignore_btn_mask |=
                                MOUSE_BTN_BIT(
                                    btn == ctx.hook_data.combination[i * 3] ?
                                    ctx.hook_data.combination[i * 3 + 1] :
                                    ctx.hook_data.combination[i * 3]);

//.........这里部分代码省略.........
开发者ID:lllllT,项目名称:mouse-processor,代码行数:101,代码来源:hook.c


示例12: function_operand

static CIStream
function_operand( const unsigned char** asp, CIStream* args ) {
    const unsigned char* ap;
    ap = *asp;
    if ( ap[2] == PT_SEPARATOR ) {
        if ( ap[0] == PT_PUT_ARG ) {
            /* special case when operand is $n and nothing else */
            CIStream arg = args[ ap[1] - 1 ];
            *asp = ap+3;
            cis_rewind(arg);
            return clone_input_stream( arg );
        } /* end PUT_PUT_ARG */
        if ( ap[0] == PT_VAR1 ) {
            /* special case for variable to avoid copying the value */
            char vname[2];
            size_t len;
            const char* value;
            vname[0] = ap[1];
            vname[1] = '\0';
            value = get_var(vname, TRUE, &len);
            if ( value != NULL ) {
                *asp = ap+3;
                return make_string_input_stream(value, len, FALSE);
            }
        }
    }
    if ( ap[0] == PT_OP ) {
        if ( ap[1] == OP_READ ) {
            CIStream path;
            ap += 2;
            path = function_operand( &ap, args );
            if ( *ap == PT_SEPARATOR ) {
                /* special case when operand is "@include{...}" and nothing else. */
                const char* pathname;
                CIStream istream;
                pathname = cis_whole_string(path);
                if ( strcmp(canonicalize_path(cos_pathname(output_stream)),
                            canonicalize_path(pathname))==0 ) {
                    /* Using same file for translation input and output --
                       actually read the backup file instead. */
                    if ( current_backup != NULL )
                        pathname = current_backup;
                    else input_error( input_stream, EXS_INPUT,
                                          "input and output files same but no backup\n" );
                }
                else
                    close_output(pathname);
                istream = open_input_file(pathname, binary );
                if ( istream == NULL )
                    istream = make_string_input_stream("", 0, FALSE);
                *asp = ap + 1;
                cis_close(path);
                return istream;
            }
            cis_close(path);
        } /* end OP_READ */
#if 0	/* changed my mind; use @read{-} instead of of @stdin{}   */
        else if ( ap[1] == OP_STDIN && ap[2] == PT_SEPARATOR ) {
            *asp = ap + 3;
            return stdin_stream;
        }
#endif
    } /* end PT_OP */
    {
        /* else general case */
        COStream outbuf;
        outbuf = make_buffer_output_stream();
        *asp = do_action( *asp, args, outbuf );
        return convert_output_to_input( outbuf );
    }
}
开发者ID:NeonMan,项目名称:gema,代码行数:71,代码来源:action.c


示例13: thread_callback

static void* thread_callback(void* raw_arg)
{
    return (void*) do_action((const char*) raw_arg);
}
开发者ID:dagix5,项目名称:android_system_core,代码行数:4,代码来源:crasher.c


示例14: main


//.........这里部分代码省略.........
						if (isdigit((unsigned char)argv[i][1])) {
							tmp_l = strtoll(argv[i]+1, &d, 10);
							if (!errno) {
								if (*d) {  /* separator between N and M */
									if (isdigit((unsigned char)d[1])) {
										tmp_c = strtoll(d+1, &d, 10);
										if (*d) errno = ERANGE;
									}
									else errno = ERANGE;
								}
							}
						}
						else errno = ERANGE;
					}
					if (!errno) {
						first_line = tmp_l;
						first_col  = tmp_c;
					}
					else {
						skip_plus = true;
						i--;
					}
				}
				else if (!strcmp(argv[i], "--binary")) {
					binary = true;
				}
				else if (!strcmp(argv[i], "--read-only") || !strcmp(argv[i], "--readonly") || !strcmp(argv[i], "--ro")) {
					read_only = true;
				}
				else {
					if (!strcmp(argv[i], "-") && stdin_buffer) {
						stdin_buffer->opt.binary = binary;
						if (read_only) stdin_buffer->opt.read_only = read_only;
						if (first_line) do_action(stdin_buffer, GOTOLINE_A, first_line, NULL);
						if (first_col)  do_action(stdin_buffer, GOTOCOLUMN_A, first_col, NULL);
						stdin_buffer = NULL;
					}
					else {
						if (!strcmp(argv[i], "--")) i++;
						if (!first_file) do_action(cur_buffer, NEWDOC_A, -1, NULL);
						else first_file = false;
						cur_buffer->opt.binary = binary;
						if (i < argc) do_action(cur_buffer, OPEN_A, 0, str_dup(argv[i]));
						if (first_line) do_action(cur_buffer, GOTOLINE_A, first_line, NULL);
						if (first_col)  do_action(cur_buffer, GOTOCOLUMN_A, first_col, NULL);
						if (read_only) cur_buffer->opt.read_only = read_only;
					}
					first_line =
					first_col  = 0;
					skip_plus  =
					binary    =
					read_only  = false;
				}
			}
		}

		free(skiplist);

		/* This call makes current the first specified file. It is called
		   only if more than one buffer exist. */

		if (get_nth_buffer(1)) do_action(cur_buffer, NEXTDOC_A, -1, NULL);

	}

	/* We delay updates. In this way the macro activity does not cause display activity. */
开发者ID:vigna,项目名称:ne,代码行数:67,代码来源:ne.c


示例15: server_socket_init

//int main(int argc,char *argv[])
int server_socket_init(void)
{
    struct sockaddr_in server_addr;
    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = htonl(INADDR_ANY); 
    server_addr.sin_port = htons(PORT);
    int client_sockfd =0;
	int on = 1; 
	int need_connect = 1;

    int size;
    char buffer[MAX_BUFFER + 1];
    struct sockaddr_in client_addr;
    socklen_t len = sizeof(client_addr);

    //reigster ctrl+c /ctrl+z signal.
    signal(SIGINT, signalHandler); 
    signal(SIGTSTP, signalHandler); 

    server_sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if((setsockopt(server_sockfd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof(on))) < 0) {  
        perror("setsockopt failed");  
        exit(EXIT_FAILURE);  
    }  

    bind(server_sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr));
    
    /* listen */
    listen(server_sockfd, 5);
    
    #ifndef UBUNTU_HOST
        mini_car_gpio_init();
    #endif

    while(1) 
    {
        if(need_connect) {
            printf("waiting connection...\n");
            client_sockfd = accept(server_sockfd, (struct sockaddr *)&client_addr, &len);
            need_connect = 0;
            printf("connect client ok!\n");
			start_camera();
        }

        memset(buffer, 0, MAX_BUFFER);
        size = read(client_sockfd, buffer, 4);
        // printf("Got %d bytes: %s\n", size, buffer);
        
        if(size == 0) {
            continue;
        }
        
        do_action(buffer, NULL);
        if(atoi(buffer) == MSG_STOP) {
            printf("disconnect client !\n");
            close(client_sockfd);
            client_sockfd = 0;
            need_connect = 1;
            //send_signal_to_proc(SIGINT, "mjpg_streamer");
        }
    }
    
    close(server_sockfd);
    return 0;
}
开发者ID:guomingyi2016,项目名称:chariot,代码行数:66,代码来源:server_tcp.cpp


示例16: input_autocomplete

static void input_autocomplete(void) {
	int dx = 0, prefix_pos = pos;
	char *p;

	/* find a usable prefix */
	if (prefix_pos && prefix_pos <= len) {
		prefix_pos = prev_pos(input_buffer, prefix_pos, encoding);
		dx--;
		while (prefix_pos && ne_isword(get_char(&input_buffer[prefix_pos], encoding), encoding)) {
			dx--;
			prefix_pos = prev_pos(input_buffer, prefix_pos, encoding);
		}
		if (! ne_isword(get_char(&input_buffer[prefix_pos], encoding), encoding)) {
			dx++;
			prefix_pos = next_pos(input_buffer, prefix_pos, encoding);
		}
		p = malloc(pos - prefix_pos + 1);
		if (!p) {
			alert(); /* OUT_OF_MEMORY */
			return;
		}
		strncpy(p, &input_buffer[prefix_pos], pos - prefix_pos);
	}
	else p = malloc(1); /* no prefix left of the cursor; we'll give an empty one. */
	p[pos - prefix_pos] = 0;

	int ac_err;
	if (p = autocomplete(p, NULL, true, &ac_err)) {
		encoding_type ac_encoding = detect_encoding(p, strlen(p));
		if (ac_encoding != ENC_ASCII && encoding != ENC_ASCII && ac_encoding != encoding) {
			free(p);
			alert();
		} else {
			encoding = ac_encoding;

			if (prefix_pos < pos) {
				memmove(&input_buffer[prefix_pos], &input_buffer[pos], len - pos + 1);
				len -= pos - prefix_pos;
				pos = prefix_pos;
			}
			int ac_len = strlen(p);
			if (ac_len + len >= MAX_INPUT_LINE_LEN) ac_len = MAX_INPUT_LINE_LEN - len;
			memmove(&input_buffer[pos + ac_len], &input_buffer[pos], len - pos + 1);
			memmove(&input_buffer[pos], p, ac_len);
			len += ac_len;
			while (ac_len > 0) {
				const int cw = get_char_width(&input_buffer[pos],encoding);
				pos = next_pos(input_buffer, pos, encoding);
				ac_len -= cw;
				dx++;
			}
			free(p); 
			x += dx;
			if (x >= ne_columns) {
				dx = x - ne_columns + 1;
				while (dx--) {
					offset = next_pos(input_buffer, offset, encoding);
				}
				x = ne_columns - 1;
			}
		}
	}
	if (ac_err == AUTOCOMPLETE_COMPLETED || ac_err == AUTOCOMPLETE_CANCELLED) {
		do_action(cur_buffer, REFRESH_A, 0, NULL);
		refresh_window(cur_buffer);
		set_attr(0);
		print_prompt(NULL);
	}
	input_refresh();
}
开发者ID:dmt4,项目名称:ne,代码行数:70,代码来源:input.c


示例17: production_table

lr_symbol* lr_parser::parse()
{
  /* set up direct reference to tables to drive the parser */
  production_tab = production_table();
  action_tab     = action_table();
  reduce_tab     = reduce_table();

  /* initialize the action encapsulation object */
  init_actions();

  /* do user initialization */
  user_init();

  /* get the first token */
  cur_token = scan();

  /* push dummy symbol with start state to get us underway */
  stack.remove_all_elements();
  lr_symbol dummy_sym(0, start_state());
  stack.push(&dummy_sym);

  /* continue until accept or fatal error */
  while (true)
    {
      /* Check current token for freshness. */
      assert(-1 == cur_token->parse_state);

      /* current state is always on the top of the stack */

      /* look up action out of the current state with the current input */
      int act = get_action(stack.peek()->parse_state, cur_token->sym);

      /* decode the action -- > 0 encodes shift */
      if (act > 0)
        {
          act = act - 1;

          DEBUG_LOG("Shift and goto " << act);

          /* shift to the encoded state by pushing it on the stack */
          cur_token->parse_state = act;
          stack.push(cur_token);

          /* advance to the next Symbol */
          cur_token = scan();
        }
      /* if its less than zero, then it encodes a reduce action */
      else if (act < 0)
        {
          act = (-act) - 1;

          DEBUG_LOG("Reduce by rule " << act);

          /* perform the action for the reduce */
          lr_symbol* lhs_sym = do_action(act);

          /* check for accept indication */
          if (lhs_sym == 0)
            {
              return stack.peek();
            }

          /* look up information about the production */

          lhs_sym->sym      = production_tab[act].lhs_sym;
          short handle_size = production_tab[act].rhs_size;

          /* pop the handle off the stack */
          stack.npop(handle_size);

          /* look up the state to go to from the one popped back to */
          act = get_reduce(stack.peek()->parse_state, lhs_sym->sym);

          /* shift to that state */
          lhs_sym->parse_state = act;
          stack.push(lhs_sym);

          DEBUG_LOG("      and goto " << act);
        }
      /* finally if the entry is zero, we have an error */
      else if (act == 0)
        {
          DEBUG_LOG("Error");

          /* call user syntax error reporting routine */
          syntax_error(cur_token);

          /* try to error recover */
          switch (error_recovery())
            {
            case ERS_FAIL:
              /* if that fails give up with a fatal syntax error */
              unrecovered_syntax_error(cur_token);
              return 0;
            case ERS_SUCCESS:
              break;
            case ERS_ACCEPT:
              return stack.peek();
            default:
              assert(0);
//.........这里部分代码省略.........
开发者ID:sten1ee,项目名称:cpp,代码行数:101,代码来源:lr_parser.cpp


示例18: tuxchess_handle_event

/* Event handler in Podzilla compiling style */
static int tuxchess_handle_event(GR_EVENT *event)
{
	int ret = 0;
	switch (event->type)
	{
	case GR_EVENT_TYPE_KEY_DOWN:
		switch (event->keystroke.ch)
		{
		case'm':
			do_menu();
			ret |= KEY_CLICK;
			break;

		case'w':
			if (end == 0) {
				do_rev();
				ret |= KEY_CLICK;
			}
			break;

		case'f':
			if (end == 0) {
				do_fwd();
				ret |= KEY_CLICK;
			}
			break;

		case'\r':
			if (end == 0) {
				do_action();
			}
			else if (end == 1) {
				draw_end(end_type);
			}
			else {
				new_game();
			}
			ret |= KEY_CLICK;
			break;

		case'l':
			if (end == 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ do_brk函数代码示例发布时间:2022-05-30
下一篇:
C++ do_accept函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap