Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1 | #! /usr/bin/perl -w |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2 | # |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 3 | # Build the server/trace.c and server/request.h files |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 4 | # from the contents of include/wine/server.h. |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 5 | # |
| 6 | # Copyright (C) 1998 Alexandre Julliard |
| 7 | # |
| 8 | |
| 9 | %formats = |
| 10 | ( |
Alexandre Julliard | 3e2517c | 2000-01-20 18:59:03 +0000 | [diff] [blame] | 11 | "int" => "%d", |
Eric Pouech | 0b83d4c | 2001-11-23 23:04:58 +0000 | [diff] [blame] | 12 | "short int" => "%d", |
Alexandre Julliard | 3e2517c | 2000-01-20 18:59:03 +0000 | [diff] [blame] | 13 | "char" => "%c", |
Alexandre Julliard | 0a7c1f6 | 2000-01-27 02:54:17 +0000 | [diff] [blame] | 14 | "unsigned char" => "%02x", |
Alexandre Julliard | 838d65a | 2001-06-19 19:16:41 +0000 | [diff] [blame] | 15 | "unsigned short"=> "%04x", |
Alexandre Julliard | 3e2517c | 2000-01-20 18:59:03 +0000 | [diff] [blame] | 16 | "unsigned int" => "%08x", |
| 17 | "void*" => "%p", |
| 18 | "time_t" => "%ld", |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 19 | "size_t" => "%d", |
Alexandre Julliard | 8081e5a | 2001-01-05 04:08:07 +0000 | [diff] [blame] | 20 | "handle_t" => "%d", |
Alexandre Julliard | d8a8c11 | 2001-10-12 18:45:29 +0000 | [diff] [blame] | 21 | "atom_t" => "%04x", |
Alexandre Julliard | 1a66d22 | 2001-08-28 18:44:52 +0000 | [diff] [blame] | 22 | "user_handle_t" => "%08x", |
Alexandre Julliard | 0d50965 | 2001-10-16 21:55:37 +0000 | [diff] [blame] | 23 | "rectangle_t" => "&dump_rectangle", |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 24 | "char_info_t" => "&dump_char_info", |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 25 | ); |
| 26 | |
| 27 | my @requests = (); |
| 28 | my %replies = (); |
| 29 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 30 | my @trace_lines = (); |
| 31 | |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 32 | # Get the server protocol version |
| 33 | my $protocol = &GET_PROTOCOL_VERSION; |
| 34 | |
| 35 | ### Create server_protocol.h and print header |
| 36 | |
| 37 | open SERVER_PROT, ">include/wine/server_protocol.h" or die "Cannot create include/wine/server_protocol.h"; |
| 38 | print SERVER_PROT "/*\n * Wine server protocol definitions\n *\n"; |
| 39 | print SERVER_PROT " * This file is automatically generated; DO NO EDIT!\n"; |
| 40 | print SERVER_PROT " * Edit server/protocol.def instead and re-run tools/make_requests\n"; |
| 41 | print SERVER_PROT " */\n\n"; |
| 42 | print SERVER_PROT "#ifndef __WINE_WINE_SERVER_PROTOCOL_H\n"; |
| 43 | print SERVER_PROT "#define __WINE_WINE_SERVER_PROTOCOL_H\n"; |
| 44 | |
| 45 | ### Parse requests to find request/reply structure definitions |
| 46 | |
| 47 | &PARSE_REQUESTS; |
| 48 | |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 49 | ### Build the request list and structures |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 50 | |
| 51 | print SERVER_PROT "\n\nenum request\n{\n"; |
| 52 | foreach $req (@requests) { print SERVER_PROT " REQ_$req,\n"; } |
| 53 | print SERVER_PROT " REQ_NB_REQUESTS\n};\n\n"; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 54 | |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 55 | print SERVER_PROT "union generic_request\n{\n"; |
| 56 | print SERVER_PROT " struct request_max_size max_size;\n"; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 57 | print SERVER_PROT " struct request_header request_header;\n"; |
| 58 | foreach $req (@requests) { print SERVER_PROT " struct ${req}_request ${req}_request;\n"; } |
| 59 | print SERVER_PROT "};\n"; |
| 60 | |
| 61 | print SERVER_PROT "union generic_reply\n{\n"; |
| 62 | print SERVER_PROT " struct request_max_size max_size;\n"; |
| 63 | print SERVER_PROT " struct reply_header reply_header;\n"; |
| 64 | foreach $req (@requests) { print SERVER_PROT " struct ${req}_reply ${req}_reply;\n"; } |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 65 | print SERVER_PROT "};\n\n"; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 66 | |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 67 | printf SERVER_PROT "#define SERVER_PROTOCOL_VERSION %d\n\n", $protocol + 1; |
| 68 | print SERVER_PROT "#endif /* __WINE_WINE_SERVER_PROTOCOL_H */\n"; |
| 69 | close SERVER_PROT; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 70 | |
| 71 | ### Output the dumping function tables |
| 72 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 73 | push @trace_lines, "static const dump_func req_dumpers[REQ_NB_REQUESTS] = {\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 74 | foreach $req (@requests) |
| 75 | { |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 76 | push @trace_lines, " (dump_func)dump_${req}_request,\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 77 | } |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 78 | push @trace_lines, "};\n\n"; |
Alexandre Julliard | d2b7a0b | 1999-05-24 12:33:10 +0000 | [diff] [blame] | 79 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 80 | push @trace_lines, "static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {\n"; |
Alexandre Julliard | d2b7a0b | 1999-05-24 12:33:10 +0000 | [diff] [blame] | 81 | foreach $req (@requests) |
| 82 | { |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 83 | push @trace_lines, " (dump_func)", $replies{$req} ? "dump_${req}_reply,\n" : "0,\n"; |
Alexandre Julliard | d2b7a0b | 1999-05-24 12:33:10 +0000 | [diff] [blame] | 84 | } |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 85 | push @trace_lines, "};\n\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 86 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 87 | push @trace_lines, "static const char * const req_names[REQ_NB_REQUESTS] = {\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 88 | foreach $req (@requests) |
| 89 | { |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 90 | push @trace_lines, " \"$req\",\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 91 | } |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 92 | push @trace_lines, "};\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 93 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 94 | REPLACE_IN_FILE( "server/trace.c", @trace_lines ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 95 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 96 | ### Output the request handlers list |
Alexandre Julliard | d2b7a0b | 1999-05-24 12:33:10 +0000 | [diff] [blame] | 97 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 98 | my @request_lines = (); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 99 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 100 | foreach $req (@requests) { push @request_lines, "DECL_HANDLER($req);\n"; } |
| 101 | push @request_lines, "\n#ifdef WANT_REQUEST_HANDLERS\n\n"; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 102 | push @request_lines, "typedef void (*req_handler)( const void *req, void *reply );\n"; |
Alexandre Julliard | ea0d028 | 2000-03-10 22:16:10 +0000 | [diff] [blame] | 103 | push @request_lines, "static const req_handler req_handlers[REQ_NB_REQUESTS] =\n{\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 104 | foreach $req (@requests) |
| 105 | { |
Alexandre Julliard | ea0d028 | 2000-03-10 22:16:10 +0000 | [diff] [blame] | 106 | push @request_lines, " (req_handler)req_$req,\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 107 | } |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 108 | push @request_lines, "};\n#endif /* WANT_REQUEST_HANDLERS */\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 109 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 110 | REPLACE_IN_FILE( "server/request.h", @request_lines ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 111 | |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 112 | ### Parse the request definitions |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 113 | |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 114 | sub PARSE_REQUESTS |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 115 | { |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 116 | # states: 0 = header 1 = declarations 2 = inside @REQ 3 = inside @REPLY |
| 117 | my $state = 0; |
| 118 | my $name = ""; |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 119 | my @in_struct = (); |
| 120 | my @out_struct = (); |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 121 | |
| 122 | open(PROTOCOL,"server/protocol.def") or die "Can't open server/protocol.def"; |
| 123 | |
| 124 | while (<PROTOCOL>) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 125 | { |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 126 | my ($type, $var); |
| 127 | # strip comments |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 128 | s!/\*.*\*/!!g; |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 129 | # strip white space at end of line |
| 130 | s/\s+$//; |
| 131 | |
| 132 | if (/^\@HEADER/) |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 133 | { |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 134 | die "Misplaced \@HEADER" unless $state == 0; |
| 135 | $state++; |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 136 | next; |
| 137 | } |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 138 | |
| 139 | # ignore everything while in state 0 |
| 140 | next if $state == 0; |
| 141 | |
| 142 | if (/^\@REQ\(\s*(\w+)\s*\)/) |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 143 | { |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 144 | $name = $1; |
| 145 | die "Misplaced \@REQ" unless $state == 1; |
| 146 | # start a new request |
| 147 | @in_struct = (); |
| 148 | @out_struct = (); |
| 149 | print SERVER_PROT "struct ${name}_request\n{\n"; |
| 150 | print SERVER_PROT " struct request_header __header;\n"; |
| 151 | $state++; |
| 152 | next; |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 153 | } |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 154 | |
| 155 | if (/^\@REPLY/) |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 156 | { |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 157 | die "Misplaced \@REPLY" unless $state == 2; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 158 | print SERVER_PROT "};\n"; |
| 159 | print SERVER_PROT "struct ${name}_reply\n{\n"; |
| 160 | print SERVER_PROT " struct reply_header __header;\n"; |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 161 | $state++; |
| 162 | next; |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 163 | } |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 164 | |
| 165 | if (/^\@END/) |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 166 | { |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 167 | die "Misplaced \@END" unless ($state == 2 || $state == 3); |
| 168 | print SERVER_PROT "};\n"; |
| 169 | |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 170 | if ($state == 2) # build dummy reply struct |
| 171 | { |
| 172 | print SERVER_PROT "struct ${name}_reply\n{\n"; |
| 173 | print SERVER_PROT " struct reply_header __header;\n"; |
| 174 | print SERVER_PROT "};\n"; |
| 175 | } |
| 176 | |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 177 | # got a complete request |
| 178 | push @requests, $name; |
| 179 | &DO_DUMP_FUNC( $name, "request", @in_struct); |
| 180 | if ($#out_struct >= 0) |
| 181 | { |
| 182 | $replies{$name} = 1; |
| 183 | &DO_DUMP_FUNC( $name, "reply", @out_struct); |
| 184 | } |
| 185 | $state = 1; |
| 186 | next; |
Alexandre Julliard | 8611353 | 2000-08-29 03:54:30 +0000 | [diff] [blame] | 187 | } |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 188 | |
| 189 | if ($state != 1) |
| 190 | { |
| 191 | # skip empty lines (but keep them in output file) |
| 192 | if (/^$/) |
| 193 | { |
| 194 | print SERVER_PROT "\n"; |
| 195 | next; |
| 196 | } |
| 197 | |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 198 | if (/^\s*VARARG\((\w+),(\w+),(\w+)\)/) |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 199 | { |
| 200 | $var = $1; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 201 | $type = "dump_varargs_" . $2 . "( min(cur_size,req->" . $3 . ") )"; |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 202 | s!(VARARG\(.*\)\s*;)!/* $1 */!; |
| 203 | } |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 204 | elsif (/^\s*VARARG\((\w+),(\w+)\)/) |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 205 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 206 | $var = $1; |
| 207 | $type = "dump_varargs_" . $2 . "( cur_size )"; |
| 208 | s!(VARARG\(.*\)\s*;)!/* $1 */!; |
| 209 | } |
| 210 | elsif (/^\s*(\w+\**(\s+\w+\**)*)\s+(\w+);/) |
| 211 | { |
| 212 | $type = $1; |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 213 | $var = $3; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 214 | die "Unrecognized type $type" unless defined($formats{$type}); |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 215 | } |
| 216 | else |
| 217 | { |
| 218 | die "Unrecognized syntax $_"; |
| 219 | } |
| 220 | if ($state == 2) { push @in_struct, $type, $var; } |
| 221 | if ($state == 3) { push @out_struct, $type, $var; } |
| 222 | } |
| 223 | |
| 224 | # Pass it through into the output file |
| 225 | print SERVER_PROT $_ . "\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 226 | } |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 227 | close PROTOCOL; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | ### Generate a dumping function |
| 231 | |
| 232 | sub DO_DUMP_FUNC |
| 233 | { |
| 234 | my $name = shift; |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 235 | my $req = shift; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 236 | push @trace_lines, "static void dump_${name}_$req( const struct ${name}_$req *req )\n{\n"; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 237 | while ($#_ >= 0) |
| 238 | { |
| 239 | my $type = shift; |
| 240 | my $var = shift; |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 241 | if (defined($formats{$type})) |
Alexandre Julliard | 338e757 | 1998-12-27 15:28:54 +0000 | [diff] [blame] | 242 | { |
Alexandre Julliard | fbb9a9f | 1999-11-23 19:38:18 +0000 | [diff] [blame] | 243 | if ($formats{$type} =~ /^&(.*)/) |
| 244 | { |
| 245 | my $func = $1; |
| 246 | push @trace_lines, " fprintf( stderr, \" $var=\" );\n"; |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 247 | push @trace_lines, " $func( &req->$var );\n"; |
Alexandre Julliard | fbb9a9f | 1999-11-23 19:38:18 +0000 | [diff] [blame] | 248 | push @trace_lines, " fprintf( stderr, \",\" );\n" if ($#_ > 0); |
| 249 | } |
| 250 | else |
| 251 | { |
| 252 | push @trace_lines, " fprintf( stderr, \" $var=$formats{$type}"; |
| 253 | push @trace_lines, "," if ($#_ > 0); |
| 254 | push @trace_lines, "\", "; |
| 255 | push @trace_lines, "req->$var );\n"; |
| 256 | } |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 257 | } |
| 258 | else # must be some varargs format |
| 259 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame^] | 260 | my $func = $type; |
| 261 | push @trace_lines, " fprintf( stderr, \" $var=\" );\n"; |
| 262 | push @trace_lines, " $func;\n"; |
| 263 | push @trace_lines, " fputc( ',', stderr );\n" if ($#_ > 0); |
Alexandre Julliard | 338e757 | 1998-12-27 15:28:54 +0000 | [diff] [blame] | 264 | } |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 265 | } |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 266 | push @trace_lines, "}\n\n"; |
| 267 | } |
| 268 | |
Alexandre Julliard | 37ec927 | 2001-07-19 00:35:37 +0000 | [diff] [blame] | 269 | ### Retrieve the server protocol version from the existing server_protocol.h file |
| 270 | |
| 271 | sub GET_PROTOCOL_VERSION |
| 272 | { |
| 273 | my $protocol = 0; |
| 274 | open SERVER_PROT, "include/wine/server_protocol.h" or return 0; |
| 275 | while (<SERVER_PROT>) |
| 276 | { |
| 277 | if (/^\#define SERVER_PROTOCOL_VERSION (\d+)/) { $protocol = $1; last; } |
| 278 | } |
| 279 | close SERVER_PROT; |
| 280 | return $protocol; |
| 281 | } |
| 282 | |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 283 | ### Replace the contents of a file between ### make_requests ### marks |
| 284 | |
| 285 | sub REPLACE_IN_FILE |
| 286 | { |
| 287 | my $name = shift; |
| 288 | my @data = @_; |
| 289 | my @lines = (); |
| 290 | open(FILE,$name) or die "Can't open $name"; |
| 291 | while (<FILE>) |
| 292 | { |
| 293 | push @lines, $_; |
| 294 | last if /\#\#\# make_requests begin \#\#\#/; |
| 295 | } |
| 296 | push @lines, "\n", @data; |
| 297 | while (<FILE>) |
| 298 | { |
| 299 | if (/\#\#\# make_requests end \#\#\#/) { push @lines, "\n", $_; last; } |
| 300 | } |
| 301 | push @lines, <FILE>; |
| 302 | open(FILE,">$name") or die "Can't modify $name"; |
| 303 | print FILE @lines; |
| 304 | close(FILE); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 305 | } |