Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/physics0/controls/pd0_receipt.c # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / physics0 / controls / pd0_receipt.c` 39 lines ยท 1923 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "pd0_receipt.h" 18 #include "pd0_codes.h" 19 #include 20 #include 21 #include 22 #include 23 #include 24 static int errno_is_exist(void) { return errno == EEXIST; } 25 int pd0_receipt_write(const char *dir, const char *kind, const uint8_t h[32], int code, const char *extra, char *path_out, size_t cap) 26 { 27 char hex[65]; for (int i = 0; i < 32; i++) snprintf(hex + 2 * i, 3, "%02x", h[i]); 28 for (unsigned n = 0; n < 100000; n++) { 29 char path[1024]; snprintf(path, sizeof path, "%s/%s-%.16s-%u.receipt", dir, kind, hex, n); 30 int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0444); 31 if (fd < 0) { if (errno_is_exist()) continue; return PD0V_RECEIPT_IO; } 32 char body[4096]; int len = snprintf(body, sizeof body, 33 "kind: %s\nverifier_commit: %s\ninput_sha256: %s\ncode: %d\nname: %s\nrecorder: STAND_IN\nrange_check: STAND_IN\n%s%s", 34 kind, PD0_VERIFIER_COMMIT, hex, code, pd0v_name(code), extra ? extra : "", extra && extra[strlen(extra) - 1] != '\n' ? "\n" : ""); 35 if (len < 0 || write(fd, body, (size_t)len) != len) { close(fd); return PD0V_RECEIPT_IO; } 36 close(fd); if (path_out) snprintf(path_out, cap, "%s", path); return 0; 37 } 38 return PD0V_RECEIPT_IO; 39 }