コード例 #1
0
ファイル: xtt_tbl_command.cpp プロジェクト: hfuhuang/proview
int XttTbl::readcmdfile( 	char		*incommand)
{
  char		input_str[160];
  int		sts;
  int		appl_sts;
  
  if ( !ccm_func_registred) {
      ccm_func_registred = 1;
  }

  strcpy( input_str, incommand);
  dcli_remove_blank( input_str, input_str);
  xtttbl_store_xtttbl( this);

  /* Read and execute the command file */
  sts = ccm_file_exec( input_str, xtttbl_externcmd_func,
		       xtttbl_ccm_deffilename_func, xtttbl_ccm_errormessage_func, 
		       &appl_sts, verify, 0, NULL, 0, 0, NULL, (void *)this);
  if ( EVEN(sts)) return sts;
  
  return 1;
}
コード例 #2
0
ファイル: co_xml_parser.cpp プロジェクト: hfuhuang/proview
//
// Convert octet string to binary
// 
int co_xml_parser::ostring_to_data( unsigned char **data, const char *str, int size, int *rsize)
{
  char valstr[40];
  int valcnt;
  unsigned int val;
  const char *s, *t;
  int sts;

  *data = (unsigned char *) calloc( 1, size);
  t = str;
  valcnt = 0;
  for ( s = str;; s++) {
    if ( valcnt > size) {
      printf( "** Size error");
      break;
    }
    if ( *s == ',' || *s == 0) {
      strncpy( valstr, t, s - t);
      valstr[s - t] = 0;
      dcli_remove_blank( valstr, valstr);
      if ( valstr[0] == '0' && valstr[1] == 'x')
	sts = sscanf( &valstr[2], "%x", &val);
      else
	sts = sscanf( valstr, "%d", &val);
      *(*data + valcnt++) = (unsigned char) val;
      if ( sts != 1)
	error_message( "Syntax error in octet string, %s", str);
 
      t = s+1;
    }
    if ( *s == 0)
      break;
  }
  if ( rsize)
    *rsize = valcnt;
  return 1;
}
コード例 #3
0
PalFileMenu *PalFile::config_tree_build( ldh_tSession ldhses, const char *filename, 
				   pal_eNameType keytype, const char *keyname, PalFileMenu *menu)
{
  ifstream	fp;
  int		line_cnt = 0;
  char		line[140];
  char		type[120];
  char		name[120];
  int           nr;
  PalFileMenu     *menu_tree = NULL;
  PalFileMenu     *menu_p, *mp;
  char          fname[120];

  dcli_translate_filename( fname, filename);

  fp.open( fname);
#ifndef OS_VMS
  if ( !fp)
    return menu_tree;
#endif

  line_cnt = 0;
  while ( 1)
  {
    if ( !fp.getline( line, sizeof( line)))
      break;
    dcli_remove_blank( line, line);
    line_cnt++;
    if ( line[0] == 0)
      continue;
    if ( line[0] == '!' || line[0] == '#')
      continue;
    nr = sscanf( line, "%s %s", type, name);
    if ( nr < 1 )
      printf( "** Syntax error in file %s, line %d\n", filename, line_cnt);

    if ( keytype != pal_eNameType_All) {
      if ( (keytype == pal_eNameType_TopObjects && 
	    cdh_NoCaseStrcmp( type, "topobjects") == 0 && 
	    cdh_NoCaseStrcmp( name, keyname) == 0) ||
	   (keytype == pal_eNameType_Palette && 
	    cdh_NoCaseStrcmp( type, "palette") == 0 && 
	    cdh_NoCaseStrcmp( name, keyname) == 0)) {
	if ( nr != 2)
	  printf( "** Syntax error in file %s, line %d\n", filename, line_cnt);

	if ( !menu)
	  menu_tree = new PalFileMenu( name, pal_eMenuType_Menu, NULL);
	else
	  menu_tree = menu;

	if ( !fp.getline( line, sizeof( line)))
	  break;
	line_cnt++;
	if ( strcmp( line, "{") != 0)
	  printf( "** Syntax error in file %s, line %d\n", filename, line_cnt);

	menu_p = config_tree_build_children( ldhses, &fp, &line_cnt, filename,
					     menu_tree);
	if ( !menu_tree->child_list)
	  menu_tree->child_list = menu_p;
	break;
      }
    }
    else {
      if ( nr != 2)
	printf( "** Syntax error in file %s, line %d\n", filename, line_cnt);

      if ( cdh_NoCaseStrcmp( type, "topobjects") == 0)
	menu_p = new PalFileMenu( name, pal_eMenuType_TopObjects, NULL);
      else if ( cdh_NoCaseStrcmp( type, "palette") == 0)
	menu_p = new PalFileMenu( name, pal_eMenuType_Palette, NULL);
      
      if ( !menu_tree)
	menu_tree = menu_p;
      else {
	for ( mp = menu_tree; mp->next; mp = mp->next)
	  ;
	mp->next = menu_p;
      }

      if ( !fp.getline( line, sizeof( line)))
	break;
      line_cnt++;
      if ( strcmp( line, "{") != 0)
	printf( "** Syntax error in file %s, line %d\n", filename, line_cnt);
      
      menu_p->child_list = config_tree_build_children( ldhses, &fp, &line_cnt,
						       filename, menu_p);
    }
  }
  fp.close();
  return menu_tree;
}
コード例 #4
0
PalFileMenu *PalFile::config_tree_build_children( ldh_tSession ldhses, ifstream *fp, 
	       int *line_cnt, const char *filename, PalFileMenu *parent)
{
  PalFileMenu	        *menu_p, *prev, *mp;
  PalFileMenu	        *return_menu = NULL;
  int			first = 1;
  int			nr;
  char			line[140];
  char			type[120];
  char			name[120];
  char			p1[120];
  char			p2[120];
  int                   found;
  int                   hide_children = 0;

    // Children might already exist
  if ( parent) {
    for ( menu_p = parent->child_list; menu_p; menu_p = menu_p->next) {
      prev = menu_p;
      first = 0;
    }
  }
  menu_p = 0;

  while ( 1)
  {
    if ( !fp->getline( line, sizeof( line)))
      break;
    dcli_remove_blank( line, line);
    (*line_cnt)++;
    if ( line[0] == 0)
      continue;
    if ( line[0] == '!' || line[0] == '#')
      continue;
    nr = sscanf( line, "%s %s %s %s", type, name, p1, p2);
    if ( nr < 1 )
      printf( "** Syntax error in file %s, line %d\n", filename, *line_cnt);

    if ( strcmp( type, "{") == 0)
    {
      if ( !hide_children) {
        if ( nr != 1 || !menu_p)
          printf( "** Syntax error in file %s, line %d\n", filename, *line_cnt);
        else
          mp = config_tree_build_children( ldhses, fp, line_cnt, filename,
		menu_p);
        if ( !menu_p->child_list)
          menu_p->child_list = mp;
      }
      else
	hide_children = 0;
    }
    else if ( strcmp( type, "}") == 0)
    {
      if ( nr != 1 )
        printf( "** Syntax error in file %s, line %d\n", filename, *line_cnt);
      return return_menu;
    }
    else if ( cdh_NoCaseStrcmp( type, "menu") == 0)
    {
      if ( !(nr == 2 || nr == 3))
        printf( "** Syntax error in file %s, line %d\n", filename, *line_cnt);

      if ( nr == 3 && ( ldhses && !check_volume( ldhses, p1))) {
        hide_children = 1;
        break;
      }

      // Check if it already exist
      found = 0;
      for ( menu_p = parent->child_list; menu_p; menu_p = menu_p->next) {
        if ( strcmp( menu_p->title, name) == 0) {
          found = 1;
          break;
        }
      } 

      if ( !found) {
        menu_p = new PalFileMenu( name, pal_eMenuType_Menu, parent);
        if ( first) {
          return_menu = menu_p;
          first = 0;
        }
        else
          prev->next = menu_p;
        prev = menu_p;
      }
    }
    else if ( cdh_NoCaseStrcmp( type, "class") == 0) {
      if ( !( nr == 2 || nr == 3))
        printf( "** Syntax error in file %s, line %d\n", filename, *line_cnt);

      if ( nr == 2 || ( nr == 3 && (!ldhses || check_volume( ldhses, p1)))) {
        menu_p = new PalFileMenu( name, pal_eMenuType_Class, parent);
        if ( first) {
          return_menu = menu_p;
          first = 0;
        }
        else
          prev->next = menu_p;
        prev = menu_p;
      }
    }
    else if ( cdh_NoCaseStrcmp( type, "classvolume") == 0)
    {
      if ( !(nr == 2 || nr == 3))
        printf( "** Syntax error in file %s, line %d\n", filename, *line_cnt);

      if ( nr == 2 || ( nr == 3 && (!ldhses || check_volume( ldhses, p1)))) {
        menu_p = new PalFileMenu( name, pal_eMenuType_ClassVolume, parent);
        if ( first) {
          return_menu = menu_p;
          first = 0;
        }
        else
          prev->next = menu_p;
        prev = menu_p;
      }
    }
  }

  return return_menu;
}