Example #1
0
int 
clipboard_c2s_in_files(struct stream *s, char *file_list)
{
    int cItems;
    int lindex;
    int str_len;
    struct clip_file_desc *cfd;
    char *ptr;

    if (!s_check_rem(s, 4))
    {
        LLOGLN(0, ("clipboard_c2s_in_files: parse error"));
        return 1;
    }
    in_uint32_le(s, cItems);
    if (cItems > 64 * 1024) /* sanity check */
    {
        LLOGLN(0, ("clipboard_c2s_in_files: error cItems %d too big", cItems));
        return 1;
    }
    xfuse_clear_clip_dir();
    LLOGLN(10, ("clipboard_c2s_in_files: cItems %d", cItems));
    cfd = (struct clip_file_desc *)
          g_malloc(sizeof(struct clip_file_desc), 0);
    ptr = file_list;
    for (lindex = 0; lindex < cItems; lindex++)
    {
        g_memset(cfd, 0, sizeof(struct clip_file_desc));
        clipboard_c2s_in_file_info(s, cfd);
        if ((g_pos(cfd->cFileName, "\\") >= 0) ||
            (cfd->fileAttributes & CB_FILE_ATTRIBUTE_DIRECTORY))
        {
            LLOGLN(0, ("clipboard_c2s_in_files: skipping directory not "
                       "supported [%s]", cfd->cFileName));
            continue;
        }
        xfuse_add_clip_dir_item(cfd->cFileName, 0, cfd->fileSizeLow, lindex);

        g_strcpy(ptr, "file://");
        ptr += 7;

        str_len = g_strlen(g_fuse_clipboard_path);
        g_strcpy(ptr, g_fuse_clipboard_path);
        ptr += str_len;

        *ptr = '/';
        ptr++;

        str_len = g_strlen(cfd->cFileName);
        g_strcpy(ptr, cfd->cFileName);
        ptr += str_len;

        *ptr = '\n';
        ptr++;
    }
    *ptr = 0;
    g_free(cfd);
    return 0;
}
Example #2
0
/* returns error */
int APP_CC
read_preamble_packet(struct xrdp_process* self)
{
    // Using the session stream
    int ns_len = 0;
    int idx;
    int len;
    // cache a pointer to client_info
    struct xrdp_client_info *client_info = self->session->client_info; 

    struct stream* s;
    make_stream(s);
    init_stream(s, 10000);

    DEBUG(("in read_preamble_packet"));

    // 5 bytes should include the colon  
    if (trans_force_read_s(self->server_trans, s, 5) == 0)
    {
        idx = g_pos(s->data, ":") + 1; // skip colon
        ns_len = g_atoi(s->data);
        DEBUG(("Preamble length %i", ns_len));
        len = ns_len - 5 + idx + 1; // trailing comma as well 
        DEBUG(("Preamble to read %i", len));
        if (trans_force_read_s(self->server_trans, s, len) == 0)
        {
            DEBUG(("Preamble body %s", s->data));
            // this will be used as a processing buffer when data required
            // so do not assume will exist in this state later on.
            client_info->osirium_preamble_buffer = (char*)g_malloc(ns_len+1, 1);
            in_uint8s(s, idx);    // skip netstring header 
            in_uint8a(s, 
                    client_info->osirium_preamble_buffer, 
                    ns_len);
            DEBUG(("Preamble %s", client_info->osirium_preamble_buffer));
            free_stream(s);
            return 0;
        }
    }
    free_stream(s);
    DEBUG(("out read_preamble_packet"));
    return 0;
}
Example #3
0
static int
xrdp_rdp_read_config(struct xrdp_client_info *client_info)
{
    int index = 0;
    struct list *items = (struct list *)NULL;
    struct list *values = (struct list *)NULL;
    char *item = NULL;
    char *value = NULL;
    char cfg_file[256];
    int pos;
    char *tmp = NULL;
    int tmp_length = 0;

    /* initialize (zero out) local variables: */
    g_memset(cfg_file, 0, sizeof(char) * 256);

    items = list_create();
    items->auto_free = 1;
    values = list_create();
    values->auto_free = 1;
    g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
    DEBUG(("cfg_file %s", cfg_file));
    file_by_name_read_section(cfg_file, "globals", items, values);

    for (index = 0; index < items->count; index++)
    {
        item = (char *)list_get_item(items, index);
        value = (char *)list_get_item(values, index);
        DEBUG(("item %s value %s", item, value));

        if (g_strcasecmp(item, "bitmap_cache") == 0)
        {
            client_info->use_bitmap_cache = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "bitmap_compression") == 0)
        {
            client_info->use_bitmap_comp = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "bulk_compression") == 0)
        {
            client_info->use_bulk_comp = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "crypt_level") == 0)
        {
            if (g_strcasecmp(value, "none") == 0)
            {
                client_info->crypt_level = 0;
            }
            else if (g_strcasecmp(value, "low") == 0)
            {
                client_info->crypt_level = 1;
            }
            else if (g_strcasecmp(value, "medium") == 0)
            {
                client_info->crypt_level = 2;
            }
            else if (g_strcasecmp(value, "high") == 0)
            {
                client_info->crypt_level = 3;
            }
            else if (g_strcasecmp(value, "fips") == 0)
            {
                client_info->crypt_level = 4;
            }
            else
            {
                log_message(LOG_LEVEL_ALWAYS,"Warning: Your configured crypt level is "
                          "undefined, 'high' will be used");
                client_info->crypt_level = 3;
            }
        }
        else if (g_strcasecmp(item, "allow_channels") == 0)
        {
            client_info->channels_allowed = g_text2bool(value);
            if (client_info->channels_allowed == 0)
            {
                log_message(LOG_LEVEL_DEBUG,"Info - All channels are disabled");
            }
        }
        else if (g_strcasecmp(item, "allow_multimon") == 0)
                {
                    client_info->multimon = g_text2bool(value);
                    if (client_info->multimon == 0)
                    {
                        log_message(LOG_LEVEL_DEBUG,"Info - Multi monitor server support disabled");
                    }
                }
        else if (g_strcasecmp(item, "max_bpp") == 0)
        {
            client_info->max_bpp = g_atoi(value);
        }
        else if (g_strcasecmp(item, "rfx_min_pixel") == 0)
        {
            client_info->rfx_min_pixel = g_atoi(value);
        }
        else if (g_strcasecmp(item, "new_cursors") == 0)
        {
            client_info->pointer_flags = g_text2bool(value) == 0 ? 2 : 0;
        }
        else if (g_strcasecmp(item, "require_credentials") == 0)
        {
            client_info->require_credentials = g_text2bool(value);
        }
        else if (g_strcasecmp(item, "use_fastpath") == 0)
        {
            if (g_strcasecmp(value, "output") == 0)
            {
                client_info->use_fast_path = 1;
            }
            else if (g_strcasecmp(value, "input") == 0)
            {
                client_info->use_fast_path = 2;
            }
            else if (g_strcasecmp(value, "both") == 0)
            {
                client_info->use_fast_path = 3;
            }
            else if (g_strcasecmp(value, "none") == 0)
            {
                client_info->use_fast_path = 0;
            }
            else
            {
                log_message(LOG_LEVEL_ALWAYS,"Warning: Your configured fastpath level is "
                          "undefined, fastpath will not be used");
                client_info->use_fast_path = 0;
            }
        }
        else if (g_strcasecmp(item, "ssl_protocols") == 0)
        {
            /* put leading/trailing comma to properly detect "TLSv1" without regex */
            tmp_length = g_strlen(value) + 3;
            tmp = g_new(char, tmp_length);
            g_snprintf(tmp, tmp_length, "%s%s%s", ",", value, ",");
            /* replace all spaces with comma */
            /* to accept space after comma */
            while ((pos = g_pos(tmp, " ")) != -1)
            {
                tmp[pos] = ',';
            }
            ssl_get_protocols_from_string(tmp, &(client_info->ssl_protocols));
            g_free(tmp);
        }
        else if (g_strcasecmp(item, "tls_ciphers") == 0)
Example #4
0
//***********************************************************
// segmentation
//  セグメンテーションを行う.
//***********************************************************
void segmentation(pcl::PointCloud<pcl::PointXYZRGB>& cloud, double th, int c)
{
    std::cout << "segmentation" << std::endl;

    pcl::PointCloud<pcl::PointXYZRGB>::Ptr tmp_rgb (new pcl::PointCloud<pcl::PointXYZRGB>);
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr tmp_cloud (new pcl::PointCloud<pcl::PointXYZRGB>);

    for(int i=0;i<cloud.points.size();i++){
        if((m_size.max_z <= cloud.points[i].z) && (cloud.points[i].z <= m_size.max_z+0.3)){
            tmp_cloud->points.push_back(cloud.points[i]);
        }
    }
    pcl::copyPointCloud(*tmp_cloud, cloud);

    // Creating the KdTree object for the search method of the extraction
    pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGB>);
    tree->setInputCloud (cloud.makeShared ());

    std::vector<pcl::PointIndices> cluster_indices;
    pcl::EuclideanClusterExtraction<pcl::PointXYZRGB> ec;
    ec.setClusterTolerance (th);
    ec.setMinClusterSize (200);
    ec.setMaxClusterSize (300000);
    ec.setSearchMethod (tree);
    ec.setInputCloud (cloud.makeShared ());
    ec.extract (cluster_indices);

    std::cout << "クラスタリング開始" << std::endl;
    int m = 0;

    for (std::vector<pcl::PointIndices>::const_iterator it = cluster_indices.begin (); it != cluster_indices.end (); ++it){
        pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_cluster_rgb (new pcl::PointCloud<pcl::PointXYZRGB>);
        pcl::PointCloud<pcl::PointXYZHSV>::Ptr cloud_cluster_hsv (new pcl::PointCloud<pcl::PointXYZHSV>);
        pcl::PointXYZ g;

        for (std::vector<int>::const_iterator pit = it->indices.begin (); pit != it->indices.end (); pit++){
            cloud_cluster_rgb->points.push_back (cloud.points[*pit]);
        }
        cloud_cluster_rgb->width = cloud_cluster_rgb->points.size ();
        cloud_cluster_rgb->height = 1;
        cloud_cluster_rgb->is_dense = true;

        //クラスタ重心を求める  
        g = g_pos(*cloud_cluster_rgb);

        if(((g.x < m_size.min_x) || (m_size.max_x < g.x)) ||
           ((g.y < m_size.min_y) || (m_size.max_y < g.y))){
            continue;
        }

        m++;

        if((m_size.max_z + 0.02 < g.z) && (g.z < m_size.max_z + 0.12)){
            object_map map;
            map.cloud_rgb = *cloud_cluster_rgb;
            map.g = g;
            map.tf = c;
            make_elevation(map);

            // RGB -> HSV
            pcl::PointCloudXYZRGBtoXYZHSV(*cloud_cluster_rgb, *cloud_cluster_hsv);

            for(int i=0;i<MAP_H;i++){
              for(int j=0;j<MAP_S;j++){
                map.histogram[i][j] = 0.000;
              }
            }

            map.cloud_hsv = *cloud_cluster_hsv;
            // H-Sヒストグラムの作成
            for(int i=0;i<cloud_cluster_hsv->points.size();i++){
                if(((int)(255*cloud_cluster_hsv->points[i].h)/((256/MAP_H)*360) >= 32) || ((int)(255*cloud_cluster_hsv->points[i].h)/((256/MAP_H)*360) < 0)) continue;
                if(((int)(255*cloud_cluster_hsv->points[i].s)/(256/MAP_H) >= 32) || ((int)(255*cloud_cluster_hsv->points[i].s)/(256/MAP_H) < 0)) continue;

                // 正規化のため,セグメントの点数で割る.
                map.histogram[(int)(255*cloud_cluster_hsv->points[i].h)/((256/MAP_H)*360)][(int)(255*cloud_cluster_hsv->points[i].s)/(256/MAP_H)] += 1.000/(float)cloud_cluster_hsv->points.size();
            }

            Object_Map.push_back(map);

            *tmp_rgb += *cloud_cluster_rgb;
        }
    }

    pcl::copyPointCloud(*tmp_rgb, cloud);

    return;
}