# zelhajou/ft_core_printf architecture

> Architecture diagram of the GitHub repository zelhajou/ft_core_printf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zelhajou/ft_core_printf
- Repository: https://github.com/zelhajou/ft_core_printf

## Overview

##### Project Type Analysis
This is a specialized C library project that implements a core functionality (printf) with variadic arguments handling. The project is focused on system-level programming and requires careful handling of memory and register operations.

##### Main Components

A. Input Processing Layer:
- Format String Parser
- Variadic Arguments Handler (va_list management)

B. Format Specifier Handlers:
- Character Handler (ft_putchar.c)
- String Handler (ft_putstr.c)
- Number Handler (ft_putnbr.c)
- Unsigned Number Handler (ft_putunbr.c)
- Hexadecimal Handler (ft_puthex.c)
- Address Handler (ft_putaddr.c)

C. Memory Management:
- Register Save Area
- Overflow Argument Area

**[Input] → [ft_printf Core] → [Output]**

- ┌─── Character Output

**[Format String] →[Parser]──────────┼─── String Output**
- ↕             │
**[Variadic Args]→[VA Handler]───────┼─── Number Output**

- Address Output

##### Specific Implementation Details to Highlight

a. VA_LIST Management Flow:
**[va_start] → [va_arg] → [va_end]**

b. Register Management:
**[Register Save Area] ← [GP Offset]**
- ← [FP Offset]

##### Implementation Notes

- Format string parsing logic
- Argument handling mechanism
- Memory management strategy
- Individual format specifier handlers

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Process]
        L2[(Memory)]
        L3([Input/Output])
        L4{{Handler}}
        style L1 fill:#90EE90
        style L2 fill:#FFA500
        style L3 fill:#87CEEB
        style L4 fill:#FFB6C1
    end

    %% Input Layer
    Input([Input String & Arguments]):::io

    %% Core Layer
    CorePrintf[ft_printf Core]:::core
    click CorePrintf "https://github.com/zelhajou/ft_core_printf/blob/main/ft_printf.c"
    
    HeaderDef[Header Definitions]:::core
    click HeaderDef "https://github.com/zelhajou/ft_core_printf/blob/main/ft_printf.h"

    %% Memory Management
    RegSave[(Register Save Area)]:::memory
    VarArgs[(Variadic Arguments)]:::memory

    %% Parser Layer
    Parser[Format String Parser]:::process
    VAHandler[VA List Handler]:::process

    %% Handlers Layer
    CharHandler{{Character Handler}}:::handler
    click CharHandler "https://github.com/zelhajou/ft_core_printf/blob/main/ft_putchar.c"
    
    StrHandler{{String Handler}}:::handler
    click StrHandler "https://github.com/zelhajou/ft_core_printf/blob/main/ft_putstr.c"
    
    NumHandler{{Number Handler}}:::handler
    click NumHandler "https://github.com/zelhajou/ft_core_printf/blob/main/ft_putnbr.c"
    
    UNumHandler{{Unsigned Number Handler}}:::handler
    click UNumHandler "https://github.com/zelhajou/ft_core_printf/blob/main/ft_putunbr.c"
    
    HexHandler{{Hexadecimal Handler}}:::handler
    click HexHandler "https://github.com/zelhajou/ft_core_printf/blob/main/ft_puthex.c"
    
    AddrHandler{{Address Handler}}:::handler
    click AddrHandler "https://github.com/zelhajou/ft_core_printf/blob/main/ft_putaddr.c"

    %% Output Layer
    Output([Formatted Output]):::io

    %% Connections
    Input --> CorePrintf
    CorePrintf --> Parser
    CorePrintf --> VAHandler
    
    HeaderDef -.-> CorePrintf
    
    Parser --> CharHandler
    Parser --> StrHandler
    Parser --> NumHandler
    Parser --> UNumHandler
    Parser --> HexHandler
    Parser --> AddrHandler
    
    VAHandler --> RegSave
    VAHandler --> VarArgs
    
    CharHandler --> Output
    StrHandler --> Output
    NumHandler --> Output
    UNumHandler --> Output
    HexHandler --> Output
    AddrHandler --> Output

    %% Styles
    classDef core fill:#90EE90
    classDef memory fill:#FFA500
    classDef process fill:#90EE90
    classDef handler fill:#FFB6C1
    classDef io fill:#87CEEB
```
