call-switch.awk 2.56 KB
Newer Older
Linus Tolke's avatar
Linus Tolke committed
1
#
David Byers's avatar
David Byers committed
2
# $Id: call-switch.awk,v 0.11 1996/06/14 15:41:46 byers Exp $
3
# Copyright (C) 1991, 1993, 1994, 1995  Lysator Academic Computer Association.
Linus Tolke's avatar
Linus Tolke committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# This file is part of the LysKOM server.
# 
# LysKOM 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 1, or (at your option) 
# any later version.
# 
# LysKOM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License
# along with LysKOM; see the file COPYING.  If not, write to
# Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
# or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
# MA 02139, USA.
#
# Please mail bug reports to bug-lyskom@lysator.liu.se. 
#
David Byers's avatar
David Byers committed
25
# $Id: call-switch.awk,v 0.11 1996/06/14 15:41:46 byers Exp $
Per Cederqvist's avatar
Per Cederqvist committed
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
BEGIN {
    printf("/* Don't edit this file - it is generated automatically");
    printf(" from\n   call-switch.awk and fncdef.txt */\n");
    printf("\tswitch(client->function)\n\t{\n"); 
}
$1 != "#" {
    printf("\tcase call_fnc_%s:\n\t    ", $2);
    if ( $1 == "success" )
	printf("status = %s(", $2);
    else
	printf("res->number = %s(", $2);
    
    num=0;
    string=0;
    c_string=0;
    for ( i = 3; i <= NF; i++)
    {
	if ( i != 3 )
	    printf(", ");
	if ( $i == ":" )
	{
	    printf("&res->%s", $(i+1));
	    break;
	}
	if ( $i == "num" )
	    printf("client->num%d", num++);
	else if ( $i == "string" )
	    printf("client->string%d", string++);
	else if ( $i == "c_string" )
	    printf("client->c_string%d", c_string++);
	else if ( $i == "priv_bits" )
	    printf("client->priv_bits");
	else if ( $i == "conf_type" )
	    printf("client->conf_type");
	else if ( $i == "c_local_text_no_p" )
	    printf("client->c_local_text_no_p");
	else if ( $i == "c_misc_info_p" )
	    printf("client->c_misc_info_p");
Linus Tolke's avatar
Linus Tolke committed
64
	else if ( $i == "time_date" )
65
	    printf("&client->time");
David Byers's avatar
David Byers committed
66
67
        else if ( $i == "info" )
            printf("&client->info");
David Byers's avatar
David Byers committed
68
69
        else if ( $i == "num_list" )
            printf("&client->num_list" );
Per Cederqvist's avatar
Per Cederqvist committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	else
	    printf("\n#error in file server/fncdef.txt\n");
    }
		  
    printf(");\n");
    if ( $1 == "number" )
    {
	if ( $2 == "get_time" )
	    printf("\t    status = OK;\n");
	else
	    printf("\t    status = (res->number != 0) ? OK : FAILURE;\n");
    }

    printf("\t    break;\n\n");
}
END { printf("\t}\n"); }