DeskAngel

Desktop softwares and information

Follow me on TwitterRSS Feeds

  • Home
  • DeskAngel
  • Oolauncher
  • Wsizer

Wildcard search with source code (C language)

Feb 4th

Posted by WilliamX in Source

No comments

Using recursive procedure to deal with the wildcard search. It is too easy to comment.

#include
#include 

//
// b_full means the whole string matching
//
bool WildSearch(char *psz_buf,
                      int n_buflen,
                      char *psz_sub,
                      int n_sublen,
                      bool b_full,
                      char sz_prechar)
{
    if (n_buflen == 0 && n_sublen != 0)
    {
        if (n_sublen == 1 && psz_sub[0] == '*')
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else if (n_buflen != 0 && n_sublen == 0)
    {
        if (b_full)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    else if (n_buflen == 0 && n_sublen == 0)
    {
        return true;
    }

    if (psz_sub[0] == '*')
    {
        psz_sub++;
        n_sublen--;
        if (n_sublen == 0)
        {
            return true;
        }
        return WildSearch(psz_buf, n_buflen, psz_sub, n_sublen, b_full, '*');
    }
    else if (psz_sub[0] == '?')
    {
        psz_buf++;
        n_buflen--;
        psz_sub++;
        n_sublen--;
        return WildSearch(psz_buf, n_buflen, psz_sub, n_sublen, b_full, '?');
    }
    else
    {
        char *psz_star_pos = strchr(psz_sub, '*');
        char *psz_question_pos = strchr(psz_sub, '?');
        int n_len_to_star = (psz_star_pos == NULL) ? (int)strlen(psz_sub) : (int)(psz_star_pos - psz_sub);
        int n_len_to_question = (psz_question_pos == NULL) ? (int)strlen(psz_sub) : (int)(psz_question_pos - psz_sub);

        int n_compare_len = n_len_to_question > n_len_to_star ? n_len_to_star : n_len_to_question;
        if (_strnicmp(psz_buf, psz_sub, n_compare_len) == 0)
        //if (psz_buf[0] == psz_sub[0])
        {
            sz_prechar = psz_sub[0];
            psz_buf++;
            n_buflen--;
            psz_sub++;
            n_sublen--;
            return WildSearch(psz_buf, n_buflen, psz_sub, n_sublen, b_full, sz_prechar);
        }
        else
        {
            if (sz_prechar != '*')
            {
                return false;
            }
            psz_buf++;
            n_buflen--;
            return WildSearch(psz_buf, n_buflen, psz_sub, n_sublen, b_full, sz_prechar);
        }
    }
    return true;
}

int main(int argc, char** argv)
{
    char sz_buf[] = "abcdefghijk";
    char sz_sub[] = "abc?e*fg?i?*k*";
    //char sz_sub[] = "ae";

    bool b_result = WildSearch(sz_buf, (int)strlen(sz_buf), sz_sub, (int)strlen(sz_sub), false, ' ');

    printf("%d\n", b_result);

    return 0;
}
wildcard

DeskAngel, why I develop it

Feb 4th

Posted by WilliamX in Software

No comments

DeskAngel is a desktop enhancement tool for windows operation system. In order to arrange my daily work and make the windows more fashion. I started to develop it on year 2002, under windows 2000 pro. It went through windows 2000, windows xp and now arrived at windows vista. Some features are dropped in the journey, but more are added.

Under windows 2K, ‘connect to remote pc’ is one of my favorites. Because in our office, we should access data share pc, our assistant’s pc, my colleagues’ pc and etc. Sometimes we must delete the previous connection in order to fire a new connection request. It helped me much. But windows xp comes and, it can remember network accounts and passwords, the feature became outdated.

Then, I have my first notebook, IBM thinkpad r40e. It has a full-size keyboard, but is lack of win key. I used to lock my system by ‘win+l’ hotkey when I left and won’t like to change it. IBM do provided a tool to map alt or control to win key, but the mapped key only pop up start menu. It could not be used as a modifier key. I also tried some other keymap tools, some of them can do the job, but they all need to restart the windows after mapped. So, I implemented the feature myself. I’m a programmer, huh!

Nowadays, my most loves are: ‘set window top most’, ‘maximize/restore by middle click’, ‘inactive document scroll’, ‘left+right->alt+right’ and ‘screen clipping’. ‘turn off monitor’ and ‘auto scroll’ are also very useful when I’m working on a desktop pc. Now, things become common and usual. Says, if you never knew it, never had it, and never used it, life won’t be different, but once you have it, you couldn’t live without it. DeskAngel is such a tool.

Besides the features that make daily works easy, DeskAngel also offers some functions which make windows look a little cool and fashion. In the age of windows 2k, DeakAngel can make the text background of icons on desktop transparent, just like other softwares do. Windows xp can transparent it by itself, so that is another feature which was dropped by time. But that is not the only effect that DA can do.

The operation system of windows 2k and laters provide a way to create a translucent window, DA can do it for every windows alread created on desktop. Linux can display only the title of a window, DA can do it. Linux display a cross-arrow cursor when you are moving a window, DA can do it. Windows 7 displays only icons on taskbar, DA can do it. Windows 7 can snap a window to the edges of screen, DA can do it too. :-) And one of the users want to hide the cursor when he is typing in non-microsoft applications, now it’s available.

Until Now, DeskAngel has about 20 features and most of them can be disabled if you don’t like it. DA is totally free, and portable, without any advertisement, backdoor or something like that. After started, you can find it on the system notification area, aka system tray. It is running in background, silently. If you don’t like it, double click the icon to exit. If you like it, signle click or right click it and select ‘start with windows’.

As it is a tool that I also use day by day, bugs will be fixed immediately and new features will be added quickly if they are useful, sometimes it will be updated frequently. No matter how many features will be added, small, simple and fast are the most important things I have considered.

Feel free to download it and have a try. Any kind of feedback are welcome.

deskangel
« First...«678910
  • Tags

    AdjBrightness aero android c++ DaCalc DaysAndDate deskangel eclipse emacs formula gnupgp gpg4win iphone latitude locale mac ntfs object oriented oolauncher openpgp opera photo Prince of Persia printf psi regular expression speedcommander stdout symbol link The Forgotten Sands tips unicode virtual memory vs2010 wii wildcard win7 wine working set wsizer
  • DeskAngel Sites

    • DeskAngel
    • Oolauncher
    • Wsizer
  • Other links

    • wkcow
    • 沧海一粟
  • Calendar

    September 2010
    S M T W T F S
    « Aug    
     1234
    567891011
    12131415161718
    19202122232425
    2627282930  
  • Recent Posts

    • Share DaysAndDate and get Ads removal code
    • error RC1106: invalid option: -ologo
    • 使用wine在Mac上运行Win程序
    • Adjust brightness for Android devices
    • 波斯王子:遗忘之沙(WII)剧情
  • Recent Comments

    • Josh on Adjust brightness for Android devices
    • WilliamX on Adjust brightness for Android devices
    • Josh on Adjust brightness for Android devices
    • Deeznutz1977 on Adjust brightness for Android devices
    • WilliamX on Adjust brightness for Android devices
  • Archives

    • August 2010 (1)
    • July 2010 (3)
    • June 2010 (2)
    • May 2010 (2)
    • April 2010 (6)
    • March 2010 (9)
    • February 2010 (5)
    • January 2010 (1)
    • October 2009 (1)
    • September 2009 (3)
    • July 2009 (1)
    • June 2009 (3)
    • March 2009 (3)
    • February 2009 (7)
  • Categories

    • Critique
    • Information
    • News
    • Programming
    • Software
    • Source
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • My latest tweets

    Loading tweets...
    Follow me on Twitter!
Mystique theme by digitalnature | Powered by WordPress
RSS Feeds XHTML 1.1 Top