Esempio n. 1
0
int main()
{

    bptree_node* root = NULL;
    int i, search_test,insert_test;
    search_test  = 1 << 10;
    insert_test = 1 << 10;
    for (i = 1;i <= insert_test;++i) {
        root = d_insert(root,i,i);
        //d_search(root,i-1);
    }
    for (i = 1;i <= insert_test / 3; ++i) {
        delete_bptree_node(root,i);
    }
    for (i = 1;i <= search_test;++i) {
        d_search(root,i);
    }
    puts("");
    return 0;
}
Esempio n. 2
0
File: d.c Progetto: sidmutha/cs2110
main() {
    d_list_item* head;
    d_list_item* search_r;
    char sendr[10], rcvr[10], msg[30];
    strcpy(sendr,"");
    packet pcket;

    head =  d_create_list();

    printf("\nEnter sender: ");
    fgets(sendr,10,stdin);
    printf("\nEnter receiver: ");
    gets(pcket.receiver);
    printf("\nEnter message: ");
    gets(pcket.message);
    strcpy(pcket.sender,sendr);
    d_add_item(head,pcket);
    strcpy(sendr,"");
    printf("\nEnter sender: ");
    fgets(sendr,10,stdin);
    printf("\nEnter receiver: ");
    gets(pcket.receiver);
    printf("\nEnter message: ");
    gets(pcket.message);
    strcpy(pcket.sender,sendr);
    d_add_item(head,pcket);
    strcpy(sendr,"");
    d_print_all(head);

    printf("\n++++++++++++Search+++++++");

    printf("\nEnter sender: ");
    fgets(sendr,10,stdin);
    search_r = d_search(head, 's', sendr);
    if (!(search_r == 0)) {
        printf("\nReceiver: %s",search_r->pckt.receiver);
    }
    else printf("\nSorry, no results\n");

}
Esempio n. 3
0
FUNCTION CODE hard_help
(
    struct   SFILE	*fctx,		/* In: file context block for opened file	*/
    TEXT  		curlib[],	/* In: library name of opened file		*/
    TEXT		procname[],	/* In: proc name for LHS of help display	*/
    TEXT		outname[],	/* In: name of output file			*/
    struct  HELPBLK	*helpblk	/* out: help output control block		*/

)
{

    IMPORT  struct  VARIABLE *char_gbl;		/* system characteristics	*/

    struct DIRBLK	dirblk;		/* directive control block		*/
    struct TXTSTOR	title;		/* context for dynamically stored title text */
    struct SFILE	f;
    struct POSCTX	saved_pos;
    struct POSCTX	level2_pos;
    BOOL		has_level2;
    TEXT		str[STRINGSIZ+1];
    CODE		code;
    TEXT		field[STRINGSIZ+1];	/* text field after a directive	*/
    TEXT		name[STRINGSIZ+1];
    TEXT		key[KEYSIZ+1];
    TEXT		msg[STRINGSIZ+1];

    /* If no output name was given,	*/
    if (NULLSTR(outname))		/* use pdf or command name	*/
    {
        f_name(procname, outname);
        s_append(".MEM", outname);	/* procname.MEM for output	*/
    }

    /* note -- SAVELUN is safe because |save| qual is not allowed for this command */
    code = f_ophf(&f, SAVELUN, outname, F_WRITE);	/* open output file	*/
    if (code != SUCCESS)
    {
        sprintf(msg, "Error opening output, host code = %d", f.host_code);
        store_help_error(helpblk, msg, "TAE-OPNWRT");
        return(FAIL);
    }

    d_init(&dirblk, fctx, curlib, (TEXT **)(*char_gbl).v_cvp,
           (*char_gbl).v_count);    		/* init directive block		*/
    if ((*helpblk).compiled)			/* if PDF is compiled		*/
    {
        if ((code = prep_c_help(&dirblk, &title, msg, key)) != SUCCESS)	/* prepare*/
            goto put_error;
        str[0] = EOS;
    }
    else					/* PDF is not compiled		*/
    {
        code = d_dirctv(&dirblk, str, field);
        if (s_equal(str, ".TITLE"))
        {   /* read the title into dynamic store			*/
            if ((code = gettitle(&dirblk, &title, msg, key))!= SUCCESS)
                goto put_error;
            code = d_dirctv(&dirblk, str, field);
        }
        else				/* no title */
        {
            title.numline = 0;
        }
    }

    code = put_title(&f, &title, msg, key);  /* start filling output file */
    if (code != SUCCESS) goto put_error;

    if (title.tp != NULL) fretxt(&title); /* free the dyamically-stored title	*/

    /* str should contain .HELP directive now.  If not, find it	*/
    if (! s_equal( str, ".HELP"))
    {
        code = d_search(&dirblk, ".HELP", field);
        if (code != SUCCESS)
        {
            store_help_error(helpblk, "No help available on '%s'.", "TAE-NOHELP");
            return (FAIL);
        }
    }

    code = put_text_block(&f, &dirblk, msg, key);	/* output general help	*/
    if (code != SUCCESS) goto put_error;

    code = d_search(&dirblk, ".LEVEL1", field);
    if (code != SUCCESS)		/* if there is no level1 help then */
        goto return_success;		/* assume we are done and exit	   */

    f_movpos(CURRENT_POS, &saved_pos);		/* save position in input */
    code = d_search(&dirblk, ".LEVEL2", field); /* find detailed help */
    has_level2 = (code == SUCCESS);
    if (has_level2)				/* if detailed help exists,  */
        f_movpos(CURRENT_POS, &level2_pos);	/* save the position in file */

    f_setpos(dirblk.sfileptr, &saved_pos);	/* reset position to curr pos */
    code = d_dirctv(&dirblk, str, name);	/* gives str=".TITLE"	     */

    while (1)
    {
        code = d_dirctv(&dirblk, str, name);
        if (code != SUCCESS)			/* if no more directives, we */
            break;				/* are done		     */

        if (s_equal(str, ".END") || s_equal(str, ".LEVEL2")) /* done */
            break;

        code = put_header(&f, &dirblk, str, name, msg, key);
        if (code != SUCCESS) goto put_error;
        if (has_level2)
            code = put_level2_text(&f, &dirblk, &level2_pos,
                                   str, name, msg, key);
        if (code != SUCCESS) goto put_error;
    }

return_success:
    f_close(&f, F_KEEP);
    s_lower(outname);
    sprintf(msg, "Wrote file \"%s\".", outname);
    put_stdout(msg);
    return (SUCCESS);

put_error:
    store_help_error(helpblk, msg, key);
    return (FAIL);
}