Hi all,
So yeah. Is it possible?
EDIT:Never mind. I'll just de-compile cat.
Concatinating a file in C (without stdio.h etc.)
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: Concatinating a file in C (without stdio.h etc.)
Perhaps you should elaborate more on your question. What is it exactly that you are trying to do?
Give us an example in C using stdio.h
Give us an example in C using stdio.h
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: Concatinating a file in C (without stdio.h etc.)
There're tons of ways, assuming you've implemented some form of file i/o of your own, external to stdio.h.
Or, technically, you can just "extern" all the stdio functions, still use them, but not include stdio.h
Or, if you're really just looking for a C solution (and not an OSDev solution) then just exec a shell command of "cat file1 file2 > file3" or "copy file1+file2 file3" depending on your OS.
--Jeff
Or, technically, you can just "extern" all the stdio functions, still use them, but not include stdio.h
Or, if you're really just looking for a C solution (and not an OSDev solution) then just exec a shell command of "cat file1 file2 > file3" or "copy file1+file2 file3" depending on your OS.
--Jeff
Re: Concatinating a file in C (without stdio.h etc.)
I mean by creating a function/command that would concatinate (like most people's second program next to Hello World or the UNIX command cat) a file by using ASM, and then letting me call it from my program, like this (for an OS):
Part 1
And then having this bit:
Thanks,
JaMiE P
Creator, Phelansys OS[/u]
Part 1
Code: Select all
{
blah
blah
blah
f_concat("file.txt")
}
Code: Select all
unsigned int f_concat(char *message, unsigned int line)
{
I need the code which goes here
}
JaMiE P
Creator, Phelansys OS[/u]
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: Concatinating a file in C (without stdio.h etc.)
The problem is (and what I was hinting at) is that if this is intended for a OS in development, you're going to need a basic kernel and IO driver/module before doing this, and even with both those, there is no standard way -- every OS is different.
That's the whole point of the libc and the stdio.h header file you mention. It provides a basic and portable way to do these things on all OSs. If you wish to circumvent this, then you're on your own. You'll need to look into the different devices you want to support (IDE? SCSI? ATAPI? etc) and write drivers for those, and some interface that will allow you do create such a 'cat'-like program.
Cheers,
Jeff
That's the whole point of the libc and the stdio.h header file you mention. It provides a basic and portable way to do these things on all OSs. If you wish to circumvent this, then you're on your own. You'll need to look into the different devices you want to support (IDE? SCSI? ATAPI? etc) and write drivers for those, and some interface that will allow you do create such a 'cat'-like program.
Cheers,
Jeff
Re: Concatinating a file in C (without stdio.h etc.)
again, those are OS dependant. Before implementing anything like that, you would need to design and code an IPC. doing stuff like cat bla | grep blah is done through pipes in linux I believe (correct me if i'm wrong)
Re: Concatinating a file in C (without stdio.h etc.)
if you are trying to write a concat function for your own OS, you have to write some I/O primitives first ...
assuming you have some functions that read file to a given memory addresse and write it from a given address, all you have to do is to copy both file in two memory adresses, create a new file and write the content of the two memory areas into it
but there is no "magic" methode to do it without any I/O methode
assuming you have some functions that read file to a given memory addresse and write it from a given address, all you have to do is to copy both file in two memory adresses, create a new file and write the content of the two memory areas into it
but there is no "magic" methode to do it without any I/O methode
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
There are 10 types of people in this world... those that understand binary, and those that don't.