MIDAS
Loading...
Searching...
No Matches
Return Class Reference

Public Member Functions

 Return ()
 
 ~Return ()
 
void reset ()
 
void zero ()
 
int return_grow (size_t len)
 
void rmemcpy (const void *buf, int len)
 
void rread (const char *filename, int fh, int len)
 
void rsputs (const char *str)
 
void rsputs2 (const char *str)
 
void rsprintf (const char *format,...) MATTRPRINTF(2
 
 va_start (argptr, format)
 
 vsprintf (str,(char *) format, argptr)
 
 va_end (argptr)
 
 assert (strlen(str)< sizeof(str))
 
 return_grow (strlen(str))
 
 if (strlen_retbuf+strlen(str) > return_size) strcpy(return_buffer
 
else strcpy (return_buffer+strlen_retbuf, str)
 

Public Attributes

size_t return_size
 
char * return_buffer
 
int strlen_retbuf
 
int return_length
 
void char str [10000]
 
< H1 > Error: return buffer too small</H1>")
 
 strlen_retbuf = strlen(str)
 
 return_length = strlen_retbuf
 

Detailed Description

Definition at line 543 of file mhttpd.cxx.

Constructor & Destructor Documentation

◆ Return()

Return::Return ( )
inline

Definition at line 554 of file mhttpd.cxx.

555 {
557 return_buffer = (char*)malloc(return_size);
558 assert(return_buffer != NULL);
559
560 strlen_retbuf = 0;
561 return_length = 0;
562 }
int strlen_retbuf
Definition mhttpd.cxx:550
size_t return_size
Definition mhttpd.cxx:547
int return_length
Definition mhttpd.cxx:551
char * return_buffer
Definition mhttpd.cxx:548
assert(strlen(str)< sizeof(str))
#define WEB_BUFFER_SIZE
Definition mhttpd.cxx:541
Here is the call graph for this function:

◆ ~Return()

Return::~Return ( )
inline

Definition at line 564 of file mhttpd.cxx.

565 {
566 if (return_buffer)
567 free(return_buffer);
568 return_buffer = NULL;
569 return_size = 0;
570 strlen_retbuf = 0;
571 return_length = 0;
572 }

Member Function Documentation

◆ assert()

Return::assert ( )
Here is the caller graph for this function:

◆ if()

Return::if ( strlen_retbuf strlenstr,
return_size   
)

◆ reset()

void Return::reset ( )
inline

Definition at line 574 of file mhttpd.cxx.

575 {
576 strlen_retbuf = 0;
577 }
Here is the caller graph for this function:

◆ return_grow() [1/2]

int Return::return_grow ( size_t  len)
inline

Definition at line 586 of file mhttpd.cxx.

587{
588 //printf("size %d, grow %d, room %d\n", return_size, len, return_size - strlen_retbuf);
589
590 for (int i=0; i<1000; i++) { // infinite loop with protection against infinite looping
591 if (strlen_retbuf + len < return_size-40)
592 return SUCCESS;
593
594 return_size *= 2;
595 return_buffer = (char*)realloc(return_buffer, return_size);
596
598
599 //printf("new size %d\n", return_size);
600 }
601
602 assert(!"Cannot happen!"); // does not return
603 return 0;
604}
#define SUCCESS
Definition mcstd.h:54
INT i
Definition mdump.cxx:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ return_grow() [2/2]

Return::return_grow ( strlen(str )

◆ rmemcpy()

void Return::rmemcpy ( const void *  buf,
int  len 
)
inline

Definition at line 608 of file mhttpd.cxx.

609{
610 return_grow(len);
611 memcpy(return_buffer + strlen_retbuf, buf, len);
612 strlen_retbuf += len;
614}
int return_grow(size_t len)
Definition mhttpd.cxx:586
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rread()

void Return::rread ( const char *  filename,
int  fh,
int  len 
)
inline

Definition at line 618 of file mhttpd.cxx.

619{
620 return_grow(len);
621 int rd = read(fh, return_buffer + strlen_retbuf, len);
622 if (rd != len) {
623 cm_msg(MERROR, "rread", "Cannot read file \'%s\', read of %d returned %d, errno %d (%s)", filename, len, rd, errno, strerror(errno));
624 memset(return_buffer + strlen_retbuf, 0, len);
625 }
626 strlen_retbuf += len;
628}
#define MERROR
Definition midas.h:559
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:931
#define read(n, a, f)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rsprintf()

void Return::rsprintf ( const char *  format,
  ... 
)
Here is the caller graph for this function:

◆ rsputs()

void Return::rsputs ( const char *  str)
inline

Definition at line 632 of file mhttpd.cxx.

633{
634 size_t len = strlen(str);
635
636 return_grow(len);
637
638 if (strlen_retbuf + len > return_size-40) {
639 strcpy(return_buffer, "<H1>Error: return buffer too small</H1>");
641 } else {
643 strlen_retbuf += len;
644 }
645
647}
else strcpy(return_buffer+strlen_retbuf, str)
void char str[10000]
Definition mhttpd.cxx:702
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rsputs2()

void Return::rsputs2 ( const char *  str)
inline

Definition at line 651 of file mhttpd.cxx.

652{
653 size_t len = strlen(str);
654
655 return_grow(len);
656
657 if (strlen_retbuf + len > return_size) {
658 mstrlcpy(return_buffer, "<H1>Error: return buffer too small</H1>", return_size);
660 } else {
661 int j = strlen_retbuf;
662 for (size_t i = 0; i < len; i++) {
663 if (strncmp(str + i, "http://", 7) == 0) {
664 int k;
665 char link[256];
666 char* p = (char *) (str + i + 7);
667
668 i += 7;
669 for (k = 0; *p && *p != ' ' && *p != '\n'; k++, i++)
670 link[k] = *p++;
671 link[k] = 0;
672
673 sprintf(return_buffer + j, "<a href=\"http://%s\">http://%s</a>", link, link);
674 j += strlen(return_buffer + j);
675 } else
676 switch (str[i]) {
677 case '<':
678 mstrlcat(return_buffer, "&lt;", return_size);
679 j += 4;
680 break;
681 case '>':
682 mstrlcat(return_buffer, "&gt;", return_size);
683 j += 4;
684 break;
685 default:
686 return_buffer[j++] = str[i];
687 }
688 }
689
690 return_buffer[j] = 0;
692 }
693
695}
INT j
Definition odbhist.cxx:40
INT k
Definition odbhist.cxx:40
Here is the call graph for this function:

◆ strcpy()

else Return::strcpy ( return_buffer strlen_retbuf,
str   
)
Here is the caller graph for this function:

◆ va_end()

Return::va_end ( argptr  )

◆ va_start()

Return::va_start ( argptr  ,
format   
)

◆ vsprintf()

Return::vsprintf ( str  ,
(char *)  format,
argptr   
)

◆ zero()

void Return::zero ( )
inline

Definition at line 579 of file mhttpd.cxx.

580 {
581 memset(return_buffer, 0, return_size);
582 strlen_retbuf = 0;
583 return_length = 0;
584 }
Here is the caller graph for this function:

Member Data Documentation

◆ Error

<H1> Return::Error

Definition at line 714 of file mhttpd.cxx.

◆ return_buffer

char* Return::return_buffer

Definition at line 548 of file mhttpd.cxx.

◆ return_length [1/2]

int Return::return_length

Definition at line 551 of file mhttpd.cxx.

◆ return_length [2/2]

Return::return_length = strlen_retbuf

Definition at line 719 of file mhttpd.cxx.

◆ return_size

size_t Return::return_size

Definition at line 547 of file mhttpd.cxx.

◆ str

void char Return::str[10000]
Initial value:
{
va_list argptr

Definition at line 702 of file mhttpd.cxx.

◆ strlen_retbuf [1/2]

int Return::strlen_retbuf

Definition at line 550 of file mhttpd.cxx.

◆ strlen_retbuf [2/2]

Return::strlen_retbuf = strlen(str)

Definition at line 718 of file mhttpd.cxx.


The documentation for this class was generated from the following file: