-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix all warnings, cleanup application interface code
Signed-off-by: Mahavir Jain <[email protected]>
- Loading branch information
Showing
12 changed files
with
166 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
#include <tinyos.h> | ||
|
||
int a = 0xa5a5; | ||
char buf[5000]; | ||
int main() | ||
{ | ||
if (a = 0xa5a5 && !buf[4500]) | ||
write("I am shell\n", 11); | ||
if (a == 0xa5a5) | ||
printf("I am shell\n"); | ||
else | ||
write("I lost you\n", 11); | ||
printf("I lost you\n"); | ||
for(;;); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef __TINYOS_H__ | ||
#define __TINYOS_H__ | ||
|
||
int printf(const char *fmt, ...); | ||
|
||
#endif /* __TINYOS_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ fork: | |
int 64 | ||
ret | ||
|
||
[GLOBAL exec] | ||
exec: | ||
[GLOBAL execve] | ||
execve: | ||
mov eax, 2 | ||
int 64 | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <stdarg.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
extern int hex_to_str(const int num, char buf[]); | ||
extern int dec_to_str(const int num, char buf[]); | ||
|
||
int printf(const char *fmt, ...) | ||
{ | ||
va_list ap; | ||
int d, x; | ||
char c, *s; | ||
const char *p; | ||
void *pi; | ||
char buf[96]; | ||
int index = 0; | ||
int ret; | ||
|
||
va_start(ap, fmt); | ||
for (p = fmt; *p; p++) { | ||
if (*p != '%') { | ||
buf[index++] = *p; | ||
continue; | ||
} | ||
switch (*++p) { | ||
case 's': /* string */ | ||
s = va_arg(ap, char *); | ||
strncpy(&buf[index], s, strlen(s)); | ||
index += strlen(s); | ||
break; | ||
case 'd': /* int */ | ||
d = va_arg(ap, int); | ||
ret = dec_to_str(d, &buf[index]); | ||
index += ret; | ||
break; | ||
case 'x': /* hex */ | ||
x = va_arg(ap, int); | ||
ret = hex_to_str(x, &buf[index]); | ||
index += ret; | ||
break; | ||
case 'p': /* pointer */ | ||
pi = va_arg(ap, void *); | ||
if (pi) { | ||
ret = hex_to_str((int) pi, &buf[index]); | ||
index += ret; | ||
} else { | ||
strncpy(&buf[index], "NULL", strlen("NULL")); | ||
index += strlen("NULL"); | ||
} | ||
break; | ||
case 'c': /* char */ | ||
/* need a cast here since va_arg only | ||
takes fully promoted types */ | ||
c = (char) va_arg(ap, int); | ||
buf[index++] = c; | ||
break; | ||
} | ||
} | ||
va_end(ap); | ||
return write(1, buf, index); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters