You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/10/09 18:32:25 UTC
(nuttx) 01/06: include/ar.h: Add the archive file header.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 73760338dc604d1678f11bc9c04352e651dd5c11
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Thu Oct 8 21:58:51 2026 +0200
include/ar.h: Add the archive file header.
Programs that read the members of archive (.a) files include <ar.h>
for struct ar_hdr and the ARMAG, SARMAG and ARFMAG constants, and
NuttX did not have it. The header describes the common ar file
format: the magic string, then a 60-byte ASCII header per member.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
include/ar.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/include/ar.h b/include/ar.h
new file mode 100644
index 00000000000..5434ac5ec95
--- /dev/null
+++ b/include/ar.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * include/ar.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_AR_H
+#define __INCLUDE_AR_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* The layout of an archive (.a) file, as written by ar(1): the magic string
+ * ARMAG, then one struct ar_hdr per member, each followed by the member
+ * data padded to an even size. All header fields are ASCII, padded with
+ * spaces.
+ */
+
+#define ARMAG "!<arch>\n" /* Magic string at the start of the file */
+#define SARMAG 8 /* Length of ARMAG */
+#define ARFMAG "`\n" /* Value of ar_fmag in every header */
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+struct ar_hdr
+{
+ char ar_name[16]; /* Member name, terminated by '/' (GNU) or a space */
+ char ar_date[12]; /* Modification time, decimal seconds since the epoch */
+ char ar_uid[6]; /* Owner user ID, decimal */
+ char ar_gid[6]; /* Owner group ID, decimal */
+ char ar_mode[8]; /* File mode, octal */
+ char ar_size[10]; /* Size of the member data in bytes, decimal */
+ char ar_fmag[2]; /* Always ARFMAG */
+};
+
+#endif /* __INCLUDE_AR_H */