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 * http://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 *
024 * based on code from the jRPM project (jrpm.sourceforge.net)
025 *
026 */
027public interface CpioConstants {
028    /** magic number of a cpio entry in the new format */
029    String MAGIC_NEW = "070701";
030
031    /** magic number of a cpio entry in the new format with crc */
032    String MAGIC_NEW_CRC = "070702";
033
034    /** magic number of a cpio entry in the old ascii format */
035    String MAGIC_OLD_ASCII = "070707";
036
037    /** magic number of a cpio entry in the old binary format */
038    int MAGIC_OLD_BINARY = 070707;
039
040    // These FORMAT_ constants are internal to the code
041
042    /** write/read a CpioArchiveEntry in the new format */
043    short FORMAT_NEW = 1;
044
045    /** write/read a CpioArchiveEntry in the new format with crc */
046    short FORMAT_NEW_CRC = 2;
047
048    /** write/read a CpioArchiveEntry in the old ascii format */
049    short FORMAT_OLD_ASCII = 4;
050
051    /** write/read a CpioArchiveEntry in the old binary format */
052    short FORMAT_OLD_BINARY = 8;
053
054    /** Mask for both new formats */
055    short FORMAT_NEW_MASK = 3;
056
057    /** Mask for both old formats */
058    short FORMAT_OLD_MASK = 12;
059
060    /*
061     * Constants for the MODE bits
062     */
063
064    /** Mask for all file type bits. */
065    int S_IFMT   = 0170000;
066
067 // http://www.opengroup.org/onlinepubs/9699919799/basedefs/cpio.h.html
068 // has a list of the C_xxx constatnts
069
070    /** Defines a socket */
071    int C_ISSOCK = 0140000;
072
073    /** Defines a symbolic link */
074    int C_ISLNK  = 0120000;
075
076    /** HP/UX network special (C_ISCTG) */
077    int C_ISNWK  = 0110000;
078
079    /** Defines a regular file */
080    int C_ISREG  = 0100000;
081
082    /** Defines a block device */
083    int C_ISBLK  = 0060000;
084
085    /** Defines a directory */
086    int C_ISDIR  = 0040000;
087
088    /** Defines a character device */
089    int C_ISCHR  = 0020000;
090
091    /** Defines a pipe */
092    int C_ISFIFO = 0010000;
093
094
095    /** Set user ID */
096    int C_ISUID  = 0004000;
097
098    /** Set group ID */
099    int C_ISGID  = 0002000;
100
101    /** On directories, restricted deletion flag. */
102    int C_ISVTX  = 0001000;
103
104
105    /** Permits the owner of a file to read the file */
106    int C_IRUSR  = 0000400;
107
108    /** Permits the owner of a file to write to the file */
109    int C_IWUSR  = 0000200;
110
111    /** Permits the owner of a file to execute the file or to search the directory */
112    int C_IXUSR  = 0000100;
113
114
115    /** Permits a file's group to read the file */
116    int C_IRGRP  = 0000040;
117
118    /** Permits a file's group to write to the file */
119    int C_IWGRP  = 0000020;
120
121    /** Permits a file's group to execute the file or to search the directory */
122    int C_IXGRP  = 0000010;
123
124
125    /** Permits others to read the file */
126    int C_IROTH  = 0000004;
127
128    /** Permits others to write to the file */
129    int C_IWOTH  = 0000002;
130
131    /** Permits others to execute the file or to search the directory */
132    int C_IXOTH  = 0000001;
133
134    /** The special trailer marker */
135    String CPIO_TRAILER = "TRAILER!!!";
136
137    /**
138     * The default block size.
139     *
140     * @since 1.1
141     */
142    int BLOCK_SIZE = 512;
143}