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
 
charreturn_buffer
 
int strlen_retbuf
 
int return_length
 
void char str [10000]
 
< H1Error: return buffer too small</H1>")
 
 strlen_retbuf = strlen(str)
 
 return_length = strlen_retbuf
 

Detailed Description

Definition at line 511 of file mhttpd.cxx.

Constructor & Destructor Documentation

◆ Return()

Return::Return ( )
inline

Definition at line 522 of file mhttpd.cxx.

523 {
527
528 strlen_retbuf = 0;
529 return_length = 0;
530 }
int strlen_retbuf
Definition mhttpd.cxx:518
size_t return_size
Definition mhttpd.cxx:515
int return_length
Definition mhttpd.cxx:519
char * return_buffer
Definition mhttpd.cxx:516
assert(strlen(str)< sizeof(str))
#define WEB_BUFFER_SIZE
Definition mhttpd.cxx:509
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~Return()

Return::~Return ( )
inline

Definition at line 532 of file mhttpd.cxx.

533 {
534 if (return_buffer)
535 free(return_buffer);
537 return_size = 0;
538 strlen_retbuf = 0;
539 return_length = 0;
540 }
Here is the call graph for this function:

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 542 of file mhttpd.cxx.

543 {
544 strlen_retbuf = 0;
545 }
Here is the caller graph for this function:

◆ return_grow() [1/2]

int Return::return_grow ( size_t  len)
inline

Definition at line 554 of file mhttpd.cxx.

555{
556 //printf("size %d, grow %d, room %d\n", return_size, len, return_size - strlen_retbuf);
557
558 for (int i=0; i<1000; i++) { // infinite loop with protection against infinite looping
559 if (strlen_retbuf + len < return_size-40)
560 return SUCCESS;
561
562 return_size *= 2;
564
566
567 //printf("new size %d\n", return_size);
568 }
569
570 assert(!"Cannot happen!"); // does not return
571 return 0;
572}
#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 576 of file mhttpd.cxx.

577{
578 return_grow(len);
580 strlen_retbuf += len;
582}
int return_grow(size_t len)
Definition mhttpd.cxx:554
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 586 of file mhttpd.cxx.

587{
588 return_grow(len);
589 int rd = read(fh, return_buffer + strlen_retbuf, len);
590 if (rd != len) {
591 cm_msg(MERROR, "rread", "Cannot read file \'%s\', read of %d returned %d, errno %d (%s)", filename, len, rd, errno, strerror(errno));
593 }
594 strlen_retbuf += len;
596}
#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:915
#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 call graph for this function:
Here is the caller graph for this function:

◆ rsputs()

void Return::rsputs ( const char str)
inline

Definition at line 600 of file mhttpd.cxx.

601{
602 size_t len = strlen(str);
603
604 return_grow(len);
605
606 if (strlen_retbuf + len > return_size-40) {
607 strcpy(return_buffer, "<H1>Error: return buffer too small</H1>");
609 } else {
611 strlen_retbuf += len;
612 }
613
615}
else strcpy(return_buffer+strlen_retbuf, str)
void char str[10000]
Definition mhttpd.cxx:670
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 619 of file mhttpd.cxx.

620{
621 size_t len = strlen(str);
622
623 return_grow(len);
624
625 if (strlen_retbuf + len > return_size) {
626 mstrlcpy(return_buffer, "<H1>Error: return buffer too small</H1>", return_size);
628 } else {
629 int j = strlen_retbuf;
630 for (size_t i = 0; i < len; i++) {
631 if (strncmp(str + i, "http://", 7) == 0) {
632 int k;
633 char link[256];
634 char* p = (char *) (str + i + 7);
635
636 i += 7;
637 for (k = 0; *p && *p != ' ' && *p != '\n'; k++, i++)
638 link[k] = *p++;
639 link[k] = 0;
640
641 sprintf(return_buffer + j, "<a href=\"http://%s\">http://%s</a>", link, link);
642 j += strlen(return_buffer + j);
643 } else
644 switch (str[i]) {
645 case '<':
647 j += 4;
648 break;
649 case '>':
651 j += 4;
652 break;
653 default:
654 return_buffer[j++] = str[i];
655 }
656 }
657
658 return_buffer[j] = 0;
660 }
661
663}
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 547 of file mhttpd.cxx.

548 {
550 strlen_retbuf = 0;
551 return_length = 0;
552 }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Error

<H1> Return::Error

Definition at line 682 of file mhttpd.cxx.

◆ return_buffer

char* Return::return_buffer

Definition at line 516 of file mhttpd.cxx.

◆ return_length [1/2]

int Return::return_length

Definition at line 519 of file mhttpd.cxx.

◆ return_length [2/2]

Return::return_length = strlen_retbuf

Definition at line 687 of file mhttpd.cxx.

◆ return_size

size_t Return::return_size

Definition at line 515 of file mhttpd.cxx.

◆ str

void char Return::str[10000]
Initial value:

Definition at line 670 of file mhttpd.cxx.

◆ strlen_retbuf [1/2]

int Return::strlen_retbuf

Definition at line 518 of file mhttpd.cxx.

◆ strlen_retbuf [2/2]

Return::strlen_retbuf = strlen(str)

Definition at line 686 of file mhttpd.cxx.


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