Exemple #1
0
/*----------------------------------------------------------------------------*/
void music_info_init(void)
{
#ifdef USB_SD_DECODE_DEFAULT_REP_OFF
    	play_mode=REPEAT_OFF;
#else
    play_mode = read_info(MEM_PLAY_MODE);
    if (play_mode > REPEAT_RANDOM)
    {
        play_mode = REPEAT_ALL;
    }
#endif
    if (given_device == 0)		  //设备启动时,given_device为0;
    {
        given_device = read_info(MEM_ACTIVE_DEV);
        if ((given_device != 0x01) && (given_device != 0x02))
        {
            given_device = 0x01;
            given_file_number = 1;
        }
    }

    eq_mode = read_info(MEM_EQ_MODE);
    if (eq_mode > CLASSIC)
    {
        eq_mode = NORMAL;
    }
}
Exemple #2
0
int request_usr(simple_person ** arr, int * size, int id,char * conect, tOPC opc)
{

	char opOK=0,qty_people=0;
	int full_size;
	clsvbuff buff;

	initConnection(TYPE_MSG_Q);

	buff.opc=opc;
	buff.id_client=id;
	write_info(&buff);
	read_info(&opOK,sizeof(char),buff.id_client);
	if(opOK==NOTOK)
	{
		return NOTOK;
	}
	read_info((char*)&qty_people,sizeof(char),buff.id_client);
	*size=qty_people;
	full_size=sizeof(simple_person) * (*size);

	if(full_size>0)
	{
		*arr=malloc(full_size);
		if(*arr==NULL)
			return NOTOK;
		read_info((char*) (*arr),full_size,buff.id_client);
	}

	return OK;
}
u16 read_radio_freq(u8 ch)
{
	xd_u16 freq_reg=0;

	freq_reg = read_info(ch+1);
	freq_reg=freq_reg<<8;
	freq_reg |= read_info(ch);

	return freq_reg;	
}
Exemple #4
0
u16 read_radio_freq(u8 ch)
{
	xd_u16 freq_reg=0;
	
	ch=ch<<1;

	freq_reg = read_info(MEM_FM_CHANNL +ch+1);
	freq_reg=freq_reg<<8;
	freq_reg |= read_info(MEM_FM_CHANNL +ch);
	return freq_reg;	
}
/*----------------------------------------------------------------------------*/
void restore_music_point(void)
{
    u8 i;
    for (i = 0;i<10;i++)
    {
        ((u8 *)(&(disk_mus_point[0].id0)))[i] = read_info(MEM_SD_PLAYPOINT_ID0+i);
    }
    for (i = 0;i<10;i++)
    {
        ((u8 *)(&(disk_mus_point[1].id0)))[i] = read_info(MEM_USB_PLAYPOINT_ID0+i);
    }

}
void
print_list_rest (FILE * in)
{
  char stringBuf[1024];

  GList *ac = NULL;
  GList *list = read_info (in);

  list = g_list_sort (list, CompareAccountByUsername);
  printf (" USER             REASON  PERIOD  LEVEL   TIME LEFT(s)\n");
  for (ac = g_list_first (list); ac != NULL; ac = g_list_next (ac))
    {
      Account *_ac = (Account *) ac->data;

      if (_ac->info.field_restrict != NO_PERIOD)
	{
	  //printf( " %-16s %-6s  %-6s   %c     %-4d\n", 
	  printf (" %-16s %-6s  %-6s   %c     %d\n", _ac->id,	//name
		  read_restrict_reason (_ac),	//reason
		  read_restrict_reriod (_ac),	//period
		  get_restrict_level (_ac->restricted),	//level
		  get_time_to_end (_ac)	//time left
	    );
	}
      free (_ac->id);
      free (_ac);
    }
  g_list_free (list);
}
int main()
{
	char service_name[256];

	printf("Input service name you want to connect:\n");
	fgets(service_name, sizeof(service_name), stdin);
	if (service_name[strlen(service_name) - 1] == '\n')
		service_name[strlen(service_name) - 1] = '\0';

	if (!connect_to_service(service_name)) {
		fprintf(stderr, "connect_to_service failed\n");
		exit(EXIT_FAILURE);
	}

	if (!read_info()) {
		fprintf(stderr, "read_info failed\n");
		exit(EXIT_FAILURE);
	}

	if (socketfd != -1) {
		close(socketfd);
	}

	exit(EXIT_SUCCESS);
}
Exemple #8
0
int
main(int argc, char *argv[])
{
	char *p;
	size_t len;
	Subrange *r;
	int (*fn)(Rune **r0, Rune **r1, Rune **r2, Rune **r3);

	p = strrchr(argv[0], '/');
	p = p? p+1 : argv[0];
	switch (*p) {
		case 'c' :	fn = fn_c;	break;
		case 'i' :		fn = fn_i;	break;
		case 'd' :	fn = fn_d;	break;
		case 'a' :	fn = fn_a;	break;
		default:
			fprintf(stderr,"Uknown program name!\n");
			exit(1);
	}
	if (*p != 'd') {
		if (argc < 2) {
			fprintf(stderr,"%c: need text argument\n", *p);
			exit(1);
		}
		argtorune(argv[1]);
	}
	read_info(0);		/* don't reverse ranges */
	do_changes(fn);
	list_changes();
	exit(0);
}
Exemple #9
0
static void get_connections_complete(int sk, void *buf, size_t len)
{
	struct mgmt_rp_get_connections *rp = buf;
	struct controller_info *info;
	uint16_t index;
	int i;

	if (len < sizeof(*rp)) {
		error("Too small get_connections complete event");
		return;
	}

	if (len < (sizeof(*rp) + (rp->conn_count * sizeof(bdaddr_t)))) {
		error("Too small get_connections complete event");
		return;
	}

	index = btohs(bt_get_unaligned(&rp->index));

	if (index > max_index) {
		error("Unexpected index %u in get_connections complete",
								index);
		return;
	}

	info = &controllers[index];

	for (i = 0; i < rp->conn_count; i++) {
		bdaddr_t *bdaddr = g_memdup(&rp->conn[i], sizeof(bdaddr_t));
		info->connections = g_slist_append(info->connections, bdaddr);
	}

	read_info(sk, index);
}
/*----------------------------------------------------------------------------*/
void music_info_init(void)
{
#ifdef NO_REM_LAST_DEV
	given_device = NO_DEVICE;
#else
     given_device = read_info(MEM_ACTIVE_DEV);
#endif

    if (given_device == DEVICE_SDMMC0)
    {
	 Set_Curr_Func(SYS_MP3DECODE_SD);
        given_file_method = PLAY_FIRST_FILE;
        given_device = DEVICE_SDMMC0;
        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
    }
    else if (given_device == DEVICE_UDISK)
    {
    	 Set_Curr_Func(SYS_MP3DECODE_USB);
        given_file_method = PLAY_FIRST_FILE;
        given_device = DEVICE_UDISK;
        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
    }
    else
    {
    	 Set_Curr_Func(SYS_MP3DECODE_USB);
        given_file_method = PLAY_FIRST_FILE;
        given_device = DEVICE_UDISK;
        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
    }
}
Exemple #11
0
int IndexFile::open_index(Asset *asset)
{
// use buffer if being built
	this->asset = asset;
	int result = 0;

	if(asset->index_status == INDEX_BUILDING)
	{
// use buffer
		result = 0;
	}
	else
	if(!(result = open_file()))
	{
// opened existing file
		if(read_info())
		{
			result = 1;
			close_index();
		}
		else
		{
			asset->index_status = INDEX_READY;
		}
	}
	else
	{
		result = 1;
	}

	return result;
}
Exemple #12
0
/**
 * Add a pseudonym to the set of known pseudonyms.
 * For all pseudonym advertisements that we discover
 * FS should automatically call this function.
 *
 * @param cfg overall configuration
 * @param id the pseudonym identifier
 * @param meta metadata for the pseudonym
 */
void
GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg,
                      const struct GNUNET_HashCode * id,
                      const struct GNUNET_CONTAINER_MetaData *meta)
{
  char *name;
  int32_t ranking;
  struct GNUNET_CONTAINER_MetaData *old;
  char *fn;
  struct stat sbuf;

  ranking = 0;
  fn = get_data_filename (cfg, PS_METADATA_DIR, id);
  GNUNET_assert (fn != NULL);

  if ((0 == STAT (fn, &sbuf)) &&
      (GNUNET_OK == read_info (cfg, id, &old, &ranking, &name)))
  {
    GNUNET_CONTAINER_meta_data_merge (old, meta);
    write_pseudonym_info (cfg, id, old, ranking, name);
    GNUNET_CONTAINER_meta_data_destroy (old);
    GNUNET_free_non_null (name);
  }
  else
  {
    write_pseudonym_info (cfg, id, meta, ranking, NULL);
  }
  GNUNET_free (fn);
  internal_notify (id, meta, ranking);
}
Exemple #13
0
int
do_info(const char *const *argv)
{
  const char *thisarg;
  struct partinfo *pi, ps;
  struct dpkg_ar *part;

  if (!*argv)
    badusage(_("--%s requires one or more part file arguments"),
             cipaction->olong);

  while ((thisarg= *argv++)) {
    part = dpkg_ar_open(thisarg);
    if (!part)
      ohshite(_("cannot open archive part file '%.250s'"), thisarg);
    pi = read_info(part, &ps);
    dpkg_ar_close(part);
    if (pi) {
      print_info(pi);
    } else {
      printf(_("file '%s' is not an archive part\n"), thisarg);
    }
    m_output(stdout, _("<standard output>"));
  }

  return 0;
}
Exemple #14
0
bool Channel::read_tile_or_closest_ancestor(TileIndex ti, TileIndex &ret_index, Tile &ret) const {
  Locker lock(*this);  // Lock self and hold lock until exiting this method
  ChannelInfo info;
  bool success = read_info(info);
  if (!success) {
    if (verbosity) log_f("read_tile_or_closest_ancestor: can't read info");
    return false;
  }
  TileIndex root = info.nonnegative_root_tile_index;

  if (ti.is_ancestor_of(root)) {
    ret_index = root;
  } else {
    if (ti != root && !root.is_ancestor_of(ti)) {
      // Tile isn't under root
      return false;
    }
    
    assert(tile_exists(root));
    ret_index = root;
    while (ret_index != ti) {
      TileIndex child = ti.start_time() < ret_index.left_child().end_time() ? ret_index.left_child() : ret_index.right_child();
      if (!tile_exists(child)) break;
      ret_index = child;
    }
  }
  // ret_index now holds closest ancestor to ti (or ti itself if it exists)  
    
  assert(read_tile(ret_index, ret));
  return true;
}
Exemple #15
0
/*----------------------------------------------------------------------------*/
static void sys_info_init(void)
{
    //u8 vol_tmp;

#if 1
    sys_main_vol = read_info(MEM_SYS_VOL);
    if ((sys_main_vol > MAX_MAIN_VOL) || (sys_main_vol == 0))              //每次开机时,不要超过最大音量的一半,以免开机音量过大
    {
        sys_main_vol = 20;
    }
#endif

    dac_init(sys_main_vol);
    delay_10ms(50);										//等待,检测USB,SD在线状态
    //init_rec_name();
    //restore_music_point();
#if 0
#if RTC_ENABLE
    if (work_mode != RTC_MODE)
#endif
    {
    	device_check();
#if USB_DEVICE_ENABLE
        if (pc_connect)
            work_mode = USB_DEVICE_MODE;
        else if (udisk_connect || sdmmc_connect)
            work_mode = MUSIC_MODE;
#else
       // if (udisk_connect || sdmmc_connect)
       //     work_mode = MUSIC_MODE;
#endif
    }
#endif

}
/*----------------------------------------------------------------------------*/
void enter_fm_rev(void)
{
    u8 i;
    	all_channl = read_info(MEM_ALL_CHANNL);
   	if (all_channl > MAX_CHANNL)
    	{
        	all_channl = MAX_CHANNL;
   	}

	for (i = 0;i<all_channl;i++)
       {
            fre_point[i] = read_info(MEM_CHANNL+i);

#ifdef UART_ENABLE_FM		
	     printf(" ----FM read  station from ROM  %4u \r\n",(u16)(fre_point[i]+MIN_FRE));
#endif			
       }


    fre_channl = read_info(MEM_FRE_CHANNL);//MEM_FRE
    if (fre_channl > all_channl)
    {
        fre_channl = 1;
    }
    else if (!fre_channl)
    {
        fre_channl = 1;
    }
    frequency = read_info(MEM_FRE)+MIN_FRE;
    if ( frequency > MAX_FRE)
    {
        frequency = MIN_FRE;
    }
    else if (frequency < MIN_FRE)
    {
        frequency = MIN_FRE;
    }

#if defined(K738_LHD_LTB1_V001)||defined(K740_LHD_916_V001)
        frequency = 880;
#endif
#if defined(CUSTOM_RADIO_FREQ_875)
        frequency = 875;
#endif

}
Exemple #17
0
void mustgetpartinfo(const char *filename, struct partinfo *ri) {
  FILE *part;

  part= fopen(filename,"r");
  if (!part) ohshite(_("cannot open archive part file `%.250s'"),filename);
  if (!read_info(part,filename,ri))
    ohshite(_("file `%.250s' is not an archive part"),filename);
  fclose(part);
}
Exemple #18
0
/** Try to open project /name/. Returns 0 if sucsessful, an error code
 * otherwise */
int
Project::open ( const char *name )
{
    if ( ! validate( name ) )
        return E_INVALID;

    close();

    chdir( name );

    if ( ! acquire_lock( &_lockfd, ".lock" ) )
        return E_LOCKED;

    int version;
    char *creation_date;
    char *created_by;

    if ( ! read_info( &version, &creation_date, &created_by ) )
        return E_INVALID;

    if ( strncmp( created_by, APP_TITLE, strlen( APP_TITLE ) ) )
        return E_INVALID;

    if ( version != PROJECT_VERSION )
        return E_VERSION;

    _is_opening = true;
    
    if ( ! Loggable::replay( "snapshot" ) )
        return E_INVALID;

    if ( creation_date )
    {
        strcpy( _created_on, creation_date );
        free( creation_date );
    }
    else
        *_created_on = 0;


    getcwd( _path, sizeof( _path ) );

    set_name( _path );

    _is_open = true;

    _is_opening = false;
//    tle->load_timeline_settings();

//    timeline->zoom_fit();

//    Loggable::clear_dirty();

    MESSAGE( "Loaded project \"%s\"", name );

    return 0;
}
 void read_info(typename Ptree::BOOST_NESTED_TEMPLATE for_char<Ch>::basic_istream &stream, Ptree &pt,
                const Ptree &default_ptree)
 {
     try {
         read_info(stream, pt);
     } catch(file_parser_error &) {
         pt = default_ptree;
     }
 }
 void read_info(std::basic_istream<Ch> &stream, Ptree &pt,
                const Ptree &default_ptree)
 {
     try {
         read_info(stream, pt);
     } catch(file_parser_error &) {
         pt = default_ptree;
     }
 }
Exemple #21
0
int get_person(person *p,int person_id,int src_id,char * conect)
{
	char opOK=0;
	clsvbuff buff;

	initConnection(TYPE_MSG_Q);

	buff.opc=GET_INFO;
	buff.id_client=src_id;
	buff.data.clsv_get_info.id=person_id;

	write_info(&buff);

	read_info(&opOK, sizeof(char), buff.id_client);
	read_info((char *)p, sizeof(person), buff.id_client);

	return opOK;
}
/*----------------------------------------------------------------------------*/
static void sys_info_init(void)
{

    sys_main_vol = read_info(MEM_VOL);

    if ((sys_main_vol > MAX_MAIN_VOL) || (sys_main_vol == 0))              //每次开机时,不要超过最大音量的一半,以免开机音量过大
    {
        sys_main_vol = MAX_MAIN_VOL / 2;

    }
        sys_main_vol = MAX_MAIN_VOL / 2;
	
    dac_init(MAX_MAIN_VOL);
    dsp_set_adc_con((0x0070));
    delay_10ms(200);										//等待,检测USB,SD在线状态
    init_rec_name();
    restore_music_point();

#if 0	
#if RTC_ENABLE
    if (work_mode != RTC_MODE)
#endif
    {
    	device_check();
#if USB_DEVICE_ENABLE
        if (pc_connect)
            work_mode = USB_DEVICE_MODE;
        else if (udisk_connect || sdmmc_connect)
            work_mode = MUSIC_MODE;
#else
        if (udisk_connect || sdmmc_connect)
            work_mode = MUSIC_MODE;
#endif
        else
        {
            work_mode = read_info(MEM_SYSMODE);
            if (work_mode > MAX_WORK_MODE)
            {
                work_mode = MUSIC_MODE;
            }
        }
    }
#endif
}
GPtrArray *
addMemoryUser (FILE * in, GPtrArray * tags)
{
  DbCtlFoundTag *found_tag_list = NULL;
  GList *ac = NULL;
  GList *list = read_info (in);
  GPtrArray *Tags = tags;


  for (ac = g_list_first (list); ac != NULL; ac = g_list_next (ac))
    {
      found_tag_list = (DbCtlFoundTag *) malloc (sizeof (DbCtlFoundTag));
      strcpy (found_tag_list->tag, "user");
      found_tag_list->attr =
	g_hash_table_new_full (g_str_hash, g_str_equal,
			       (GDestroyNotify) found_tag_key_destroyed,
			       (GDestroyNotify) found_tag_data_destroyed);
      found_tag_list->limit_attr = g_ptr_array_new ();

      Account *_ac = (Account *) ac->data;
      int found_user = 0, i = 0;
      for (; i < Tags->len; i++)
	{
	  DbCtlFoundTag *found_tag_ = g_ptr_array_index (Tags, i);
	  char *name_list = GetUserName (found_tag_->attr);
	  if (name_list)
	    if (strcmp (name_list, _ac->id) == 0)
	      found_user++;
	}

      if (!found_user)
	{
	  char *key_ = g_strdup ("name");
	  char *val_ = g_strdup (_ac->id);
	  g_hash_table_insert (found_tag_list->attr, key_, val_);
	  key_ = g_strdup ("mode");
	  val_ = g_strdup ("restrict");
	  g_hash_table_insert (found_tag_list->attr, key_, val_);
	  g_ptr_array_add (Tags, found_tag_list);
	}
      else
	{
	  if (found_tag_list->attr)
	    g_hash_table_destroy (found_tag_list->attr);
	  if (found_tag_list->limit_attr)
	    g_ptr_array_free (found_tag_list->limit_attr, TRUE);
	  free (found_tag_list);
	}

      free (_ac->id);
      free (_ac);
    }

  g_list_free (list);
  return Tags;
}
/*----------------------------------------------------------------------------*/
void save_fm_point(u8 fre)
{
    u8 i,j, k;

    i = fre / 8;
    k = fre % 8;

    j = read_info(MEM_CHANNL + i) | BIT(k);
    write_info(MEM_CHANNL + i, j);
}
Exemple #25
0
InfoEditor&
InfoEditor::insert(const std::string& section, std::istream& stream)
{
  boost::property_tree::ptree pt;
  read_info(stream, pt);

  m_info.add_child(section.c_str(), pt);

  return *this;
}
Exemple #26
0
std::string Channel::dump_tile_summaries() const {
  Locker lock(*this);  // Lock self and hold lock until exiting this method
  ChannelInfo info;
  bool success = read_info(info);
  if (success) {
    return dump_tile_summaries_internal(info.nonnegative_root_tile_index, 0);
  } else {
    return "";
  }
}
Exemple #27
0
void mustgetpartinfo(const char *filename, struct partinfo *ri) {
  struct dpkg_ar *part;

  part = dpkg_ar_open(filename);
  if (!part)
    ohshite(_("cannot open archive part file '%.250s'"), filename);
  if (!read_info(part, ri))
    ohshite(_("file '%.250s' is not an archive part"), filename);
  dpkg_ar_close(part);
}
 void read_info(const std::string &filename,
                Ptree &pt,
                const Ptree &default_ptree,
                const std::locale &loc = std::locale())
 {
     try {
         read_info(filename, pt, loc);
     } catch(file_parser_error &) {
         pt = default_ptree;
     }
 }
Exemple #29
0
int evaluate(boolean * match,boolean opinion,int person_id, int src_id,char * conect)
{
	char opOK=0;
	clsvbuff buff;

	initConnection(TYPE_MSG_Q);

	buff.id_client=src_id;
	buff.opc=EVALUATION;
	buff.data.clsv_evaluation.id=person_id;
	buff.data.clsv_evaluation.like=opinion;

	write_info(&buff);

	read_info(&opOK, sizeof(char), buff.id_client);
	read_info((char *)match, sizeof(boolean), buff.id_client);
	if(opOK==NOTOK)
		return NOTOK;
	return OK;
}
Exemple #30
0
void
Config::load()
{
    try {
        read_info(path, props);
    } catch (pt::info_parser_error &) {
        // It's OK if specific configuration doesn't exist yet.
        if (fs::exists(path)) {
            throw;
        }
    }
}