Beispiel #1
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);
}
Beispiel #2
0
/**
 * Check that the image unit state matches the result of the specified
 * action.
 */
static bool
check_action(const struct image_unit_action a)
{
        if ((a.action == BIND_NEW ||
             a.action == BIND_OBJ ||
             a.action == BIND_IDX) &&
            a.expect_status == GL_NO_ERROR) {
                const GLuint obj = (a.action == BIND_NEW ? get_texture(a.idx) :
                                    a.action == BIND_IDX ? get_texture(a.obj) :
                                    a.obj);

                if (a.action == BIND_NEW &&
                    !check_tex_parameter(a.obj, obj,
                                         GL_IMAGE_FORMAT_COMPATIBILITY_TYPE,
                                         GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE))
                        return false;

                return check_integer(GL_IMAGE_BINDING_NAME, a.idx,
                                     obj) &&
                        check_integer(GL_IMAGE_BINDING_LEVEL, a.idx,
                                      a.level) &&
                        check_integer(GL_IMAGE_BINDING_LAYERED, a.idx,
                                      a.layered) &&
                        check_integer(GL_IMAGE_BINDING_LAYER, a.idx,
                                      a.layer) &&
                        check_integer(GL_IMAGE_BINDING_ACCESS, a.idx,
                                      a.access) &&
                        check_integer(GL_IMAGE_BINDING_FORMAT, a.idx,
                                      a.format);

        } else {
                return check_integer(GL_IMAGE_BINDING_NAME, a.idx, 0);
        }
}
Beispiel #3
0
/**
 * парсер целых чисел
 */
int try_parse(char param, char* arg)
{
if(!check_integer(arg))
  {
  syslog(LOG_ERR, "Ошибка при разборе параметра <-%c %s>\n", param, arg);
  go_out();
  };
return(atoi(arg));
}
Beispiel #4
0
char* check_option(char **in,int n,int which,int type)
{
  char test,*ret=NULL,wasfound=0,ok=1;
  int i;
  
  for (i=1;i<n;i++) {
    if (in[i] != NULL) {
      test= (in[i][0] == '-') && (in[i][1] == which);
      if (test) {
	wasfound=1;
	if (type != 'n') {
	  if (strlen(in[i]) > 2) {
	    switch(type) {
	    case 'u': check_unsigned(in[i]+2,which);break;
	    case 'd': check_integer(in[i]+2,which);break;
	    case 'f': check_float(in[i]+2,which);break;
	    case '2': check_two(in[i]+2,which);break;
	    case '3': check_three(in[i]+2,which);break;
	    }
	    if (ret != NULL)
	      free(ret);
	    check_alloc(ret=(char*)calloc(strlen(in[i]+2)+1,(size_t)1));
	    strcpy(ret,in[i]+2);
	    in[i]=NULL;
	  }
	  else {
	    in[i]=NULL;
	    i++;
	    if (i < n) {
	      if (in[i] != NULL) {
		switch(type) {
		case 'u': check_unsigned(in[i],which);break;
		case 'd': check_integer(in[i],which);break;
		case 'f': check_float(in[i],which);break;
		case '2': check_two(in[i],which);break;
   	        case '3': check_three(in[i]+2,which);break;
		case 'o': ok=check_optional(in[i],which);break;
		}
		if (ok) {
		  if (ret != NULL)
		    free(ret);
		  check_alloc(ret=(char*)calloc(strlen(in[i])+1,(size_t)1));
		  strcpy(ret,in[i]);
		  in[i]=NULL;
		}
		else {
		  i--;
		  if (ret != NULL)
		    free(ret);
		  ret=NULL;
		}
	      }
	    }
	    else {
	      if (ret != NULL) {
		free(ret);
		ret=NULL;
	      }
	    }
	  }
	}
	else {
	  in[i]=NULL;
	}
      }
    }
  }
  
  if (((type == 'o') || (type == 'n')) && (ret == NULL) && wasfound)
    return "";

  if (wasfound && (ret == NULL)) {
    fprintf(stderr,"The option -%c needs some value. Exiting!\n",which);
    exit(CHECK_OPTION_C_NO_VALUE);
  }
  return ret;
}
Beispiel #5
0
/*******************************************************************************
Set targettime by subtracting the (relative) "age" command line argument, e.g.,
"15D" from starttime. Note: targettime will always be less than starttime.
I.e., "-30s" and "[+]30s" both result in targettime = starttime-30s, but the
'-' is used to set the newerthantargetflag. This function is called for both
last access time and last modification time.
*******************************************************************************/
void set_target_time_by_relative_age(char *relativeagestr, char c) {
	char		timeunitchar;
	struct tm	*brkdwntimeptr;
	char		datestr[MAXDATESTRLENGTH];
	time_t		relagenanoseconds;
	time_t		relage_ns = DEFAULTAGE;

	if (c == RELMODAGECHAR) {
		accesstimeflag = 0;
	} else {
		accesstimeflag = 1;
	}

	if (*relativeagestr == '-' ) {
		/* eg, "-m -15D" find objects modified <= 15 days ago (newer than) */
		newerthantargetflag = 1;
		relativeagestr++;
	} else {
		/* eg, "-m [+]15D" find objects modified >= 15 days ago (older than) */
		newerthantargetflag = 0;
	}

	timeunitchar = *(relativeagestr+strlen(relativeagestr+1));
	brkdwntimeptr = localtime(&starttime_s);

	switch (timeunitchar) {
		case 's': relage_ns = adjust_relative_age(relativeagestr, &(brkdwntimeptr->tm_sec), 1);
			break;
		case 'm': relage_ns = adjust_relative_age(relativeagestr, &(brkdwntimeptr->tm_sec), SECONDSPERMINUTE);
			break;
		case 'h': relage_ns = adjust_relative_age(relativeagestr, &(brkdwntimeptr->tm_sec), SECONDSPERHOUR);
			break;
		case 'D': relage_ns = adjust_relative_age(relativeagestr, &(brkdwntimeptr->tm_sec), SECONDSPERDAY);
			break;
		case 'W': relage_ns = adjust_relative_age(relativeagestr, &(brkdwntimeptr->tm_sec), SECONDSPERWEEK);
			break;
		case 'M': check_integer(relativeagestr);
			brkdwntimeptr->tm_mon -= atoi(relativeagestr);
			break;
		case 'Y': check_integer(relativeagestr);
			brkdwntimeptr->tm_year -= atoi(relativeagestr);
			break;
		default: fprintf(stderr, "Illegal time unit '%c'\n", timeunitchar);
			exit(1);
	}

	targettime_s = mktime(brkdwntimeptr);

	/* Due to storing times in 2 variables (*_s and *_ns), it is necessary to add 1s to
		the targettime_ns value and subtract 1s from the targettime_s value whenever
		starttime_ns < relage_ns. */
	if (starttime_ns >= relage_ns) {
		targettime_ns = starttime_ns - relage_ns;
	} else {
		targettime_ns = starttime_ns - relage_ns + NANOSECONDSPERSECOND;
		targettime_s--;
	}

	/* This will be a problem in 2262 */
	relagenanoseconds = (starttime_s-targettime_s)*NANOSECONDSPERSECOND + starttime_ns-targettime_ns;

	if (verbosity > 1) {
		strftime(datestr, MAXDATESTRLENGTH, "%c", brkdwntimeptr);
		fprintf(stderr, "i: target time: %15ld.%09lds ~= %s\n", targettime_s, targettime_ns, datestr);
		fprintf(stderr, "i: %13.5fD ~= %10ld.%09lds last %s %s target time ('%s')\n",
			(float)(starttime_s-targettime_s)/SECONDSPERDAY,
			relagenanoseconds/NANOSECONDSPERSECOND,
			relagenanoseconds%NANOSECONDSPERSECOND,
			accesstimeflag ? "accessed" : "modified",
			newerthantargetflag ? "after (newer than)" : "before (older than)",
			relativeagestr);
		fflush(stderr);
	}
}