Example #1
0
static int		get_msgq(t_lemipc *lemipc)
{
  if ((lemipc->msg_id = msgget(lemipc->key, FLG(0))) == -1)
    if ((lemipc->msg_id = msgget(lemipc->key, FLG(1))) == -1)
      return (lemipc_perror(MSGGET_ERROR));
  return (EXIT_SUCCESS);
}
Example #2
0
static int		get_sem(t_lemipc *lemipc)
{
  if ((lemipc->sem_id = semget(lemipc->key, 1, FLG(0))) == -1)
    {
      if ((lemipc->sem_id = semget(lemipc->key, 1, FLG(1))) == -1)
	return (lemipc_perror(SEMGET_ERROR));
      else if (semctl(lemipc->sem_id, 0, SETVAL, 1) == -1)
	return (lemipc_perror(SEMCTL_ERROR));
    }
  return (EXIT_SUCCESS);
}
Example #3
0
static int		get_shm(t_lemipc *lemipc)
{
  unsigned int		count;

  if ((lemipc->shm_id = shmget(lemipc->key, MAP_SIZE, FLG(0))) == -1)
    if ((lemipc->shm_id = shmget(lemipc->key, MAP_SIZE, FLG(1))) == -1)
      return (lemipc_perror(SHMGET_ERROR));
    else if ((lemipc->map = shmat(lemipc->shm_id, NULL, FLG(0))) == (void *)-1)
      return (lemipc_perror(SHMAT_ERROR));
    else
      {
	count = -1;
	while (++count < MAP_SIZE)
	  lemipc->map[count] = 0;
      }
  else
    if ((lemipc->map = shmat(lemipc->shm_id, NULL, FLG(0))) == (void *)-1)
      return (lemipc_perror(SHMAT_ERROR));
  return (EXIT_SUCCESS);
}
Example #4
0
#define CLI_TEST_ARGID_TRACE_FLAGS 	0
#define CLI_TEST_ARGID_DEBUG	 	1
#define CLI_TEST_ARGID_MORE_FLAGS 	2
#define CLI_TEST_ARGID_A_STRING 	3
#define CLI_TEST_ARGID_A_LONG_STRING 	4

static struct cli_arg_entry cli_args_system_modify[] = {
#if 0
	{ "trace_flags", 	{ 0, 0, 			cli_arg_parse_int32, 	"description on trace flags" } },
	{ "debug", 		{ 1, CLI_ARG_FLAG_NO_VALUE, 	NULL, 			"description on debug"} },
	{ "more_flags", 	{ 2, 0, 			cli_arg_parse_int32, 	"more flags" } },
	{ "a_string", 		{ 3, 0, 			cli_arg_parse_string, 	"a test string" } },
#else
	ARG(TRACE_FLAGS, 	"trace_flags", 		0, 	int32, "description on trace flags"),
	FLG(DEBUG, 		"debug", 				"description on debug"),
	ARG(MORE_FLAGS, 	"more_flags", 		0, 	int32, 	"description on more flags"),
	ARG(A_STRING, 		"a_string", 		0, 	string, "a test string"),
	ARG(A_LONG_STRING,	"a_long_string",	0,	string, ("Wibble is a word that I first heard a long "
									 "time ago on a British comedy show called "
									 "Black Adder. Rowan Akinson, the actor, put "
									 "on a funny face when he said it.\n"
									 "a) to make people laugh\n"
									 "b) to be stupid\n"
									 "c) wibble\n"
									 "British comedy rocks!\n")),
#endif
	{ NULL, },
};

static int cli_test_act_system_modify(struct cli_node *node, int argc, char *argv[], int *arg_num)