Ejemplo n.º 1
0
void qof_date_format_set(QofDateFormat df)
{
    if (df >= DATE_FORMAT_FIRST && df <= DATE_FORMAT_LAST)
    {
        prevQofDateFormat = dateFormat;
        dateFormat = df;
    }
    else
    {
        /* hack alert - Use a neutral default. */
        PERR("non-existent date format set attempted. Setting ISO default");
        prevQofDateFormat = dateFormat;
        dateFormat = QOF_DATE_FORMAT_ISO;
    }

    return;
}
Ejemplo n.º 2
0
gboolean qof_commit_edit (QofInstance *inst)
{
    QofInstancePrivate *priv;

    if (!inst) return FALSE;

    priv = GET_PRIVATE(inst);
    priv->editlevel--;
    if (0 < priv->editlevel) return FALSE;

    if (0 > priv->editlevel)
    {
        PERR ("unbalanced call - resetting (was %d)", priv->editlevel);
        priv->editlevel = 0;
    }
    return TRUE;
}
Ejemplo n.º 3
0
template<> void
GncDbiProviderImpl<DbType::DBI_SQLITE>::append_col_def(std::string& ddl,
        const GncSqlColumnInfo& info)
{
    const char* type_name = nullptr;

    if (info.m_type == BCT_INT)
    {
        type_name = "integer";
    }
    else if (info.m_type == BCT_INT64)
    {
        type_name = "bigint";
    }
    else if (info.m_type == BCT_DOUBLE)
    {
        type_name = "float8";
    }
    else if (info.m_type == BCT_STRING || info.m_type == BCT_DATE
             || info.m_type == BCT_DATETIME)
    {
        type_name = "text";
    }
    else
    {
        PERR ("Unknown column type: %d\n", info.m_type);
        type_name = "";
    }
    ddl += (info.m_name + " " + type_name);
    if (info.m_size != 0)
    {
        ddl += "(" + std::to_string(info.m_size) + ")";
    }
    if (info.m_primary_key)
    {
        ddl += " PRIMARY KEY";
    }
    if (info.m_autoinc)
    {
        ddl += " AUTOINCREMENT";
    }
    if (info.m_not_null)
    {
        ddl += " NOT NULL";
    }
}
Ejemplo n.º 4
0
s8 wl_pointer_req(struct client *c,s32 pointer_slot,struct msg *m)
{
  s8 r;
  switch(m->req_op){
  case WL_POINTER_SET_CURSOR:
    r=set_cursor(c,pointer_slot,m);
    break;
  case WL_POINTER_CLOSE:
    LOG_WIRE("client(%d):pointer::close pointer_id=%u\n",c->so,m->req[0]);
    r=pointer_close(c,pointer_slot);
    break;
  default:
    PERR("client(%d):fatal:pointer unknown opcode %u\n",c->so,m->req_op);
    r=LWL_ERR;
  };
  return r;
}
Ejemplo n.º 5
0
static void
set_options(dbi_conn conn, const PairVec& options)
{
    for (auto option : options)
    {
        auto opt = option.first.c_str();
        auto val = option.second.c_str();
        auto result = dbi_conn_set_option(conn, opt, val);
        if (result < 0)
        {
            const char *msg = nullptr;
            int err = dbi_conn_error(conn, &msg);
            PERR("Error setting %s option to %s: %s", opt, val, msg);
            throw std::runtime_error(msg);
        }
    }
}
Ejemplo n.º 6
0
void
gnc_ui_file_access_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
{
    FileAccessWindow* faw;
    gchar* url;

    g_return_if_fail( dialog != NULL );

    faw = g_object_get_data( G_OBJECT(dialog), "FileAccessWindow" );
    g_return_if_fail( faw != NULL );

    switch ( response )
    {
    case GTK_RESPONSE_HELP:
        gnc_gnome_help( HF_HELP, HL_GLOBPREFS );
        break;

    case GTK_RESPONSE_OK:
        url = geturl( faw );
        if ( url == NULL )
        {
            return;
        }
        if ( faw->type == FILE_ACCESS_OPEN )
        {
            gnc_file_open_file( url );
        }
        else if ( faw->type == FILE_ACCESS_SAVE_AS )
        {
            gnc_file_do_save_as( url );
        }
        break;

    case GTK_RESPONSE_CANCEL:
        break;

    default:
        PERR( "Invalid response" );
        break;
    }

    if ( response != GTK_RESPONSE_HELP )
    {
        gtk_widget_destroy( GTK_WIDGET(dialog) );
    }
}
Ejemplo n.º 7
0
template<> void
error_handler<DbType::DBI_PGSQL> (dbi_conn conn, void* user_data)
{
    GncDbiBackend<DbType::DBI_PGSQL>* dbi_be =
        static_cast<decltype(dbi_be)>(user_data);
    const char* msg;

    (void)dbi_conn_error (conn, &msg);
    if (g_str_has_prefix (msg, "FATAL:  database") &&
        g_str_has_suffix (msg, "does not exist\n"))
    {
        PINFO ("DBI error: %s\n", msg);
        dbi_be->set_exists(false);
    }
    else if (g_strrstr (msg,
                        "server closed the connection unexpectedly"))    // Connection lost
    {
        if (!dbi_be->connected())
        {
            PWARN ("DBI Error: Connection lost, connection pointer invalid");
            return;
        }
        PINFO ("DBI error: %s - Reconnecting...\n", msg);
        dbi_be->set_dbi_error (ERR_BACKEND_CONN_LOST, 1, true);
        dbi_be->retry_connection(msg);
    }
    else if (g_str_has_prefix (msg, "connection pointer is NULL") ||
             g_str_has_prefix (msg, "could not connect to server"))       // No connection
    {

        if (!dbi_be->connected())
            qof_backend_set_error(reinterpret_cast<QofBackend*>(dbi_be),
                                  ERR_BACKEND_CANT_CONNECT);
        else
        {
            dbi_be->set_dbi_error(ERR_BACKEND_CANT_CONNECT, 1, true);
            dbi_be->retry_connection (msg);
        }
    }
    else
    {
        PERR ("DBI error: %s\n", msg);
        if (dbi_be->connected())
            dbi_be->set_dbi_error (ERR_BACKEND_MISC, 0, false);
    }
}
static int __init htc_fingerprint_init(void)
{
	int ret;

	ret = register_chrdev(0, DEVICE_NAME, &htc_fingerprint_fops);
	if (ret < 0) {
		PERR("register module fail");
		return ret;
	}
	htc_fingerprint_major = ret;

	htc_fingerprint_class = class_create(THIS_MODULE, "htc_fingerprint");
	device_create(htc_fingerprint_class, NULL, MKDEV(htc_fingerprint_major, 0), NULL, DEVICE_NAME);

	PDEBUG("register module ok");
	return 0;
}
Ejemplo n.º 9
0
s8 wl_shm_pool_buffer_req(struct client *c,s32 shm_pool_buffer_slot,
                                                                  struct msg *m)
{
  s8 r;
  switch(m->req_op){
  case WL_BUFFER_DESTROY:
    LOG_WIRE("client(%d):shm_pool_buffer::destroy shm_pool_buffer_id=%u\n",
                                                               c->so,m->req[0]);
    r=shm_pool_buffer_destroy(c,shm_pool_buffer_slot);
    break;
  default:
    PERR("client(%d):fatal:shm_pool_buffer unknown opcode %u\n",c->so,
                                                                     m->req_op);
    r=LWL_ERR;
  };
  return r;
}
Ejemplo n.º 10
0
bool CTun::injectIp6Packet(IpPacket::IPv6* p_poPacket)
{
	/* ipv6 payload + ipv6 header itself */
	ssize_t packetLen = ntohs(p_poPacket->m_u16_PayloadLength) + offsetof(IpPacket::IPv6, m_oIP_Payload);
	if (packetLen > MAX_IP_PACKET_SIZE)
	{
		NLOG_WARN("CTun::injectIp6Packet, packetLen(%d) > MAX_PACKET_SIZE(%d)", packetLen, MAX_IP_PACKET_SIZE );
		return false;
	}
	Ip6PseudoHdr oPHdr(p_poPacket);
	// pseudoheader checksum
	uint16_t checksum = IpPacket::Checksum((uint8_t*)&oPHdr, sizeof oPHdr);
	switch(p_poPacket->m_u8_NextHeader)
	{
		case IPPROTO_ICMPV6:
			p_poPacket->m_oICMP_Payload.m_u16_Checksum = 0;
			/* substract the ipv6 header size from the whole packet length */
			p_poPacket->m_oICMP_Payload.m_u16_Checksum = htons(IpPacket::Checksum((const uint8_t*)&p_poPacket->m_oICMP_Payload,
								packetLen - offsetof(IpPacket::IPv6, m_oIP_Payload), checksum));
			break;
		case IPPROTO_UDP:
			p_poPacket->m_oUDP_Payload.m_u16_Checksum = 0;
			/* substract the ipv6 header size from the whole packet length */
			checksum = IpPacket::Checksum((const uint8_t*)&p_poPacket->m_oUDP_Payload
					, packetLen - offsetof(IpPacket::IPv6, m_oIP_Payload), checksum);
			if(!checksum){
				p_poPacket->m_oUDP_Payload.m_u16_Checksum = 0xFFFF;
			}else{
				p_poPacket->m_oUDP_Payload.m_u16_Checksum = htons(checksum);
			}
			break;
		default:
			NLOG_ERR("CTun::injectIp6Packet: unsupported IP next header %d, discarding packet", p_poPacket->m_u8_NextHeader);
			return false;
	}
	ssize_t bw = write(m_nTunHandle, p_poPacket, packetLen);
	if(bw < packetLen)
	{
		PERR("CTun::injectIp6Packet, write "TUN_INTERFACE);
		return false;
	}
	NLOG_DBG("injectIp6Packet, if:%s, sz:%d, data[%s%s]", m_szTunName, bw,
		GET_HEX_LIMITED(&p_poPacket, (size_t)bw, m_uHexLimit))
	return true;
}
Ejemplo n.º 11
0
static ComponentInfo *
gnc_register_gui_component_internal (const char * component_class)
{
    ComponentInfo *ci;
    gint component_id;

    g_return_val_if_fail (component_class, NULL);

    /* look for a free handler id */
    component_id = next_component_id;

    /* design warning: if we ever get 2^32-1 components,
       this loop is infinite.  Instead of fixing it, we'll just
       complain when (if) we get half way there (probably never).
    */
    while (find_component (component_id))
        if (++component_id == NO_COMPONENT)
            component_id++;

    if (component_id < 0)
        PERR("Amazing! Half way to running out of component_ids.");

    /* found one, add the handler */
    ci = g_new0 (ComponentInfo, 1);

    ci->watch_info.event_masks = g_hash_table_new (g_str_hash, g_str_equal);
    ci->watch_info.entity_events = guid_hash_table_new ();

    ci->component_class = g_strdup (component_class);
    ci->component_id = component_id;
    ci->session = NULL;

    components = g_list_prepend (components, ci);

    /* update id for next registration */
    next_component_id = component_id + 1;

#if CM_DEBUG
    fprintf (stderr, "Register component %d in class %s\n",
             component_id, component_class ? component_class : "(null)");
    dump_components ();
#endif

    return ci;
}
Ejemplo n.º 12
0
static s8 set_cursor(struct client *c,s32 pointer_slot,struct msg *m)
{
  s8 r;
  if(m->req_dws<6){
    PERR("client(%d):fatal:pointer::set_cursor missing data\n",c->so);
    r=LWL_ERR;goto exit;
  }

  LOG_WIRE("client(%d):pointer::set_cursor serial=%u surface_id=%u"
                       " hotspot_x=%d hotspot_y=%d\n",c->so,m->req[2],m->req[3],
                                                 (s32)m->req[4],(s32)m->req[5]);

  r=pointer_set_cusor(c,pointer_slot,m->req[2],m->req[3],(s32)m->req[4],
                                                              (  s32)m->req[5]);

exit:
  return r;
}
Ejemplo n.º 13
0
bool CTun::BringUpIp6(in6_addr& p_IP, unsigned p_uMtu)
{
	m_nTunSocket = socket(AF_INET6, SOCK_DGRAM, 0);
	ioctl(m_nTunSocket, SIOGIFINDEX, &ifr);

	struct in6_ifreq ifr6;
	ifr6.ifr6_ifindex = ifr.ifr_ifindex;
	ifr6.ifr6_prefixlen = 64;
	ifr6.ifr6_addr = p_IP;

	if (ioctl(m_nTunSocket, SIOCSIFADDR, &ifr6) < 0)
	{
		PERR("SIOCSIFADDR: "TUN_INTERFACE", %s", m_szTunName);
		return false;
	}

	return bringUp(p_uMtu);;
}
Ejemplo n.º 14
0
char *
gnc_gnome_locate_pixmap (const char *name)
{
    char *fullname;

    g_return_val_if_fail (name != NULL, NULL);

    fullname = gnome_program_locate_file (gnucash_program,
                                          GNOME_FILE_DOMAIN_APP_PIXMAP,
                                          name, TRUE, NULL);
    if (fullname == NULL)
    {
        PERR ("Could not locate pixmap/pixbuf file %s", name);
        return NULL;
    }

    return fullname;
}
Ejemplo n.º 15
0
void QGenodeClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
{
	if (!data || !data->hasText() || !supportsMode(mode))
		return;

	QString text = data->text();
	QByteArray utf8text = text.toUtf8();

	if (!_clipboard_reporter)
		return;

	try {
		Genode::Reporter::Xml_generator xml(*_clipboard_reporter, [&] () {
			xml.append_sanitized(utf8text.constData(), utf8text.size()); });
	} catch (...) {
		PERR("could not write clipboard data");
	}
}
Ejemplo n.º 16
0
void
gnc_close_gui_component (gint component_id)
{
    ComponentInfo *ci;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component not found");
        return;
    }

    if (!ci->close_handler)
        return;

    if (ci->close_handler)
        ci->close_handler (ci->user_data);
}
Ejemplo n.º 17
0
/* gnc_configure_date_format
 *    sets dateFormat to the current value on the scheme side
 *
 * Args: Nothing
 * Returns: Nothing
 */
static void
gnc_configure_date_format (void)
{
    QofDateFormat df = gnc_prefs_get_int(GNC_PREFS_GROUP_GENERAL,
                                         GNC_PREF_DATE_FORMAT);

    /* Only a subset of the qof date formats is currently
     * supported for date entry.
     */
    if ((df > QOF_DATE_FORMAT_LOCALE)
            || (df > QOF_DATE_FORMAT_LOCALE))
    {
        PERR("Incorrect date format");
        return;
    }

    qof_date_format_set(df);
}
Ejemplo n.º 18
0
gboolean
gnc_dom_tree_to_address (xmlNodePtr node, GncAddress *address)
{
    struct address_pdata addr_pdata;
    gboolean successful;

    addr_pdata.address = address;

    successful = dom_tree_generic_parse (node, address_handlers_v2,
                                         &addr_pdata);

    if (!successful)
    {
        PERR ("failed to parse address tree");
    }

    return successful;
}
Ejemplo n.º 19
0
/*
 * mmls_init()
 *
 * This function returns memory size and phys addr from lower cmd
 * driver. Cmd driver is the direct interface to hardware module.
 *
 * Currently, cmd drv returns one device only.
 * To support more mmls device with 1 major cdev and multiple
 * minor num cdev, then cmd drv and mmls_init fn need to be changed
 */
static int mmls_init(void)
{
	PINFO("%s: enter\n", __func__);

	if (mmls_io_init()) {
		PERR("mmls_start/mmls_size is zero. ret=%d\n", -EINVAL);
		return -EINVAL;
	}

	get_mmls_iodata(&mmls_io_data);

	PINFO("%s: found mmls device with size and addr:\n", __func__);
	PINFO("mmls_io_data.m_size=%lu\n", mmls_io_data.m_size);
	PINFO("mmls_io_data.m_iomem=%p\n", mmls_io_data.m_iomem);
	PINFO("mmls_nsectors=%lu", (mmls_io_data.m_size)/HV_BLOCK_SIZE);

	return 0;
}
Ejemplo n.º 20
0
static s8 set_popup(struct client *c,s32 shell_surface_slot,struct msg *m)
{
  s8 r;
  if(m->req_dws<8){
    PERR("client(%d):fatal:shell_surface::set_popup missing data\n",c->so);
    r=LWL_ERR;goto exit;
  }

  LOG_WIRE("client(%d):shell_surface::set_popup seat_id=%u serial=%u"
                  " parent_surface_id=%u x=%d y=%d flags=%u \n",c->so,m->req[2],
                              m->req[3],m->req[4],(s32)m->req[5],(s32)m->req[6],
                                                                     m->req[7]);

  r=shell_surface_set_popup(c,shell_surface_slot,m->req[2],m->req[3],m->req[4],
                                       (s32)m->req[5],(s32)m->req[6],m->req[7]);
exit:
  return r;
}
Ejemplo n.º 21
0
static void
qof_instance_list_foreach(gpointer data, gpointer user_data)
{
    QofInstanceCopyData *qecd;
    QofInstance *original;
    QofInstance *inst;
    QofBook *book;
    const GncGUID *g;

    g_return_if_fail(data != NULL);
    original = QOF_INSTANCE(data);
    g_return_if_fail(user_data != NULL);
    qecd = (QofInstanceCopyData*)user_data;
    if (qof_instance_guid_match(qecd->new_session, original))
    {
        return;
    }
    qecd->from = original;
    if (!qof_object_compliance(original->e_type, FALSE))
    {
        qecd->error = TRUE;
        return;
    }
    book = qof_session_get_book(qecd->new_session);
    inst = (QofInstance*)qof_object_new_instance(original->e_type, book);
    if (!inst)
    {
        PERR (" failed to create new entity type=%s.", original->e_type);
        qecd->error = TRUE;
        return;
    }
    qecd->to = inst;
    g = qof_instance_get_guid(original);
    qof_instance_set_guid(qecd->to, g);
    if (qecd->param_list != NULL)
    {
        g_slist_free(qecd->param_list);
        qecd->param_list = NULL;
    }
    qof_class_param_foreach(original->e_type, qof_instance_param_cb, qecd);
    qof_begin_edit(inst);
    g_slist_foreach(qecd->param_list, qof_instance_foreach_copy, qecd);
    qof_commit_edit(inst);
}
Ejemplo n.º 22
0
bool CTun::injectIp4Packet(IpPacket::IPv4* p_poPacket)
{
	ssize_t packetLen = ntohs(p_poPacket->m_u16_TotalLength);
	if (packetLen > MAX_IP_PACKET_SIZE)
	{
		NLOG_WARN("CTun::injectIp4Packet, packetLen(%d) > MAX_IP_PACKET_SIZE(%d)", packetLen, MAX_IP_PACKET_SIZE );
		return false;
	}
	switch(p_poPacket->m_u8_Protocol)
	{
		case IPPROTO_ICMP:
			p_poPacket->m_oICMP_Payload.m_u16_Checksum = 0;
			p_poPacket->m_oICMP_Payload.m_u16_Checksum = IpPacket::Checksum((const uint8_t*)(&p_poPacket->m_oICMP_Payload),
								packetLen - 4 * p_poPacket->IHL());
			p_poPacket->m_oICMP_Payload.m_u16_Checksum = htons(p_poPacket->m_oICMP_Payload.m_u16_Checksum );
			break;
		case IPPROTO_UDP:
		{
			Ip4UDPPseudoHdr oPHdr(p_poPacket);
			// pseudoheader checksum
			uint16_t checksum = IpPacket::Checksum((uint8_t*)&oPHdr, sizeof (Ip4UDPPseudoHdr));
			p_poPacket->m_oUDP_Payload.m_u16_Checksum = 0;
			checksum = IpPacket::Checksum((uint8_t*)&p_poPacket->m_oUDP_Payload, ntohs(oPHdr.m_u16_UDP_length), checksum);
			if(!checksum){
				p_poPacket->m_oUDP_Payload.m_u16_Checksum = 0xFFFF;
			}else{
				p_poPacket->m_oUDP_Payload.m_u16_Checksum = htons(checksum);
			}
			break;
		}
		default:;
	}
	p_poPacket->m_u16_Checksum = 0;
	p_poPacket->m_u16_Checksum = htons(IpPacket::Checksum((const uint8_t*)p_poPacket, p_poPacket->IHL()*4));
	ssize_t bw = write(m_nTunHandle, p_poPacket, packetLen);
	if(bw < packetLen)
	{
		PERR("CTun::injectIp4Packet, write "TUN_INTERFACE);
		return false;
	}
	NLOG_DBG("injectIp4Packet, if:%s, sz:%d, data[%s%s]", m_szTunName, bw,
		GET_HEX_LIMITED(&p_poPacket, (size_t)bw, m_uHexLimit))
	return true;
}
Ejemplo n.º 23
0
gboolean
gnc_dom_tree_to_owner (xmlNodePtr node, GncOwner* owner, QofBook* book)
{
    struct owner_pdata owner_pdata;
    gboolean successful;

    owner_pdata.owner = owner;
    owner_pdata.book = book;

    successful = dom_tree_generic_parse (node, owner_handlers_v2,
                                         &owner_pdata);

    if (!successful)
    {
        PERR ("failed to parse owner tree");
    }

    return successful;
}
Ejemplo n.º 24
0
Archivo: client.c Proyecto: sylware/lwl
void client_kill(struct client *c)
{
  l r=epoll_ctl(ep_fd,EPOLL_CTL_DEL,c->so,0);
  if(ISERR(r)){
    PERR("fatal(%ld):unable to delete client socket(%d) from epoll(%d)\n",r,
                                                                   c->so,ep_fd);
    exit(LWL_ERR);
  }

  s32 slot=0;
  while(1){
    if(slot==CLIENT_OBJS_MAX) break;
    if(!c->objs[slot].state&CLIENT_OBJ_INVALID) c->objs[slot].release(c,slot);
    ++slot;
  }

  while(1){r=close(c->so); if(r!=-EINTR) break;}
  c->so=-1;
}
Ejemplo n.º 25
0
void
gnc_gui_component_watch_entity (gint component_id,
                                const GncGUID *entity,
                                QofEventId event_mask)
{
    ComponentInfo *ci;

    if (entity == NULL)
        return;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component not found");
        return;
    }

    add_event (&ci->watch_info, entity, event_mask, FALSE);
}
Ejemplo n.º 26
0
Archivo: dce.c Proyecto: sylware/lwl
s8 dce_mode_select(s32 output_name,void *cfg_mode)
{
  s8 r=LWL_OK;
  struct output *o=&registry[output_name].output;
  struct alga_timing *o_timings=&o->dce_info.timings[o->blk_idx][0];
  void *sysname=(void*)udev_device_get_sysname(o->d);

  u8 timing_idx=0;
  if(*(u8*)cfg_mode!=0){//if cfg file did provide a mode
    while(1){
      if(timing_idx==ALGA_TIMINGS_MAX) break;
      if(o_timings[timing_idx].pixel_clk==0) break;
      u8 mode_str[sizeof("hhhhxvvvv@rrr")];
      alga_timing_to_str(&mode_str[0],&o_timings[timing_idx]);
      DCE_LOG("have mode:%s\n",&mode_str[0]);
      if(strncmp(mode_str,cfg_mode,sizeof("hhhhxvvvv@rrr")-1)==0){
        DCE_LOG("mode %s match provided config mode\n",&mode_str[0]);
        break;
      }
      ++timing_idx;
    }
    //no timing matching the one provided by cfg file, choose the default one
    if(timing_idx==ALGA_TIMINGS_MAX||o_timings[timing_idx].pixel_clk==0){
      DCE_LOG("config mode %s was not match, selecting mode\n", cfg_mode);
      timing_idx=0;
    }
  }

  o->current=&o_timings[timing_idx];

  o->pixel_fmt=dce_pixel_fmt_select_heuristics(o->blk_idx,&o->dce_info);

  if(o->pixel_fmt==ALGA_PIXEL_FMT_INVALID){
    PERR("output:%s:dce:no pixel format supported\n",sysname);
    r=LWL_ERR;goto exit;
  }

  LOG("output:%s:dce:video mode selected is %ux%u@%u with %s pixel"
       " format\n",sysname,o->current->h,o->current->v,v_refresh(o->current),
                                             alga_pixel_fmts_str[o->pixel_fmt]);
exit:
  return r;
}
Ejemplo n.º 27
0
pweibo_feed weibo_destroy(const GString* szID)
{
    CHECK_WEIBO_TOKEN();

    GString* szApi = g_string_new("statuses/destroy/:");
    g_string_append(szApi, szID->str);
    g_string_append(szApi, ".json");
    char* reply =  weibo_do_api(szApi->str, NULL, pToken->m_szToken, pToken->m_szTokenSecret, FALSE);

    if(!reply){
        PERR("do oauth post failed!\n");
        return NULL;
    }

    DEBUG("%s\n", reply);

    return weibo_feed_create(reply);
    return NULL;
}
Ejemplo n.º 28
0
guint
guid_hash_to_guint (gconstpointer ptr)
{
    if (!ptr)
    {
        PERR ("received NULL guid pointer.");
        return 0;
    }
    GncGUID const & guid = * reinterpret_cast <GncGUID const *> (ptr);
    gnc::GUID const & temp {guid};

    guint hash {0};
    unsigned retspot {0};
    std::for_each (temp.begin (), temp.end (), [&hash] (unsigned char a) {
        hash <<=4;
        hash |= a;
    });
    return hash;
}
Ejemplo n.º 29
0
static long htc_msgservice_ioctl(struct file *file, uint32_t command, unsigned long arg)
{
	htc_msgservcie_t mmsg;
	int32_t ret = 0;
	int32_t ii;
	/*
	if (!capable(CAP_SYS_ADMIN)) {
		return -EPERM;
	}
	*/
	PDEBUG("command = %x\n", command);
	switch (command) {
	case HTC_IOCTL_MSGSERVICE:
		if (copy_from_user(&mmsg, (void __user *)arg, sizeof(htc_msgservcie_t))) {
			PERR("copy_from_user error (msg)");
			return -EFAULT;
		}
		PDEBUG("func = %x\n", mmsg.func);

		switch (mmsg.func) {
		case ITEM_REMOTE_MSG:
			if ((mmsg.req_buf == NULL) || (mmsg.req_len != sizeof(htc_remote_msg_t))) {
				PERR("invalid arguments");
				return -EFAULT;
			}
			if (copy_from_user(htc_rmt_msg, (void __user *)mmsg.req_buf, mmsg.req_len)) {
				PERR("copy_from_user error (sdkey)");
				return -EFAULT;
			}
			PDEBUG("Input message:");
			for (ii = 0; ii < sizeof(htc_remote_msg_t); ii++) {
				PDEBUG("%02x", *((uint8_t *)htc_rmt_msg + ii));
			}
			scm_flush_range((uint32_t)htc_rmt_msg, (uint32_t)(htc_rmt_msg) + mmsg.req_len);
			ret = secure_access_item(1, ITEM_REMOTE_MSG, mmsg.req_len, htc_rmt_msg);
			PERR("Do nothing! (%d)\n", ret);
			break;

		default:
			PERR("func error\n");
			return -EFAULT;
		}
		break;

	default:
		PERR("command error\n");
		return -EFAULT;
	}
	return ret;
}
Ejemplo n.º 30
0
/*	i2c read routine for API*/
static char bmm_i2c_read(struct i2c_client *client, u8 reg_addr,
		u8 *data, u8 len)
{
#if !defined BMM_USE_BASIC_I2C_FUNC
	s32 dummy;
	if (NULL == client)
		return -1;

	while (0 != len--) {
#ifdef BMM_SMBUS
		dummy = i2c_smbus_read_byte_data(client, reg_addr);
		if (dummy < 0) {
			PERR("i2c bus read error");
			return -1;
		}
		*data = (u8)(dummy & 0xff);
#else
		dummy = i2c_master_send(client, (char *)&reg_addr, 1);
		if (dummy < 0)
			return -1;

		dummy = i2c_master_recv(client, (char *)data, 1);
		if (dummy < 0)
			return -1;
#endif
		reg_addr++;
		data++;
	}
	return 0;
#else
	int retry;

	struct i2c_msg msg[] = {
		{
		 .addr = client->addr,
		 .flags = 0,
		 .len = 1,
		 .buf = &reg_addr,
		},

		{
		 .addr = client->addr,