예제 #1
0
파일: avctp.c 프로젝트: BirdAndEarth/RPi
static bool avrcp_set_addressed_player(struct avctp_frame *avctp_frame,
						uint8_t ctype, uint8_t len,
						uint8_t indent)
{
	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
	uint16_t id;
	uint8_t status;

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (!l2cap_frame_get_be16(frame, &id))
		return false;

	print_field("%*cPlayerID: 0x%04x (%u)", (indent - 8), ' ', id, id);

	return true;

response:
	if (!l2cap_frame_get_u8(frame, &status))
		return false;

	print_field("%*cStatus: 0x%02x (%s)", (indent - 8), ' ',
						status, error2str(status));

	return true;
}
예제 #2
0
static void avrcp_set_addressed_player(int level, struct frame *frm,
						uint8_t ctype, uint16_t len)
{
	uint16_t id;
	uint8_t status;

	p_indent(level, frm);

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (len < 2) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	id = get_u16(frm);
	printf("PlayerID: 0x%04x (%u)", id, id);
	return;

response:
	if (len < 1) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	status = get_u8(frm);
	printf("Status: 0x%02x (%s)\n", status, error2str(status));
}
cs_error_t CorosyncCpg::init() {
  if (ready) {
    return CS_OK;
  }
  cpg_callbacks_t callbacks;
  ::memset(&callbacks, 0, sizeof(callbacks));
  callbacks.cpg_deliver_fn = &globalDeliver;
  callbacks.cpg_confchg_fn = &globalConfigChange;

  //    QPID_LOG(notice, "Initializing CPG");
  cs_error_t err = cpg_initialize(&handle, &callbacks);
  int retries = 6; // @todo: make this configurable.
  while (err == CS_ERR_TRY_AGAIN && --retries) {
    LOG(WARNING)<< "cpg initialize retry " << retries;
    std::chrono::microseconds dura(5);
    std::this_thread::sleep_for(dura);
    err = cpg_initialize(&handle, &callbacks);
  }
  if (err != CS_OK) {
    LOG(ERROR)<< "cpg_initialize error, caused by " << error2str(err);
    return err;
  }
  if (CS_OK != cpg_context_set(handle, this)) {
    LOG(ERROR)<< "Cannot set CPG context";
    return err;
  }

  ready = true;
  return CS_OK;
}
예제 #4
0
파일: Log.cpp 프로젝트: RokkiGH/wowboss
void oLog::Init(int fileLogLevel, LogType logType)
{
	SetFileLoggingLevel( fileLogLevel );

	const char* logNormalFilename = NULL, *logErrorFilename = NULL;
	switch ( logType )
	{
		case LOGON_LOG:
			{
				logNormalFilename = "logon-normal.log";
				logErrorFilename = "logon-error.log";
				break;
			}
		case WORLD_LOG:
			{
				logNormalFilename = "world-normal.log";
				logErrorFilename = "world-error.log";
				break;
			}
	}

	errno_t err = fopen_s( &m_normalFile, logNormalFilename, "a" );
	if ( err )
	{
		fprintf( stderr, "%s: Error opening '%s': %s\n", __FUNCTION__, logNormalFilename, error2str(err) );
	}
	else
	{
		tm aTm;
		localtime_s( &aTm, &UNIXTIME );
		outBasic( "[%-4d-%02d-%02d %02d:%02d:%02d] "
			, aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec );
	}

	err = fopen_s( &m_errorFile, logErrorFilename, "a" );
	if ( err )
	{
		fprintf( stderr, "%s: Error opening '%s': %s\n", __FUNCTION__, logErrorFilename, error2str(err) );
	}
	else
	{
		tm aTm;
		localtime_s( &aTm, &UNIXTIME );
		outError( "[%-4d-%02d-%02d %02d:%02d:%02d] "
			, aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec );
	}
}
예제 #5
0
/*  7.10  */
static int  ErrorHandler(XML_STATUS   errorCode,
                         PString      context,
                         void       * usrData)
{
/*
-----------------------------------------------------------------------------
*/
/*  Data structures */

  char _buf[256];
  SDocData *_s = (SDocData*)usrData;

/* Code */

  if(!_s->m_error) {
      if(context) {
          wPrint(STR_LEN(context),STR_DATA(context),
                 64,_buf);
          if(_s->m_docURL)
              wmlLOGssss( WSL_LOG_ERROR,
                      "XML error:",
                      (char*)_s->m_docURL,
                      (char*)error2str(errorCode),
                      _buf);
          else
              wmlLOGsss( WSL_LOG_ERROR,
                      "XML error: URL?:",
                      (char*)error2str(errorCode),
                      _buf);
      }
      else {
          if(_s->m_docURL)
              wmlLOGsss( WSL_LOG_ERROR,
                      "XML error: ",
                      (char*)_s->m_docURL,
                      (char*)error2str(errorCode));
          else
              wmlLOGss( WSL_LOG_ERROR,
                      "XML error: URL?: %s",
                      (char*)error2str(errorCode));
      }
      _s->m_error = errorCode;
  }

  return 1;
}
예제 #6
0
/*  7.10  */
void setWmlError(WML_VALIDATION_ERROR   status,
                 PString     context,
                 SDocData   *data)
{
/* Set the status of the document if it was clean.
 *---------------------------------------------------------------------------
 */
/* Data structures */
  char _buf[256];
/* Code */

  if(!data->m_error) {
      if(context) {
          wPrint(STR_LEN(context),STR_DATA(context),
                 64,_buf);
          if(data->m_docURL)
              wmlLOGssss( WSL_LOG_ERROR,
                      "WML error:",
                      (char*)data->m_docURL,
                      (char*)error2str(status),
                      _buf);
          else
              wmlLOGsss( WSL_LOG_ERROR,
                      "WML error: URL?:",
                      (char*)error2str(status),
                      _buf);
      }
      else {
          if(data->m_docURL)
              wmlLOGsss( WSL_LOG_ERROR,
                      "WML error:",
                      (char*)data->m_docURL,
                      (char*)error2str(status));
          else
              wmlLOGss( WSL_LOG_ERROR,
                      "WML error: URL?:",
                      (char*)error2str(status));
      }

      data->m_error = status;
  }

}
예제 #7
0
파일: avctp.c 프로젝트: BirdAndEarth/RPi
static bool avrcp_rejected_packet(struct l2cap_frame *frame, uint8_t indent)
{
	uint8_t status;

	if (!l2cap_frame_get_u8(frame, &status))
		return false;

	print_field("%*cError: 0x%02x (%s)", (indent - 8), ' ', status,
							error2str(status));

	return true;
}
예제 #8
0
static void avrcp_rejected_dump(int level, struct frame *frm, uint16_t len)
{
	uint8_t status;

	p_indent(level, frm);

	if (len < 1) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	status = get_u8(frm);
	printf("Error: 0x%02x (%s)\n", status, error2str(status));
}
예제 #9
0
파일: avctp.c 프로젝트: BirdAndEarth/RPi
static bool avrcp_add_to_now_playing(struct avctp_frame *avctp_frame,
						uint8_t ctype, uint8_t len,
						uint8_t indent)
{
	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
	uint64_t uid;
	uint16_t uidcounter;
	uint8_t scope, status;

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (!l2cap_frame_get_u8(frame, &scope))
		return false;

	print_field("%*cScope: 0x%02x (%s)", (indent - 8), ' ',
						scope, scope2str(scope));

	if (!l2cap_frame_get_be64(frame, &uid))
		return false;

	print_field("%*cUID: 0x%16" PRIx64 " (%" PRIu64 ")", (indent - 8),
								' ', uid, uid);

	if (!l2cap_frame_get_be16(frame, &uidcounter))
		return false;

	print_field("%*cUIDCounter: 0x%04x (%u)", (indent - 8), ' ',
							uidcounter, uidcounter);

	return true;

response:
	if (!l2cap_frame_get_u8(frame, &status))
		return false;

	print_field("%*cStatus: 0x%02x (%s)", (indent - 8), ' ', status,
							error2str(status));

	return true;
}
예제 #10
0
gboolean mcap_delete_mdl(struct mcap_mdl *mdl, mcap_mdl_notify_cb delete_cb,
							gpointer user_data,
							GDestroyNotify destroy,
							GError **err)
{
	struct mcap_mcl *mcl= mdl->mcl;
	struct mcap_mdl_op_cb *con;
	GSList *l;

	l = g_slist_find(mcl->mdls, mdl);

	if (!l) {
		g_set_error(err, MCAP_ERROR, MCAP_ERROR_INVALID_MDL,
					"%s" , error2str(MCAP_INVALID_MDEP));
		return FALSE;
	}

	if (mdl->state == MDL_WAITING) {
		g_set_error(err, MCAP_ERROR, MCAP_ERROR_FAILED,
							"Mdl is not created");
		return FALSE;
	}

	mdl->state = MDL_DELETING;

	con = g_new0(struct mcap_mdl_op_cb, 1);
	con->mdl = mcap_mdl_ref(mdl);
	con->cb.notify = delete_cb;
	con->destroy = destroy;
	con->user_data = user_data;

	if (!send_delete_req(mcl, con, mdl->mdlid, err)) {
		mcap_mdl_unref(con->mdl);
		g_free(con);
		return FALSE;
	}

	return TRUE;
}
예제 #11
0
static void avrcp_set_browsed_player(int level, struct frame *frm,
						uint8_t ctype, uint16_t len)
{
	uint32_t items;
	uint16_t id, uids, charset;
	uint8_t status, folders;

	p_indent(level, frm);

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (len < 2) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	id = get_u16(frm);
	printf("PlayerID: 0x%04x (%u)", id, id);
	return;

response:
	if (len != 1 && len < 10) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	status = get_u8(frm);
	printf("Status: 0x%02x (%s)\n", status, error2str(status));

	if (len == 1)
		return;

	p_indent(level, frm);

	uids = get_u16(frm);
	printf("UIDCounter: 0x%04x (%u)", uids, uids);

	p_indent(level, frm);

	items = get_u32(frm);
	printf("Number of Items: 0x%04x (%u)", items, items);

	p_indent(level, frm);

	charset = get_u16(frm);
	printf("CharsetID: 0x%04x (%s)\n", charset, charset2str(charset));

	p_indent(level, frm);

	folders = get_u8(frm);
	printf("Folder Depth: 0x%02x (%u)", folders, folders);

	for (; folders > 0; folders--) {
		uint16_t len;

		p_indent(level, frm);

		len = get_u8(frm);
		printf("Folder: ");
		for (; len > 0; len--) {
			uint8_t c = get_u8(frm);
			printf("%1c", isprint(c) ? c : '.');
		}
		printf("\n");
	}
}
예제 #12
0
    /**
     * Add domain. Create users as specified in configuration file.
     * For each users create many configuration entries as specified
     * in configuration file. For each pair user,pfix call user_conf_ls
     * and check whether it returns all entries as in configuration
     * file. Also for each pair call user_conf_ls_by_type and check results.
     * Remove domain.
     */
    void case10() {
        const char * dom = "case10.pl";
        std_try {
            typedef std::deque< std::string > string_array;
            CORBA::String_var dom_id;
            test_dom_user_add(dom, dom_id);

            string_array conf;
            std::ifstream ifs("data/case10/conf");
            BOOST_REQUIRE(sys::getlines<std::string>(ifs, conf));
            ifs.close();

            ::vq::ivq::auth_info ai;
            ai.id_domain = dom_id;
            ai.pass = static_cast<const char *>("asdasd");
            ai.flags = 0;

            string_array::const_iterator bc, be, fc, fe, pfix;
            string_array fields, uia;
            ::vq::ivq::user_conf_info ui;

            for( bc=conf.begin(), be=conf.end(); bc!=be; ++bc ) {
                if( '#' == (*bc)[0] ) continue;
                fields = text::split(*bc, " ");
                fc = fields.begin();
                fe = fields.end();
                BOOST_REQUIRE(fc != fe);
                ai.login = fc->c_str();

                err = auth->user_add(ai, FALSE);
                if( err->ec != ::vq::ivq::err_no
                && err->ec != ::vq::ivq::err_exists ) {
                    BOOST_ERROR(error2str(err));
                }

                ++fc;
                if( fc == fe ) continue;

                for( pfix=fc, ++fc; fc!=fe; ++fc )  {
                    uia = text::split(*fc, ",");
                    BOOST_REQUIRE(uia.size() == 2);
                    ui.type = boost::lexical_cast<CORBA::UShort>
                              (uia[0].c_str());
                    ui.val = uia[1].c_str();
                    IVQ_ERROR_EQUAL( auth->user_conf_add(dom_id,
                                                         ai.login, pfix->c_str(), ui),
                                     ::vq::ivq::err_no);
                }
            }

            for( bc=conf.begin(), be=conf.end(); bc!=be; ++bc ) {
                if( '#' == (*bc)[0] ) continue;
                fields = text::split(*bc, " ");
                fc = fields.begin();
                fe = fields.end();
                ai.login = fc->c_str();

                ++fc;
                if( fc == fe ) continue;

                pfix = fc++;

                ::vq::ivq::user_conf_info_list_var uis;
                IVQ_ERROR_EQUAL(auth->user_conf_ls(dom_id,
                                                   ai.login, pfix->c_str(), uis ),
                                ::vq::ivq::err_no );

                BOOST_CHECK_EQUAL(uis->length(), fields.size()-2);

                for( ; fc!=fe; ++fc )  {
                    uia = text::split(*fc, ",");
                    ui.type = boost::lexical_cast<CORBA::UShort>
                              (uia[0].c_str());
                    ui.val = uia[1].c_str();
                    bool has = false;
                    CORBA::ULong type_cnt=0;
                    for( CORBA::ULong i=0, s=uis->length();
                            i<s; ++i ) {
                        if( uis[i].type == ui.type ) {
                            ++type_cnt;
                            if(  uis[i].val == ui.val )
                                has = true;
                        }
                    }
                    BOOST_CHECK(has);

                    ::vq::ivq::user_conf_info_list_var uistype;
                    IVQ_ERROR_EQUAL(auth->user_conf_ls_by_type(dom_id,
                                    ai.login, pfix->c_str(), ui.type, uistype ),
                                    ::vq::ivq::err_no );

                    BOOST_CHECK_EQUAL(uistype->length(), type_cnt);
                    has = false;
                    for( CORBA::ULong i=0, s=uistype->length();
                            i<s; ++i ) {
                        if( uistype[i].type == ui.type
                                && uistype[i].val == ui.val ) {
                            has = true;
                            break;
                        }
                    }
                    BOOST_CHECK(has);
                }
            }
        } std_catch
        test_dom_rm(dom);
    }