// 
// Decompiled by Procyon v0.6.0
// 

package org.jline.nativ;

public class CLibrary
{
    public static int TCSANOW;
    public static int TCSADRAIN;
    public static int TCSAFLUSH;
    public static long TIOCGWINSZ;
    public static long TIOCSWINSZ;
    
    private static native void init();
    
    public static native int isatty(final int p0);
    
    public static native String ttyname(final int p0);
    
    public static native int openpty(final int[] p0, final int[] p1, final byte[] p2, final Termios p3, final WinSize p4);
    
    public static native int tcgetattr(final int p0, final Termios p1);
    
    public static native int tcsetattr(final int p0, final int p1, final Termios p2);
    
    public static native int ioctl(final int p0, final long p1, final int[] p2);
    
    public static native int ioctl(final int p0, final long p1, final WinSize p2);
    
    public static short getTerminalWidth(final int fd) {
        final WinSize sz = new WinSize();
        ioctl(fd, CLibrary.TIOCGWINSZ, sz);
        return sz.ws_col;
    }
    
    static {
        if (JLineNativeLoader.initialize()) {
            init();
        }
    }
    
    public static class WinSize
    {
        public static int SIZEOF;
        public short ws_row;
        public short ws_col;
        public short ws_xpixel;
        public short ws_ypixel;
        
        private static native void init();
        
        public WinSize() {
        }
        
        public WinSize(final short ws_row, final short ws_col) {
            this.ws_row = ws_row;
            this.ws_col = ws_col;
        }
        
        static {
            if (JLineNativeLoader.initialize()) {
                init();
            }
        }
    }
    
    public static class Termios
    {
        public static int SIZEOF;
        public long c_iflag;
        public long c_oflag;
        public long c_cflag;
        public long c_lflag;
        public byte[] c_cc;
        public long c_ispeed;
        public long c_ospeed;
        
        public Termios() {
            this.c_cc = new byte[32];
        }
        
        private static native void init();
        
        static {
            if (JLineNativeLoader.initialize()) {
                init();
            }
        }
    }
}
