aboutsummaryrefslogtreecommitdiffstats
path: root/ui/cgi/iframe_env.c
blob: 61d0b22b804a69aafb2fbb3a8e562a674e7d721b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * File Name:       iframe_env.c
 * Workflow:        fullfill HTML iframe
 * Return Value:    0 always
 */

/* Header files */
#include <stdio.h>
#include <stdlib.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>

#include "cgic.h"
#include "proto.h"

/* cgiMain, main in cgic.h */
int cgiMain() {
  key_t shm_key;
  int shm_id;
  SHM_STRUCT *p_shm_struct;

  shm_key = ftok("/usr/bin/boa", 'm');
  shm_id = shmget(shm_key, sizeof(SHM_STRUCT), 0600);

  p_shm_struct = shmat(shm_id, NULL, 0);

  cgiHeaderContentType("text/html");
  fprintf(cgiOut, "<HTML>\n");
  fprintf(cgiOut, "<head><meta http-equiv=\"refresh\" content=\"5\"></head>\n");
  fprintf(cgiOut, "<BODY bgcolor=\"green\">\n");
  fprintf(cgiOut, "<h1>Temperature:\t%d</h1>\n", p_shm_struct->tempNow);
  fprintf(cgiOut, "<h1>Humidity:\t%d</h1>\n", p_shm_struct->humiNow);
  fprintf(cgiOut, "</BODY></HTML>\n");

  return 0;
}