コード例 #1
0
ファイル: ldbm_instance_config.c プロジェクト: ohamada/389ds
static int
ldbm_instance_config_instance_dir_set(void *arg, void *value, char *errorbuf, int phase, int apply)
{
    ldbm_instance *inst = (ldbm_instance *)arg;

    if (!apply) {
        return LDAP_SUCCESS;
    }

    if ((value == NULL) || (strlen(value) == 0))
    {
        inst->inst_dir_name = NULL;
        inst->inst_parent_dir_name = NULL;
    }
    else
    {
        char *dir = (char *)value;
        if (is_fullpath(dir))
        {
            char sep = get_sep(dir);
            char *p = strrchr(dir, sep);
            if (NULL == p)    /* should not happens, tho */
            {
                inst->inst_parent_dir_name = NULL;
                inst->inst_dir_name = rel2abspath(dir); /* normalize dir;
                                                           strdup'ed in 
                                                           rel2abspath */
            }
            else
            {
                *p = '\0';
                inst->inst_parent_dir_name = rel2abspath(dir); /* normalize dir;
                                                                  strdup'ed in
                                                                  rel2abspath */
                inst->inst_dir_name = slapi_ch_strdup(p+1);
                *p = sep;
            }
        }
        else
        {
            inst->inst_parent_dir_name = NULL;
            inst->inst_dir_name = slapi_ch_strdup(dir);
        }
    }
    return LDAP_SUCCESS;
}
コード例 #2
0
ファイル: behavior_path.cpp プロジェクト: Beifeng/qui
		virtual BOOL on_draw   (HELEMENT he, UINT draw_type, HDC hdc, const RECT& rc ) 
		{ 
			if( draw_type != DRAW_CONTENT )
				return FALSE; /*do default draw*/ 

			dom::element el = he;
			const wchar_t* filename = el.get_attribute("filename");
			if( !filename )
				return FALSE;  // no such attribute at all.

			// 先画图标
			SHFILEINFOW sfi;
			HIMAGELIST hlist = (HIMAGELIST) SHGetFileInfoW( filename,
				0, &sfi, sizeof(SHFILEINFO), 
				/*SHGFI_USEFILEATTRIBUTES |*/ SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
			if(!hlist)
				return FALSE;
			int szx = 16;
			int szy = 16;
			ImageList_GetIconSize(hlist, &szx, &szy);
			int x = rc.left - 19; // 水平居左 // + (rc.right - rc.left - szx) / 2; 
			int y = rc.top + (rc.bottom - rc.top - szy) / 2; // 垂直居中

			//draw_file_icon(hdc, x, y, filename);
			ImageList_Draw(hlist, sfi.iIcon, hdc, x, y, ILD_TRANSPARENT);

			// 输出文字
			UINT pta = GetTextAlign(hdc);
			SetTextAlign(hdc, TA_LEFT | TA_TOP |TA_NOUPDATECP); 
			DrawTextW(hdc,  (is_fullpath(el) && (wcslen(filename) > 1)) ? filename : el.text(),
				-1,const_cast<RECT*>(&rc), 
				DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_PATH_ELLIPSIS | DT_NOPREFIX);
			SetTextAlign(hdc, pta); 

			return TRUE; /*skip default draw as we did it already*/ 
		}