File: enc-rules.c

package info (click to toggle)
esnacc 1.8.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,452 kB
  • sloc: ansic: 42,340; cpp: 13,880; yacc: 2,682; tcl: 1,587; lex: 688; sh: 573; makefile: 111
file content (112 lines) | stat: -rw-r--r-- 2,362 bytes parent folder | download | duplicates (4)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * compiler/core/enc-rules.c
 *
 * utilities for dealing with different encoding rules 
 *
 * AUTHOR: Dean Povey 
 * DATE:   97/08/27 
 *
 * Copyright (C) 1997 Dean Povey and the Distributed Systems Technology Centre 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * $Header: /baseline/SNACC/compiler/core/enc-rules.c,v 1.2 2003/07/07 14:50:13 nicholar Exp $
 * $Log: enc-rules.c,v $
 * Revision 1.2  2003/07/07 14:50:13  nicholar
 * Eliminated headers and cleaned up include references
 *
 * Revision 1.1.1.1  2000/08/21 20:35:59  leonberp
 * First CVS Version of SNACC.
 *
 * Revision 1.1  1997/08/28 07:37:15  povey
 * Initial revision
 *
 *
 */

#if !defined(lint)
static const char rcsid[] = "@(#)$RCSfile: enc-rules.c,v $ $Revision: 1.2 $";
#endif


/*
 * Local file includes
 */
#include "enc-rules.h"
#include "asn1module.h"
#include "lib-types.h"


/* Static variables. */
static EncRulesType rulesG;
static char* prefixG;
static EncRulesType rulesListG[3] = {NOP, NOP, NOP};

/* Set the encoding rule to be used */
int SetEncRules PARAMS ((encoding), EncRulesType encoding)
{
  switch(encoding) {
  case BER:
    /* Basic Encoding Rules */
    rulesG = BER;
    prefixG = "B";

    /* Set the correct encodings */
    SET_BER_LIBTYPE();

    return 1; 
  case DER:
    /* Distinguished Encoding Rules */
    rulesG = DER;
    prefixG = "D";
    
    /* Set the encodings for each lib type */
    SET_DER_LIBTYPE();
    return 1;
  default:
    /* No such rule */
    return 0;
  }
}

/* Add an encoding to the list of encoders to generate */
void AddEncRules PARAMS((encoding), EncRulesType encoding)
{
  if (rulesListG[0] == NOP) {
    rulesListG[0] = encoding;
  } else if (rulesListG[0] != encoding && rulesListG[1] == NOP) {
    rulesListG[1] = encoding;
  } else {
    /* Encoding must be already set */
    return;
  }

  return;
    
}

/* Return a list of the encoders to generate */
EncRulesType *GetEncRules()
{
  return rulesListG;
}

char* GetEncRulePrefix()
{
  return prefixG;
}

EncRulesType GetEncRulesType()
{
  return rulesG;
}





/***************************************************************/
/* end of FILE_C */