1*148c5f43SAlan Wright# 2*148c5f43SAlan Wright# CDDL HEADER START 3*148c5f43SAlan Wright# 4*148c5f43SAlan Wright# The contents of this file are subject to the terms of the 5*148c5f43SAlan Wright# Common Development and Distribution License (the "License"). 6*148c5f43SAlan Wright# You may not use this file except in compliance with the License. 7*148c5f43SAlan Wright# 8*148c5f43SAlan Wright# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*148c5f43SAlan Wright# or http://www.opensolaris.org/os/licensing. 10*148c5f43SAlan Wright# See the License for the specific language governing permissions 11*148c5f43SAlan Wright# and limitations under the License. 12*148c5f43SAlan Wright# 13*148c5f43SAlan Wright# When distributing Covered Code, include this CDDL HEADER in each 14*148c5f43SAlan Wright# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*148c5f43SAlan Wright# If applicable, add the following below this CDDL HEADER, with the 16*148c5f43SAlan Wright# fields enclosed by brackets "[]" replaced with your own identifying 17*148c5f43SAlan Wright# information: Portions Copyright [yyyy] [name of copyright owner] 18*148c5f43SAlan Wright# 19*148c5f43SAlan Wright# CDDL HEADER END 20*148c5f43SAlan Wright# 21*148c5f43SAlan Wright 22*148c5f43SAlan Wright# 23*148c5f43SAlan Wright# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24*148c5f43SAlan Wright# 25*148c5f43SAlan Wright 26*148c5f43SAlan Wright# 27*148c5f43SAlan Wright# Generate the table mapping NT status codes to strings. 28*148c5f43SAlan Wright# The table is sorted in numerical order by putting the 29*148c5f43SAlan Wright# numeric constants as a comment first on each line, and 30*148c5f43SAlan Wright# then running the table body through sort(1). 31*148c5f43SAlan Wright# 32*148c5f43SAlan Wright 33*148c5f43SAlan WrightBEGIN { 34*148c5f43SAlan Wright printf("/* Table generated by smb_status_gen.awk */\n"); 35*148c5f43SAlan Wright printf("#include <smb/ntstatus.h>\n\n"); 36*148c5f43SAlan Wright printf("typedef struct smb_status_table {\n"); 37*148c5f43SAlan Wright printf("\tunsigned int value;\n"); 38*148c5f43SAlan Wright printf("\tconst char *name;\n"); 39*148c5f43SAlan Wright printf("} smb_status_table_t;\n\n"); 40*148c5f43SAlan Wright printf("static const smb_status_table_t ntx_table[] = {\n"); 41*148c5f43SAlan Wright} 42*148c5f43SAlan Wright/^#define.NT_STATUS_/ { 43*148c5f43SAlan Wright # Skip the _SEVERITY defines. 44*148c5f43SAlan Wright if ( $2 ~ /^NT_STATUS_SEVERITY_/ ) 45*148c5f43SAlan Wright next 46*148c5f43SAlan Wright 47*148c5f43SAlan Wright 48*148c5f43SAlan Wright # Make sure the constant looks as expected. 49*148c5f43SAlan Wright if ( $3 !~ /^0x[0-9A-F]+$/ ) { 50*148c5f43SAlan Wright print "Warning: Unexpected format: "$0 > "/dev/stderr" 51*148c5f43SAlan Wright exit 1; 52*148c5f43SAlan Wright } 53*148c5f43SAlan Wright 54*148c5f43SAlan Wright # print: comment { macro, string }, 55*148c5f43SAlan Wright printf("\t/* %s */\t{ %s,\t\"%s\" },\n", 56*148c5f43SAlan Wright $3, $2, substr($2,11)) | "sort" ; 57*148c5f43SAlan Wright} 58*148c5f43SAlan WrightEND { 59*148c5f43SAlan Wright close("sort"); 60*148c5f43SAlan Wright printf("};\n"); 61*148c5f43SAlan Wright} 62