Download userspace/examples/write_worm.c from Snapkitty/asos-syscall-os: direct link, hf CLI and curl.
- Browser
- Download file 4.46 kB
-
https://huggingface.co/Snapkitty/asos-syscall-os/resolve/main/userspace/examples/write_worm.c
- Command line
-
hf download hf://Snapkitty/asos-syscall-os/userspace/examples/write_worm.c
-
curl -L -o write_worm.c https://huggingface.co/Snapkitty/asos-syscall-os/resolve/main/userspace/examples/write_worm.c
4.46 kB
| /** | |
| * write_worm.c | |
| * ู ุซุงู ูุชุงุจุฉ WORM - ุงููุชุงุจุฉ ุบูุฑ ุงููุงุจูุฉ ููุชุบููุฑ | |
| * WORM Write Example - Immutable Write Intent | |
| * | |
| * Demonstrates WORM-sealed durable write with ASOS. | |
| * | |
| * Author: Ahmad Ali Parr | |
| * License: Sovereign Source | |
| */ | |
| int main(void) | |
| { | |
| printf("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n"); | |
| printf(" ASOS WORM Write Example\n"); | |
| printf(" ู ุซุงู ุงููุชุงุจุฉ ุบูุฑ ุงููุงุจูุฉ ููุชุบููุฑ\n"); | |
| printf("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n\n"); | |
| /* Initialize */ | |
| if (asos_init() < 0) { | |
| fprintf(stderr, "Failed to initialize ASOS\n"); | |
| return 1; | |
| } | |
| /* Create write intent */ | |
| asos_intent_t *intent = asos_intent_new(ASOS_INTENT_IO_WRITE, | |
| ASOS_PRIORITY_HIGH); | |
| if (!intent) { | |
| fprintf(stderr, "Failed to create intent\n"); | |
| asos_cleanup(); | |
| return 1; | |
| } | |
| /* Set goal: durable write with WORM seal and replication */ | |
| if (asos_intent_set_goal(intent, | |
| "persist:durability=WORM,replication=3,fsync=true") < 0) { | |
| fprintf(stderr, "Failed to set goal\n"); | |
| asos_intent_free(intent); | |
| asos_cleanup(); | |
| return 1; | |
| } | |
| /* Set payload: sovereign financial data */ | |
| const char *data = | |
| "TRANSACTION_ID=TX_2026_08_08_001\n" | |
| "AMOUNT=125000.00\n" | |
| "CURRENCY=USD\n" | |
| "FROM=ACCOUNT_A\n" | |
| "TO=ACCOUNT_B\n" | |
| "TIMESTAMP=1723142400\n" | |
| "SOVEREIGN_SEAL=WORM\n"; | |
| if (asos_intent_set_payload(intent, data, strlen(data)) < 0) { | |
| fprintf(stderr, "Failed to set payload\n"); | |
| asos_intent_free(intent); | |
| asos_cleanup(); | |
| return 1; | |
| } | |
| printf("Intent Details:\n"); | |
| printf(" Type: IO_WRITE\n"); | |
| printf(" Priority: HIGH\n"); | |
| printf(" Goal: persist:durability=WORM,replication=3,fsync=true\n"); | |
| printf(" Payload size: %zu bytes\n", strlen(data)); | |
| printf("\n"); | |
| printf("Payload:\n"); | |
| printf("%s\n", data); | |
| printf("Submitting to KAR for WORM sealing...\n\n"); | |
| /* Submit */ | |
| asos_result_t *result = asos_submit_intent(intent); | |
| if (!result) { | |
| fprintf(stderr, "Failed to submit intent\n"); | |
| asos_intent_free(intent); | |
| asos_cleanup(); | |
| return 1; | |
| } | |
| /* Check result */ | |
| int status = asos_result_status(result); | |
| size_t bytes = asos_result_bytes_transferred(result); | |
| uint64_t exec_time = asos_result_execution_time_ns(result); | |
| printf("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n"); | |
| printf(" Write Result\n"); | |
| printf("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n"); | |
| printf(" Status: %d (%s)\n", status, | |
| status == 0 ? "SUCCESS" : asos_strerror(status)); | |
| printf(" Bytes written: %zu\n", bytes); | |
| printf(" Execution time: %.3f ms\n", exec_time / 1000000.0); | |
| /* Get WORM seal (immutable proof) */ | |
| uint8_t seal[32]; | |
| if (asos_result_worm_seal(result, seal) == 0) { | |
| printf(" WORM Seal (Blake3): "); | |
| for (int i = 0; i < 32; i++) | |
| printf("%02x", seal[i]); | |
| printf("\n"); | |
| } | |
| printf("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n"); | |
| printf(" Data sealed to immutable chain.\n"); | |
| printf(" ุงูุจูุงูุงุช ู ุฎุชูู ุฉ ูู ุณูุณูุฉ ุบูุฑ ูุงุจูุฉ ููุชุบููุฑ.\n"); | |
| printf("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n"); | |
| /* Cleanup */ | |
| asos_result_free(result); | |
| asos_intent_free(intent); | |
| asos_cleanup(); | |
| return 0; | |
| } | |