forked from jbarbier/printf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrot13.c
More file actions
64 lines (56 loc) · 1010 Bytes
/
rot13.c
File metadata and controls
64 lines (56 loc) · 1010 Bytes
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
62
63
64
#include "holberton.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
/**
* conversion_R - conversion check for rot13
* @s: formatter
* Return: 1 if true, 0 otherwise
*/
int conversion_R(char *s)
{
(void) s;
return (1);
}
/**
* make_rot13 - makes the rot13 string
* @s: formatter
* @vl: arguement/string to encode
* @buf: to fill
* Return: none
*/
void make_rot13(char *s, va_list vl, buf_type *buf)
{
char *result;
(void) s;
result = _strdup(va_arg(vl, char *));
if (result == NULL)
result = "(null)";
result = rot13(result);
fill_buffer(buf, result, _strlen(result));
}
/**
* rot13 - conver string o rot13
* @s: string
* Return: string
*/
char *rot13(char *s)
{
int i;
i = 0;
while (s[i] != '\0')
{
if ((s[i] >= 'a' && s[i] <= 'm') || (s[i] >= 'A' && s[i] <= 'M'))
{
s[i] = (s[i] + 13);
}
else
while ((s[i] >= 'n' && s[i] <= 'z') ||
(s[i] >= 'N' && s[i] <= 'Z'))
{
s[i] = (s[i] - 13);
}
i++;
}
return (s);
}