Beispiel #1
0
main()
{
	html_start("TITLEXX");
	html_h1("Header1");
	html_h2("Header1");
	html_end();
}
Beispiel #2
0
static void retrieveStudies(llist entries)
{
  html_header();
  html_begin_body_options("DICOM Study Search", "bgcolor=#ffffff");
  printf("%s<p>\n", cgi_val(entries, "patientID"));

  html_end();

}
Beispiel #3
0
void NullForm()
{
  html_begin("Null Form Submitted");
  h1("Null Form Submitted");
  printf("You have sent an empty form.  Please go back and fill out\r\n");
  printf("the form properly, or email <i>%s</i>\r\n",WEBADMIN);
  printf("if you are having difficulty.\r\n");
  html_end();
}
Beispiel #4
0
static void moveSeries(llist entries)
{
  CONDITION cond;
  char dbKey[64] = "";
  char studyUID[65] = "";
  char seriesUID[65] = "";
  char destinationApplication[17] = "";
  char password[64] = "";
  int i;
  long successes = 0;
  long warnings = 0;
  long failures = 0;
  void *timeStamp = 0;
  double deltaTime = 0;

  DMAN_HANDLE *controlHandle;

  strcpy(dbKey, cgi_val(entries, "DBKey"));
  strcpy(studyUID, cgi_val(entries, "StudyUID"));
  strcpy(seriesUID, cgi_val(entries, "SeriesUID"));
  strcpy(password, cgi_val(entries, "password"));
  strcpy(destinationApplication, cgi_val(entries, "DestinationApplication"));

  TBL_SetOption("OPEN_SPEEDUP");

  html_header();
  html_begin_body_options("CTN Archive: Move Series", "bgcolor=#ffffff");

  printf("<pre>\n");
  printf("DB Key:      %s<br>\n", dbKey);
  printf("Study UID:   %s<br>\n", studyUID);
  printf("Series UID:  %s<br>\n", seriesUID);
  /*printf("Password:    %s<br>\n", password);*/
  printf("Destination: %s<br>\n", destinationApplication);

  timeStamp = UTL_GetTimeStamp();

  cond = moveSeriesRequest(dbKey, studyUID, seriesUID, destinationApplication,
			   &successes, &warnings, &failures);

  deltaTime = UTL_DeltaTime(timeStamp);
  UTL_ReleaseTimeStamp(timeStamp);

  printf("Successes:   %d<br>\n", successes);
  printf("Warnings:    %d<br>\n", warnings);
  printf("Failures:    %d<br>\n", failures);
  printf("Xmit time:   %8.2f seconds <br>\n", deltaTime);

  printf("</pre>\n");

  logMoveRequest(dbKey, studyUID, seriesUID, destinationApplication,
		 successes, warnings, failures);

  html_end();
}
Beispiel #5
0
__externC cyg_bool cyg_httpd_send_html( FILE *client, char *filename,
                                        char *request, void *arg )
{
    html_begin( client );
    
    fwrite( arg, 1, strlen((char *)arg), client );

    html_end( client );

    return true;
}
Beispiel #6
0
int main(int argc, char **argv) {
   FILE *q, *z;
   int zeichen;

   if(argc < 3) {
      printf("Benutzung : %s quelle ziel\n",*argv);
      return EXIT_FAILURE;
   }

   q = fopen(argv[1], "r");
   z = fopen(argv[2], "w");

   if(q == NULL || z == NULL) {
      printf("Fehler bei fopen() ... ");
      return EXIT_SUCCESS;
   }
   /* Kopfzeile für HTML-Dokument */
   html_head(z);

   while( (zeichen=getc(q)) != EOF) {
      if(zeichen=='<')
         sonderzeichen(4,"&lt;", z);
      else if(zeichen=='>')
         sonderzeichen(4,"&gt;", z);
      else if(zeichen=='\"')
         sonderzeichen(6,"&quot;",z);
      else if(zeichen=='&')
         sonderzeichen(5,"&amp;",z);
      else if(zeichen=='ä')
         sonderzeichen(6 ,"&auml;",z);
      else if(zeichen=='Ä')
         sonderzeichen(6 ,"&Auml;",z);
      else if(zeichen=='ö')
         sonderzeichen(6 ,"&ouml;",z);
      else if(zeichen=='Ö')
         sonderzeichen(6 ,"&Ouml;",z);
      else if(zeichen=='ü')
         sonderzeichen(6 ,"&uuml;",z);
      else if(zeichen=='Ü')
         sonderzeichen(6 ,"&Uuml;",z);
      else if(zeichen=='ß')
         sonderzeichen(6 ,"&szlig;",z);
      else if(zeichen=='\n') /* Zeilenumbruch */
         sonderzeichen(4, "<br>", z);
      else if(zeichen==' ')  /* Leerzeichen */
         sonderzeichen(6, "&nbsp;", z);
      else
         putc(zeichen, z);
   }
   /* Ende von HTML-Datei */
   html_end(z);
   return EXIT_SUCCESS;
}
Beispiel #7
0
static void directoryToHTML(const char* path)
{
  LST_HEAD* l;
#if 0
  char topDirectory[1024];
  char currentDirectory[1024];
  char key[1024];
#endif
  FILE_ENTRY* f;
  char parentPath[1024];
  char *c;

  strcpy(parentPath, path);
  c = parentPath + strlen(parentPath);
  while (*(--c) != '/')
    ;
  *c = '\0';

  l = LST_Create();
  listDirectory(path, &l);

  html_header();
  html_begin_body_options("File View", "bgcolor=#ffffff");

  while ((f = LST_Dequeue(&l)) != NULL) {
    if (strcmp(f->fileName, "..") == 0) {
      printf("<br><a href=""/cgi-bin/fileview.cgi"
		"?submitSearch=FileSelect"
		"&Key=%s"
		"&CurrentDirectory=%s"
		"&>%s</a>\n",
	   ".",
	   parentPath,
	   f->fileName);
    } else {
      printf("<br><a href=""/cgi-bin/fileview.cgi"
		"?submitSearch=FileSelect"
		"&Key=%s"
		"&CurrentDirectory=%s"
		"&>%s</a>\n",
	   f->fileName,
	   path,
	   f->fileName);
    }
    free(f);
  }
  html_end();
  LST_Destroy(&l);
}
Beispiel #8
0
int main()
{
  llist entries;
  int status;

  html_header();
  html_begin("Query Results");
  status = read_cgi_input(&entries);
  printf("<h1>Status = %d</h1>\n",status);
  h1("Query results");
  print_entries(entries);
  html_end();
  list_clear(&entries);
  return 0;
}
Beispiel #9
0
int main()
{
	char ip_range_start[50],ip_range_end[50],country[50];
	char *osinfo,*browserinfo;
	char *ip,*trueip;

  	html_header();
  	html_begin("cgi-lib 测试程序");

	ip = REMOTE_ADDR;
	trueip = HTTP_CLIENT_IP;

	if(trueip == NULL)
		trueip = HTTP_X_FORWARDED_FOR;
	if(trueip == NULL)
		trueip = ip;	
//	printf("-%s--%s-",ip,trueip);
		
	get_user_ipinfo(trueip,ip_range_start,ip_range_end,country);

	printf("访问者IP地址为: %s <br>\n",ip);
	printf("IP所属区域为:%s <br>\n",country);
	printf("IP所在范围为: %s - %s <br>\n",ip_range_start,ip_range_end);

	if(strstr(trueip,ip) == NULL)
	{
		get_user_ipinfo(ip,ip_range_start,ip_range_end,country);

		printf("访问者代理IP地址为: %s <br>\n",trueip);
		printf("代理IP所属区域为:%s <br>\n",country);
		printf("代理IP所在范围为: %s - %s <br>\n",ip_range_start,ip_range_end);
	
	}
	else
		if(HTTP_X_FORWARDED_FOR != NULL)
			printf("代理 IP 地址未知(没有使用代理、代理服务器 IP 显示被禁止)<br>\n");


	osinfo = get_user_osinfo();
	browserinfo = get_user_browserinfo();
	
	printf("操作系统为: %s <br>\n",osinfo);
	
	printf("浏览器为: %s <br>\n",browserinfo);
	
  	html_end();
  	return 0;
}
Beispiel #10
0
int main()
{
  	float usetime;

	html_header();
	html_begin("Test CGI");
	printf("开始计时!\n<br>");
	timeuse_microsecond_begin();
	printf("输出1!\n<br>");
	printf("输出2\n<br>");
	timeuse_microsecond_end();
	printf("计时结束!\n<br>");
	usetime = timeuse_microsecond_result();
	printf("输出1和输出2共计用时:%f 秒\n<br>",usetime);
	html_end();
	
	return 0;
}
Beispiel #11
0
int main()
{
  llist entries;
  int status;

  html_header();
  html_begin("Test CGI");
  h1("CGI Test Program");
  printf("<hr>\n");
  h2("CGI Environment Variables");
  print_cgi_env();
  status = read_cgi_input(&entries);
  printf("<h2>Status = %d</h2>\n",status);
  h2("CGI Entries");
  print_entries(entries);
  html_end();
  list_clear(&entries);
  return 0;
}
Beispiel #12
0
static void localDirectory(llist entries)
{
  LST_HEAD *patientList;
  DCM_OBJECT *dirFile;
  DDR_PATIENT *patientNode;
  CONDITION cond;

  cond = DCM_OpenFile("/tmp/dicomdir", DCM_ORDERLITTLEENDIAN | DCM_PART10FILE,
		      &dirFile);
  patientList = LST_Create();

  cond = DDR_GetPatientList(&dirFile, &patientList);

  html_header();
  html_begin_body_options("DICOM Patient Search", "bgcolor=#ffffff");

  printf("Please select one patient to see a list of studies<p>\n");

  printf("<form method=GET action=""/cgi-bin/acc_agent.cgi"">\n");

  patientNode = LST_Dequeue(&patientList);
  printf("<select name=patientID size=10>\n");
  while(patientNode != NULL) {
    printf("<option value=""%s"">%s %s %s\n",
	   patientNode->PatientID,
	   patientNode->PatientID,
	   patientNode->PatientName,
	   patientNode->BirthDate);
    free(patientNode);
    patientNode = LST_Dequeue(&patientList);
  }
  printf("</select>\n");
  printf("<br>\n");
  printf("<input type=submit value=""LocalPatientSelect"" name=submitSearch>\n");
  printf("<input type=submit value=""Retrieve All Studies from Archive"" name=submitSearch>\n");

  printf("</form>\n");
  html_end();
  LST_Destroy(&patientList);

  DCM_CloseObject(&dirFile);
}
Beispiel #13
0
static void fileToHTML(const char* path)
{
  DCM_OBJECT* obj;
  CONDITION cond;

  THR_Init();
  cond = DCM_OpenFile(path, DCM_ORDERLITTLEENDIAN, &obj);
  if (cond != DCM_NORMAL) {
    (void) DCM_CloseObject(&obj);
    cond = DCM_OpenFile(path, DCM_PART10FILE, &obj);
  }
  if (cond != DCM_NORMAL) {
    exit(0);
  }
#if 1
    printf("Content-type: text/html\n\n");
    printf("<HTML>\n");
    printf("<HEAD>\n");
    printf("<META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=iso-2022-jp"">\n");
    printf("<TITLE>dcm_to_html</TITLE>\n");
    printf("</HEAD>");

    printf("<BODY BGCOLOR=#ffffff FGCOLOR=#ff000000>\n");
    printf("<B>%s</B>\n", path);
    printf("<TABLE BORDER>\n");
    DCM_ScanParseObject(&obj,
			NULL, 0,           /* Buffer/buffer size */
			NULL, 0,           /* Vector of elements to scan */
			callback, NULL);
    printf("</TABLE>\n");
    printf("</BODY>\n");
    printf("</HTML>");

    (void) DCM_CloseObject(&obj);
    THR_Shutdown();
#else
  html_header();
  html_begin_body_options("File View", "bgcolor=#ffffff");
  printf("%s<br>\n", path);
  html_end();
#endif
}
Beispiel #14
0
void authenticate(char *dest)
{
  FILE *access;
  char s[80];
  short FOUND = 0;

  access = fopen(AUTH,"r");
  while ( (fgets(s,80,access)!=NULL) && (!FOUND) ) {
    s[strlen(s) - 1] = '\0';
    if (!strcmp(s,dest))
      FOUND = 1;
  }
  if (!FOUND) {
    /* not authenticated */
    html_begin("Unauthorized Destination");
    h1("Unauthorized Destination");

    html_end();
    exit(1);
  }
}
Beispiel #15
0
int main()
{
  llist entries;
  int status;
  char *form;

  status = read_cgi_input(&entries);
  form = cgi_val(entries, "submitSearch");

  if (strcmp(form, "View") == 0)
    view(entries);
  else if (strcmp(form, "FileSelect") == 0)
    fileSelect(entries);
  else {
    html_header();
    html_begin_body_options("Query Results", "bgcolor=#ffffff");
    printf("<h1>Status = %d</h1>\n",status);
    h1("Query results");
    print_entries(entries);
    html_end();
  }
  list_clear(&entries);
  return 0;
}
Beispiel #16
0
static void localPatientSelect(llist entries)
{
  LST_HEAD *studyList;
  DCM_OBJECT *dirFile;
  DDR_STUDY *studyNode;
  CONDITION cond;

  cond = DCM_OpenFile("/tmp/dicomdir", DCM_ORDERLITTLEENDIAN | DCM_PART10FILE,
		      &dirFile);
  studyList = LST_Create();

  cond = DDR_GetStudyList(&dirFile,
		cgi_val(entries, "patientID"),
		&studyList);

  html_header();
  html_begin_body_options("DICOM Study Search", "bgcolor=#ffffff");

  studyNode = LST_Dequeue(&studyList);
  printf("<tt>\n");
  while(studyNode != NULL) {
    printf("%s %s %s %s <br>\n",
	   studyNode->StudyDate,
	   studyNode->AccessionNumber,
	   studyNode->StudyID,
	   studyNode->StudyDescription);

    free(studyNode);
    studyNode = LST_Dequeue(&studyList);
  }
  printf("</tt>\n");
  html_end();


  DCM_CloseObject(&dirFile);
}
Beispiel #17
0
static void selectSeries(llist entries)
{
  CONDITION cond;
  char dbKey[64];
  char studyUID[65];
  char seriesUID[65];
  IDB_Query series;
  QUERY_LIST_ITEM *item;
  IDB_InstanceListElement *instancePtr;
  unsigned long byteCount = 0;
  char password[64];
  DMAN_HANDLE *controlHandle;

  LST_HEAD *destinationList;

  openCTN(&controlHandle);

  strcpy(dbKey, cgi_val(entries, "DBKey"));
  strcpy(studyUID, cgi_val(entries, "StudyUID"));
  strcpy(seriesUID, cgi_val(entries, "SeriesUID"));
  strcpy(password, cgi_val(entries, "password"));

  TBL_SetOption("OPEN_SPEEDUP");
  cond = searchOneSeries(dbKey, studyUID, seriesUID, &series);

  html_header();
  html_begin_body_options("CTN Archive: Series Management", "bgcolor=#ffffff");

  printf("<table>\n");

  printf("<TR><TH align=right>Name: <TH align=left>%s</TR>\n",
	 series.patient.PatNam);
  printf("<TR><TH align=right>Date of Birth: <TH align=left>%s</TR>\n",
	 series.patient.PatBirDat);
  printf("<TR><TH align=right>Series Number: <TH align=left>%s</TR>\n",
	 series.series.SerNum);
  printf("<TR><TH align=right>Image Count: <TH align=left>%d</TR>\n",
	 series.series.NumSerRelIma);

  printf("</table>\n");

  printf("<form method=GET action=""archive_agent.cgi"">\n");
  printf("<input type=hidden name=DBKey value=%s>\n", dbKey);
  printf("<input type=hidden name=StudyUID value=%s>\n", studyUID);
  printf("<input type=hidden name=SeriesUID value=%s>\n", seriesUID);
  printf("<input type=hidden name=password value=%s>\n", password);


  { DMAN_VIDEOIMAGEDEST *video;

    destinationList = LST_Create();

    cond = listOfDestinations(&controlHandle, destinationList);

    printf("<select name=DestinationApplication size=10>\n");

    video = LST_Dequeue(&destinationList);
    while (video != NULL) {
      /*char tmp[1024];*/
      DMAN_APPLICATIONENTITY ae;

      memset(&ae, 0, sizeof(ae));
      ae.Type = DMAN_K_APPLICATIONENTITY;
      DMAN_LookupApplication(&controlHandle, video->RespondingTitle, &ae);

      /*sprintf(tmp, "%17s %s", ae.Title, ae.Title, ae.Node, ae.Comment);*/
      printf("<option value=""%s"">%16s %15s %d %s\n",
/*	   ae.Title,*/
	   video->RespondingTitle,
	   ae.Title,
	   ae.Node,
	   ae.Port,
	   ae.Comment);

      free(video);
      video = LST_Dequeue(&destinationList);
    }
    printf("</select>\n");
  }
  LST_Destroy(&destinationList);

  printf("<br>\n");
  printf("<input type=submit value=""MoveSeries"" name=submitSearch>\n");

  printf("</form>\n");

  html_end();
}
Beispiel #18
0
void simulate() {
    bool action;
    double start = START_TIME;
    gstate.now = start;
    html_start();
    fprintf(summary_file,
        "Hardware summary\n   %d CPUs, %.1f GFLOPS\n",
        gstate.host_info.p_ncpus, gstate.host_info.p_fpops/1e9
    );
    for (int i=1; i<coprocs.n_rsc; i++) {
        fprintf(summary_file,
            "   %d %s GPUs, %.1f GFLOPS\n",
            coprocs.coprocs[i].count,
            coprocs.coprocs[i].type,
            coprocs.coprocs[i].peak_flops/1e9
        );
    }
    fprintf(summary_file,
        "Preferences summary\n"
        "   work buf min %f max %f\n"
        "   Scheduling period %f\n"
        "Scheduling policies\n"
        "   Round-robin only: %s\n"
        "   Scheduler EDF simulation: %s\n"
        "   REC half-life: %f\n",
        gstate.work_buf_min(), gstate.work_buf_total(),
        gstate.global_prefs.cpu_scheduling_period(),
        cpu_sched_rr_only?"yes":"no",
        server_uses_workload?"yes":"no",
        cc_config.rec_half_life
    );
    fprintf(summary_file, "Jobs\n");
    for (unsigned int i=0; i<gstate.results.size(); i++) {
        RESULT* rp = gstate.results[i];
        fprintf(summary_file,
            "   %s %s (%s)\n      time left %s deadline %s\n",
            rp->project->project_name,
            rp->name,
            rsc_name_long(rp->avp->gpu_usage.rsc_type),
            timediff_format(rp->sim_flops_left/rp->avp->flops).c_str(),
            timediff_format(rp->report_deadline - START_TIME).c_str()
        );
    }
    fprintf(summary_file,
        "Simulation parameters\n"
        "   time step %f, duration %f\n"
        "-------------------\n",
        delta, duration
    );

    write_inputs();

    while (1) {
        on = on_proc.sample(delta);
        if (on) {
            active = active_proc.sample(delta);
            if (active) {
                gpu_active = gpu_active_proc.sample(delta);
            } else {
                gpu_active = false;
            }
            connected = connected_proc.sample(delta);
        } else {
            active = gpu_active = connected = false;
        }
        // do accounting for the period that just ended,
        // even if we're now in an "off" state.
        //
        // need both of the following, else crash
        //
        action |= gstate.active_tasks.poll();
        action |= gstate.handle_finished_apps();
        if (on) {
            while (1) {
                action = false;
                action |= gstate.schedule_cpus();
                if (connected) {
                    action |= gstate.scheduler_rpc_poll();
                        // this deletes completed results
                }
                action |= gstate.active_tasks.poll();
                action |= gstate.handle_finished_apps();
                gpu_suspend_reason = gpu_active?0:1;
                //msg_printf(0, MSG_INFO, action?"did action":"did no action");
                if (!action) break;
            }
        }
        //msg_printf(0, MSG_INFO, "took time step");
        for (unsigned int i=0; i<gstate.active_tasks.active_tasks.size(); i++) {
            ACTIVE_TASK* atp = gstate.active_tasks.active_tasks[i];
            if (atp->task_state() == PROCESS_EXECUTING) {
                atp->elapsed_time += delta;
            }
        }
        html_rec();
        write_recs();
        gstate.now += delta;
        if (gstate.now > start + duration) break;
    }
    html_end();
}
Beispiel #19
0
int main()
{
  llist entries;
  FILE *mail;
  char command[256] = "/usr/lib/sendmail ";
  char *dest,*name,*email,*subject,*content;

  html_header();
  read_cgi_input(&entries);
  if ( !strcmp("",cgi_val(entries,"name")) &&
      !strcmp("",cgi_val(entries,"email")) &&
      !strcmp("",cgi_val(entries,"subject")) &&
      !strcmp("",cgi_val(entries,"content")) )
    NullForm();
  else {
    if (is_field_empty(entries,"to"))
      dest = newstr(WEBADMIN);
    else
      dest = newstr(cgi_val(entries,"to"));
    name = newstr(cgi_val(entries,"name"));
    email = newstr(cgi_val(entries,"email"));
    subject = newstr(cgi_val(entries,"subject"));
    if (dest[0]=='\0')
      strcpy(dest,WEBADMIN);
    else
      authenticate(dest);
    /* no need to escape_input() on dest, since we assume there aren't
       insecure entries in the authentication file. */
    strcat(command,dest);
    mail = popen(command,"w");
    if (mail == NULL) {
      html_begin("System Error!");
      h1("System Error!");
      printf("Please mail %s and inform\r\n",WEBADMIN);
      printf("the web maintainers that the comments script is improperly\r\n");
      printf("configured. We apologize for the inconvenience<p>\r\n");
      printf("<hr>\r\nWeb page created on the fly by ");
      printf("<i>%s</i>.\r\n",WEBADMIN);
      html_end();
    }
    else {
      content = newstr(cgi_val(entries,"content"));
      fprintf(mail,"From: %s (%s)\n",email,name);
      fprintf(mail,"Subject: %s\n",subject);
      fprintf(mail,"To: %s\n",dest);
      fprintf(mail,"X-Sender: %s\n\n",WEBADMIN);
      fprintf(mail,"%s\n\n",content);
      pclose(mail);
      html_begin("Comment Submitted");
      h1("Comment Submitted");
      printf("You submitted the following comment:\r\n<pre>\r\n");
      printf("From: %s (%s)\r\n",email,name);
      printf("Subject: %s\r\n\r\n",subject);
      printf("%s\r\n</pre>\r\n",content);
      printf("Thanks again for your comments.<p>\r\n");
      printf("<hr>\r\nWeb page created on the fly by ");
      printf("<i>%s</i>.\r\n",WEBADMIN);
      html_end();
    }
  }
  list_clear(&entries);
  return 0;
}
Beispiel #20
0
static void selectStudy(llist entries)
{
  CONDITION cond;
  char dbKey[64];
  char studyUID[65];
  IDB_Query study;
  LST_HEAD *imageList;
  LST_HEAD *seriesList;
  QUERY_LIST_ITEM *item;
  IDB_InstanceListElement *instancePtr;
  unsigned long byteCount = 0;
  char password[64];


  strcpy(dbKey, cgi_val(entries, "DBKey"));
  strcpy(studyUID, cgi_val(entries, "StudyUID"));
  strcpy(password, cgi_val(entries, "password"));

  TBL_SetOption("OPEN_SPEEDUP");
  cond = searchOneStudy(dbKey, studyUID, &study);

  imageList = LST_Create();
  seriesList = LST_Create();
  cond = searchImages(dbKey, studyUID, imageList);
  while ((item = LST_Dequeue(&imageList)) != NULL) {

    instancePtr = LST_Dequeue(&(item->query.image.InstanceList));

    if (instancePtr != NULL)
      byteCount += instancePtr->Size;
#if 0
    while (instancePtr != NULL) {
      free(instancePtr);
      instancePtr = LST_Dequeue(&(item->query.image.InstanceList));
    }

    free(item);
#endif
  }

  html_header();
  html_begin_body_options("CTN Archive: Study Management", "bgcolor=#ffffff");

  printf("<table>\n");
  printf("<TR><TH>Name: <TH>%s</TR>\n", study.patient.PatNam);
  printf("<TR><TH>Date of Birth: <TH>%s</TR>\n", study.patient.PatBirDat);
  printf("<TR><TH>Accession Number: <TH>%s</TR>\n", study.study.AccNum);
  printf("<TR><TH>Study Date: <TH>%s</TR>\n", study.study.StuDat);
  printf("<TR><TH>Study Description: <TH>%s</TR>\n", study.study.StuDes);
  printf("<TR><TH>Series: <TH>%d</TR>\n", study.study.NumStuRelSer);
  printf("<TR><TH>Images: <TH>%d</TR>\n", study.study.NumStuRelIma);
  printf("<TR><TH>Image Volume: <TH>%d bytes</TR>\n", byteCount);
  printf("</table>\n");

  printf("<form method=GET action=""archive_agent.cgi"">\n");
  printf("<input type=hidden name=DBKey value=%s>\n", dbKey);
  printf("<input type=hidden name=StudyUID value=%s>\n", studyUID);

/*********/
  printf("<pre>\n");
  cond = searchSeries(dbKey, studyUID, seriesList);
  item = LST_Dequeue(&seriesList);
  printf("%-10s %6s %15s %15s %15s <br>",
	"Series #",
	"Images",
	"Proc Name",
	"Series Des",
	"Body Part");
  while(item != NULL) {
    char tmp[1024];
    sprintf(tmp, "%-10s %6d %15s %15s %15s",
	    item->query.series.SerNum,
	    item->query.series.NumSerRelIma,
	    item->query.series.ProNam,
	    item->query.series.SerDes,
	    item->query.series.BodParExa);

    printf(
"<a href=""/cgi-bin/archive_agent.cgi?submitSearch=%s&DBKey=%s&\
password=%s&StudyUID=%s&SeriesUID=%s"">%s</a>\n",
	   "SeriesSelect",
	   dbKey,
	   password,
	   studyUID,
	   item->query.series.SerInsUID,
	   tmp);

    free(item);
    item = LST_Dequeue(&seriesList);
  }
  printf("</pre>\n");
/**********/

  if (strcmp(password, "READONLY") != 0) {
    printf("<input type=submit value=""Delete_Study"" name=submitSearch>\n");
  }
  printf("</form>\n");

  html_end();
}
Beispiel #21
0
static void selectArchive(llist entries)
{
  CONDITION cond;
  LST_HEAD *studyList;
  char dbKey[64];
  QUERY_LIST_ITEM *item;
  IDB_Limits limits;
  char password[64];
  int flag = 0;

  studyList = LST_Create();
  strcpy(dbKey, cgi_val(entries, "DBKey"));
  strcpy(password, cgi_val(entries, "password"));

  TBL_SetOption("OPEN_SPEEDUP");
  cond = listOfStudies(dbKey, studyList);
  orderStudyListByName(studyList);

  flag = passwordCompare(dbKey, password);
  if (flag == 0)
    strcpy(password, "READONLY");

  memset(&limits, 0, sizeof(limits));
  cond = dbLimits(dbKey, &limits);

  html_header();
  html_begin_body_options("CTN Archive: List of Studies", "bgcolor=#ffffff");

  if (flag == 0) {
    printf("Read only access granted <br>\n");
  }

  printf("CTN Archive: %s <br> \n", dbKey);
  { char *remoteUser;

    remoteUser = getenv("REMOTE_USER");
    if (remoteUser == NULL)
      remoteUser = "******";

    printf("Remote user: %s<br>\n", remoteUser);
  }

  printf("%d patients, %d studies, %d images <br>\n",
	 limits.PatientCount,
	 limits.StudyCount,
	 limits.ImageCount);
  printf("DB Size/Limits (MB): %d/%d<br>\n",
	 limits.DBSize/1000000,
	 limits.DBLimit);
#if 0
  printf("%d studies <br><br>\n", LST_Count(&studyList));
#endif

  printf("<pre>\n");
  item = LST_Dequeue(&studyList);
  while(item != NULL) {
    char tmp[1024];
    sprintf(tmp, "%-30s %8s (%2d series) %-32s",
	    item->query.patient.PatNam,
	    item->query.study.StuDat,
	    item->query.study.NumStuRelSer,
	    item->query.study.StuDes);

#if 0
    printf("<a href=""/cgi-bin/archive_agent.cgi?submitSearch=%s&DBKey=%s&StudyUID=%s"">%s</a><br>\n",
#endif

    printf(
"<a href=""/cgi-bin/archive_agent.cgi?submitSearch=%s&DBKey=%s&\
password=%s&StudyUID=%s"">%s</a>\n",
	   "StudySelect",
	   dbKey,
	   password,
	   item->query.study.StuInsUID,
	   tmp);

    free(item);
    item = LST_Dequeue(&studyList);
  }
  printf("</pre>\n");

  LST_Destroy(&studyList);

  html_end();
}
Beispiel #22
0
int main()
{
	LIST_STRU entries;
  	LIST_STRU configs;
  	char *configname = "simple-webmail.conf";
  	FILE *mail;
  	char *dest,*name,*from,*subject,*content;
	char command[256];

  	html_header();

  	read_cgi_input(&entries);
  	read_configs(&configs,configname);

  	if( (is_field_empty(entries,"name")) && (is_field_empty(entries,"from")) &&
      		(is_field_empty(entries,"subject")) && (is_field_empty(entries,"content")) )
	{
	    printf("重新输入!");
  	}
  	else
  	{

    		if (is_field_empty(entries,"to"))
      			dest = strdup(TO);
    		else
      			dest = strdup(cgi_val(entries,"to"));
		
		if (!xstrcmp("*@*.*",dest))
		{
			printf("收件人 %s 不是标准的邮件格式 *@*.*\n",dest);
			exit(-1);
		}
    		name = strdup(cgi_val(entries,"name"));
    		from = strdup(cgi_val(entries,"from"));
    		subject = strdup(cgi_val(entries,"subject"));
		
    		if (dest[0] == '\0')
      			strcpy(dest,WEBADMIN);

		sprintf(command,"%s %s",SENDMAIL,dest);

    		mail = popen(command,"w");
    		if (mail == NULL) 
    		{
      			html_begin("系统出错!");
      			printf("系统出错!");
      			printf("请发信给 %s 。 \r\n",WEBADMIN);
      			printf("<hr>\r\n简单WEB邮件发送程序 v 0.1 . 作者: ");
      			printf("<i>%s</i>.\r\n",WEBADMIN);
      			exit(-1);
      			html_end();
    		}
    		else 
    		{
      			content = strdup(cgi_val(entries,"content"));
      			fprintf(mail,"From: %s (%s)\n",from,name);
      			fprintf(mail,"Subject: %s\n",subject);
      			fprintf(mail,"To: %s\n",dest);
      			fprintf(mail,"X-Sender: %s\n\n",WEBADMIN);
	  		if (REMOTE_ADDR != NULL)
				fprintf(mail,"发送者 IP 地址 %s\n",REMOTE_ADDR);
			// 增加 http 代理 相关环境变量,可判断是否有代理服务器,可显示出非匿名代理的源地址  2003.08.17
  			if (HTTP_X_FORWARDED_FOR != NULL)
				fprintf(mail,"经过代理前IP地址 %s\n",HTTP_X_FORWARDED_FOR);
  			if (HTTP_CLIENT_IP != NULL)
				fprintf(mail,"代理服务器地址 %s\n",HTTP_CLIENT_IP);
      			fprintf(mail,"%s\n\n",content);
      			pclose(mail);
      			html_begin("邮件发送成功");
      			printf("邮件发送成功");
      			printf("你发送了以下的信息:\r\n<pre>\r\n");
      			printf("收信人: %s \r\n",dest);
      			printf("发信人: %s (%s)\r\n",from,name);
      			printf("标 题: %s\r\n\r\n",subject);
      			printf("%s\r\n</pre>\r\n",content);
	  		if (REMOTE_ADDR != NULL)
				printf("发送者 IP 地址 %s<br>\n",REMOTE_ADDR);
			// 增加 http 代理 相关环境变量,可判断是否有代理服务器,可显示出非匿名代理的源地址  2003.08.17
  			if (HTTP_X_FORWARDED_FOR != NULL)
				printf("经过代理前IP地址 %s<br>\n",HTTP_X_FORWARDED_FOR);
  			if (HTTP_CLIENT_IP != NULL)
				printf("代理服务器地址 %s<br>\n",HTTP_CLIENT_IP);
      			printf("谢谢使用!<p>\r\n");
      			printf("<hr>\r\n简单WEB邮件发送程序 v 0.1 . 作者: ");
      			printf("<i>%s</i>.\r\n",WEBADMIN);
      			html_end();
    		}
	}

  	list_clear(&entries);
  	list_clear(&configs);
  	return 0;
}