📄 webserve.lst
字号:
431 /* *
432 /* Arguments : *
433 /* None. *
434 /* Return : *
435 /* None. *
436 /* Comment : *
437 /* This function initialize file table from code memory and *
438 /* EEPROM. *
439 /* *
440 /************************************************************************/
441 void Init_HTML_pages()
442 {
443 1 #include "hwi2c.h"
444 1
445 1 /*EEPROM file alloction table.*/
446 1 typedef struct _eep_fs{
447 1 unsigned char length[2];
448 1 unsigned char offset[2];
449 1 unsigned char pad[3];
450 1 char name[12];
451 1 }EEP_FS;
452 1
453 1 EEP_FS *fp;
454 1 int i;
455 1 unsigned char total_files=0;
456 1 /*Buffer for EEPROM file table.*/
457 1 unsigned char buf[MAX_HTTP_FILES*sizeof(EEP_FS)];
458 1 unsigned int name_index=0;
459 1 unsigned char name_length;
460 1 unsigned char *p;
461 1
462 1 /*Buffer for store EEPROM file name strings.*/
463 1 extern xdata unsigned char http_name_buff[];
464 1
465 1 /*Code memory file alloction table.*/
466 1 extern RAM_WEB_PAGE web_page_table_incode[];
467 1
468 1 int index_start=0;
469 1 /*Copy all code memory FAT to system FAT*/
470 1 while ((web_page_table_incode[index_start].RAM_WEB_PAGE_NAME)&&(index_start<MAX_HTTP_FILES))
471 1 {
472 2 memcpy(&web_page_table[index_start],&web_page_table_incode[index_start],sizeof(RAM_WEB_PAGE));
473 2 index_start++;
474 2 }
475 1 if (!detect_24256())/*No I2C EEPROM detect.*/
476 1 {
477 2 /*Set end of system FAT.*/
478 2 web_page_table[index_start].RAM_WEB_PAGE_NAME=0;
479 2 web_page_table[index_start].RAM_WEB_PAGE_DATA=0;//set the point type to 00
480 2 web_page_table[index_start].RAM_WEB_PAGE_LEN=0;
481 2 }
482 1 else/*Have I2C EEPROM.*/
483 1 {
484 2 name_index=0;
485 2 memset(http_name_buff,0,MAX_HTTP_FILES*MAX_HTTP_FILE_NAME_L);
486 2 /*Copy file table from EEPROM to buffer*/
487 2 c256_pageread(0,buf,MAX_HTTP_FILES*sizeof(EEP_FS));
488 2
C51 COMPILER V7.50 WEBSERVE 10/12/2006 15:31:42 PAGE 9
489 2
490 2 fp=(EEP_FS*)buf;
491 2 total_files=(fp->offset[1]*256+fp->offset[0]+1)/sizeof(EEP_FS);
492 2
493 2 /*Append EEPROM FAT to system FAT.*/
494 2 for (i=0;i<MAX_HTTP_FILES-index_start,i<total_files,name_index<(MAX_HTTP_FILES-1)*MAX_HTTP_FILE_NAME_L;i+
-+)
495 2 {
496 3 fp=(EEP_FS*)&buf[sizeof(EEP_FS)*i];
497 3 if (fp->length[1]==0xff)
498 3 break;
499 3 fp->name[11]=0;
500 3 if ((name_length=strlen(fp->name))&&((long)fp->offset[1]*256+fp->offset[0]+(long)fp->length[1]*256+(long
-)fp->length[0]<1024*31))
501 3 {
502 4 strcpy(&http_name_buff[name_index],fp->name);
503 4 web_page_table[i+index_start].RAM_WEB_PAGE_NAME=&http_name_buff[name_index];
504 4 p=(unsigned char*)&(web_page_table[i+index_start].RAM_WEB_PAGE_DATA);
505 4 p[0]=0x80;//set type to 0x80 for eeprom
506 4 p[1]=fp->offset[1]; //Addr high
507 4 p[2]=fp->offset[0]; //Addr low
508 4 web_page_table[i+index_start].RAM_WEB_PAGE_LEN=fp->length[1]*256+fp->length[0];
509 4 name_index+=name_length+1;
510 4 }
511 3 else
512 3 break;
513 3 }
514 2 /*Set end of system FAT.*/
515 2 *web_page_table[i+index_start].RAM_WEB_PAGE_NAME=0;
516 2 web_page_table[i+index_start].RAM_WEB_PAGE_DATA=0;
517 2 web_page_table[i+index_start].RAM_WEB_PAGE_LEN=0;
518 2 }
519 1 /*Display system FAT*/
520 1 #if SHOW_FILES_TABLE
521 1 for (i=0;i<i+index_start-1;i++)
522 1 {
523 2 unsigned char p_type;
524 2 if ((web_page_table[i].RAM_WEB_PAGE_NAME==0)||
525 2 (web_page_table[i].RAM_WEB_PAGE_DATA==0)||
526 2 (web_page_table[i].RAM_WEB_PAGE_LEN==0))
527 2 break;
528 2 p=(unsigned char*)&(web_page_table[i].RAM_WEB_PAGE_DATA);
529 2 p_type=p[0];
530 2 printf("\nname=%12.12s,In ",web_page_table[i].RAM_WEB_PAGE_NAME);
531 2 if (p_type==0xff)
532 2 printf("Code ,");
533 2 else if (p_type==0x80)
534 2 printf("EEPROM,");
535 2 else if (p_type==0x01)
536 2 printf("SRAM ,");
537 2 else printf("?????????? ");
538 2 printf("address=%4.4xH,",(int)(((long)web_page_table[i].RAM_WEB_PAGE_DATA)&0xffff));
539 2 printf("size=%4.4xH,",web_page_table[i].RAM_WEB_PAGE_LEN);
540 2 }
541 1 printf("\n");
542 1 #endif
543 1 }
544 /************************************************************************
545 /* Function Name : I2cmemcpy *
546 /* *
547 /* Arguments : *
548 /* unsigned char *dest:Buffer to copy to. *
C51 COMPILER V7.50 WEBSERVE 10/12/2006 15:31:42 PAGE 10
549 /* unsigned char * src:I2C point(0x80xxxx) to copy from. *
550 /* unsigned int len:Length of byte to copy. *
551 /* Return : *
552 /* None. *
553 /* Comment : *
554 /* This function act as memcpy but copy from EEPROM. *
555 /* *
556 /************************************************************************/
557 void I2cmemcpy(unsigned char *dest,unsigned char * src,unsigned int len)
558 {
559 1 #include "hwi2c.h"
560 1 int offset;
561 1 offset=(int)(((long)src)&0xffff);
562 1 c256_pageread(offset,dest,len);
563 1 }
564 /************************************************************************
565 /* Function Name : vfat_mem_cpy *
566 /* *
567 /* Arguments : *
568 /* unsigned char *dest:Buffer to copy to. *
569 /* unsigned char * src:I2C point(0x80xxxx) to copy from. *
570 /* unsigned int len:Length of byte to copy. *
571 /* Return : *
572 /* None. *
573 /* Comment : *
574 /* This function act as memcpy but it according to point type *
575 /* to copy from EEPROM or memory. *
576 /* *
577 /************************************************************************/
578 void vfat_mem_cpy(unsigned char *dest,unsigned char * src,unsigned int len)
579 {
580 1 unsigned char tmp,*p;
581 1 p=(unsigned char*)&src;
582 1 tmp=p[0];
583 1 //tmp=(int)((((long)src)>>16)&0xff);
584 1 if (tmp==0x80)
585 1 I2cmemcpy(dest,src,len);
586 1 else
587 1 memcpy(dest,src,len);
588 1 }
589 /************************************************************************
590 /* Function Name : search_get_web_page *
591 /* *
592 /* Arguments : *
593 /* unsigned char *p:File name string to search for *
594 /* Return : *
595 /* A point to RAM_WEB_PAGE if success or *
596 /* NULL if fail. *
597 /* Comment : *
598 /* This function search the web page table and check if the *
599 /* file exists .If the file exists, return the file information*
600 /* about the file. *
601 /* *
602 /************************************************************************/
603 RAM_WEB_PAGE * search_get_web_page (unsigned char *p)
604 {
605 1 RAM_WEB_PAGE *ptr_index;
606 1
607 1 ptr_index = &web_page_table [0];
608 1
609 1 /* If *p == '\0 ', it means there is no file name, so just get first file.*/
610 1 if (*p != '\0')
C51 COMPILER V7.50 WEBSERVE 10/12/2006 15:31:42 PAGE 11
611 1 while (ptr_index->RAM_WEB_PAGE_NAME)
612 1 {
613 2 if (strcmp (p, &ptr_index->RAM_WEB_PAGE_NAME[0]) == 0)
614 2 {
615 3 break;
616 3 }
617 2 else
618 2 {
619 3 ptr_index++;
620 3 }
621 2 }
622 1
623 1 if (ptr_index->RAM_WEB_PAGE_NAME == NULL)
624 1 {
625 2 /* cannot find the file. So get the first (index) file*/
626 2 ptr_index = &web_page_table [0];
627 2 }
628 1 return (ptr_index);
629 1 }
630
631
632
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 3986 ----
CONSTANT SIZE = 130 ----
XDATA SIZE = 1413 1261
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -