Esempio n. 1
0
void test_strpart_1()
{
	const char tmp[] = "x";
	const char *res;

	res = strpart(NULL, tmp);

	CU_ASSERT_PTR_NULL(res);
}
Esempio n. 2
0
void test_strpart_2()
{
	const char tmp[] = "x";
	const char *res;

	res = strpart(tmp, NULL);

	CU_ASSERT_PTR_NULL(res);
}
Esempio n. 3
0
void test_strpart_5()
{
	const char tmp1[] = "abcdefg";
	const char tmp2[] = "abc";
	const char *res;

	res = strpart(tmp1, tmp2);

	CU_ASSERT_PTR_NULL(res);
}
Esempio n. 4
0
void test_strpart_3()
{
	const char tmp1[] = "abcdefg";
	const char tmp2[] = "abcdefghijkl";
	const char *res;

	res = strpart(tmp1, tmp2);

	CU_ASSERT_PTR_EQUAL(res, tmp2 + 7);
}
Esempio n. 5
0
void regusers_load(struct bot *bot, const char *file)
{
    char linebuf[512] = {0};
    FILE *f;

    if (!(f = fopen(file, "r"))) {
        log_perror("fopen()", LOG_ERROR);
        return;
    } else {
        while (fgets(linebuf, sizeof(linebuf), f)) {
            if (!strlen(linebuf))
                continue;

            char *line = strstrp(linebuf);
            char *p = NULL;

            char a[256] = {0}; /* name */
            char b[33] = {0};  /* flags */
            char c[256] = {0}; /* mask */
            char r[512] = {0}; /* rest */

            if ((p = strpart(line, ':', a, sizeof(a) - 1, r, sizeof(r) - 1))) {
                if (strpart(p, ':',  b, sizeof(b) - 1, c, sizeof(c) - 1)) {

                    reguser_add(bot, a, _reguser_strtoflg(b), c);
                    log_debug("Name: '%s', RegEx: '%s', Flags: %s",
                            a, c, b);
                }
            }

            memset(linebuf, 0, sizeof(linebuf));
        }
    }

    fclose(f);
    return;
}
Esempio n. 6
0
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
    const QStyleOptionViewItem &/* option */,
    const QModelIndex &index ) const
{   srand(time(0));
    if(index.column() == 2){
        QComboBox *box = new QComboBox(parent);
        QStringList str;
        QString strpart("8-");
        for(unsigned int i(0); i < 10; i++){
            str << strpart +QString::number(rand() %888 + 111) + "-"+QString::number(rand() %888 + 111)+"-" + QString::number(rand() %88+11)+"-"+ QString::number(rand() %88+11);
        }
        box->addItems(str);
        box->setFrame(false);
        return box;
    }
    QLineEdit *editor = new QLineEdit(parent);
    editor->setFrame(false);
    //editor->setMinimum(0);
    //editor->setMaximum(1000);

    return editor;
}