~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/extensions/xmlterm/tests/escape.c

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* escape.c: Generates XMLterm/LineTerm escape sequences */
 
2
 
 
3
#include <stdio.h>
 
4
 
 
5
int main(int argc, char *argv[])
 
6
{
 
7
  int nparam, j;
 
8
  char *param1, *param2, *param3, *code, *sparam;
 
9
 
 
10
  param1 = NULL;
 
11
  param2 = NULL;
 
12
  param3 = NULL;
 
13
  code =   NULL;
 
14
  sparam = "";
 
15
  nparam = 0;
 
16
 
 
17
  for (j=1; j<argc; j++) {
 
18
    if ((*argv[j] >= '0') && (*argv[j] <= '9')) {
 
19
      if (j == 1) {
 
20
        param1 = argv[j];
 
21
        nparam = 1;
 
22
      } else if (j == 2) {
 
23
        param2 = argv[j];
 
24
        nparam = 2;
 
25
      } else if (j == 3) {
 
26
        param3 = argv[j];
 
27
        nparam = 3;
 
28
      }
 
29
    } else if (code == NULL) {
 
30
      code = argv[j];
 
31
    } else {
 
32
      sparam = argv[j];
 
33
    }
 
34
  }
 
35
 
 
36
  if (code == NULL) {
 
37
    fprintf(stderr, "Usage: %s [<param1> [<param2> [<param3>]]] <code-character> [<string-param>] \n", argv[0]);
 
38
    return 1;
 
39
  }
 
40
 
 
41
  if (nparam == 0) {
 
42
    fprintf(stderr, "ESC{%s%s\\n\n", code, sparam);
 
43
    fprintf(stdout, "\033{%s%s\n", code, sparam);
 
44
  } else if (nparam == 1) {
 
45
    fprintf(stderr, "ESC{%s%s%s\\n\n", param1, code, sparam);
 
46
    fprintf(stdout, "\033{%s%s%s\n", param1, code, sparam);
 
47
  } else if (nparam == 2) {
 
48
    fprintf(stderr, "ESC{%s;%s%s%s\\n\n", param1, param2, code, sparam);
 
49
    fprintf(stdout, "\033{%s;%s%s%s\n", param1, param2, code, sparam);
 
50
  } else {
 
51
    fprintf(stderr, "ESC{%s;%s;%s%s%s\\n\n", param1, param2, param3, code, sparam);
 
52
    fprintf(stdout, "\033{%s;%s;%s%s%s\n", param1, param2, param3, code, sparam);
 
53
  }
 
54
 
 
55
  return 0;
 
56
}