-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_p_P.c
More file actions
61 lines (54 loc) · 1.08 KB
/
Copy pathmy_p_P.c
File metadata and controls
61 lines (54 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
** my_put_ptr.c for in /u/epitech_2012/brenne_t/cu/rendu/c/my_printf
**
** Made by thomas brennetot
** Login <brenne_t@epitech.net>
**
** Started on Sun Dec 23 17:53:32 2007 thomas brennetot
** Last update Fri Dec 28 16:40:29 2007 thomas brennetot
*/
#include <stdarg.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include "my_printf.h"
void my_put_ptr_adr(unsigned int adr, int flag)
{
char *base;
char res[9];
int i;
if (flag == 1)
base = "0123456789abcdef";
else
base = "0123456789ABCDEF";
i = 8;
while ((adr / 16) > 0 || i >= 8)
{
res[i] = base[(adr % 16)];
adr /= 16;
i--;
}
res[i] = base[(adr % 16)];
#if !(solaris)
write(1, "0x", 2);
#endif
while (i < 9)
write(1, &res[i++], 1);
return ;
}
void my_printf_p(char *str, va_list *args)
{
unsigned int adr;
adr = va_arg(*args, unsigned int);
my_put_ptr_adr(adr, 1);
str++;
return;
}
void my_printf_P(char *str, va_list *args)
{
unsigned int adr;
adr = va_arg(*args, unsigned int);
my_put_ptr_adr(adr, 2);
str++;
return;
}