Example #1
0
initrd /boot/initrd

#endif

void run_test(struct parser_test *test)
{
	struct discover_boot_option *opt;
	struct discover_context *ctx;

	test_read_conf_embedded(test, "/boot/petitboot.conf");

	test_run_parser(test, "native");

	ctx = test->ctx;

	check_boot_option_count(ctx, 2);

	opt = get_boot_option(ctx, 0);

	check_name(opt, "first");
	check_resolved_local_resource(opt->boot_image, ctx->device, "/vmlinuz");
	check_args(opt, "console=hvc0");
	check_resolved_local_resource(opt->initrd, ctx->device, "/initrd");
	check_is_default(opt);

	opt = get_boot_option(ctx, 1);
	check_name(opt, "second");
	check_resolved_local_resource(opt->boot_image, ctx->device, "/boot/vmlinuz");
	check_args(opt, "console=tty0");
	check_resolved_local_resource(opt->initrd, ctx->device, "/boot/initrd");
}
Example #2
0
int
main(int argc, const char *const argv[])
{
    int exitcode;

    check_args(argc, argv, 2);

    if (strcmp(argv[1], "echo") == 0) {
        check_args(argc, argv, 3);
        exitcode = h_echo(argv[2]);
    } else if (strcmp(argv[1], "exit-failure") == 0)
        exitcode = h_exit_failure();
    else if (strcmp(argv[1], "exit-signal") == 0)
        exitcode = h_exit_signal();
    else if (strcmp(argv[1], "exit-success") == 0)
        exitcode = h_exit_success();
    else if (strcmp(argv[1], "stdout-stderr") == 0) {
        check_args(argc, argv, 3);
        exitcode = h_stdout_stderr(argv[2]);
    } else {
        fprintf(stderr, "%s: Unknown helper %s\n", argv[0], argv[1]);
        exitcode = EXIT_FAILURE;
    }

    return exitcode;
}
Example #3
0
bool ZorbaCMDProperties::loadProperties(int argc, char* argv[]) 
{
  std::string result = load_argv(argc, (const char **) argv);

  if (result.empty())
    result = check_args();

  if (result == "!HELP") 
  {
    std::cout << "Zorba XQuery Engine, Version: " 
              << zorba::Zorba::version() << std::endl;
    std::cout << "Available options:\n\n";
    std::cout << get_help_msg ();
    return false;
  }
  else if (result == "!VER") 
  {
    std::cout << "Zorba XQuery Engine, Version: " 
              << zorba::Zorba::version() << std::endl;
    return false;
  }
  else if (result.empty ())
  {
    return true;
  }
  else if (result [0] != '!')
  {
    std::cout << "Error: " << result << std::endl;
    return false;
  }
  else
  {
    return false;
  }  
}
Example #4
0
int			main(int ac, char **av)
{
	pid_t	pid;
	int		i;
	long	tab_set[MAX_FRACTALS];
	int		nbr_frac;

	i = 0;
	ft_memset(tab_set, 0, MAX_FRACTALS);
	(ac == 2 && !ft_strcmp("-all", av[1]) ? show_them_all(tab_set, &nbr_frac) :
	check_args(ac, av, tab_set, &nbr_frac));
	while (i < nbr_frac)
	{
		pid = fork();
		if (pid == -1)
		{
			perror("Error forking");
			return (EXIT_FAILURE);
		}
		if (pid == 0)
			start_fractal((void *)tab_set[i]);
		i++;
	}
	if (pid > 0)
		waitpid(-1, NULL, 0);
	return (EXIT_SUCCESS);
}
Example #5
0
/**
 * Main function
 * checks commandline args with check_args, then calls detect()
 */
int main(int argc, char* argv[])
{
    /* Check ARGs */
    if(check_args(argc, argv) != EXIT_SUCCESS)
        return EXIT_FAILURE;
    return detect();
}
Example #6
0
int	op_add(t_action *action, char *str, t_pos *pos)
{
  int	i;
  char	c;
  char	type;
  char	**tab;
  char	**list_arg;

  if ((c = 0) || !(pos->prog_size += 2) ||
      !(i = -1) || !(action->identifier = 0x04) ||
      !(action->args = malloc(sizeof(t_arg *) * 4)) ||
      !(tab = str_to_word_tab(str, ',')) ||
      !(list_arg = str_to_word_tab("1 1 1", ' ')) ||
      init_args(action, 3))
    return (1);
  while (tab[++i])
    {
      if (i > 2 || (type = check_type(tab[i], pos)) == -1 ||
	  check_args(type, list_arg[i], pos) ||
	  fill_arg(type, tab[i], action->args[i], action->pos - i - 1))
	return (1);
      add_prog_size(type, pos);
      c += (type << (6 - (i * 2)));
    }
  action->coding_byte = c;
  return (free_tab(tab), free_tab(list_arg), (i < 3) ? 1 : 0);
}
int check_args_enc(type_image *img) {
	if (strstr(img->in_file, ".bsq") != NULL)
		img->bsq_file = 1;
	if (strstr(img->in_file, ".bip") != NULL)
		img->bip_file = 1;
	if (strstr(img->in_file, ".bil") != NULL)
		img->bil_file = 1;

	if (img->in_hfile != NULL) {
		if (strstr(img->in_hfile, ".hdr") == NULL) {
			fprintf(stderr, "Wrong header file: %s! (Should be *.hdr)\n", img->in_hfile);
			return ERROR;
		} else {
			if ((strstr(img->in_file, ".bsq") == NULL) && (strstr(img->in_file, ".bip") == NULL) && (strstr(
					img->in_file, ".bil") == NULL)) {
				fprintf(stderr, "Wrong image file: %s! (Should be one of following: *.bsq, *.bip, *.bil)\n",
						img->in_file);
				return ERROR;
			}
		}
	} else {
		if (strstr(img->out_file, ".j2k") == NULL) {
			fprintf(stderr, "Wrong extension: %s (Should be *.j2k)\n", img->out_file);
			return ERROR;
		}
	}

	return check_args(img);
}
static int rbody_ranged_scatter (lua_State *L)
{
TRY_START
        check_args(L, 12);
        GET_UD_MACRO(RigidBody, self, 1, RBODY_TAG);
        std::string mat    = check_path(L, 2);
        GET_UD_MACRO(GfxRangedInstancesPtr, gri, 3, GFXRANGEDINSTANCES_TAG);
        float density       = check_float(L, 4);
        float min_slope     = check_float(L, 5);
        float max_slope     = check_float(L, 6);
        float min_elevation = check_float(L, 7);
        float max_elevation = check_float(L, 8);
        bool no_z           = check_bool(L, 9);
        bool rotate         = check_bool(L, 10);
        bool align_slope    = check_bool(L, 11);
        unsigned seed       = check_t<unsigned>(L, 12);

        SimpleTransform world_trans(self.getPosition(), self.getOrientation());

        self.colMesh->scatter(phys_mats.getMaterial(mat)->id,
                              world_trans, density, min_slope, max_slope, min_elevation,
                              max_elevation, no_z, rotate, align_slope, seed,
                              *gri);

        return 0;
TRY_END
}
static void
ybinomial(void)
{
	K = pop();
	N = pop();

	if (check_args() == 0) {
		push(zero);
		return;
	}

	push(N);
	factorial();

	push(K);
	factorial();

	divide();

	push(N);
	push(K);
	subtract();
	factorial();

	divide();
}
int python_exec_string(void)
{
    if( !python_is_initialised_check() )
        return 0;

    EmacsString command;

    if( cur_exec == NULL )
    {
        EmacsString prompt( ": Python-exec " );

        command = get_string_interactive( prompt );
    }
    else
    {
        if( check_args( 1, 1 ) )
            return 0;

        command = get_string_mlisp();
    }

    EmacsPythonExecCommand py_command( command );

    py_command.executeCommand();

    if( py_command.failed() )
        error( py_command.failureReason() );
    else
        ml_value = py_command.getResult();

    return 0;
}
initrd /initrd
#endif

void run_test(struct parser_test *test)
{
	struct discover_boot_option *opt;
	struct discover_context *ctx;

	test_read_conf_embedded_url(test, "tftp://host/path/to/conf.txt");

	test_set_event_source(test);
	test_set_event_param(test->ctx->event, "pxepathprefix",
			"tftp://host/path/to/");
	test_set_event_param(test->ctx->event, "pxeconffile", "conf.txt");

	test_run_parser(test, "pxe");

	ctx = test->ctx;

	check_boot_option_count(ctx, 1);
	opt = get_boot_option(ctx, 0);

	check_name(opt, "linux");
	check_args(opt, "command line");

	check_resolved_url_resource(opt->boot_image,
			"tftp://host/path/to/./kernel");
	check_resolved_url_resource(opt->initrd,
			"tftp://host/path/to/initrd");
}
Example #12
0
static VALUE strongtyping_overload(int argc, VALUE *argv, VALUE self UNUSED) {
  struct RArray *q;
    
  if(argc < 1)
    rb_raise(rb_eArgError, "At least one parameter required");

  Check_Type(argv[0], T_ARRAY);
  q = RARRAY(argv[0]);

  if(RARRAY_LEN(q) && rb_funcall(RARRAY_PTR(q)[0], id_isa, 1, cQueryParams)) {
    rb_funcall(RARRAY_PTR(q)[0], rb_intern("<<"), 1, rb_ary_new4(argc - 1, argv + 1));
    return Qnil;
  }

  if(RARRAY_LEN(q) != (argc - 1))
    return Qnil;

  if(check_args(argc - 1, RARRAY_PTR(q), argv + 1) < 0){
    if(argc == 2)
      rb_yield(*RARRAY_PTR(*argv));
    else
      rb_yield(*argv);
  }

  return Qnil;
}
Example #13
0
int main(int argc, char** argv) {
    nabto_main_setup* nms = unabto_init_context();

    stream_echo_init();
    
    if (!check_args(argc, argv, nms)) {
        return 1;
    }

    if (!unabto_init()) {
        return 1;
    }
    
    while(true) {
        unabto_tick();
#ifdef WIN32
        Sleep(1);
#endif
#if (_POSIX_C_SOURCE >= 199309L)
        struct timespec sleepTime;
        sleepTime.tv_sec = 0;
        sleepTime.tv_nsec = 10*1000000;
        nanosleep(&sleepTime, NULL);
#endif
    }
    
    unabto_close();
}
Example #14
0
int		main(int ac, char **av)
{
  t_args	option;

  if (ac < 5)
    return (usage(av[0]));
  signal(SIGINT, &signal_handler);
  signal(SIGPIPE, SIG_IGN);
  srand(time(NULL) + getpid());
  init_args(&option);
  if (check_args(ac, av, &option) == false
      || check_all_args(&option) == false)
    return (usage(av[0]));
  display_init(&option);
  g_s.global_time = 0;
  g_s.id_egg = 1;
  g_s.other_size = 0;
  if ((g_s.sock = init_server(option.port)) == -1)
    return (display_error("Error : Could not init the server.\n"));
  printf("**** Initialization done\n");
  init_map(&g_s, option.width, option.height);
  init_team(&g_s, option.nb_client, option.team_name);
  init_stone(&g_s, option.width * option.height);
  g_s.option = &option;
  server_loop(&g_s);
  xclose(g_s.sock);
  return (0);
}
Example #15
0
static int global_current_dir (lua_State *L)
{
    check_args(L, 0);
    std::string dir = lua_current_dir(L);
    push_string(L, dir);
    return 1;
}
Example #16
0
int				check_size(char *line, char *col, t_gboard *board)
{
	int		check_int;

	if ((check_int = check_args(line, col)) == -1)
	{
		ft_puterr(P4_ERROR);
		ft_puterr(P4_COORDS);
		ft_puterr("\n");
		return (-1);
	}
	else
	{
		board->nb_columns = ft_atoi(col);
		board->nb_lines = ft_atoi(line);
		if (board->nb_lines < 6 || board->nb_columns < 7)
		{
			ft_puterr(P4_ERROR);
			ft_puterr(P4_SIZE);
			ft_puterr("\n");
			return (-1);
		}
	}
	return (0);
}
Example #17
0
int
mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
{
	v_pre		*p;
	int		 line, pos;
	char		*tp;

	switch (n->type) {
	case (MDOC_TEXT):
		tp = n->string;
		line = n->line;
		pos = n->pos;
		check_text(mdoc, line, pos, tp);
		/* FALLTHROUGH */
	case (MDOC_TBL):
		/* FALLTHROUGH */
	case (MDOC_ROOT):
		return(1);
	default:
		break;
	}

	check_args(mdoc, n);

	if (NULL == mdoc_valids[n->tok].pre)
		return(1);
	for (p = mdoc_valids[n->tok].pre; *p; p++)
		if ( ! (*p)(mdoc, n)) 
			return(0);
	return(1);
}
static int global_physics_test (lua_State *L)
{
TRY_START
        LuaTestCallback lcb;
        push_cfunction(L, my_lua_error_handler);
        int error_handler = lua_gettop(L);
        if (lua_gettop(L)==5) {
                float radius = lua_tonumber(L, 1);
                Vector3 pos = check_v3(L, 2);
                bool only_dyn = check_bool(L, 3);
                if (lua_type(L, 4) != LUA_TFUNCTION)
                        my_lua_error(L, "Parameter 4 should be a function.");

                physics_test_sphere(radius, pos, only_dyn, lcb);
                lcb.pushResults(L, 4, error_handler);
        } else {
                check_args(L, 6);
                std::string col_mesh_name = check_path(L, 1);
                DiskResource *col_mesh_ = disk_resource_get_or_make(col_mesh_name);
                CollisionMesh *col_mesh = dynamic_cast<CollisionMesh*>(col_mesh_);
                if (col_mesh==NULL) my_lua_error(L, "Not a collision mesh: \""+col_mesh_name+"\"");
                if (!col_mesh->isLoaded()) my_lua_error(L, "Not loaded: \""+col_mesh_name+"\"");
                Vector3 pos = check_v3(L, 2);
                Quaternion quat = check_quat(L, 3);
                bool only_dyn = check_bool(L, 4);
                if (lua_type(L, 5) != LUA_TFUNCTION)
                        my_lua_error(L, "Parameter 5 should be a function.");

                physics_test(col_mesh, pos, quat, only_dyn, lcb);
                lcb.pushResults(L, 5, error_handler);
        }
        lua_pop(L, 1); // error handler
        return 0;
TRY_END
}
Example #19
0
kernel vmlinux --name test-option append kernel args
initrd initrd
#endif

/**
 * Test that we recognise an ipxe-formatted script obtained from bootfile_url
 * (DHCPv6 option 59) that some vendors use, and that we correctly parse the
 * --name parameter from the kernel arguments.
 */

void run_test(struct parser_test *test)
{
	struct discover_boot_option *opt;
	struct discover_context *ctx;

	test_read_conf_embedded_url(test, "tftp://host/dir1/conf");

	test_set_event_source(test);
	test_set_event_param(test->ctx->event, "bootfile_url", "tftp://host/dir1/conf");

	test_run_parser(test, "pxe");

	ctx = test->ctx;

	check_boot_option_count(ctx, 1);
	opt = get_boot_option(ctx, 0);

	check_name(opt, "test-option");

	check_resolved_url_resource(opt->boot_image,
			"tftp://host/dir1/vmlinux");
	check_resolved_url_resource(opt->initrd,
			"tftp://host/dir1/initrd");
	check_args(opt, "append kernel args");
}
Example #20
0
int main(int argc, char *argv[])
{
  int loop;
  check_args(argc);
  for (loop=0;loop<=19-1;loop++)
  {
    inData[loop] = 0;
  }
  unsigned short addlist[2] = {atoi(argv[1]), NOADDR}; // list to enable inst 

  //Reset Card 0 (i.e:gpib0)
  SendIFC(0);
  // ENABLE all on GPIB bus
  EnableRemote(0, addlist);
  // If error, Bye!
  if (ibsta & ERR)
  {
    printf("Instrument enable failed!\n");
    exit(1);
  }

  // Send (BoardID, GPIBAddr, Command, LengthCommand, Endline)
  // typical command:
  // Send(0, 20, "*RST", 4l, NLend);
  Send(0, atoi(argv[1]), argv[2], strlen(argv[2]), NLend);
  Receive(0, atoi(argv[1]), inData, 19, STOPend);
  printf("%s",inData);
}
Example #21
0
dtb ./pxe/de-ad-de-ad-be-ef.dtb
#endif

void run_test(struct parser_test *test)
{
	struct discover_boot_option *opt;
	struct discover_context *ctx;

	test_read_conf_embedded_url(test, "tftp://host/dir/conf.txt");

	test_set_event_source(test);
	test_set_event_param(test->ctx->event, "pxeconffile",
			"tftp://host/dir/conf.txt");

	test_run_parser(test, "pxe");

	ctx = test->ctx;

	check_boot_option_count(ctx, 1);
	opt = get_boot_option(ctx, 0);

	check_name(opt, "linux");
	check_args(opt, "command line");

	check_resolved_url_resource(opt->boot_image,
			"tftp://host/dir/./pxe/de-ad-de-ad-be-ef.vmlinuz");
	check_resolved_url_resource(opt->initrd,
			"tftp://host/dir/./pxe/de-ad-de-ad-be-ef.initrd");
	check_resolved_url_resource(opt->dtb,
			"tftp://host/dir/./pxe/de-ad-de-ad-be-ef.dtb");
}
Example #22
0
void
cmd_dump (int argc, char **argv)
{
  mu_off_t off = 0;
  size_t n;
  mu_stream_t stream;
  char buf[512];
  int status;
  
  if (check_args (argv[0], argc, 1, 2))
    return;

  if (argc == 2)
    off = strtoul (argv[1], NULL, 0);

  status = mu_header_get_stream (header, &stream);
  if (status)
    {
      mu_error ("%u: cannot get stream: %s", line_num, mu_strerror (status));
      return;
    }

  status = mu_stream_seek (stream, off, SEEK_SET);
  if (status)
    {
      mu_error ("%u: cannot seek: %s", line_num, mu_strerror (status));
      return;
    }

  while (mu_stream_sequential_read (stream, buf, sizeof buf, &n) == 0
	 && n > 0)
    {
      fwrite (buf, 1, n, stdout);
    }
}  
Example #23
0
void
cmd_write (int argc, char **argv)
{
  char buf[512];
  mu_stream_t str;
  int status;
  
  if (check_args (argv[0], argc, 1, 1))
    return;

  status = mu_header_get_stream (header, &str);
  if (status)
    {
      mu_error ("%u: cannot get stream: %s", line_num, mu_strerror (status));
      return;
    }
  printf("[reading headers; end with an empty line]\n");
  mu_stream_seek (str, 0, SEEK_SET);
  while (prompt (1), fgets(buf, sizeof buf, stdin))
    {
      mu_stream_sequential_write (str, buf, strlen (buf));
      if (buf[0] == '\n')
	break;
    }
}
Example #24
0
int main(int argc, char **argv)
{
  int ts = 0, var = 0;
  init_mpi(argc, argv);
  parse_args(argc, argv);
  check_args();
  calculate_per_process_offsets();
  create_synthetic_simulation_data();

  rank_0_print("Simulation Data Created\n");

  create_pidx_var_point_and_access();
  for (ts = 0; ts < time_step_count; ts++)
  {
    set_pidx_file(ts);
    for (var = 0; var < variable_count; var++)
      set_pidx_variable(var);
    PIDX_close(file);
  }
  destroy_pidx_var_point_and_access();

  destroy_synthetic_simulation_data();
  shutdown_mpi();

  return 0;
}
static int stringdb_index(lua_State *L)
{
TRY_START
        check_args(L,2);
        GET_UD_MACRO(StringDB,self,1,STRINGDB_TAG);
        if (lua_type(L,2)==LUA_TNUMBER) {
                if (self.size()==0) {
                        my_lua_error(L,"Empty stringdb");
                }
                unsigned short index=check_t<unsigned short>(L,2,1,self.size());
                lua_pushstring(L,self[index-1].c_str());
        } else {
                std::string key  = luaL_checkstring(L,2);
                if (key=="add") {
                        push_cfunction(L,stringdb_add);
                } else if (key=="clear") {
                        push_cfunction(L,stringdb_clear);
                } else if (key=="table") {
                        lua_createtable(L, self.size(), 0);
                        for (unsigned int i=0 ; i<self.size() ; i++) {
                                lua_pushnumber(L,i+1);
                                lua_pushstring(L,self[i].c_str());
                                lua_settable(L,-3);
                        }
                } else {
                        my_lua_error(L,"Not a readable StringDB member: "+key);
                }
        }
        return 1;
TRY_END
}
Example #26
0
void pciconfread(int dmod, int offset, int count)
{
    int err = 0;
    short dbytes;

    if(!diagdev) {
        printf("Run pcidiagset first\n");
        return;
    }

    if(check_args(dmod, offset, count))
        return;

    dbytes=dmod/8;

    count/=dbytes;
    if(count==0) count=1;

    for(;count && !err;offset+=dbytes,count--) {
        epicsUInt8 u8;
        epicsUInt16 u16;
        epicsUInt32 u32;
        printf("0x%04x ", offset);
        switch(dmod) {
        case 8: err = devPCIConfigRead8(diagdev, offset, &u8); printf("%02x\n", u8); break;
        case 16: err = devPCIConfigRead16(diagdev, offset, &u16); printf("%04x\n", u16); break;
        case 32: err = devPCIConfigRead32(diagdev, offset, &u32); printf("%08x\n", u32); break;
        default:
            printf("Invalid dmod %d, must be 8, 16, or 32\n", dmod);
            break;
        }
    }
    if(err)
        printf("read error %d\n", err);
}
Example #27
0
void pciread(int dmod, int offset, int count)
{
  epicsUInt32 tval;
  volatile char* dptr;
  short dbytes;
  int i;

  if(!diagbase) {
      printf("Run pcidiagset first\n");
      return;
  }

  if(check_args(dmod, offset, count))
      return;

  dbytes=dmod/8;

  count/=dbytes;
  if(count==0) count=1;

  for(i=0, dptr=diagbase+offset; i<count; i++, dptr+=dbytes) {
      if ((i*dbytes)%16==0)
          printf("\n0x%08x ",i*dbytes);
      else if ((i*dbytes)%4==0)
          printf(" ");

      switch(dmod){
      case 8:  tval=ioread8(dptr); printf("%02x",tval);break;
      case 16: tval=nat_ioread16(dptr);printf("%04x",tval);break;
      case 32: tval=nat_ioread32(dptr);printf("%08x",tval);break;
      }
  }
  printf("\n");
}
Example #28
0
void
cmd_free (int argc, char **argv)
{
  if (check_args (argv[0], argc, 1, 1))
    return;
  mu_iterator_destroy (&iterator);
  mu_header_destroy (&header, NULL);
}
Example #29
0
void
cmd_load (int argc, char **argv)
{
  if (check_args (argv[0], argc, 2, 2))
    return;
  mu_header_destroy (&header, NULL);
  load_file (argv[1]);
}
static int global_physics_option_reset (lua_State *L)
{
TRY_START
        check_args(L, 0);
        physics_option_reset();
        return 0;
TRY_END
}