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

Constructor & Destructor Documentation

◆ Return()

Return::Return ( )
inline

Definition at line 524 of file mhttpd.cxx.

525 {
529
530 strlen_retbuf = 0;
531 return_length = 0;
532 }
int strlen_retbuf
Definition mhttpd.cxx:520
size_t return_size
Definition mhttpd.cxx:517
int return_length
Definition mhttpd.cxx:521
char * return_buffer
Definition mhttpd.cxx:518
assert(strlen(str)< sizeof(str))
#define WEB_BUFFER_SIZE
Definition mhttpd.cxx:511
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 534 of file mhttpd.cxx.

535 {
536 if (return_buffer)
537 free(return_buffer);
539 return_size = 0;
540 strlen_retbuf = 0;
541 return_length = 0;
542 }
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 544 of file mhttpd.cxx.

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

◆ return_grow() [1/2]

int Return::return_grow ( size_t  len)
inline

Definition at line 556 of file mhttpd.cxx.

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

579{
580 return_grow(len);
582 strlen_retbuf += len;
584}
int return_grow(size_t len)
Definition mhttpd.cxx:556
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 588 of file mhttpd.cxx.

589{
590 return_grow(len);
591 int rd = read(fh, return_buffer + strlen_retbuf, len);
592 if (rd != len) {
593 cm_msg(MERROR, "rread", "Cannot read file \'%s\', read of %d returned %d, errno %d (%s)", filename, len, rd, errno, strerror(errno));
595 }
596 strlen_retbuf += len;
598}
#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:929
#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 602 of file mhttpd.cxx.

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

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

550 {
552 strlen_retbuf = 0;
553 return_length = 0;
554 }
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 684 of file mhttpd.cxx.

◆ return_buffer

char* Return::return_buffer

Definition at line 518 of file mhttpd.cxx.

◆ return_length [1/2]

int Return::return_length

Definition at line 521 of file mhttpd.cxx.

◆ return_length [2/2]

Return::return_length = strlen_retbuf

Definition at line 689 of file mhttpd.cxx.

◆ return_size

size_t Return::return_size

Definition at line 517 of file mhttpd.cxx.

◆ str

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

Definition at line 672 of file mhttpd.cxx.

◆ strlen_retbuf [1/2]

int Return::strlen_retbuf

Definition at line 520 of file mhttpd.cxx.

◆ strlen_retbuf [2/2]

Return::strlen_retbuf = strlen(str)

Definition at line 688 of file mhttpd.cxx.


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