Skip to content

Commit

Permalink
libdynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoudkhalef committed Dec 29, 2023
1 parent 8120862 commit 489e445
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 0 deletions.
Binary file added 0x18-dynamic_libraries/.100-operations.so.swp
Binary file not shown.
4 changes: 4 additions & 0 deletions 0x18-dynamic_libraries/1-create_dynamic_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
gcc -fPIC -c *.c
gcc -shared *.o -o liball.so

30 changes: 30 additions & 0 deletions 0x18-dynamic_libraries/100-operations.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>

int add(int a, int b) {
return a + b;
}

int sub(int a, int b) {
return a - b;
}

int mul(int a, int b) {
return a * b;
}

int div(int a, int b) {
if (b == 0) {
printf("Error: Division by zero\n");
return 0;
}
return a / b;
}

int mod(int a, int b) {
if (b == 0) {
printf("Error: Division by zero\n");
return 0;
}
return a % b;
}

Binary file added 0x18-dynamic_libraries/100-operations.o
Binary file not shown.
Binary file added 0x18-dynamic_libraries/100-operations.so
Binary file not shown.
4 changes: 4 additions & 0 deletions 0x18-dynamic_libraries/101-make_me_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
wget -P /tmp https://github.com/mahmoudkhalef/alx-low_level_programming/raw/master/0x18-dynamic_libraries/libgiga.so
export LD_PRELOAD=/tmp/libgiga.so

1 change: 1 addition & 0 deletions 0x18-dynamic_libraries/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dynamiclib
Binary file added 0x18-dynamic_libraries/libdynamic.so
Binary file not shown.
Binary file added 0x18-dynamic_libraries/libgiga.so
Binary file not shown.
29 changes: 29 additions & 0 deletions 0x18-dynamic_libraries/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef MAIN_H
#define MAIN_H

#include <stdio.h>
#include <stdlib.h>

int _putchar(char c);
int _islower(int c);
int _isalpha(int c);
int _abs(int n);
int _isupper(int c);
int _isdigit(int c);
int _strlen(char *s);
void _puts(char *s);
char *_strcpy(char *dest, char *src);
int _atoi(char *s);
char *_strcat(char *dest, char *src);
char *_strncat(char *dest, char *src, int n);
char *_strncpy(char *dest, char *src, int n);
int _strcmp(char *s1, char *s2);
char *_memset(char *s, char b, unsigned int n);
char *_memcpy(char *dest, char *src, unsigned int n);
char *_strchr(char *s, char c);
unsigned int _strspn(char *s, char *accept);
char *_strpbrk(char *s, char *accept);
char *_strstr(char *haystack, char *needle);

#endif /* MAIN_H */

0 comments on commit 489e445

Please sign in to comment.