    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one
    003 * or more contributor license agreements.  See the NOTICE file
    004 * distributed with this work for additional information
    005 * regarding copyright ownership.  The ASF licenses this file
    006 * to you under the Apache License, Version 2.0 (the
    007 * "License"); you may not use this file except in compliance
    008 * with the License.  You may obtain a copy of the License at
    009 *
    010 *   https://www.apache.org/licenses/LICENSE-2.0
    011 *
    012 * Unless required by applicable law or agreed to in writing,
    013 * software distributed under the License is distributed on an
    014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    015 * KIND, either express or implied.  See the License for the
    016 * specific language governing permissions and limitations
    017 * under the License.
    018 */
    019package org.apache.commons.compress.archivers.cpio;
    020
    021/**
    022 * All constants needed by CPIO.
    023 * <p>
    024 * Based on code from the <a href="jrpm.sourceforge.net">jRPM project</a>.
    025 * </p>
    026 * <p>
    027 * A list of the {@code C_xxx} constants is <a href="http://www.opengroup.org/onlinepubs/9699919799/basedefs/cpio.h.html">here</a>.
    028 * </p>
    029 * <p>
    030 * TODO Next major version: Update to a class.
    031 * </p>
    032 */
    033public interface CpioConstants {
    034    /** Magic number of a cpio entry in the new format */
    035    String MAGIC_NEW = "070701";
    036
    037    /** Magic number of a cpio entry in the new format with CRC */
    038    String MAGIC_NEW_CRC = "070702";
    039
    040    /** Magic number of a cpio entry in the old ASCII format */
    041    String MAGIC_OLD_ASCII = "070707";
    042
    043    /** Magic number of a cpio entry in the old binary format */
    044    int MAGIC_OLD_BINARY = 070707;
    045
    046    /** Write/read a CpioArchiveEntry in the new format. FORMAT_ constants are internal. */
    047    short FORMAT_NEW = 1;
    048
    049    /** Write/read a CpioArchiveEntry in the new format with CRC. FORMAT_ constants are internal. */
    050    short FORMAT_NEW_CRC = 2;
    051
    052    /** Write/read a CpioArchiveEntry in the old ASCII format. FORMAT_ constants are internal. */
    053    short FORMAT_OLD_ASCII = 4;
    054
    055    /** Write/read a CpioArchiveEntry in the old binary format. FORMAT_ constants are internal. */
    056    short FORMAT_OLD_BINARY = 8;
    057
    058    /** Mask for both new formats. FORMAT_ constants are internal. */
    059    short FORMAT_NEW_MASK = 3;
    060
    061    /** Mask for both old formats. FORMAT_ constants are internal. */
    062    short FORMAT_OLD_MASK = 12;
    063
    064    /*
    065     * Constants for the MODE bits
    066     */
    067
    068    /** Mask for all file type bits. */
    069    int S_IFMT = 0170000;
    070
    071    /** Defines a socket */
    072    int C_ISSOCK = 0140000;
    073
    074    /** Defines a symbolic link */
    075    int C_ISLNK = 0120000;
    076
    077    /** HP/UX network special (C_ISCTG) */
    078    int C_ISNWK = 0110000;
    079
    080    /** Defines a regular file */
    081    int C_ISREG = 0100000;
    082
    083    /** Defines a block device */
    084    int C_ISBLK = 0060000;
    085
    086    /** Defines a directory */
    087    int C_ISDIR = 0040000;
    088
    089    /** Defines a character device */
    090    int C_ISCHR = 0020000;
    091
    092    /** Defines a pipe */
    093    int C_ISFIFO = 0010000;
    094
    095    /** Sets user ID */
    096    int C_ISUID = 0004000;
    097
    098    /** Sets group ID */
    099    int C_ISGID = 0002000;
    100
    101    /** On directories, restricted deletion flag. */
    102    int C_ISVTX = 0001000;
    103
    104    /** Permits the owner of a file to read the file */
    105    int C_IRUSR = 0000400;
    106
    107    /** Permits the owner of a file to write to the file */
    108    int C_IWUSR = 0000200;
    109
    110    /** Permits the owner of a file to execute the file or to search the directory */
    111    int C_IXUSR = 0000100;
    112
    113    /** Permits a file's group to read the file */
    114    int C_IRGRP = 0000040;
    115
    116    /** Permits a file's group to write to the file */
    117    int C_IWGRP = 0000020;
    118
    119    /** Permits a file's group to execute the file or to search the directory */
    120    int C_IXGRP = 0000010;
    121
    122    /** Permits others to read the file */
    123    int C_IROTH = 0000004;
    124
    125    /** Permits others to write to the file */
    126    int C_IWOTH = 0000002;
    127
    128    /** Permits others to execute the file or to search the directory */
    129    int C_IXOTH = 0000001;
    130
    131    /** The special trailer marker */
    132    String CPIO_TRAILER = "TRAILER!!!";
    133
    134    /**
    135     * The default block size.
    136     *
    137     * @since 1.1
    138     */
    139    int BLOCK_SIZE = 512;
    140}