ST struct plugins *parse_plugin(const char *rcline)
{
    struct plugins *q = (struct plugins*)c_alloc(sizeof(*q) + strlen(rcline));

    if ('#' == *rcline || 0 == *rcline)
        q->is_comment = true;
    else
    if ('!' == *rcline)
        while (' '== *++rcline);
    else
        q->enabled = true;

    if ('&' == *rcline)
    {
        q->useslit = true;
        while (' '== *++rcline);
    }

    char *s = strcpy(q->fullpath, rcline);
    if (false == q->is_comment)
    {
        s = strcpy(q->name, get_file(s)); // copy name
        *(char*)get_ext(s) = 0; // strip ".dll"

        // accept BBSlit and BBSlitX
        q->is_slit = 0 == memicmp(s, "BBSlit", 6) && (s[6] == 0 || s[7] == 0);

        // lookup for duplicates
        int n = 0; int l = strlen(s); struct plugins *q2;
        dolist (q2, bbplugins)
        {
            char *p = q2->name;
            if (0 == memicmp(p, s, l) && (0 == *(p+=l) || '/' == *p))
                if (0 == n++) strcpy(p, "/1");
        }
Beispiel #2
0
static void load_nls(void)
{
	const char *lang_file =
		ReadString(extensionsrcPath(), "blackbox.options.language:", NULL);
	if (NULL == lang_file) return;

	char full_path[MAX_PATH];
	FILE *fp = fopen (make_bb_path(full_path, lang_file), "rb");
	if (NULL == fp) return;

	char line[4000], key[200], new_text[4000], *np;
	int nl;
	key[0] = 0;

	new_text[0] = 0;
	np = new_text;
	nl = 0;
	for (;;)
	{
		bool eof = false == read_next_line(fp, line, sizeof line);
		char *s = line, c = *s;
		if ('$' == c || eof)
		{
			if (key[0] && new_text[0])
			{
				struct nls *t = (struct nls *)c_alloc(sizeof *t + strlen(key));
				t->hash = calc_hash(t->key, key, &t->k);
				t->translation = new_str(new_text);
				cons_node(&pNLS, t);
			}
			if (eof) break;
			if (' ' == s[1]) s += 2;
			decode_escape(key, s);
			new_text[0] = 0;
			np = new_text;
			nl = 0;
			continue;
		}

		if ('#' == c || '!' == c) continue;

		if ('\0' != c)
		{
			while (nl--) *np++ = '\n';
			np += decode_escape(np, s);
			nl = 0;
		}

		nl ++;
	}
	fclose(fp);
	reverse_list(&pNLS);
}
void SetToolTip(RECT *tipRect, char *tipText)
{
	if (NULL==hToolTips) return;

	struct tt **tp, *t; unsigned n=0;
	for (tp=&tt0; NULL!=(t=*tp); tp=&t->next){
		if (0==memcmp(&t->ti.rect, tipRect, sizeof(RECT))){
			t->used_flg = 1;
			if (0!=strcmp(t->ti.lpszText, tipText)){
				strcpy(t->text, tipText);
				SendMessage(hToolTips, TTM_UPDATETIPTEXT, 0, (LPARAM)&t->ti);
			}
			return;
		}
		if (t->ti.uId > n)
			n = t->ti.uId;
	}

	t = (struct tt*)c_alloc(sizeof (*t));
	t->used_flg  = 1;
	t->next = NULL;
	strcpy(t->text, tipText);
	*tp = t;

	memset(&t->ti, 0, sizeof(TOOLINFO));

	t->ti.cbSize   = sizeof(TOOLINFO);
	t->ti.uFlags   = TTF_SUBCLASS;
	t->ti.hwnd     = hwndPlugin;
	t->ti.uId      = n+1;
	//t->ti.hinst    = NULL;
	t->ti.lpszText = t->text;
	t->ti.rect     = *tipRect;

	SendMessage(hToolTips, TTM_ADDTOOL, 0, (LPARAM)&t->ti);
}