Example #1
0
static char *
handle_type_mo(Msg_node *mnp, struct msg_pack *mp)
{
	char	*result;

	switch (mnp->type) {
	case T_ILL_MO:
		/* invalid MO */
		return (NULL);
	case T_SUN_MO:
		/* Sun MO found */
		mp->status |= ST_SUN_MO_FOUND;

		if (mp->plural) {
			/*
			 * *ngettext is called against
			 * Sun MO file
			 */
			int	exp = (mp->n == 1);
			result = (char *)mp->msgid1;
			if (!exp)
				result = (char *)mp->msgid2;
			return (result);
		}
		result = key_2_text(mnp->msg.sunmsg, mp->msgid1);
		if (!mnp->trusted) {
			result = check_format(mp->msgid1, result, 0);
		}
		return (result);
	case T_GNU_MO:
		/* GNU MO found */
		mp->status |= ST_GNU_MO_FOUND;

		result = gnu_key_2_text(mnp->msg.gnumsg,
		    get_codeset(mp->domain), mp);

		if (result == mp->msgid1 || result == mp->msgid2) {
			/* no valid msg found */
			return (result);
		}

		/* valid msg found */
		mp->status |= ST_GNU_MSG_FOUND;

		if (!mnp->trusted) {
			result = check_format(mp->msgid1, result, 0);
			if (result == mp->msgid1) {
				DFLTMSG(result, mp->msgid1, mp->msgid2,
				    mp->n, mp->plural);
			}
		}
		return (result);
	default:
		/* this should never happen */
		DFLTMSG(result, mp->msgid1, mp->msgid2, mp->n, mp->plural);
		return (result);
	}
	/* NOTREACHED */
}
Example #2
0
static char *
handle_gnu_mo(struct cache_pack *cp, struct msg_pack *mp,
	Gettext_t *gt)
{
	char	*result;
	char	*codeset = get_codeset(mp->domain);

	result = gnu_key_2_text(cp->mnp->msg.gnumsg, codeset, mp);
	if (mp->plural) {
		if (((result == mp->msgid1) && (mp->n == 1)) ||
			((result == mp->msgid2) && (mp->n != 1))) {
			return (NULL);
		}
	} else {
		if (result == mp->msgid1) {
			return (NULL);
		}
	}
	gt->c_m_node = cp->mnp;
	if (!cp->mnp->trusted) {
		result = check_format(mp->msgid1, result, 0);
		if (result == mp->msgid1) {
			DFLTMSG(result, mp->msgid1, mp->msgid2, mp->n,
				mp->plural);
		}
	}
	return (result);
}
Example #3
0
int main(int argc, char **argv) {
	int opt;
	//struct timeval tv;

	getopt_init();

	while (-1 != (opt = getopt(argc, argv, "hs:"))) {
		printf("\n");
		switch (opt) {
		case 'h': /* show help */
			print_usage();
			break;
		case 's': /* set date*/
			set_date(argv[2]);
			break;
		default:
			break;
		}
	}

	/* show date and kernel time */
	if (argc == 1) {
		show_date();
		//ktime_get_timeval(&tv);
		//printf("ktime_get_timeval %d:%d (s:ms)\n", (int)tv.tv_sec, (int)tv.tv_usec/1000);
		return 0;
	}
	check_format(argv[argc-1]);

	return 0;
}
Example #4
0
/* --------------------------------------------- */
static void check_options(void) {
  if (srcvolid == NULL) {
    fprintf(stderr,"A source volume path must be supplied\n");
    exit(1);
  }
  if(roifile == NULL && roitxtfile == NULL && ListFile == NULL) {
    fprintf(stderr,"ERROR: No output specified\n");
    exit(1);
  }

  if (msksamesrc && mskregfile != NULL) {
    fprintf(stderr,"ERROR: cannot specify both --mskreg and --msksamesrc\n");
    exit(1);
  }

  if (msksamesrc) mskregfile = srcregfile;

  if (srcfmt == NULL) srcfmt = "bvolume";
  check_format(srcfmt);

  if (src2lblregfile != NULL && labeltal) {
    printf("ERROR: cannot specify --labelreg and --labeltal\n");
    exit(1);
  }

  outext = getenv("FSF_OUTPUT_FORMAT");
  if(outext == NULL) outext = "bhdr";

  return;
}
Example #5
0
int main(int argc, char **argv)
{
	char *outtyp;
	char *outcomp;
	int forcehead;
	int stdret;
	dsk_format_t format;

	if (argc < 2) return help(argc, argv);
        if (find_arg("--help",    argc, argv) > 0) return help(argc, argv);
	stdret = standard_args(argc, argv); if (!stdret) return 0;
        ignore_arg("-itype", 2, &argc, argv);
        ignore_arg("-iside", 2, &argc, argv);
        ignore_arg("-icomp", 2, &argc, argv);
        ignore_arg("-otype", 2, &argc, argv);
        ignore_arg("-oside", 2, &argc, argv);
        ignore_arg("-ocomp", 2, &argc, argv);
        outtyp    = check_type("-type", &argc, argv); if (!outtyp) outtyp = "dsk";
        outcomp   = check_type("-comp", &argc, argv); 
        forcehead = check_forcehead("-side", &argc, argv);
	format    = check_format("-format", &argc, argv);
        retries   = check_retry("-retry", &argc, argv);
	if (format == -1) format = FMT_180K;
	args_complete(&argc, argv);

	return do_format(argv[1], outtyp, outcomp, forcehead, format);
}
Example #6
0
void g95_check_format_string(g95_expr *d) {   
   
  mode = MODE_STRING;     
  format_string = format_start = d->value.character.string;       
  format_length = d->value.character.length;     
  where = d->where;    
  check_format();
}     
Example #7
0
/******************************************************************************
 * private メソッド
 *****************************************************************************/
inline apr_size_t UploadItemReader::read_and_check(File *uitem_file,
                                             apr_mmap_t **uitem_file_map)
{
    uitem_file->open(APR_READ|APR_BINARY);
    *uitem_file_map = uitem_file->mmap(0, 0, APR_MMAP_READ, true);

    return check_format(*uitem_file_map);
}
Example #8
0
int main(int argc, char **argv)
{
	char *outtyp;
	char *outcomp;
	int forcehead;
	int n, err;

	if (argc < 2) return help(argc, argv);

        ignore_arg("-itype", 2, &argc, argv);
        ignore_arg("-iside", 2, &argc, argv);
        ignore_arg("-icomp", 2, &argc, argv);
        ignore_arg("-otype", 2, &argc, argv);
        ignore_arg("-oside", 2, &argc, argv);
        ignore_arg("-ocomp", 2, &argc, argv);

	outtyp    = check_type("-type", &argc, argv);
	outcomp   = check_type("-comp", &argc, argv);
	forcehead = check_forcehead("-side", &argc, argv);	
	retries   = check_retry("-retry", &argc, argv);
	format    = check_format("-format", &argc, argv);

        if (find_arg("--help",    argc, argv) > 0) return help(argc, argv);
        if (find_arg("--version", argc, argv) > 0) return version();
        if ((n = find_arg("--pcdos",   argc, argv) > 0)) 
	{
		md = FORCE_PCDOS;
		excise_arg(n, &argc, argv);
	}
        if ((n = find_arg("-pcdos",    argc, argv) > 0))
	{
		md = FORCE_PCDOS;
		excise_arg(n, &argc, argv);
	}
        if ((n = find_arg("--apricot", argc, argv) > 0))
	{
		md = FORCE_APRICOT;
		excise_arg(n, &argc, argv);
	}
        if ((n = find_arg("-apricot",  argc, argv) > 0))
	{
		md = FORCE_APRICOT;
		excise_arg(n, &argc, argv);
	}
	args_complete(&argc, argv);

	err = 0;
	for (n = 1; n < argc; n++)
	{
		if (do_swapboot(argc, argv[n], outtyp, outcomp, forcehead))
			++err;
	}
	return err;
}
Example #9
0
/// Constructs a compiler output handler.
///
/// \param format %Output format to use.
/// \param stream Stream to output to.
///
/// \exception InvalidFormat Invalid format specified.
///
CompilerOutput::CompilerOutput(const string& format, ostream& stream)
    :	Output(),
      _format(format),
      _stream(stream)
{
    int expr(0), file(0), line(0);

    for (string::size_type pos = 0;
            (pos = _format.find_first_of('%', pos)) != string::npos; )
    {
        ++pos;
        if (check_format(_format, pos, "expr", expr))      ;
        else if (check_format(_format, pos, "file", file)) ;
        else if (check_format(_format, pos, "line", line)) ;
        else
            throw InvalidFormat(format);
    }

    if (!expr && !file && !line)
        throw InvalidFormat(format);
}
Example #10
0
/* Decompresses the huff file and writes out the original file */
void decompress(unsigned char* file_pointer, unsigned long long file_length, char* filename)
{
    if(!check_format(file_pointer, file_length, filename))
    {
        printf("Can't decompress a non-huff file.\n");
        exit(-1);
    }

    unsigned long long start_of_compressed;
    char* mapping = get_mapping_from_file(file_pointer, file_length, &start_of_compressed);
    write_decompressed_file(file_pointer, file_length, filename, mapping, start_of_compressed);
    free(mapping);
}
Example #11
0
File: fs.c Project: Alkzndr/freebsd
static svn_error_t *
base_open(svn_fs_t *fs, const char *path, apr_pool_t *pool,
          apr_pool_t *common_pool)
{
  int format;
  svn_error_t *svn_err;
  svn_boolean_t write_format_file = FALSE;

  /* Read the FS format number. */
  svn_err = svn_io_read_version_file(&format,
                                     svn_dirent_join(path, FORMAT_FILE, pool),
                                     pool);
  if (svn_err && APR_STATUS_IS_ENOENT(svn_err->apr_err))
    {
      /* Pre-1.2 filesystems did not have a format file (you could say
         they were format "0"), so they get upgraded on the fly.
         However, we stopped "upgrading on the fly" in 1.5, so older
         filesystems should only be bumped to 1.3, which is format "1". */
      svn_error_clear(svn_err);
      svn_err = SVN_NO_ERROR;
      format = 1;
      write_format_file = TRUE;
    }
  else if (svn_err)
    goto error;

  /* Create the environment and databases. */
  svn_err = open_databases(fs, FALSE, format, path, pool);
  if (svn_err) goto error;

  ((base_fs_data_t *) fs->fsap_data)->format = format;
  SVN_ERR(check_format(format));

  /* If we lack a format file, write one. */
  if (write_format_file)
    {
      svn_err = svn_io_write_version_file(svn_dirent_join(path, FORMAT_FILE,
                                                        pool),
                                          format, pool);
      if (svn_err) goto error;
    }

  SVN_ERR(populate_opened_fs(fs, pool));
  return SVN_NO_ERROR;

 error:
  svn_error_clear(cleanup_fs(fs));
  return svn_err;
}
Example #12
0
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels)
{
	bool is_set = false;
	
#ifdef _DEBUG
	return;
#endif

#if 1 // no mipmap
	if (level > 0)
		return;
#endif

	if (!GLImpl.tmus[GLImpl.current_tmu].boundtexture) {
		printf("Not texture binded\n");
		return;
	}
		
	GLImpl.device->SetTexture(0, NULL);
	GLTexture * surf = NULL;
	
	if (GLImpl.tmus[GLImpl.current_tmu].boundtexture && GLImpl.tmus[GLImpl.current_tmu].boundtexture->teximg ) {
		surf = GLImpl.tmus[GLImpl.current_tmu].boundtexture->teximg;
	}
	
	if (surf) {
		int srcbytes = src_format_to_bypp(format);
		int dstbytes = dst_format_to_bypp(GLImpl.tmus[GLImpl.current_tmu].boundtexture->internalformat);
		BYTE * surfbuf;
		BYTE * srcdata = (BYTE*) pixels;
		BYTE * dstdata;

		surf->lockTexture(level);

		srcdata = (BYTE*) pixels;
		surfbuf = (BYTE*)surf->getData();		
		dstdata = (BYTE*)surf->getData();
		
		check_format(srcbytes, dstbytes);

		copyImage(xoffset, yoffset, width, height, srcdata, srcbytes, surfbuf, dstbytes);

		surf->unlockTexture(level);

		GLImpl.tmus[GLImpl.current_tmu].boundtexture->dirty = 1;
	}
}
Example #13
0
/** 
 * @brief  Open a file and check the format
 *
 * @param filename [in] file name to open
 * 
 * @return TRUE on success, FALSE on failure.
 */
static boolean
adin_sndfile_open(char *filename)
{
#ifndef HAVE_LIBSNDFILE_VER1
  sinfo.samplerate = sfreq;
  sinfo.pcmbitwidth = 16;
  sinfo.channels = 1;
#endif
  sinfo.format = 0x0;
  if ((sp = 
#ifdef HAVE_LIBSNDFILE_VER1
       sf_open(filename, SFM_READ, &sinfo)
#else
       sf_open_read(filename, &sinfo)
#endif
       ) == NULL) {
    /* retry assuming raw format */
    sinfo.samplerate = sfreq;
    sinfo.channels = 1;
#ifdef HAVE_LIBSNDFILE_VER1
    sinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 | SF_ENDIAN_BIG;
#else
    sinfo.pcmbitwidth = 16;
    sinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_BE;
#endif
    if ((sp =
#ifdef HAVE_LIBSNDFILE_VER1
	 sf_open(filename, SFM_READ, &sinfo)
#else
	 sf_open_read(filename, &sinfo)
#endif
	 ) == NULL) {
      sf_perror(sp);
      jlog("Error: adin_sndfile: failed to open speech data: \"%s\"\n",filename);
    }
  }
  if (sp == NULL) {		/* open failure */
    return FALSE;
  }
  /* check its format */
  if (! check_format(&sinfo)) {
    return FALSE;
  }
  return TRUE;
}
Example #14
0
int main(int argc, char *argv[])
{
    struct GModule *module;
    struct _options options;
    struct _flags   flags;

    G_gisinit(argv[0]);

    module = G_define_module();
    G_add_keyword(_("vector"));
    G_add_keyword(_("export"));
    G_add_keyword(_("output"));
    G_add_keyword(_("external"));
    module->description =
	_("Defines vector output format utilizing OGR library.");

    OGRRegisterAll();

    parse_args(argc, argv, &options, &flags);

    if (flags.f->answer) {
	list_formats();
	exit(EXIT_SUCCESS);
    }

    if (flags.r->answer) {
	G_remove("", "OGR");
	exit(EXIT_SUCCESS);
    }

    if (options.format->answer)
	check_format(options.format->answer);

    if (options.dsn->answer)
	make_link(options.dsn->answer,
		  options.format->answer, options.opts->answers);
    
    if (flags.p->answer || flags.g->answer) {
	print_status(flags.g->answer ? 1 : 0);
    }

    exit(EXIT_SUCCESS);
}
Example #15
0
/* Prints out the table mapping bytes to huffman codes */
void print_table(unsigned char* file_pointer, unsigned long long file_length, char* filename)
{
    /* If this is a huff file, get it from the table in the file. Otherwise calculate it from the file */
    if(check_format(file_pointer, file_length, filename))
    {
        unsigned long long start_of_compressed;
        char* mapping = get_mapping_from_file(file_pointer, file_length, &start_of_compressed);
        printf("%s\n", mapping);
        free(mapping);
    }
    else
    {
        unsigned long long frequencies[256] = {0};
        find_frequencies(frequencies, file_pointer, file_length);

        char* mapping = get_huffman_table(frequencies);
        printf("%s", mapping);
        free(mapping);
    }
}
Example #16
0
/*** 
 * convert the content to the needed vector format
 * return empty vector if the content isn't
 * satisfy the needed format, for exmample the content:
 * "key3":{"key31":"value31","key32":"value32"},"key4":"vaule4"
 * become [key, "key31":"value31","key32":"value32", key4, value4]
 */
vector<string> strops::content2vector (string content)
{
  vector<string>   rsVector;
  vector<string>   errVector;  // it's empty
  if (0 == content.size()) {
    return  errVector;
    this->formatTag = false;
  }
  string nospacestr = delete_content_space(content);
  int keybpos       = 0;     // key begin position
  int pos           = 0;
  bool subTag       = false;

  for (int i = 0; i < nospacestr.size();)
  {
    if (nospacestr[i] == ':') {    
      if (nospacestr[keybpos] == ',')   keybpos++;
      string key(nospacestr.substr(keybpos, i-keybpos));
      rsVector.push_back(key);
      if ((i+1) == nospacestr.size()) { 
	return errVector;
	this->formatTag = false;
      }
      pos = find_match_pos(nospacestr, nospacestr[i+1], i+1);
      if (pos == -1) {
	return errVector;
	this->formatTag = false;
      }
      string value(nospacestr.substr(i+1, pos - i));
      rsVector.push_back(value);
      i = pos + 1;
      keybpos = i;
      continue;
    } else {
      i++;
    }
  } // end for
  this->strVec = rsVector;
  this->formatTag = check_format();
  return  rsVector;
}
Example #17
0
 void MetaEntryVisitor::operator()(std::map<std::string, std::string> & value) const
 {
     auto & id = entry.id;
     if (id == ALT) {
         check_alt(value);
     } else if (id == ASSEMBLY) {
         // TODO May check URL correctness (regexp?)
     } else if (id == CONTIG) {
         check_contig(value);
     } else if (id == FILTER) {
         check_filter(value);
     } else if (id == FORMAT) {
         check_format(value);
     } else if (id == INFO) {
         check_info(value);
     } else if (id == PEDIGREE) {
         // Nothing to check
     } else if (id == PEDIGREEDB) {
         // Nothing to check
     } else if (id == SAMPLE) {
         check_sample(value);
     }
 }
Example #18
0
int		ft_printf(const char *format, ...)
{
	va_list		va;
	int			i;

	g_ret = 0;
	va_start(va, format);
	i = 0;
	while (format[i])
	{
		if (format[i] == '%' && format[i + 1] == '%')
			i++;
		else if (format[i] == '%' && format[i + 1] != '%'
				&& format[i + 1] != '\0')
		{
			if ((check_format(format + i + 1)) == -1)
				return (0);
		}
		i++;
	}
	set_format(format, va);
	va_end(va);
	return (g_ret);
}
Example #19
0
static try check_format(void) {    
char *error,
     *posint_required = "Positive width required",
     *period_required = "Period required",          
     *nonneg_required = "Nonnegative width required",
     *unexpected_element = "Unexpected element",      
     *unexpected_end = "Unexpected end of format string";

format_token l, c;       
int m;         
try r;

  use_last_char = 0;       
  saved_token = FMT_NONE;        
  m = 0;
  r = SUCCESS;    
    
  l = format_lex();          
  if (l != FMT_LPAREN) {          
    error = "Missing leading left parenthesis";      
    goto syntax;     
  }        
        
/* In this state, the next thing has to be a format item */       
       
format_item:        
  l = format_lex();  
  switch(l) {   
  case FMT_POSINT:  
    l = format_lex();        
    if (l == FMT_LPAREN) { 
      m++;         
      goto format_item; 
    }     
     
    if (l == FMT_SLASH) goto optional_comma;      
      
    goto data_desc;       
       
  case FMT_ZERO:   
    l = format_lex();          
    if (l != FMT_P) {  
      error = "Zero repeat count not allowed";     
      goto syntax;    
    } 
 
    goto p_descriptor;    
    
  case FMT_LPAREN: 
    m++; 
    goto format_item;       
       
  case FMT_RPAREN:      
    goto rparen;     
     
  case FMT_SIGNED_INT:  /* Signed integer can only precede a P format */ 
    l = format_lex();      
    if (l != FMT_P) {      
      error = "Expected P edit descriptor";         
      goto syntax;       
    }          
          
    goto data_desc;     
     
  case FMT_P:       /* P and X require a prior number */  
    error = "P descriptor requires leading scale factor";   
    goto syntax;          
          
  case FMT_X:        
    error = "X descriptor requires leading space count";
    goto syntax;        
        
  case FMT_SIGN:       
  case FMT_BLANK:     
  case FMT_CHAR:       
    goto between_desc;        
        
  case FMT_COLON:          
  case FMT_SLASH:        
    goto optional_comma;       
       
  case FMT_DOLLAR:  
    l = format_lex();      
    if (l != FMT_RPAREN || m > 0) {    
      error = "$ must the last specifier";         
      goto syntax;   
    }     
     
    goto finished;     
     
  case FMT_POS:  case FMT_IBOZ:  case FMT_F:  case FMT_E:  case FMT_EXT:        
  case FMT_G:    case FMT_L:     case FMT_A:  case FMT_D:      
    goto data_desc;    
    
  case FMT_H:  
    repeat = 1;         
    goto handle_hollerith;      
      
  case FMT_END: 
    error = unexpected_end;  
    goto syntax;       
       
  default:        
    error = unexpected_element;          
    goto syntax;     
  }     
     
/* In this state, t must currently be a data descriptor.  Deal with
 * things that can/must follow the descriptor */          
          
data_desc:          
  switch(l) {        
  case FMT_SIGN:         
  case FMT_BLANK:    
  case FMT_X:    
    break;        
        
  case FMT_P:      
  p_descriptor: 
    if (g95_option.fmode != 0) {         
      l = format_lex();         
      if (l == FMT_POSINT) {          
	error = "Repeat count cannot follow P descriptor";     
	goto syntax;   
      }          
          
      saved_token = l;      
    }         
         
    goto optional_comma; 
 
  case FMT_POS:    
  case FMT_L:       
    l = format_lex();    
    if (l == FMT_POSINT) break;   
   
    error = posint_required;      
    goto syntax;         
         
  case FMT_A:     
    l = format_lex();          
    if (l != FMT_POSINT) saved_token = l;          
    break;          
          
  case FMT_D:  case FMT_E:        
  case FMT_G:  case FMT_EXT:
    c = format_lex();     
    if (c != FMT_POSINT) {        
      error = posint_required;         
      goto syntax;   
    }    
    
    c = format_lex();   
    if (c != FMT_PERIOD) {  
      error = period_required;    
      goto syntax;  
    } 
 
    c = format_lex();       
    if (c != FMT_ZERO && c != FMT_POSINT) {    
      error = nonneg_required;    
      goto syntax;       
    }    
    
    if (l == FMT_D) break;         
         
/* Look for optional exponent */        
        
    c = format_lex();      
    if (c != FMT_E) {   
      saved_token = c;
    } else {      
      c = format_lex();          
      if (c != FMT_POSINT) {          
	error = "Positive exponent width required";    
	goto syntax;     
      }         
    }        
        
    break;       
       
  case FMT_F:         
    l = format_lex();         
    if (l != FMT_ZERO && l != FMT_POSINT) { 
      error = nonneg_required;  
      goto syntax;     
    }        
        
    l = format_lex();
    if (l != FMT_PERIOD) {
      error = period_required;     
      goto syntax;          
    }

    l = format_lex(); 
    if (l != FMT_ZERO && l != FMT_POSINT) {         
      error = nonneg_required;      
      goto syntax;      
    } 
 
    break;         
         
  case FMT_H:   
  handle_hollerith:      
    if (g95_option.fmode != 0) {        
      error = "The H format specifier is a deleted language feature";          
      goto syntax; 
    }       
       
    while(repeat>0) { 
      if (next_char(0) == '\0') {   
	error = unexpected_end;    
	goto syntax;          
      }          
          
      repeat--;     
    }        
        
    break; 
 
  case FMT_IBOZ:      
    l = format_lex();      
    if (l != FMT_ZERO && l != FMT_POSINT) {  
      error = nonneg_required;          
      goto syntax;   
    }

    l = format_lex();      
    if (l != FMT_PERIOD) {      
      saved_token = l;  
    } else {      
      l = format_lex();       
      if (l != FMT_ZERO && l != FMT_POSINT) {
	error = nonneg_required;    
	goto syntax;      
      }     
    }    
    
    break;  
  
  default:     
    error = unexpected_element;         
    goto syntax;       
  }  
  
/* Between a descriptor and what comes next */   
   
between_desc: 
  l = format_lex();
  switch(l) {        
        
  case FMT_COMMA: 
    goto format_item; 
 
  case FMT_RPAREN:     
  rparen:         
    m--;          
    if (m < 0) goto finished;      
    goto between_desc;          
          
  case FMT_COLON:       
  case FMT_SLASH:         
    goto optional_comma;   
   
  case FMT_END:    
    error = unexpected_end;   
    goto syntax;       
       
  default:    
    error = "Missing comma";          
    goto syntax;   
  }     
     
/* Optional comma is a weird between state where we've just finished
 * reading a colon, slash or P descriptor. */          
          
optional_comma: 
  l = format_lex();   
  switch(l) {          
  case FMT_COMMA:         
    break;         
         
  case FMT_RPAREN:       
    m--;    
    if (m < 0) goto finished;    
    goto between_desc;   
   
  default:     /* Assume that we have another format item */    
    saved_token = l;       
    break;   
  }      
      
  goto format_item;     
     
/* Something went wrong.  If the format we're checking is a string,
 * generate a warning, since the program is correct.  If the format is
 * in a FORMAT statement, this messes up parsing, which is an error. */      
      
syntax:   
  if (mode != MODE_STRING)        
    g95_error("%s in format string at %L", error, &where);  
  else          
    g95_warning(100, "%s in format string at %L", error, &where);         
         
  r = FAILURE;   
   
finished:     
  return r;    
}       
       
       
        
        
/* g95_match_format()-- Match a FORMAT statement.  This amounts to
 * actually parsing the format descriptors in order to correctly
 * locate the end of the format string. */ 
 
match g95_match_format(void) { 
g95_locus sta;
g95_expr *g;       
       
  if (g95_statement_label == NULL) {       
    g95_error("FORMAT statement at %C does not have a statement label");         
    return MATCH_ERROR;     
  } 
 
  g95_gobble_whitespace();          
          
  mode = MODE_FORMAT;         
  format_length = 0; 
 
  sta = where = new_where = g95_current_locus;     
     
  if (check_format() == FAILURE) return MATCH_ERROR;     
     
  if (g95_match_eos() != MATCH_YES) {
    g95_syntax_error(ST_FORMAT);  
    return MATCH_ERROR;  
  }          
          
  /* The label doesn't get created until after the statement is done
   * being matched, so we have to leave the string for later. */       
       
  g95_current_locus = sta;      /* Back to the beginning */

  g = g95_get_expr();          
  g->type = EXPR_CONSTANT;         
  g->ts.type = BT_CHARACTER;          
  g->ts.kind = g95_default_character_kind();       
       
  g->where = sta;       
  g->value.character.string = format_string = g95_getmem(format_length+1);          
  g->value.character.length = format_length;

  g95_statement_label->format = g;        
        
  mode = MODE_COPY;   
  check_format();       /* Guaranteed to succeed */         
         
  g95_match_eos();      /* Guaranteed to succeed */   
  new_st.type = EXEC_NOP;         
         
  return MATCH_YES;     
} 
Example #20
0
static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
{
	struct video_device *vdev = video_devdata(file);
	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
	struct v4l2_fh *vfh = file->private_data;
#if defined(CPTCFG_VIDEO_V4L2_SUBDEV_API)
	struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
	int rval;
#endif

	switch (cmd) {
	case VIDIOC_QUERYCTRL:
		return v4l2_queryctrl(vfh->ctrl_handler, arg);

	case VIDIOC_QUERY_EXT_CTRL:
		return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);

	case VIDIOC_QUERYMENU:
		return v4l2_querymenu(vfh->ctrl_handler, arg);

	case VIDIOC_G_CTRL:
		return v4l2_g_ctrl(vfh->ctrl_handler, arg);

	case VIDIOC_S_CTRL:
		return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);

	case VIDIOC_G_EXT_CTRLS:
		return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);

	case VIDIOC_S_EXT_CTRLS:
		return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);

	case VIDIOC_TRY_EXT_CTRLS:
		return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);

	case VIDIOC_DQEVENT:
		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
			return -ENOIOCTLCMD;

		return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);

	case VIDIOC_SUBSCRIBE_EVENT:
		return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);

	case VIDIOC_UNSUBSCRIBE_EVENT:
		return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);

#ifdef CPTCFG_VIDEO_ADV_DEBUG
	case VIDIOC_DBG_G_REGISTER:
	{
		struct v4l2_dbg_register *p = arg;

		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		return v4l2_subdev_call(sd, core, g_register, p);
	}
	case VIDIOC_DBG_S_REGISTER:
	{
		struct v4l2_dbg_register *p = arg;

		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		return v4l2_subdev_call(sd, core, s_register, p);
	}
#endif

	case VIDIOC_LOG_STATUS: {
		int ret;

		pr_info("%s: =================  START STATUS  =================\n",
			sd->name);
		ret = v4l2_subdev_call(sd, core, log_status);
		pr_info("%s: ==================  END STATUS  ==================\n",
			sd->name);
		return ret;
	}

#if defined(CPTCFG_VIDEO_V4L2_SUBDEV_API)
	case VIDIOC_SUBDEV_G_FMT: {
		struct v4l2_subdev_format *format = arg;

		rval = check_format(sd, format);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
	}

	case VIDIOC_SUBDEV_S_FMT: {
		struct v4l2_subdev_format *format = arg;

		rval = check_format(sd, format);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
	}

	case VIDIOC_SUBDEV_G_CROP: {
		struct v4l2_subdev_crop *crop = arg;
		struct v4l2_subdev_selection sel;

		rval = check_crop(sd, crop);
		if (rval)
			return rval;

		memset(&sel, 0, sizeof(sel));
		sel.which = crop->which;
		sel.pad = crop->pad;
		sel.target = V4L2_SEL_TGT_CROP;

		rval = v4l2_subdev_call(
			sd, pad, get_selection, subdev_fh->pad, &sel);

		crop->rect = sel.r;

		return rval;
	}

	case VIDIOC_SUBDEV_S_CROP: {
		struct v4l2_subdev_crop *crop = arg;
		struct v4l2_subdev_selection sel;

		rval = check_crop(sd, crop);
		if (rval)
			return rval;

		memset(&sel, 0, sizeof(sel));
		sel.which = crop->which;
		sel.pad = crop->pad;
		sel.target = V4L2_SEL_TGT_CROP;
		sel.r = crop->rect;

		rval = v4l2_subdev_call(
			sd, pad, set_selection, subdev_fh->pad, &sel);

		crop->rect = sel.r;

		return rval;
	}

	case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
		struct v4l2_subdev_mbus_code_enum *code = arg;

		if (code->which != V4L2_SUBDEV_FORMAT_TRY &&
		    code->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (code->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
					code);
	}

	case VIDIOC_SUBDEV_ENUM_FRAME_SIZE: {
		struct v4l2_subdev_frame_size_enum *fse = arg;

		if (fse->which != V4L2_SUBDEV_FORMAT_TRY &&
		    fse->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (fse->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
					fse);
	}

	case VIDIOC_SUBDEV_G_FRAME_INTERVAL: {
		struct v4l2_subdev_frame_interval *fi = arg;

		if (fi->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, video, g_frame_interval, arg);
	}

	case VIDIOC_SUBDEV_S_FRAME_INTERVAL: {
		struct v4l2_subdev_frame_interval *fi = arg;

		if (fi->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, video, s_frame_interval, arg);
	}

	case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: {
		struct v4l2_subdev_frame_interval_enum *fie = arg;

		if (fie->which != V4L2_SUBDEV_FORMAT_TRY &&
		    fie->which != V4L2_SUBDEV_FORMAT_ACTIVE)
			return -EINVAL;

		if (fie->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
					fie);
	}

	case VIDIOC_SUBDEV_G_SELECTION: {
		struct v4l2_subdev_selection *sel = arg;

		rval = check_selection(sd, sel);
		if (rval)
			return rval;

		return v4l2_subdev_call(
			sd, pad, get_selection, subdev_fh->pad, sel);
	}

	case VIDIOC_SUBDEV_S_SELECTION: {
		struct v4l2_subdev_selection *sel = arg;

		rval = check_selection(sd, sel);
		if (rval)
			return rval;

		return v4l2_subdev_call(
			sd, pad, set_selection, subdev_fh->pad, sel);
	}

	case VIDIOC_G_EDID: {
		struct v4l2_subdev_edid *edid = arg;

		rval = check_edid(sd, edid);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, get_edid, edid);
	}

	case VIDIOC_S_EDID: {
		struct v4l2_subdev_edid *edid = arg;

		rval = check_edid(sd, edid);
		if (rval)
			return rval;

		return v4l2_subdev_call(sd, pad, set_edid, edid);
	}

	case VIDIOC_SUBDEV_DV_TIMINGS_CAP: {
		struct v4l2_dv_timings_cap *cap = arg;

		if (cap->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
	}

	case VIDIOC_SUBDEV_ENUM_DV_TIMINGS: {
		struct v4l2_enum_dv_timings *dvt = arg;

		if (dvt->pad >= sd->entity.num_pads)
			return -EINVAL;

		return v4l2_subdev_call(sd, pad, enum_dv_timings, dvt);
	}

	case VIDIOC_SUBDEV_QUERY_DV_TIMINGS:
		return v4l2_subdev_call(sd, video, query_dv_timings, arg);

	case VIDIOC_SUBDEV_G_DV_TIMINGS:
		return v4l2_subdev_call(sd, video, g_dv_timings, arg);

	case VIDIOC_SUBDEV_S_DV_TIMINGS:
		return v4l2_subdev_call(sd, video, s_dv_timings, arg);
#endif
	default:
		return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
	}

	return 0;
}
Example #21
0
	presentation_message::presentation_message(const message& _message) :
		message(_message)
	{
		check_format();
	}
Example #22
0
	presentation_message::presentation_message(const void* buf, size_t buf_len) :
		message(buf, buf_len)
	{
		check_format();
	}
Example #23
0
void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum pixelformat, GLenum type, const GLvoid *pixels)
{
	int format;
	int need_texture = 1;
	struct XenosSurface * surf = NULL;
	
	if (type != GL_UNSIGNED_BYTE) {		
		xe_gl_error("glTexImage2D: Unrecognised pixel format\n");
		
		return;
	}
	if (target != GL_TEXTURE_2D)
		return;
		
	if (!xeTmus[xeCurrentTMU].boundtexture) {
		printf("No texture bound\n");
		return;
	}
	
	if (level > 0)
		return;
		
#if 1
	int srcbytes = src_format_to_bypp(pixelformat);
	int dstbytes = 4;
	
	// validate format
	switch (internalformat)
	{
	case 1:
	case GL_LUMINANCE:
		dstbytes = 1;
		format = XE_FMT_8;
		break;
	case 3:
	case GL_RGB:
		dstbytes = 4;
		format = XE_FMT_ARGB|XE_FMT_8888;
		break;
	case 4:
	case GL_RGB8:
	case GL_RGBA:
		dstbytes = 4;
		format = XE_FMT_ARGB|XE_FMT_8888;
		break;
	default:
		printf("%X internalformat\n" , internalformat);
		xe_gl_error ("invalid texture internal format\n");
		return;
	}
	
	if (xeTmus[xeCurrentTMU].boundtexture->teximg) {
		surf = xeTmus[xeCurrentTMU].boundtexture->teximg;
		if ((surf->width != width) || (surf->height != height) || (surf->format != format)) {
			need_texture = 1;
			// destroy texture
			Xe_DestroyTexture(xe, xeTmus[xeCurrentTMU].boundtexture->teximg);
		}
		else {
			need_texture = 0;
		}
	}
	
	if (need_texture) {	
#ifdef USE_TILED_TEXTURE				
		surf = MyXeCreateTexture(xe, width, height, 0, format, 1);
#else
		surf = MyXeCreateTexture(xe, width, height, 0, format, 0);
#endif
		xeTmus[xeCurrentTMU].boundtexture->teximg = surf;
	}
	
	memset(surf->base, 0xFF, surf->wpitch * surf->hpitch);
	xeTmus[xeCurrentTMU].boundtexture->internalformat = internalformat;
		
	uint8_t * surfbuf = (uint8_t*) MyXeSurfaceLockRect(xe, surf, 0, 0, 0, 0, XE_LOCK_WRITE);
	uint8_t * srcdata = (uint8_t*) pixels;
	uint8_t * dstdata = surfbuf;
	int y, x;
	
	check_format(srcbytes, dstbytes);

	for (y = 0; y <height; y++) {
		dstdata = surfbuf + ((y * width) * dstbytes);
		for (x = 0; x < width; x++) {
			if (srcbytes == 4) {
				if (dstbytes == 4) {
					dstdata[0] = srcdata[3];
					dstdata[3] = srcdata[2];
					dstdata[2] = srcdata[1];
					dstdata[1] = srcdata[0];
				} else if(dstbytes == 1) {
					dstdata[0] = ((int) srcdata[0] + (int) srcdata[1] + (int) srcdata[2] + (int) srcdata[3]) / 3;
				}
					
				srcdata += srcbytes;
				dstdata += dstbytes;
				
			} else if (srcbytes == 3) {
				if (dstbytes == 4) {		
					dstdata[0] = 0xff;
					dstdata[3] = srcdata[2];
					dstdata[2] = srcdata[1];
					dstdata[1] = srcdata[0];
				} else if (dstbytes == 1) {
					dstdata[0] = ((int) srcdata[0] + (int) srcdata[1] + (int) srcdata[2]) / 3;
				}
					
				srcdata += srcbytes;
				dstdata += dstbytes;
			} else if (srcbytes == 1) {
				if (dstbytes == 1) {
					dstdata[0] = srcdata[0];
				} else if (dstbytes == 4) {
					dstdata[0] = srcdata[0];
					dstdata[1] = srcdata[0];
					dstdata[2] = srcdata[0];
					dstdata[3] = srcdata[0];
				}
				srcdata += srcbytes;
				dstdata += dstbytes;
			}
		}
	}
	MyXeSurfaceUnlock(xe, surf);


	xeTmus[xeCurrentTMU].boundtexture->dirty = 1;
#endif	
	handle_small_surface(surf, NULL);
}
Example #24
0
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels)
{
	if (level > 0)
		return;
		
	if (!xeTmus[xeCurrentTMU].boundtexture) {
		printf("Not texture binded\n");
		return;
	}
		
	struct XenosSurface * surf = NULL;
	
	if (xeTmus[xeCurrentTMU].boundtexture && xeTmus[xeCurrentTMU].boundtexture->teximg ) {
		surf = xeTmus[xeCurrentTMU].boundtexture->teximg;
	}
	
	if (surf) {
		int srcbytes = src_format_to_bypp(format);
		int dstbytes = dst_format_to_bypp(xeTmus[xeCurrentTMU].boundtexture->internalformat);
		
		uint8_t * surfbuf = (uint8_t*) MyXeSurfaceLockRect(xe, surf, 0, 0, 0, 0, XE_LOCK_WRITE);
		uint8_t * srcdata = (uint8_t*) pixels;
		uint8_t * dstdata = surfbuf;
		
		int y, x;

		int pitch = (width * dstbytes);
		int offset = 0;
		
		check_format(srcbytes, dstbytes);

		for (y = yoffset; y < (yoffset + height); y++) {
			offset = (y * pitch)+(xoffset * dstbytes);
			dstdata = surfbuf + offset;
			
			for (x = xoffset; x < (xoffset + width); x++) {
				if (srcbytes == 4) {
					if (dstbytes == 4) {
						dstdata[0] = srcdata[3];
						dstdata[3] = srcdata[2];
						dstdata[2] = srcdata[1];
						dstdata[1] = srcdata[0];
					} else if(dstbytes == 1) {
						dstdata[0] = ((int) srcdata[0] + (int) srcdata[1] + (int) srcdata[2] + (int) srcdata[3]) / 3;
					}
						
					srcdata += srcbytes;
					dstdata += dstbytes;
					
				} else if (srcbytes == 3) {
					if (dstbytes == 4) {					
						dstdata[0] = 0xff;
						dstdata[3] = srcdata[2];
						dstdata[2] = srcdata[1];
						dstdata[1] = srcdata[0];
					} else if (dstbytes == 1) {
						dstdata[0] = ((int) srcdata[0] + (int) srcdata[1] + (int) srcdata[2]) / 3;
					}
						
					srcdata += srcbytes;
					dstdata += dstbytes;
				} else if (srcbytes == 1) {
					if (dstbytes == 1) {
						dstdata[0] = srcdata[0];
					} else if (dstbytes == 4) {
						dstdata[0] = srcdata[0];
						dstdata[1] = srcdata[0];
						dstdata[2] = srcdata[0];
						dstdata[3] = srcdata[0];
					}
					srcdata += srcbytes;
					dstdata += dstbytes;
				}
			}
		}
	
		MyXeSurfaceUnlock(xe, surf);		
		
		xeTmus[xeCurrentTMU].boundtexture->dirty = 1;

#ifndef USE_TILED_TEXTURE	
		handle_small_surface(surf, NULL);
#endif		
	}
}
Example #25
0
File: fs.c Project: Alkzndr/freebsd
static svn_error_t *
base_hotcopy(svn_fs_t *src_fs,
             svn_fs_t *dst_fs,
             const char *src_path,
             const char *dest_path,
             svn_boolean_t clean_logs,
             svn_boolean_t incremental,
             svn_cancel_func_t cancel_func,
             void *cancel_baton,
             apr_pool_t *pool)
{
  svn_error_t *err;
  u_int32_t pagesize;
  svn_boolean_t log_autoremove = FALSE;
  int format;

  if (incremental)
    return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
                             _("BDB repositories do not support incremental "
                               "hotcopy"));

  /* Check the FS format number to be certain that we know how to
     hotcopy this FS.  Pre-1.2 filesystems did not have a format file (you
     could say they were format "0"), so we will error here.  This is not
     optimal, but since this has been the case since 1.2.0, and no one has
     complained, it apparently isn't much of a concern.  (We did not check
     the 'format' file in 1.2.x, but we did blindly try to copy 'locks',
     which would have errored just the same.)  */
  SVN_ERR(svn_io_read_version_file(
          &format, svn_dirent_join(src_path, FORMAT_FILE, pool), pool));
  SVN_ERR(check_format(format));

  /* If using Berkeley DB 4.2 or later, note whether the DB_LOG_AUTO_REMOVE
     feature is on.  If it is, we have a potential race condition:
     another process might delete a logfile while we're in the middle
     of copying all the logfiles.  (This is not a huge deal; at worst,
     the hotcopy fails with a file-not-found error.) */
#if SVN_BDB_VERSION_AT_LEAST(4, 2)
  err = check_env_flags(&log_autoremove,
#if SVN_BDB_VERSION_AT_LEAST(4, 7)
                          DB_LOG_AUTO_REMOVE,
 /* DB_LOG_AUTO_REMOVE was named DB_LOG_AUTOREMOVE before Berkeley DB 4.7. */
#else
                          DB_LOG_AUTOREMOVE,
#endif
                          src_path, pool);
#endif
  SVN_ERR(err);

  /* Copy the DB_CONFIG file. */
  SVN_ERR(svn_io_dir_file_copy(src_path, dest_path, "DB_CONFIG", pool));

  /* In order to copy the database files safely and atomically, we
     must copy them in chunks which are multiples of the page-size
     used by BDB.  See sleepycat docs for details, or svn issue #1818. */
#if SVN_BDB_VERSION_AT_LEAST(4, 2)
  SVN_ERR(get_db_pagesize(&pagesize, src_path, pool));
  if (pagesize < SVN__STREAM_CHUNK_SIZE)
    {
      /* use the largest multiple of BDB pagesize we can. */
      int multiple = SVN__STREAM_CHUNK_SIZE / pagesize;
      pagesize *= multiple;
    }
#else
  /* default to 128K chunks, which should be safe.
     BDB almost certainly uses a power-of-2 pagesize. */
  pagesize = (4096 * 32);
#endif

  /* Copy the databases.  */
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "nodes", pagesize, FALSE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "transactions", pagesize, FALSE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "revisions", pagesize, FALSE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "copies", pagesize, FALSE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "changes", pagesize, FALSE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "representations", pagesize, FALSE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "strings", pagesize, FALSE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "uuids", pagesize, TRUE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "locks", pagesize, TRUE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "lock-tokens", pagesize, TRUE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "node-origins", pagesize, TRUE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "checksum-reps", pagesize, TRUE, pool));
  SVN_ERR(copy_db_file_safely(src_path, dest_path,
                              "miscellaneous", pagesize, TRUE, pool));

  {
    apr_array_header_t *logfiles;
    int idx;
    apr_pool_t *subpool;

    SVN_ERR(base_bdb_logfiles(&logfiles,
                              src_path,
                              FALSE,   /* All logs */
                              pool));

    /* Process log files. */
    subpool = svn_pool_create(pool);
    for (idx = 0; idx < logfiles->nelts; idx++)
      {
        svn_pool_clear(subpool);
        err = svn_io_dir_file_copy(src_path, dest_path,
                                   APR_ARRAY_IDX(logfiles, idx,
                                                 const char *),
                                   subpool);
        if (err)
          {
            if (log_autoremove)
              return
                svn_error_quick_wrap
                (err,
                 _("Error copying logfile;  the DB_LOG_AUTOREMOVE feature\n"
                   "may be interfering with the hotcopy algorithm.  If\n"
                   "the problem persists, try deactivating this feature\n"
                   "in DB_CONFIG"));
            else
              return svn_error_trace(err);
          }
      }
    svn_pool_destroy(subpool);
  }

  /* Since this is a copy we will have exclusive access to the repository. */
  err = bdb_recover(dest_path, TRUE, pool);
  if (err)
    {
      if (log_autoremove)
        return
          svn_error_quick_wrap
          (err,
           _("Error running catastrophic recovery on hotcopy;  the\n"
             "DB_LOG_AUTOREMOVE feature may be interfering with the\n"
             "hotcopy algorithm.  If the problem persists, try deactivating\n"
             "this feature in DB_CONFIG"));
      else
        return svn_error_trace(err);
    }

  /* Only now that the hotcopied filesystem is complete,
     stamp it with a format file. */
  SVN_ERR(svn_io_write_version_file(
             svn_dirent_join(dest_path, FORMAT_FILE, pool), format, pool));

  if (clean_logs)
    SVN_ERR(svn_fs_base__clean_logs(src_path, dest_path, pool));

  return SVN_NO_ERROR;
}
Example #26
0
data_message::data_message(const void* buf, size_t buf_len) :
    message(buf, buf_len)
{
    check_format();
}
Example #27
0
data_message::data_message(const message& _message) :
    message(_message)
{
    check_format();
}
Example #28
0
// Initialization and runtime control
static int control(struct af_instance_s* af, int cmd, void* arg)
{
  switch(cmd){
  case AF_CONTROL_REINIT:{
    char buf1[256];
    char buf2[256];
    af_data_t *data = arg;

    // Make sure this filter isn't redundant
    if(af->data->format == data->format &&
       af->data->bps == data->bps)
      return AF_DETACH;

    // Allow trivial AC3-endianness conversion
    if (!AF_FORMAT_IS_AC3(af->data->format) || !AF_FORMAT_IS_AC3(data->format))
    // Check for errors in configuration
    if((AF_OK != check_bps(data->bps)) ||
       (AF_OK != check_format(data->format)) ||
       (AF_OK != check_bps(af->data->bps)) ||
       (AF_OK != check_format(af->data->format)))
      return AF_ERROR;

    mp_msg(MSGT_AFILTER, MSGL_V, "[format] Changing sample format from %s to %s\n",
	   af_fmt2str(data->format,buf1,256),
	   af_fmt2str(af->data->format,buf2,256));

    af->data->rate = data->rate;
    af->data->nch  = data->nch;
    af->mul        = (double)af->data->bps / data->bps;

    af->play = play; // set default

    // look whether only endianness differences are there
    if ((af->data->format & ~AF_FORMAT_END_MASK) ==
	(data->format & ~AF_FORMAT_END_MASK))
    {
	mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated endianness conversion only\n");
	af->play = play_swapendian;
    }
    if ((data->format == AF_FORMAT_FLOAT_NE) &&
	(af->data->format == AF_FORMAT_S16_NE))
    {
	mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated %s to %s conversion\n",
	   af_fmt2str(data->format,buf1,256),
	   af_fmt2str(af->data->format,buf2,256));
	af->play = play_float_s16;
    }
    if ((data->format == AF_FORMAT_S16_NE) &&
	(af->data->format == AF_FORMAT_FLOAT_NE))
    {
	mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated %s to %s conversion\n",
	   af_fmt2str(data->format,buf1,256),
	   af_fmt2str(af->data->format,buf2,256));
	af->play = play_s16_float;
    }
    return AF_OK;
  }
  case AF_CONTROL_COMMAND_LINE:{
    int format = af_str2fmt_short(bstr0(arg));
    if (format == -1) {
      mp_msg(MSGT_AFILTER, MSGL_ERR, "[format] %s is not a valid format\n", (char *)arg);
      return AF_ERROR;
    }
    if(AF_OK != af->control(af,AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET,&format))
      return AF_ERROR;
    return AF_OK;
  }
  case AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET:{
    // Check for errors in configuration
    if(!AF_FORMAT_IS_AC3(*(int*)arg) && AF_OK != check_format(*(int*)arg))
      return AF_ERROR;

    af->data->format = *(int*)arg;
    af->data->bps = af_fmt2bits(af->data->format)/8;

    return AF_OK;
  }
  }
  return AF_UNKNOWN;
}
Example #29
0
/*
 * parse one line from magic file, put into magic[index++] if valid
 */
static int parse(RMagic *ms, struct r_magic_entry **mentryp, ut32 *nmentryp, const char *line, size_t lineno, int action) {
	static ut32 last_cont_level = 0;
	size_t i;
	struct r_magic_entry *me;
	struct r_magic *m;
	const char *l = line;
	char *t;
	int op;
	ut32 cont_level = 0;

	for (; *l == '>'; l++, cont_level++);
	if (cont_level == 0 || cont_level > last_cont_level)
		if (file_check_mem (ms, cont_level) == -1)
			return -1;
	last_cont_level = cont_level;
#define ALLOC_CHUNK	(size_t)10
#define ALLOC_INCR	(size_t)200
	if (cont_level != 0) {
		if (*nmentryp == 0) {
			file_error(ms, 0, "No current entry for continuation");
			return -1;
		}
		me = &(*mentryp)[*nmentryp - 1];
		if (me->cont_count == me->max_count) {
			struct r_magic *nm;
			size_t cnt = me->max_count + ALLOC_CHUNK;
			if (!(nm = realloc(me->mp, sizeof (*nm) * cnt))) {
				file_oomem(ms, sizeof (*nm) * cnt);
				return -1;
			}
			me->mp = nm;
			me->max_count = cnt;
		}
		m = &me->mp[me->cont_count++];
		(void)memset(m, 0, sizeof (*m));
		m->cont_level = cont_level;
	} else {
		if (*nmentryp == maxmagic) {
			struct r_magic_entry *mp;

			maxmagic += ALLOC_INCR;
			if (!(mp = realloc (*mentryp, sizeof (*mp) * maxmagic))) {
				file_oomem (ms, sizeof (*mp) * maxmagic);
				return -1;
			}
			(void)memset(&mp[*nmentryp], 0, sizeof (*mp) *
			    ALLOC_INCR);
			*mentryp = mp;
		}
		me = &(*mentryp)[*nmentryp];
		if (!me->mp) {
			if (!(m = malloc (sizeof (*m) * ALLOC_CHUNK))) {
				file_oomem (ms, sizeof (*m) * ALLOC_CHUNK);
				return -1;
			}
			me->mp = m;
			me->max_count = ALLOC_CHUNK;
		} else
			m = me->mp;
		(void)memset(m, 0, sizeof (*m));
		m->cont_level = 0;
		me->cont_count = 1;
	}
	m->lineno = lineno;

	if (*l == '&') {  /* m->cont_level == 0 checked below. */
                ++l;            /* step over */
                m->flag |= OFFADD;
        }
	if (*l == '(') {
		++l;		/* step over */
		m->flag |= INDIR;
		if (m->flag & OFFADD)
			m->flag = (m->flag & ~OFFADD) | INDIROFFADD;

		if (*l == '&') {  /* m->cont_level == 0 checked below */
			++l;            /* step over */
			m->flag |= OFFADD;
		}
	}
	/* Indirect offsets are not valid at level 0. */
	if (m->cont_level == 0 && (m->flag & (OFFADD | INDIROFFADD)))
		if (ms->flags & R_MAGIC_CHECK)
			file_magwarn(ms, "relative offset at level 0");

	/* get offset, then skip over it */
	m->offset = (ut32)strtoul(l, &t, 0);
        if ((l == t) && (ms->flags & R_MAGIC_CHECK))
		file_magwarn(ms, "offset `%s' invalid", l);
        l = t;

	if (m->flag & INDIR) {
		m->in_type = FILE_LONG;
		m->in_offset = 0;
		/*
		 * read [.lbs][+-]nnnnn)
		 */
		if (*l == '.') {
			l++;
			switch (*l) {
			case 'l':
				m->in_type = FILE_LELONG;
				break;
			case 'L':
				m->in_type = FILE_BELONG;
				break;
			case 'm':
				m->in_type = FILE_MELONG;
				break;
			case 'h':
			case 's':
				m->in_type = FILE_LESHORT;
				break;
			case 'H':
			case 'S':
				m->in_type = FILE_BESHORT;
				break;
			case 'c':
			case 'b':
			case 'C':
			case 'B':
				m->in_type = FILE_BYTE;
				break;
			case 'e':
			case 'f':
			case 'g':
				m->in_type = FILE_LEDOUBLE;
				break;
			case 'E':
			case 'F':
			case 'G':
				m->in_type = FILE_BEDOUBLE;
				break;
			default:
				if (ms->flags & R_MAGIC_CHECK)
					file_magwarn(ms,
					    "indirect offset type `%c' invalid",
					    *l);
				break;
			}
			l++;
		}

		m->in_op = 0;
		if (*l == '~') {
			m->in_op |= FILE_OPINVERSE;
			l++;
		}
		if ((op = get_op(*l)) != -1) {
			m->in_op |= op;
			l++;
		}
		if (*l == '(') {
			m->in_op |= FILE_OPINDIRECT;
			l++;
		}
		if (isdigit((ut8)*l) || *l == '-') {
			m->in_offset = (int32_t)strtol(l, &t, 0);
			if (l == t)
				if (ms->flags & R_MAGIC_CHECK)
					file_magwarn(ms,
					    "in_offset `%s' invalid", l);
			l = t;
		}
		if (*l++ != ')' ||
		    ((m->in_op & FILE_OPINDIRECT) && *l++ != ')'))
			if (ms->flags & R_MAGIC_CHECK)
				file_magwarn(ms,
				    "missing ')' in indirect offset");
	}
	EATAB;

	m->cond = get_cond(l, &l);
	if (check_cond(ms, m->cond, cont_level) == -1)
		return -1;
	EATAB;

	if (*l == 'u') {
		++l;
		m->flag |= UNSIGNED;
	}

	m->type = get_type(l, &l);
	if (m->type == FILE_INVALID) {
		if (ms->flags & R_MAGIC_CHECK)
			file_magwarn(ms, "type `%s' invalid", l);
		return -1;
	}

	/* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
	/* New and improved: ~ & | ^ + - * / % -- exciting, isn't it? */

	m->mask_op = 0;
	if (*l == '~') {
		if (!MAGIC_IS_STRING (m->type))
			m->mask_op |= FILE_OPINVERSE;
		else if (ms->flags & R_MAGIC_CHECK)
			file_magwarn (ms, "'~' invalid for string types");
		++l;
	}
	m->str_range = 0;
	m->str_flags = 0;
	m->num_mask = 0;
	if ((op = get_op (*l)) != -1) {
		if (!MAGIC_IS_STRING (m->type)) {
			ut64 val;
			++l;
			m->mask_op |= op;
			val = (ut64)strtoull (l, &t, 0);
			l = t;
			m->num_mask = file_signextend (ms, m, val);
			eatsize (&l);
		}
		else if (op == FILE_OPDIVIDE) {
			int have_range = 0;
			while (!isspace ((ut8)*++l)) {
				switch (*l) {
				case '0':  case '1':  case '2':
				case '3':  case '4':  case '5':
				case '6':  case '7':  case '8':
				case '9':
					if (have_range &&
					    (ms->flags & R_MAGIC_CHECK))
						file_magwarn(ms,
						    "multiple ranges");
					have_range = 1;
					m->str_range = strtoul(l, &t, 0);
					if (m->str_range == 0)
						file_magwarn(ms,
						    "zero range");
					l = t - 1;
					break;
				case CHAR_COMPACT_BLANK:
					m->str_flags |= STRING_COMPACT_BLANK;
					break;
				case CHAR_COMPACT_OPTIONAL_BLANK:
					m->str_flags |=
					    STRING_COMPACT_OPTIONAL_BLANK;
					break;
				case CHAR_IGNORE_LOWERCASE:
					m->str_flags |= STRING_IGNORE_LOWERCASE;
					break;
				case CHAR_IGNORE_UPPERCASE:
					m->str_flags |= STRING_IGNORE_UPPERCASE;
					break;
				case CHAR_REGEX_OFFSET_START:
					m->str_flags |= REGEX_OFFSET_START;
					break;
				default:
					if (ms->flags & R_MAGIC_CHECK)
						file_magwarn(ms,
						"string extension `%c' invalid",
						*l);
					return -1;
				}
				/* allow multiple '/' for readability */
				if (l[1] == '/' && !isspace ((ut8)l[2]))
					l++;
			}
			if (string_modifier_check(ms, m) == -1)
				return -1;
		} else {
			if (ms->flags & R_MAGIC_CHECK)
				file_magwarn(ms, "invalid string op: %c", *t);
			return -1;
		}
	}
	/*
	 * We used to set mask to all 1's here, instead let's just not do
	 * anything if mask = 0 (unless you have a better idea)
	 */
	EATAB;

	switch (*l) {
	case '>':
	case '<':
	/* Old-style anding: "0 byte &0x80 dynamically linked" */
	case '&':
	case '^':
	case '=':
  		m->reln = *l;
  		++l;
		if (*l == '=') {
		   /* HP compat: ignore &= etc. */
		   ++l;
		}
		break;
	case '!':
		m->reln = *l;
		++l;
		break;
	default:
  		m->reln = '=';	/* the default relation */
		if (*l == 'x' && ((isascii((ut8)l[1]) &&
				isspace ((ut8)l[1])) || !l[1])) {
			m->reln = *l;
			++l;
		}
		break;
	}
	/*
	 * Grab the value part, except for an 'x' reln.
	 */
	if (m->reln != 'x' && getvalue (ms, m, &l, action))
		return -1;

	/*
	 * TODO finish this macro and start using it!
	 * #define offsetcheck {if (offset > HOWMANY-1)
	 *	magwarn("offset too big"); }
	 */

	/*
	 * Now get last part - the description
	 */
	EATAB;
	if (l[0] == '\b') {
		++l;
		m->flag |= NOSPACE;
	} else if ((l[0] == '\\') && (l[1] == 'b')) {
		++l;
		++l;
		m->flag |= NOSPACE;
	}
	for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof (m->desc); )
		continue;
	if (i == sizeof (m->desc)) {
		m->desc[sizeof (m->desc) - 1] = '\0';
		if (ms->flags & R_MAGIC_CHECK)
			file_magwarn(ms, "description `%s' truncated", m->desc);
	}

        /*
	 * We only do this check while compiling, or if any of the magic
	 * files were not compiled.
         */
        if (ms->flags & R_MAGIC_CHECK)
		if (check_format (ms, m) == -1)
			return -1;
	if (action == FILE_CHECK)
		file_mdump (m);
	m->mimetype[0] = '\0';		/* initialise MIME type to none */
	if (m->cont_level == 0)
		++(*nmentryp);		/* make room for next */
	return 0;
}
Example #30
0
void parse_comand_line(int argc, char* argv[], char*& input_filename, 
		       char*& input_sites, char*& mesh_format, char*& tetgen_params)
{
  int i = 1;

  if (argc == 1)
  {
    printf("Usage: GenerateMesh [OPTION] FILE\n");
    exit(0);
  }

  // Parse command line
  while (i < argc)
  {
    // Parse --help
    if (strcmp (argv[i], "--help") == 0)
    {
      long_usage();
      exit(0);
    }

    // Parse --format option
    if (strcmp (argv[i], "--format") == 0)
    {
      i++;
      if (i == argc)
	option_error();
      mesh_format = argv[i];
      if (check_format(mesh_format))
	option_error();
      i++;
      if (i == argc)
	option_error();
      
      continue;
    }

    // Parse --format option
    if (strcmp (argv[i], "--tetgen-params") == 0)
    {
      i++;
      if (i == argc)
	option_error();
      sprintf(tetgen_params, "%s%s", tetgen_default_params, argv[i]);
      i++;
      if (i == argc)
	option_error();
      
      continue;
    }

    // Parse --active-sites option
    if (strcmp (argv[i], "--active-sites") == 0)
    {
      i++;
      if (i == argc)
	option_error();
      input_sites = argv[i];
      i++;
      if (i == argc)
	option_error();
      
      continue;
    }
    
    // Parse filename
    input_filename = argv[i];
    i++;
    if (i != argc)
      option_error();
    
  }

}