LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-02-2009, 05:23 PM   #1
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,234

Rep: Reputation: 189Reputation: 189
ironing out the bugs in my kernel--need make few functions-dont know how they work


ok i have my kernel booting loading and printing on screen
now i need to make fscanf, sscanf and sprintf
does anybody know how they work
 
Old 10-02-2009, 07:43 PM   #2
orgcandman
Member
 
Registered: May 2002
Location: dracut MA
Distribution: Ubuntu; PNE-LE; LFS (no book)
Posts: 594

Rep: Reputation: 102Reputation: 102
They use varargs.

There's a pretty famous example. In fact, you might even be able to google the following phrase

Quote:
Wirzenius wrote this portably, Torvalds XXXXed it up
Note: XXXX is substituted for an expletive beginning with the letter f.
 
Old 10-02-2009, 07:48 PM   #3
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,234

Original Poster
Rep: Reputation: 189Reputation: 189
Quote:
Wirzenius wrote this portably, Torvalds XXXXed it up
Note: XXXX is substituted for an expletive beginning with the letter f.
is that a joke!?
 
Old 10-02-2009, 07:49 PM   #4
orgcandman
Member
 
Registered: May 2002
Location: dracut MA
Distribution: Ubuntu; PNE-LE; LFS (no book)
Posts: 594

Rep: Reputation: 102Reputation: 102
http://www.google.com/#hl=en&q=Wirze...15299a959dbb33

2nd link in google goes to vsprintf.c
 
Old 10-02-2009, 08:14 PM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,234

Original Poster
Rep: Reputation: 189Reputation: 189
LHOL
now i have another problem with the code
vsprintf.c needs strnlen but i dont even know what it does much less have it in the kernel
 
Old 10-02-2009, 09:04 PM   #6
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by smeezekitty View Post
LHOL
now i have another problem with the code
vsprintf.c needs strnlen but i dont even know what it does much less have it in the kernel
More programming by newsgroup?

Code:
$ man strnlen
 
Old 10-02-2009, 09:41 PM   #7
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,234

Original Poster
Rep: Reputation: 189Reputation: 189
it doesnt work
i worked it into the kernel and it just freezes at the sprintf call
then i tried it out of the kernel still didnt work quite right
 
Old 10-02-2009, 11:07 PM   #8
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,234

Original Poster
Rep: Reputation: 189Reputation: 189
here i will post my code:
Code:
#include <string.h>
#include <vsprintf.c>
extern void printf(char *, ...);
int main(){
char buffer[665];
sprintf(buffer, "hello world %d\n", 123);
printf("\n%s\n", buffer);
}
 
Old 10-03-2009, 07:58 AM   #9
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,142

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
printf and all the things it calls directly or indirectly adds up to a lot of library routines.

From your other threads, I got the idea you were linking without standard libraries. Where are all those library functions coming from? If you let the (Turbo C) library functions into your link, it will be quite a bit of effort to catch and correct all the things that depend on DOS. If you don't, then the likely bugs are in the replacements you've coded for those library routines. Either way, posting your top level code is nearly useless.

Also, where did you get vsprintf.c? Is it a copy compatible with your 16 bit environment? Including a .c file in another .c file sometimes causes problems. I think you said you were using .cpp. Including a .c file in a .cpp is even more likely to cause problems.
 
Old 10-03-2009, 12:42 PM   #10
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,234

Original Poster
Rep: Reputation: 189Reputation: 189
i ended up writing my own
still need to figure out the *scanf() functions
 
  


Reply

Tags
kernel, printf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
php image functions dont work ihopeto Linux - Server 4 11-14-2006 03:51 AM
'make' and 'make install' commands dont work on my system? ginda Linux - Newbie 9 04-18-2004 12:17 PM
ifconfig dont work with new kernel neozero62 Linux - Networking 4 11-05-2003 09:47 AM
new kernel modem dont work demmylls Linux - General 4 10-08-2003 06:22 AM
After kernel update some things dont work Vencalator Linux - Newbie 9 09-18-2003 05:10 AM


All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration