~ubuntu-branches/ubuntu/saucy/ruby-erubis/saucy

« back to all changes in this revision

Viewing changes to examples/pi/example.ec

  • Committer: Package Import Robot
  • Author(s): Laurent Bigonville
  • Date: 2012-01-26 15:15:58 UTC
  • Revision ID: package-import@ubuntu.com-20120126151558-9u7mnf9ooqnw3bwz
Tags: upstream-2.7.0
ImportĀ upstreamĀ versionĀ 2.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?c
 
2
#include <stdio.h>
 
3
 
 
4
void escape(char *str, FILE *out);
 
5
 
 
6
int main(int argc, char *argv[])
 
7
{
 
8
    int i;
 
9
 
 
10
?>
 
11
<p>Hello @!{argv[0]}@!</p>
 
12
<table>
 
13
  <tbody>
 
14
    <?c for (i = 1; i < argc; i++) { ?>
 
15
    <tr bgcolor="@{i % 2 == 0 ? "#FFCCCC" : "#CCCCFF"}@">
 
16
      <td>@!{"%d", i}@</td>
 
17
      <td>@{argv[i]}@</td>
 
18
    </tr>
 
19
    <?c } ?>
 
20
  </tbody>
 
21
</table>
 
22
<?c
 
23
 
 
24
    return 0; 
 
25
}
 
26
 
 
27
void escape(char *str, FILE *out)
 
28
{
 
29
    char *pch;
 
30
    for (pch = str; *pch != '\0'; pch++) {
 
31
        switch (*pch) {
 
32
        case '&':   fputs("&amp;",  out);  break;
 
33
        case '>':   fputs("&gt;",   out);  break;
 
34
        case '<':   fputs("&lt;",   out);  break;
 
35
        case '"':   fputs("&quot;", out);  break;
 
36
        case '\'':  fputs("&#039;", out);  break;
 
37
        default:    fputc(*pch, out);
 
38
        }
 
39
    }
 
40
}
 
41
 
 
42
?>