162306a36Sopenharmony_ci#!/bin/sh 262306a36Sopenharmony_ci# SPDX-License-Identifier: LGPL-2.1 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci# also as: 762306a36Sopenharmony_ci# #define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len) 862306a36Sopenharmony_ci 962306a36Sopenharmony_ciprintf "static const char *usbdevfs_ioctl_cmds[] = {\n" 1062306a36Sopenharmony_ciregex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)(\(\w+\))?[[:space:]]+_IO[CWR]{0,2}\([[:space:]]*(_IOC_\w+,[[:space:]]*)?'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*" 1162306a36Sopenharmony_cigrep -E "$regex" ${header_dir}/usbdevice_fs.h | grep -E -v 'USBDEVFS_\w+32[[:space:]]' | \ 1262306a36Sopenharmony_ci sed -r "s/$regex/\4 \1/g" | \ 1362306a36Sopenharmony_ci sort | xargs printf "\t[%s] = \"%s\",\n" 1462306a36Sopenharmony_ciprintf "};\n\n" 1562306a36Sopenharmony_ciprintf "#if 0\n" 1662306a36Sopenharmony_ciprintf "static const char *usbdevfs_ioctl_32_cmds[] = {\n" 1762306a36Sopenharmony_ciregex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)[[:space:]]+_IO[WR]{0,2}\([[:space:]]*'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*" 1862306a36Sopenharmony_cigrep -E $regex ${header_dir}/usbdevice_fs.h | grep -E 'USBDEVFS_\w+32[[:space:]]' | \ 1962306a36Sopenharmony_ci sed -r "s/$regex/\2 \1/g" | \ 2062306a36Sopenharmony_ci sort | xargs printf "\t[%s] = \"%s\",\n" 2162306a36Sopenharmony_ciprintf "};\n" 2262306a36Sopenharmony_ciprintf "#endif\n" 23