tgrekov-pipex
HIVE pipex May 2024
Loading...
Searching...
No Matches
unsigned_arg.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* unsigned_arg.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/01/31 07:31:57 by tgrekov #+# #+# */
9/* Updated: 2024/02/13 08:36:45 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
20#include <stdarg.h>
21#include <stdlib.h>
22#include "../../subspec.h"
23#include "../../../utils/internal_types.h"
24
35t_ubiggest unsigned_arg(va_list args, t_lenmod lenmod)
36{
37 if (lenmod == hh)
38 return ((unsigned char) va_arg(args, unsigned int));
39 if (lenmod == h)
40 return ((unsigned short) va_arg(args, unsigned int));
41 if (lenmod == l)
42 return (va_arg(args, unsigned long));
43 if (lenmod == ll)
44 return (va_arg(args, unsigned long long));
45 if (lenmod == j)
46 return (va_arg(args, uintmax_t));
47 if (lenmod == z)
48 return (va_arg(args, size_t));
49 if (lenmod == t)
50 return (va_arg(args, t_ptrdiff_t));
51 return (va_arg(args, unsigned int));
52}
unsigned long long t_ubiggest
Convenience typedef for largest unsigned type I need to handle.
long t_ptrdiff_t
If _PTRDIFF_T is defined, set to ptrdiff_t. Set to long otherwise.
enum e_lenmod t_lenmod
Represents the length modifiers for a format specifier's variable argument.
t_ubiggest unsigned_arg(va_list args, t_lenmod lenmod)
Retrieves the next unsigned variable argument in the appropriate size dependent on the length modifie...