Ejemplo n.º 1
0
/* Driver program to test removeDups */
int main()
{
    char str[] = "geeksforgeeks";
    printf("%s", removeDups(str));
    getchar();
    return 0;
} 
Ejemplo n.º 2
0
void CFilterMan::addFilter (const TCHAR *name, const TCHAR *ext)
{
	CFilter flt;
	flt.setName (name);
	flt.parseExt (ext);
	m_Filters.push_back (flt);
	removeDups ();
}
Ejemplo n.º 3
0
int main()
{
    char str[] = "aabc";
    
    removeDups(str);

    printf("%s", str);

    return 0;
}
Ejemplo n.º 4
0
void CFilter::addExt  (const TCHAR *ext)
{
	CString ext_str (ext);
	ext_str.TrimLeft ();
	ext_str.TrimRight ();
	if (!ext_str.IsEmpty ())
	{
		m_Ext.push_back (ext_str);
		removeDups ();
	}	
}
int main()
{
    struct Node* head = NULL;
    push(&head, 20);
    push(&head, 13);
    push(&head, 13);
    push(&head, 12);
    push(&head, 12);
    push(&head, 11);
    push(&head, 11);
    printList(head);
    removeDups(head);
    printList(head);
    return 0;
}
Ejemplo n.º 6
0
int main()
{
    Node *node1 = createNode(4);
    Node *node2 = createNode(3);
    Node *node3 = createNode(4);
    Node *node4 = createNode(5);
    Node *node5 = createNode(5);
    node1->next = node2;
    node2->next = node3;
    node3->next = node4;
    node4->next = node5;
    printLL(removeDups(node1));

    return 0;
}
Ejemplo n.º 7
0
int main(){
    std::array<int, 8> values{1,2, 4, 5, 2, 1, 6, 3};

    Node* firstNode = new Node(values[0]);

    for(int i = 1; i < values.size(); i++)
    {
        insertAtEnd(firstNode, values[i]);
    }

    printValues(firstNode);

    removeDups(firstNode);

    printValues(firstNode);

    delete firstNode;
    
}
Ejemplo n.º 8
0
static int
parseSplitFile(AtomPtr filename)
{
    char buf[512], *cn, * cm;
    int rc;
    struct in_addr inamask, inanetwork;
    int  mask, i, maskbits;
    FILE *f;

    if(!filename || filename->length == 0)
    {
        do_log(L_ERROR, "Split tunneling file name not supplied\n");
        return -1;

    }
    f = fopen(filename->string, "r");
    if(f == NULL) {
        do_log(L_ERROR, "Couldn't open split tunneling file %s: %d.\n",
                filename->string, errno);
        return -1;
    }

    while(fgets(buf, 512, f)) {
        mask = 0;
        cn = cm = NULL;

        cn = strtok(buf, " \t");
        cm = strtok(NULL, " \t");

        if(!cn || !cm)
            continue;

        rc = inet_aton(cn, &inanetwork);
        if(!rc) //read next line
            continue;

        rc = inet_aton(cm, &inamask);
        if(!rc) //read next line
            continue;

        /* Calculate the number of network bits */
        mask = ntohl(inamask.s_addr);
        for ( maskbits=32 ; (mask & (1L<<(32-maskbits))) == 0 ; maskbits-- )
            ;
        /* Re-create the netmask and compare to the oroginal
         * to make sure it is a valid netmask.
         */
        mask = 0;
        for ( i=0 ; i<maskbits ; i++ )
            mask |= 1<<(31-i);
        if ( mask != ntohl(inamask.s_addr) )
            continue;

        if(localNetworks == NULL) {
            localNetworks = makeNetworkList(0);
            if(localNetworks == NULL) {
                do_log(L_ERROR, "Couldn't allocate NetworkList.\n");
                exit(1);
            }
        }
        NetworkRec nw;
        nw.network = inanetwork;
        nw.netmask = inamask;
        nw.maskbits = maskbits;
        networkListCons(&nw, localNetworks);
    }
    fclose(f);

    if(NULL == localNetworks)
        return 1;

    //Sort the array
    qsort(localNetworks->networks, localNetworks->used, sizeof(NetworkPtr), cmpNetworks);

    //remove duplicate networks from
    //the array
    removeDups(&localNetworks);
    //set flag for DNS over TCP
    splitTunneling = 1;
    return 1;
}
Ejemplo n.º 9
0
void CFilterMan::addFilter (CFilter &filter)
{
	m_Filters.push_back (filter);
	removeDups ();
}