Newsgroups: comp.os.minix
Subject: Re: Colored Directories and Files
References: <d1b33313.0105281451.5fdbc7d4@posting.google.com> <d1b33313.0105281958.43154b59@posting.google.com> <rj0ve9.b03.ln@nnews.ath.cx>
Organization: Syracuse University, Syracuse
From: mcconnel@rodan.syr.edu (Terry R. McConnell)
NNTP-Posting-Host: rodan.syr.edu
Message-ID: <3b13e632.0@news.syr.edu>
Date: 29 May 2001 14:10:58 -0500
X-Trace: 29 May 2001 14:10:58 -0500, rodan.syr.edu
Lines: 41
Path: news.adfa.edu.au!clarion.carno.net.au!news0.optus.net.au!news1.optus.net.au!optus!news-out.cwix.com!newsfeed.cwix.com!news.maxwell.syr.edu!news.syr.edu!rodan.syr.edu!mcconnel
Xref: news.adfa.edu.au comp.os.minix:37492

In article <rj0ve9.b03.ln@nnews.ath.cx>,
Paul Weeenix <paul@mmail.ath.cx> wrote:
>Hi
>I look at the file at /usr/src/lib/stdio/printf.c, it doesn't use putc...
>However, the file /usr/src/lib/stdio/putc.c looks very interesting.... It
>looks very recursive.
>Can someone explain putc.c?
>
>If I understand things correctly, c library functions should be calling
>system functions. For example, fopen should encapsulate open, etc etc.
>printf should somehow be using /dev/console or /dev/ttyS* or appropriate
>devices. I could be totally wrong of course....
>
>/*
> * putc.c - print (or buffer) one character
> */
>/* $Header: putc.c,v 1.2 89/12/18 15:03:15 eck Exp $ */
>
>#include <stdio.h>
>
>int
>(putc)(int c, FILE *stream)
>{
> return putc(c, stream);        // <------- awfully recursive
>}


putc is a macro declared in /usr/include/stdio.h. Wrapping it in () prevents
expansion of the macro.      

Ultimately the printing is done via the write system call. Like all
system calls, it is implemented in the library using send/receive. Look in
/usr/src/lib/..../rts for the implementation of sendrec in assembler for
your platform.


-- 
************************************************************************
Terry R. McConnell   Mathematics/304B Carnegie/Syracuse, N.Y. 13244-1150
trmcconn@syr.edu     http://barnyard.syr.edu/~tmc    Question Authority?
************************************************************************
