예제 #1
0
static t_bool	check_right(t_token *b, t_token *e)
{
  int		r;
  int		l;
  int		word;

  word = 0;
  r = 0;
  if (b->id != WORD)
    return (check_prefix_exec(&b, e, &l, &r));
  while (b && b != e)
    {
      if (b->id == S_RED_RIGHT || b->id == D_RED_RIGHT ||
	  b->id == S_RED_RIGHT_ERR || b->id == D_RED_RIGHT_ERR)
	{
	  if (!word)
	    return (puterror(AMB_OUT, NULL));
	  r++;
	}
      else if (r >= 1 && b->id != WORD)
	return (puterror(AMB_OUT, NULL));
      word = (b->id == WORD) ? (1) : (0);
      b = b->next;
    }
  if (!word && r == 1)
    return (puterror(MISSING_N, NULL));
  return ((r > 1) ? (puterror(AMB_OUT, NULL)) : (TRUE));
}
예제 #2
0
int		check_str_redi(char *str)
{
  unsigned int	i;

  i = 0;
  while (str[i])
  {
    if ((str[i] == '>' && str[i + 1] == '>' && str[i + 2] == '>')
	|| (str[i] == '>' && str[i + 1] == ' ' && str[i + 2] == '>'))
      return (puterror("error: expression expected near '>'.\n"));
    if ((str[i] == '<' && str[i + 1] == '<' && str[i + 2] == '<')
	|| (str[i] == '<' && str[i + 1] == ' ' && str[i + 2] == '<'))
      return (puterror("error: expression expected near '<'.\n"));
    if ((str[i] == '>' || str[i] == '<')
	&& (str[i + 1] == '|' || str[i + 1] == '\0'
	    || (str[i + 1] == ' '
		&& (str[i + 2] == '\0' || str[i + 2] == '|'))))
      return (puterror("error: expression expected near '<' or '>'.\n"));
    if ((str[i] == '>' && str[i + 1] == '<')
	|| (str[i] == '<' && str[i + 1] == '>'))
      return (puterror("error: expression expected near '<' or '>'.\n"));
    i += 1;
  }
  return (0);
}
예제 #3
0
int		check_str(char *str)
{
  unsigned int	i;

  i = 0;
  if (check_str_redi(str) == -1)
    return (-1);
  if (str[0] == ';' || str[0] == '|')
    return (puterror("error: expression expected near ';' or '|'.\n"));
  while (str[i])
  {
    if ((str[i] == ';' || str[i] == '|')
	&& ((str[i + 1] == ';' || str[i + 1] == '|')
	    || (str[i + 1] == ' '
		&& (str[i + 2] == ';' || str[i + 2] == '|'))))
    {
      puterror("error: expression expected between ';' or '|'.\n");
      return (-1);
    }
    i += 1;
  }
  if (str[i - 1] == ';' || str[i - 1] == '|')
    return (puterror("error: expression expected near ';' or '|'.\n"));
  return (0);
}
예제 #4
0
int		do_redirections(t_pipe *list_pipe,
				int i,
				char **env,
				int is_redi)
{
  int		ret;

  ret = 0;
  if (list_pipe->cmd[i]->is_redi_left != 0)
    ret += do_redi_left(list_pipe, i, env);
  else if (is_redi == 1)
  {
    if (list_pipe->list_in[i] != -1)
      if ((dup2(list_pipe->list_in[i], 0)) == -1)
	return (puterror("error: dup2\n"));
  }
  if (list_pipe->cmd[i]->is_redi_right != 0)
    ret += do_redi_right(list_pipe, i);
  else if (is_redi == 1)
  {
    if (list_pipe->list_out[i] != -1)
      if ((dup2(list_pipe->list_out[i], 1)) == -1)
        return (puterror("error: dup2\n"));
  }
  restore_term(&term_attr);
  return (ret);
}
예제 #5
0
static t_bool	check_left(t_token *b, t_token *e)
{
  int		r;
  int		l;
  int		word;

  word = 0;
  l = 0;
  r = 0;
  if (b->id != WORD)
    return (check_prefix_exec(&b, e, &l, &r));
  while (b && b != e)
    {
      if (b->id == PIPE || b->id == S_RED_LEFT || b->id == D_RED_LEFT)
	{
	  if (!word || (b->id == PIPE && r == 0))
	    return (puterror(AMB_IN, NULL));
	  r++;
	}
      if (l >= 1 && (b->id == S_RED_LEFT || b->id == D_RED_LEFT))
	return (puterror(AMB_IN, NULL));
      word = (b->id == WORD) ? (1) : (0);
      b = b->next;
    }
  if (!word && l == 1)
    return (puterror(MISSING_N, NULL));
  return ((l > 1) ? (puterror(AMB_IN, NULL)) : (TRUE));
}
예제 #6
0
int		error_boss(char *map)
{
  char		*file;
  char		**tab;
  int		width;
  int		height;

  if (check_existence(map) == -1
      || (file = get_file_content(map)) == NULL
      || check_integer(file, "ibwsm.lg\n") == -1
      || (file = put_return(file)) == NULL
      || (tab = my_str_to_wordtab(file, '\n')) == NULL
      || check_largest(tab) == -1
      || is_present("i", file) != 1
      || is_present("b", file) != 1
      || check_tab(tab) == -1)
    return (puterror("One of Boss map isn't correct.\n"));
  width = my_strlen(tab[0]) * 29;
  height = tablen(tab) * 26;
  if (width > 1300 || height > 750)
    return (puterror("Error: Dimension are too big in Boss Map.\n"));
  free(file);
  free_tab(tab);
  return (0);
}
예제 #7
0
t_bool	check_grammar_exec(t_token *b, t_token *e)
{
  t_token	*tmp;
  int		word;
  int		pipe;
  int		res;

  tmp = b;
  word = 0;
  pipe = 0;
  while (tmp && tmp != e)
    {
      if (!word && tmp->id == PIPE)
	return (puterror(NULL_CMD, NULL));
      word = (tmp->id == WORD) ? (1) : (0);
      pipe = (tmp->id == PIPE) ? (1) : (0);
      tmp = tmp->next;
    }
  if (pipe)
    return (puterror(NULL_CMD, NULL));

  res = there_are_red(b, e);
  if (res == 1 && check_left(b, e) != TRUE)
    return (FALSE);
  else if (res == 2 && check_right(b, e) != TRUE)
    return (FALSE);
  return (TRUE);
}
예제 #8
0
int
ckkeywd(char *strval, char *keyword[], char *defstr, char *error, char *help,
	char *prompt)
{
	int valid, i, n;
	char input[MAX_INPUT];
	char defmesg[512];
	char *ept;

	(void) sprintf(defmesg, "Please enter one of the following keywords: ");
	ept = defmesg + strlen(defmesg);
	for (i = 0; keyword[i]; ) {
		if (i)
			(void) strcat(ept, ", ");
		(void) strcat(ept, keyword[i++]);
	}
	(void) strcat(ept, ckquit ? ", q." : ".");

	if (!prompt)
		prompt = "Enter appropriate value";

start:
	putprmpt(stderr, prompt, keyword, defstr);
	if (getinput(input))
		return (1);

	n = (int)strlen(input);
	if (n == 0) {
		if (defstr) {
			(void) strcpy(strval, defstr);
			return (0);
		}
		puterror(stderr, defmesg, error);
		goto start;
	}
	if (strcmp(input, "?") == 0) {
		puthelp(stderr, defmesg, help);
		goto start;
	}
	if (ckquit && (strcmp(input, "q") == 0)) {
		(void) strcpy(strval, input);
		return (3);
	}

	valid = 1;
	if (keyword)
		valid = !match(input, keyword);

	if (!valid) {
		puterror(stderr, defmesg, error);
		goto start;
	}
	(void) strcpy(strval, input);
	return (0);
}
예제 #9
0
int		check_key_door(char *file)
{
  if (is_present("i", file) != 1)
    return (puterror("Error: the map must countain one entry.\n"));
  else
    if (is_present("o", file) != 1)
      return (puterror("Error: the map must countain one door.\n"));
    else
      if (is_present("k", file) != 1)
	return (puterror("Error: the map must countain one key.\n"));
      else
	return (0);
}
예제 #10
0
static int	do_redi_right(t_pipe *list_pipe, int i)
{
  int		fd;
  int		flags;

  fd = 0;
  flags = O_CREAT | O_RDWR;
  flags |= (list_pipe->cmd[i]->is_redi_right == 1) ? (O_TRUNC) : (O_APPEND);
  if ((fd = open(list_pipe->cmd[i]->redi_right, flags, 0644)) == -1)
    return (puterror("error: open\n"));
  if ((dup2(fd, 1)) == -1)
    return (puterror("error: dup2\n"));
  return (fd);
}
예제 #11
0
char	*history_substitution(char *cmd, t_history *list, char **type_str)
{
  int	i;
  ptr_f_history subs[5];
  char *save_cmd;

  save_cmd = strdup(cmd);
  create_ptr_func_history(subs);
  i = -1;
  if (cmd && cmd[0])
    while (subs[++i] && strchr(type_str[i], cmd[1]) == NULL);
  else
    return (NULL);
  if (subs[i] == NULL)
    {
      fprintf(stderr, "%s : Event not found.\n", cmd);
      return (NULL);
    }
  if (cmd && cmd[0] && cmd[1])
    {
      if ((cmd = subs[i](&cmd[1], list)) == NULL)
	return (puterror(save_cmd, i));
      printf("%s\n", cmd);
      return (cmd);
    }
  return (NULL);
}
예제 #12
0
파일: hsplua.cpp 프로젝트: MihailJP/hsplua
static int cmdfunc( int cmd )
{
	//		実行処理 (命令実行時に呼ばれます)
	//
	code_next();							// 次のコードを取得(最初に必ず必要です)

	switch( cmd ) {							// サブコマンドごとの分岐
		case 0x00: hsplua_cmd::hl_newstate();             break;
		case 0x01: hsplua_cmd::hl_switchstate();          break;
		case 0x02: hsplua_cmd::hl_close();                break;
		case 0x04: hsplua_cmd::hl_gccollect();            break;
		case 0x05: hsplua_cmd::hl_gcgen();                break;
		case 0x06: hsplua_cmd::hl_gcinc();                break;
		case 0x07: hsplua_cmd::hl_gcrestart();            break;
		case 0x08: hsplua_cmd::hl_gcsetpause();           break;
		case 0x09: hsplua_cmd::hl_gcsetstepmul();         break;
		case 0x0a: hsplua_cmd::hl_gcstep();               break;
		case 0x0b: hsplua_cmd::hl_gcstop();               break;
		case 0x10: hsplua_cmd::hl_pop();                  break;
		case 0x11: hsplua_cmd::hl_pushboolean();          break;
		case 0x12: hsplua_cmd::hl_pushfunction();         break;
		case 0x13: hsplua_cmd::hl_pushinteger();          break;
		case 0x14: hsplua_cmd::hl_pushlightuserdata();    break;
		case 0x15: hsplua_cmd::hl_pushlstring();          break;
		case 0x16: hsplua_cmd::hl_pushnil();              break;
		case 0x17: hsplua_cmd::hl_pushnumber();           break;
		case 0x18: hsplua_cmd::hl_pushstring();           break;
		case 0x19: hsplua_cmd::hl_pushvalue();            break;
		case 0x1a: hsplua_cmd::hl_pushvarptr();           break;
		default: puterror( HSPERR_UNSUPPORTED_FUNCTION ); break;
	}
	return RUNMODE_RUN;
}
예제 #13
0
static t_bool	get_spe_red(t_node **r, t_token *b, t_token *e)
{
  t_token	*tmp;
  t_token	*tok;

  tmp = b;
  while (tmp && tmp != e && tmp->id != S_RED_RIGHT && tmp->id != D_RED_RIGHT &&
	       tmp->id != D_RED_RIGHT_ERR && tmp->id != S_RED_RIGHT_ERR)
    tmp = tmp->next;
  if (!tmp ||  !tmp->next)
    return (puterror(MISSING_N, NULL));
  tok = tmp->next;
  if (add_node(r, tmp->id, tmp->content) == EXIT_FAILURE)
    return (ERROR);
  if (add_child(r) == EXIT_FAILURE)
    return (ERROR);
  if (add_node(&((*r)->child->nd), CMD, tmp->next->content) == EXIT_FAILURE)
    return (ERROR);
  if (get_spe_red_ext(r, &tmp, e) == FALSE)
    return (ERROR);
  if (add_child(r) == EXIT_FAILURE)
    return (ERROR);
  if (check_red(b, tok, &((*r)->child->nd)) != TRUE)
    return (FALSE);
  return (TRUE);
}
예제 #14
0
static t_bool	check_red(t_token *b, t_token *e, t_node **root)
{
  t_token	*begin;
  t_token	*end;
  t_token	*file;
  int		type;

  type = b->id;
  end = e;
  if (b->id != WORD)
    get_pre_exec(b->next, &file, &begin, &end);
  else
    type = get_exec(b, &file, &begin, &end);
  add_node(root, type, NULL);
  add_child(root);
  if (!file)
    return (puterror(MISSING_N, NULL));
  add_node(&((*root)->child->nd), CMD, file->content);
  add_child(root);
  add_node(&((*root)->child->nd), CMD, begin->content);
  begin = begin->next;
  while (begin && begin != end)
    {
      add_child(&((*root)->child->nd));
      add_node(&((*root)->child->nd->child->nd), ARG, begin->content);
      begin = begin->next;
    }
  my_rev_node(&((*root)->child->nd->child));
  return (TRUE);
}
예제 #15
0
파일: init_sdl.c 프로젝트: Alban95/epikong
int		init_my_sdl(t_struct *st)
{
  st->pos.x = 0;
  st->pos.y = 0;
  st->ecran = NULL;
  if (SDL_Init(SDL_INIT_VIDEO) == -1
      || (st->ecran = SDL_SetVideoMode(st->width,
				       st->height, 32, SDL_HWSURFACE)) == NULL)
    return (puterror("Error: In init SDL.\n"));
  SDL_EnableKeyRepeat(50, 50);
  if (st->world_sel == 1)
    SDL_FillRect(st->ecran, NULL,
		 SDL_MapRGB(st->ecran->format, 143, 126, 126));
  else
    if (st->world_sel == 2)
      SDL_FillRect(st->ecran, NULL,
		 SDL_MapRGB(st->ecran->format, 151, 227, 255));
    else
      if (st->world_sel == 3)
	SDL_FillRect(st->ecran, NULL,
		     SDL_MapRGB(st->ecran->format, 100, 1, 1));
  SDL_WM_SetCaption("EPIKONG", NULL);
  SDL_WM_SetIcon(IMG_Load("./conf/img/logo.png"), NULL);
  init_my_sound();
  return (0);
}
예제 #16
0
//------------------------------------------------
// 値をシステム変数に代入する
//------------------------------------------------
void SetResultSysvar(PDAT const* data, vartype_t vtype)
{
	if ( !data ) return;

	ctx->retval_level = ctx->sublev;

	switch ( vtype ) {
		case HSPVAR_FLAG_INT:
			ctx->stat = VtTraits::derefValptr<vtInt>(data);
			break;

		case HSPVAR_FLAG_STR:
			strcpy_s(
				ctx->refstr, HSPCTX_REFSTR_MAX,
				VtTraits::asValptr<vtStr>(data)
			);
			break;

		case HSPVAR_FLAG_DOUBLE:
			ctx->refdval = VtTraits::derefValptr<vtDouble>(data);
			break;

		default:
			puterror( HSPERR_TYPE_MISMATCH );
	}
}
예제 #17
0
static HMODULE knowbug_getInstance()
{
	// cf: http://hwada.hatenablog.com/entry/20100214/1266073808
	// and http://cpplover.blogspot.jp/2010/02/blog-post_8598.html

	struct moduleDeleter {
		using pointer = HMODULE;
		void operator ()(HMODULE p) { FreeLibrary(p); }
	};
	using moduleHandle_t = std::unique_ptr< HMODULE, moduleDeleter >;
	
	// singleton (thread unsafe style)
	static moduleHandle_t stt_hKnowbug;

	if ( hpimod::isDebugMode() && !stt_hKnowbug ) {
		stt_hKnowbug.reset(LoadLibrary("hsp3debug.dll"));
		if ( !stt_hKnowbug ) {
#if _DEBUG
			MessageBox(nullptr, "knowbug の load に失敗しました。", "hpimod", MB_OK);
#endif
			puterror(HSPERR_EXTERNAL_EXECUTE);
		}
	}

	return stt_hKnowbug.get();
}
예제 #18
0
static t_bool	check_red(t_token *b, t_token *end, t_node **root)
{
  t_token	*begin;
  t_token	*file;
  int		type;

  begin = NULL;
  if ((type = b->id) != WORD && b->next)
    get_pre_exec(b->next, &file, &begin, &end);
  else
    type = get_exec(b, &file, &begin, &end);
  if (add_node(root, type, NULL) == EXIT_FAILURE)
    return (ERROR);
  if (add_child(root) == EXIT_FAILURE)
    return (ERROR);
  if (!file)
    return (puterror(MISSING_N, NULL));
  if (add_node(&((*root)->child->nd), CMD, file->content) == EXIT_FAILURE)
    return (ERROR);
  if (add_child(root) == EXIT_FAILURE)
    return (ERROR);
   if (begin && add_node(&((*root)->child->nd), CMD, begin->content)
       == EXIT_FAILURE)
    return (ERROR);
  if (check_red_ext(&begin, root, end) != TRUE)
    return (ERROR);
  return (TRUE);
}
예제 #19
0
int
ckstr(char *strval, char *regexp[], int length, char *defstr, char *error,
	char *help, char *prompt)
{
	int	n;
	char	*defhlp;
	char	input[MAX_INPUT],
		hlpbuf[1024],
		errbuf[1024];

	defhlp = NULL;
	if (!prompt)
		prompt = "Enter an appropriate value";

start:
	putprmpt(stderr, prompt, NULL, defstr);
	if (getinput(input))
		return (1);

	n = (int)strlen(input);
	if (n == 0) {
		if (defstr) {
			(void) strcpy(strval, defstr);
			return (0);
		}
		puterror(stderr, ERRMSG0, error);
		goto start;
	}
	if (strcmp(input, "?") == 0) {
		if (defhlp == NULL)
			defhlp = sethlp(hlpbuf, regexp, length);
		puthelp(stderr, defhlp, help);
		goto start;
	}
	if (ckquit && (strcmp(input, "q") == 0)) {
		(void) strcpy(strval, input);
		return (3);
	}
	if (ckstr_val(regexp, length, input)) {
		/* LINTED E_SEC_PRINTF_VAR_FMT */
		(void) snprintf(errbuf, sizeof (errbuf), errstr, length);
		puterror(stderr, errbuf, error);
		goto start;
	}
	(void) strcpy(strval, input);
	return (0);
}
예제 #20
0
static int	make_two_redi_left(t_pipe *list_pipe, int i, char *buffer)
{
  int		*pipefd;

  if (list_pipe->list_in[i] != -1)
    close(list_pipe->list_in[i]);
  if ((list_pipe->list_fd = (int*)malloc(sizeof(int) * 2)) == NULL)
    return (puterror("error: malloc\n"));
  pipefd = list_pipe->list_fd;
  if ((pipe(pipefd)) == -1)
    return (puterror("error: pipe\n"));
  write(pipefd[1], buffer, my_strlen(buffer));
  close(pipefd[1]);
  if ((dup2(pipefd[0], 0)) == -1)
    return (puterror("error: dup2\n"));
  return (pipefd[0]);
}
예제 #21
0
void
ckint_err(short base, char *error)
{
	char	defmesg[64];

	setmsg(defmesg, base);
	puterror(stdout, defmesg, error);
}
예제 #22
0
파일: hsplua.cpp 프로젝트: MihailJP/hsplua
static void *reffunc( int *type_res, int cmd )
{
	//		関数・システム変数の実行処理 (値の参照時に呼ばれます)
	//

	int answerType = 0;

	//			'('で始まるかを調べる
	//
	if ( *type != TYPE_MARK ) puterror( HSPERR_INVALID_FUNCPARAM );
	if ( *val != '(' ) puterror( HSPERR_INVALID_FUNCPARAM );
	code_next();

	switch( cmd ) {							// サブコマンドごとの分岐
		case 0x80: *type_res = hsplua_func::hl_isboolean();       break;
		case 0x81: *type_res = hsplua_func::hl_iscfunction();     break;
		case 0x82: *type_res = hsplua_func::hl_isfunction();      break;
		case 0x83: *type_res = hsplua_func::hl_islightuserdata(); break;
		case 0x84: *type_res = hsplua_func::hl_isnil();           break;
		case 0x85: *type_res = hsplua_func::hl_isnone();          break;
		case 0x86: *type_res = hsplua_func::hl_isnoneornil();     break;
		case 0x87: *type_res = hsplua_func::hl_isnumber();        break;
		case 0x88: *type_res = hsplua_func::hl_isstring();        break;
		case 0x89: *type_res = hsplua_func::hl_istable();         break;
		case 0x8a: *type_res = hsplua_func::hl_isthread();        break;
		case 0x8b: *type_res = hsplua_func::hl_isuserdata();      break;
		case 0x90: *type_res = hsplua_func::hl_toboolean();       break;
		case 0x91: *type_res = hsplua_func::hl_tocfunction();     break;
		case 0x92: *type_res = hsplua_func::hl_tointeger();       break;
		case 0x93: *type_res = hsplua_func::hl_tonumber();        break;
		case 0x94: *type_res = hsplua_func::hl_topointer();       break;
		case 0x95: *type_res = hsplua_func::hl_tostring();        break;
		case 0x96: *type_res = hsplua_func::hl_touserdata();      break;
		case 0x98: *type_res = hsplua_func::hl_gccount();         break;
		case 0x99: *type_res = hsplua_func::hl_gcisrunning();     break;
		default: puterror( HSPERR_UNSUPPORTED_FUNCTION );         break;
	}

	//			'('で終わるかを調べる
	//
	if ( *type != TYPE_MARK ) puterror( HSPERR_INVALID_FUNCPARAM );
	if ( *val != ')' ) puterror( HSPERR_INVALID_FUNCPARAM );
	code_next();

	return (void *)&ref_val;
}
예제 #23
0
int		check_existence(char *map)
{
  int		fd;

  if ((fd = open(map, O_RDONLY)) == -1)
    return (puterror("Error: The name file isn't correct.\n"));
  close(fd);
  return (0);
}
예제 #24
0
void
ckstr_err(char *regexp[], int length, char *error, char *input)
{
	char	*defhlp;
	char	temp[1024];

	if (input) {
		if (ckstr_val(regexp, length, input)) {
			/* LINTED E_SEC_PRINTF_VAR_FMT */
			(void) snprintf(temp, sizeof (temp), errstr, length);
			puterror(stdout, temp, error);
			return;
		}
	}

	defhlp = sethlp(temp, regexp, length);
	puterror(stdout, defhlp, error);
}
예제 #25
0
static int	do_simple_left_redi(t_pipe *list_pipe, int i)
{
  int		fd;
  int		flags;

  fd = 0;
  flags = O_RDONLY;
  if ((fd = open(list_pipe->cmd[i]->redi_left, flags)) == -1)
  {
    puterror("error: ");
    puterror(list_pipe->cmd[i]->redi_left);
    puterror(": no such file\n");
    return (-1);
  }
  if ((dup2(fd, 0)) == -1)
    return (puterror("error: dup2\n"));
  return (fd);
}
예제 #26
0
파일: menu.c 프로젝트: Alban95/epikong
int		menu(t_struct *st)
{
  st->sound = 0;
  st->width = 1300;
  st->height = 750;
  if (init_my_sdl(st) == -1)
    return (puterror("Error during the init of sdl.\n"));
  st->menu = 1;
  return (aff_menu(st));
}
예제 #27
0
int
ckint(long *intval, short base, char *defstr, char *error, char *help,
	char *prompt)
{
	long	value;
	char	*ptr,
		input[MAX_INPUT],
		defmesg[64],
		temp[64];

	if (!prompt) {
		setprmpt(temp, base);
		prompt = temp;
	}
	setmsg(defmesg, base);

start:
	putprmpt(stderr, prompt, NULL, defstr);
	if (getinput(input))
		return (1);

	if (strlen(input) == 0) {
		if (defstr) {
			*intval = strtol(defstr, NULL, (int)base);
			return (0);
		}
		puterror(stderr, defmesg, error);
		goto start;
	} else if (strcmp(input, "?") == 0) {
		puthelp(stderr, defmesg, help);
		goto start;
	} else if (ckquit && (strcmp(input, "q") == 0))
		return (3);

	value = strtol(input, &ptr, (int)base);
	if (*ptr != '\0') {
		puterror(stderr, defmesg, error);
		goto start;
	}
	*intval = value;
	return (0);
}
예제 #28
0
//##########################################################
//        変数の作成
//##########################################################
//------------------------------------------------
// dimtype
//------------------------------------------------
void code_dimtype(PVal* pval, vartype_t vtype)
{
	int len[4] {};

	for ( int i = 0; i < ArrayDimMax; ++i ) {
		len[i] = code_getdi(0);
		if ( len[i] < 0 ) puterror(HSPERR_ILLEGAL_FUNCTION);
		if ( len[i] == 0 ) break;
	}
	exinfo->HspFunc_dim(pval, vtype, 0, len[0], len[1], len[2], len[3]);
	return;
}
예제 #29
0
파일: init_sdl.c 프로젝트: Alban95/epikong
int		init_my_sdl(t_struct *st)
{
  st->pos.x = 0;
  st->pos.y = 0;
  st->ecran = NULL;
  if (SDL_Init(SDL_INIT_VIDEO) == -1
      || (st->ecran = SDL_SetVideoMode(st->width,
				       st->height, 32, SDL_HWSURFACE)) == NULL)
    return (puterror("Error: In init SDL.\n"));
  SDL_FillRect(st->ecran, NULL,
	       SDL_MapRGB(st->ecran->format, 143, 126, 126));
  SDL_WM_SetCaption("EPIKONG", NULL);
  SDL_WM_SetIcon(IMG_Load("./conf/img/logo.png"), NULL);
  return (0);
}
예제 #30
0
int
ckyorn(char *yorn, char *defstr, char *error, char *help, char *prompt)
{
	int	n;
	char	input[MAX_INPUT];

	if (!prompt)
		prompt = "Yes or No";
start:
	putprmpt(stderr, prompt, choices, defstr);
	if (getinput(input))
		return (1);

	n = (int)strlen(input);
	if (n == 0) {
		if (defstr) {
			(void) strcpy(yorn, defstr);
			return (0);
		}
		puterror(stderr, REQMSG, error);
		goto start;
	}
	if (strcmp(input, "?") == 0) {
		puthelp(stderr, HLPMSG, help);
		goto start;
	}
	if (ckquit && (strcmp(input, "q") == 0))
		return (3);

	if (ckyorn_val(input)) {
		puterror(stderr, ERRMSG, error);
		goto start;
	}
	(void) strcpy(yorn, input);
	return (0);
}