void main() { int n,num,num1,flag=0; while(1) { clrscr(); printf("\n\t\t****** DOUBLY LINKED LIST OPERATION ******\n"); printf("\t\t......______________________________......\n"); printf("\nWELCOME,WHAT YOU WANT TO DO ?::"); printf("\n_____________________________\n\n"); printf("\nINSERTION --PRESS 1\n"); printf("\nDELETION --PRESS 2\n"); printf("\nSEARCH --PRESS 3\n"); printf("\nCOUNT --PRESS 4\n"); printf("\nDISPLAY(F) --PRESS 5\n"); printf("\nDISPLAY(R) --PRESS 6\n"); printf("\nEXIT --PRESS 7\n"); printf("\n\nENTER YOUR CHOICE::\n"); scanf("%d",&n); switch(n) { case 1: while(1) { flag=0; clrscr(); printf("INSERT A NODE ::\n"); printf("\t\tAT FIRST -PRESS 1.\n"); printf("\t\tAFTER A NODE -PRESS 2.\n"); printf("\t\tBEFORE A NODE -PRESS 3.\n"); printf("\t\tAT LAST -PRESS 4.\n"); printf("\t\tEXIT FROM HERE-PRESS 5.\n"); printf("\n\nENTER YOUR CHOICE::\n"); scanf("%d",&n); switch(n) { case 1: printf("\nENTER A ELEMENT FOR INSERTION\n"); scanf("%d",&num); finsert(num); printf("\n%d IS INSERT AT FIRST PROPERLY\n",num); break; case 2: printf("\nENTER A ELEMENT FOR INSERTION\n"); scanf("%d",&num); printf("AFTER WHICH ELEMENT YOU WANT TO INSERT\n"); scanf("%d",&num1); ainsert(num,num1); break; case 3: printf("ENTER A ELEMENT FOR INSERTION\n"); scanf("%d",&num); printf("BEFORE WHICH ELEMENT YOU WANT TO INSERT\n"); scanf("%d",&num1); binsert(num,num1); break; case 4: printf("ENTER AN ELEMENT FOR INSERT IN LAST\n"); scanf("%d",&num); linsert(num); break; case 5: printf("\nTHANK YOU FOR USING INSERT OPERETION\n"); flag=1; break; } getch(); if(flag==1) break; } break; case 2: while(1) { flag=0; clrscr(); printf("DELETE A NODE ::\n"); printf("\t\tAT FIRST -PRESS 1.\n"); printf("\t\tAFTER A NODE -PRESS 2.\n"); printf("\t\tBEFORE A NODE -PRESS 3.\n"); printf("\t\tAT LAST -PRESS 4.\n"); printf("\t\tEXACT A NODE -PRESS 5.\n"); printf("\t\tEXIT FROM HERE-PRESS 6.\n"); printf("\n\nENTER YOUR CHOICE::\n"); scanf("%d",&n); switch(n) { case 1: fdelete(); break; case 2: printf("\nENTER AFTER WHICH ELEMENT YOU WANT TO DELETE A NODE\n"); scanf("%d",&num); adelete(num); break; case 3: printf("\nENTER BEFORE WHICH ELEMENT YOU WANT TO DELETE A NODE\n"); scanf("%d",&num); bdelete(num); break; case 4: ldelete(); break; case 5: printf("WHICH ELEMENT CONTAIN NODE YOU WANT TO DELETE:\n"); scanf("%d",&num); edelete(num); break; case 6: printf("THANK YOU FOR USING DELETE OPERETION"); flag=1; break; } getch(); if(flag==1) break; } break; case 3: printf("WHICH ELEMENT YOU WANT TO SEARCH ?"); scanf("%d",&num); search(num); break; case 4: num=count(); printf("AT PRESENT LINKLIST CONTAIN %d NODES\n",num); break; case 5: fdisplay(); break; case 6: rdisplay(); break; case 7: printf("\n\nTHANK YOU FOR USING THIS PROGRAM\n"); getch(); exit(0); } getch(); } }
/*---------------------------------------------------------------------------*/ BOOL DLIF_copy(void* client_handle, struct DLOAD_MEMORY_REQUEST* targ_req) { struct DLOAD_MEMORY_SEGMENT* obj_desc = targ_req->segment; FILE * f = targ_req->fp; unsigned int dst_addr = 0; struct rproc_fw_section * fwsect; void * buf; void * fwbuf; unsigned int buf_size; unsigned int fwbuf_size; unsigned int type; int i; if (obj_desc->objsz_in_bytes == 0) { printf("skipping empty section at %p\n", obj_desc->target_address); return TRUE; } dst_addr = (unsigned int)obj_desc->target_address; /* insure all sections are word-multiples for easier loading */ buf_size = (obj_desc->objsz_in_bytes + 3) & ~0x3; fwbuf_size = buf_size + 16; fwbuf = calloc(4, fwbuf_size / 4); buf = fwbuf + 16; fseek(f, targ_req->offset, SEEK_SET); fread(buf, obj_desc->objsz_in_bytes, 1, f); type = FW_DATA; // default for (i = 0; i < num_tags; i++) { type = FW_DATA; // default if (dst_addr == tag_addr[i]) { printf(" matched destination addr w/ specified tag addr\n"); if (!strcmp(tag_name[i], "restab")) { printf(" found 'restab' section\n"); type = FW_RESOURCE; patchup_resources((struct rproc_fw_resource *)buf, buf_size); break; } else if (!strcmp(tag_name[i], "text")) { printf(" found 'text' section\n"); type = FW_TEXT; break; } else if (!strcmp(tag_name[i], "data")) { printf(" found 'data' section\n"); type = FW_DATA; break; } } } fwsect = (struct rproc_fw_section *)fwbuf; fwsect->type = type; fwsect->da = dst_addr; fwsect->len = buf_size; if (type == FW_RESOURCE) { finsert(fwbuf, fwbuf_size, out_file); } else { fwrite(fwbuf, 1, fwbuf_size, out_file); } free(fwbuf); return 1; }
void cgi_mpfd_t::parse_guts () { abuf_stat_t r = ABUF_OK; str dummy; bool inc; while (r == ABUF_OK) { OKDBG4(SVC_MPFD, CHATTER, "cgi_mpfd_t::parse_guts loop " "r=%d, state=%d", int (r), int (state)); inc = true; switch (state) { case MPFD_START: r = match_boundary (); break; case MPFD_EOL0: r = require_crlf (); break; case MPFD_KEY: r = gobble_crlf (); if (r == ABUF_OK) { if (to_start) { state = MPFD_START; to_start = false; } else state = MPFD_SEARCH; inc = false; } else if (r == ABUF_NOMATCH) { r = delimit_key (&mpfd_key); if (r == ABUF_OK) kt = mpfd_ktmap.lookup (mpfd_key); } // else a WAIT or an EOF in gobble_crlf break; case MPFD_SPC: r = abuf->skip_hws (1); cdp.reset (); break; case MPFD_VALUE: if (kt == MPFD_DISPOSITION) { OKDBG3(SVC_MPFD, CHATTER, "cgi_mpfd_t::parse_guts branch to nested " "content disposition parser"); cdp.parse (wrap (this, &cgi_mpfd_t::ext_parse_cb)); OKDBG3(SVC_MPFD, CHATTER, "cgi_mpfd_t::parse_guts return due to " "content disposition parser"); return; } else if (kt == MPFD_TYPE) { r = delimit_val (&content_typ); if (r == ABUF_OK) { if (multipart_rxx.match (content_typ)) { add_boundary (multipart_rxx[1]); to_start = true; } } } else { r = delimit_val (&dummy); } break; case MPFD_EOL1A: r = require_crlf (); break; case MPFD_EOL1B: if (kt == MPFD_DISPOSITION) { if (cdp.typ == CONTDISP_FORMDAT) { cgi_key = cdp.name; filename = cdp.filename; attach = filename; } else if (cdp.typ == CONTDISP_ATTACH) { filename = cdp.filename; attach = true; } else { r = ABUF_PARSE_ERR; } } state = MPFD_KEY; inc = false; break; case MPFD_SEARCH: r = match_boundary (&dat); if (r == ABUF_OK) { if (cgi_key) { if (attach) finsert (cgi_key, cgi_file_t (filename, content_typ, dat)); else insert (cgi_key, dat); cgi_key = NULL; } // in this case, no more boundaries } else if (r == ABUF_PARSE_ERR) { r = ABUF_OK; state = MPFD_EOF; inc = false; } break; case MPFD_SEARCH2: r = parse_2dash (); if (r == ABUF_OK) { remove_boundary (); nxt_state = MPFD_SEARCH; } else if (r == ABUF_NOMATCH) { r = ABUF_OK; nxt_state = MPFD_KEY; } break; case MPFD_SEARCH3: r = require_crlf (); if (r == ABUF_OK) { state = nxt_state; inc = false; } break; case MPFD_EOF: r = abuf->skip_ws (); break; default: break; } if (r == ABUF_OK && inc) MPFD_INC_STATE; } OKDBG4(SVC_MPFD, CHATTER, "cgi_mpfd_t::parse_guts exit loop " "r=%d, state=%d", int (r), int (state)); switch (r) { case ABUF_EOF: int rc; if (state == MPFD_EOF) { rc = HTTP_OK; } else { rc = HTTP_UNEXPECTED_EOF; warn ("mpfd EOF in state %d after %d bytes read\n", int (state), abuf ? abuf->get_ccnt () : -1); } finish_parse (rc); break; case ABUF_PARSE_ERR: finish_parse (HTTP_BAD_REQUEST); break; default: break; } }