Exemple #1
0
int
man_valid_post(struct man *man)
{
	v_check		*cp;

	if (MAN_VALID & man->last->flags)
		return(1);
	man->last->flags |= MAN_VALID;

	switch (man->last->type) {
	case (MAN_TEXT): 
		check_text(man, man->last);
		return(1);
	case (MAN_ROOT):
		return(check_root(man, man->last));
	case (MAN_EQN):
		/* FALLTHROUGH */
	case (MAN_TBL):
		return(1);
	default:
		break;
	}

	if (NULL == (cp = man_valids[man->last->tok].posts))
		return(1);
	for ( ; *cp; cp++)
		if ( ! (*cp)(man, man->last))
			return(0);

	return(1);
}
Exemple #2
0
void
man_valid_post(struct man *man)
{
	struct man_node	*n;
	v_check		*cp;

	n = man->last;
	if (n->flags & MAN_VALID)
		return;
	n->flags |= MAN_VALID;

	switch (n->type) {
	case MAN_TEXT:
		check_text(man, n);
		break;
	case MAN_ROOT:
		check_root(man, n);
		break;
	case MAN_EQN:
		/* FALLTHROUGH */
	case MAN_TBL:
		break;
	default:
		cp = man_valids + n->tok;
		if (*cp)
			(*cp)(man, n);
		break;
	}
}
Exemple #3
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);
}
Exemple #4
0
static void blink_screen()
{
	if (animation.is_animating == true) return;
	
	if (get_enable_blink_value() == false) 
	{
		now = get_time_value();
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			bool has_changed = check_text(&layers[i], false);
			if (has_changed == true) 
			{
				if (animation.is_animating == false) layer_update(&layers[i]);
			}
		}
	}
	else
	{	
		animation.current_flag = false;
		animation.index = 0;
		animation.is_animating = true;
		timer = app_timer_register(animation.duration, handle_timer, NULL);
	}
}
Exemple #5
0
static void
check_argv(struct mdoc *m, struct mdoc_node *n, struct mdoc_argv *v)
{
	int		 i;

	for (i = 0; i < (int)v->sz; i++)
		check_text(m, v->line, v->pos, v->value[i]);

	/* FIXME: move to post_std(). */

	if (MDOC_Std == v->arg)
		if ( ! (v->sz || m->meta.name))
			mdoc_nmsg(m, n, MANDOCERR_NONAME);
}
Exemple #6
0
//for each tick of the timer, walk through the flag list of the animation class
//a false flag will show the original layers, while a true flag will show the blank layer
//do not do anything if the flag has not changed from the last iteration
//at the end of the flag list, stop the animation
//    if the animation is for the splash screen,
//        force a redraw of the the main screen since the minute tick may still be a while
static void handle_timer(void *data)
{
	if(animation.index >= (int) sizeof(animation.flags)) 
	{
		if(animation.current_flag == true) 
		{
			for (int i = 0; i < LAYER_COUNT; i++) 
			{
				layer_set_hidden(text_layer_get_layer(layers[i].layer), false);
			}
		}
		
		animation.is_animating = false;
		app_timer_cancel(timer);
		
		if(is_splash_showing == true) is_splash_showing = false;
		
		//blink animation has just ended
		//so draw the main watch face even if the minute did not tick yet
		//this is to clear the previous screen and show the time immediately
		now = get_time_value();
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			bool has_changed = check_text(&layers[i], false);
			if (has_changed == true) 
			{
				if (animation.is_animating == false) layer_update(&layers[i]);
			}
		}
		
		return;
	}
	
	if(animation.current_flag != animation.flags[animation.index])
	{
		animation.current_flag = animation.flags[animation.index];
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			layer_set_hidden(text_layer_get_layer(layers[i].layer), animation.current_flag);
		}
	}
	
	animation.index++;
	timer = app_timer_register(animation.duration, handle_timer, NULL);
}
Exemple #7
0
static void field_changed(const uint32_t key, const void *old_value, const void *new_value)
{
	for (int i = 0; i < LAYER_COUNT; i++) 
	{
		if (animation.is_animating == true) return;

		if(key == CONFIG_KEY_COUNT_UP_CUTOVER)
		{
			check_text(&layers[i], true);
		}

		if(key == CONFIG_KEY_INVERT_SCREEN
			|| key == CONFIG_KEY_COUNT_UP_CUTOVER)
		{
			 layer_update(&layers[i]);
		}
	}
}
Exemple #8
0
void
man_node_validate(struct roff_man *man)
{
	struct roff_node *n;
	v_check		*cp;

	n = man->last;
	man->last = man->last->child;
	while (man->last != NULL) {
		man_node_validate(man);
		if (man->last == n)
			man->last = man->last->child;
		else
			man->last = man->last->next;
	}

	man->last = n;
	man->next = ROFF_NEXT_SIBLING;
	switch (n->type) {
	case ROFFT_TEXT:
		check_text(man, n);
		break;
	case ROFFT_ROOT:
		check_root(man, n);
		break;
	case ROFFT_EQN:
	case ROFFT_TBL:
		break;
	default:
		cp = man_valids + n->tok;
		if (*cp)
			(*cp)(man, n);
		if (man->last == n)
			man_state(man, n);
		break;
	}
}
int check_arguments( struct_arg_options arg_options, char* text ){

    /* On enregistre l'ID par défaut.*/

    if ( ( strlen( ID ) == ( LENGTH_ID - 1 ) ) && ( atoi( ID ) == 1 ) )
    	strcpy( options.id, ID );
    else{
    	printf( "Bad value of ID in check_arguments.\n" );
    	return EXIT_FAILURE;
    }

    /* Check each display option */

    if ( check_option_page( arg_options.page ) != 0 )
    	return EXIT_FAILURE;

    if ( check_option_lead_cmd( arg_options.lead_cmd ) != 0 )
    	return EXIT_FAILURE;

    if ( check_option_display_meth( arg_options.display_meth ) !=0 )
    	return EXIT_FAILURE;

    if ( check_option_wait_time( arg_options.wait_time ) != 0 )
    	return EXIT_FAILURE;

    if ( check_option_lag_cmd( arg_options.lag_cmd ) != 0 )
    	return EXIT_FAILURE;


    /* Check priority and save it */

    if ( ( arg_options.priority != '0' ) && ( arg_options.priority != '1' ) ){
   	 printf("[!!]ERROR the option 'priority' is not correct.\n");
   	 return EXIT_FAILURE;
    }


    /* Save options to be written in the framework */

    if ( save_option( options.page, arg_options.page ) != 0 )
        	return EXIT_FAILURE;

     if ( save_option( options.lead_cmd, arg_options.lead_cmd ) != 0 )
     	return EXIT_FAILURE;

     if ( save_option( options.display_meth, arg_options.display_meth ) != 0 )
     	return EXIT_FAILURE;

     if ( save_option( options.wait_time, arg_options.wait_time ) != 0 )
     	return EXIT_FAILURE;

     if ( save_option( options.lag_cmd, arg_options.lag_cmd ) != 0 )
     	return EXIT_FAILURE;

     options.priority[0] = arg_options.priority;

    /* Check test message doesn't have any non-supported characters, or replace them */
    if ( check_text( text ) != 0 )
    	return EXIT_FAILURE;

	return EXIT_SUCCESS;
}
Exemple #10
0
int check_trace_header(Settings *opts, srf_t *srf, Previous_data *seen) {
  int i;
  int j;
  int n;
  uint8_t  *data;
  uint32_t  val;
  ztr_chunk_t *chunk;

  if (NULL != srf->mf) {
    mfrecreate(srf->mf, NULL, 0);
  } else {
    srf->mf = mfcreate(NULL, 0);
  }
  if (NULL == srf->mf) die("%s\n", strerror(errno));

  if (srf->th.trace_hdr_size) {
    if (1 != mfwrite(srf->th.trace_hdr, srf->th.trace_hdr_size, 1, srf->mf)) {
      die("mfwrite failed: %s\n", strerror(errno));
    }
  }

  if (srf->ztr) delete_ztr(srf->ztr);

  mrewind(srf->mf);

  if (NULL != (srf->ztr = partial_decode_ztr(srf, srf->mf, NULL))) {
    srf->mf_pos = mftell(srf->mf);
  } else {
    /* We expect this to work for srfs made by illumina2srf */
    printf("partial_decode_ztr failed for trace header\n");
    srf->mf_pos = 0;
    return -1;
  }

  mfseek(srf->mf, 0, SEEK_END);
  srf->mf_end = mftell(srf->mf);

  /* Go through chunks */
  for (i = 0; i < srf->ztr->nchunks; i++) {
    chunk = &srf->ztr->chunk[i];
    if (opts->verbosity > 1) {
      printf(" Chunk %d type %.4s\n", i,
	      (char *) &chunk->type);
    }
    switch (chunk->type) {
    case ZTR_TYPE_HUFF:
      break;
    case ZTR_TYPE_BPOS:
      if (0 != uncompress_chunk(srf->ztr, chunk)) {
	printf("Couldn't uncompress BPOS chunk\n");
	return -1;
      }
      n = (chunk->dlength - 4) / 4;
      for (j = 0; j < n; j++) {
	data = (uint8_t *) &chunk->data[j * 4 + 4];
	val = (  ((uint32_t) data[0]) << 24
	       | ((uint32_t) data[1]) << 16
	       | ((uint32_t) data[2]) <<  8
	       | ((uint32_t) data[3]));
	if (val != j) {
	  printf("BPOS data misses cycles\n");
	  return -1;
	}
      }
      break;
    case ZTR_TYPE_REGN:
      if (0 != uncompress_chunk(srf->ztr, chunk)) {
	printf("Couldn't uncompress REGN chunk\n");
	return -1;
      }
      if (NULL == seen->regn) {
	/* Copy REGN chunk */
	seen->regn_meta_sz = chunk->mdlength;
	seen->regn_meta = smalloc(seen->regn_meta_sz);
	memcpy(seen->regn_meta, chunk->mdata, seen->regn_meta_sz);
	seen->regn_sz = chunk->dlength;
	seen->regn = smalloc(seen->regn_sz);
	memcpy(seen->regn, chunk->data, seen->regn_sz);
      } else {
	/* Compare with last copy */
	if (seen->regn_meta_sz != chunk->mdlength
	    || seen->regn_sz != chunk->dlength
	    || 0 != memcmp(seen->regn_meta, chunk->mdata, seen->regn_meta_sz)
	    || 0 != memcmp(seen->regn, chunk->data, seen->regn_sz)) {
	  printf("REGN chunk changed between header blocks\n");
	  return -1;
	}
      }
      break;
    case ZTR_TYPE_TEXT:
      if (0 != uncompress_chunk(srf->ztr, chunk)) {
	printf("Couldn't uncompress REGN chunk\n");
	return -1;
      }
      if (NULL == seen->text) {
	seen->text_sz = chunk->dlength;
	seen->text = smalloc(seen->text_sz);
	memcpy(seen->text, chunk->data, seen->text_sz);
	
	if (0 != check_text(opts, seen)) return -1;
      } else {
	if (seen->text_sz != chunk->dlength
	    || 0 != memcmp(seen->text, chunk->data, seen->text_sz)) {
	  printf("New TEXT chunk found\n");
	  seen->text_sz = chunk->dlength;
	  seen->text = srealloc(seen->text, seen->text_sz);
	  memcpy(seen->text, chunk->data, seen->text_sz);
	  
	  if (0 != check_text(opts, seen)) return -1;
	}
      }
      break;
    default:
      printf("Found unexpected chunk type in header block\n");
      return -1;
    }
  }

  return 0;
}
/* Validate the subtree rooted at man->last. */
void
man_validate(struct roff_man *man)
{
	struct roff_node *n;
	const v_check	 *cp;

	/*
	 * Translate obsolete macros such that later code
	 * does not need to look for them.
	 */

	n = man->last;
	switch (n->tok) {
	case MAN_LP:
	case MAN_P:
		n->tok = MAN_PP;
		break;
	default:
		break;
	}

	/*
	 * Iterate over all children, recursing into each one
	 * in turn, depth-first.
	 */

	man->last = man->last->child;
	while (man->last != NULL) {
		man_validate(man);
		if (man->last == n)
			man->last = man->last->child;
		else
			man->last = man->last->next;
	}

	/* Finally validate the macro itself. */

	man->last = n;
	man->next = ROFF_NEXT_SIBLING;
	switch (n->type) {
	case ROFFT_TEXT:
		check_text(man, n);
		break;
	case ROFFT_ROOT:
		check_root(man, n);
		break;
	case ROFFT_COMMENT:
	case ROFFT_EQN:
	case ROFFT_TBL:
		break;
	default:
		if (n->tok < ROFF_MAX) {
			roff_validate(man);
			break;
		}
		assert(n->tok >= MAN_TH && n->tok < MAN_MAX);
		cp = man_valids + (n->tok - MAN_TH);
		if (*cp)
			(*cp)(man, n);
		if (man->last == n)
			n->flags |= NODE_VALID;
		break;
	}
}