`
yuanyao
  • 浏览: 148226 次
  • 性别: Icon_minigender_1
  • 来自: 就那小山沟
社区版块
存档分类
最新评论

stdio.c and ctype.c source

阅读更多
<stdio.h>
00001 /*
00002  * Copyright (c) 1990 The Regents of the University of California.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms are permitted
00006  * provided that the above copyright notice and this paragraph are
00007  * duplicated in all such forms and that any documentation,
00008  * advertising materials, and other materials related to such
00009  * distribution and use acknowledge that the software was developed
00010  * by the University of California, Berkeley.  The name of the
00011  * University may not be used to endorse or promote products derived
00012  * from this software without specific prior written permission.
00013  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
00014  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
00015  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00016  *
00017  *      @(#)stdio.h     5.3 (Berkeley) 3/15/86
00018  */
00019 
00020 /*
00021  * NB: to fit things in six character monocase externals, the
00022  * stdio code uses the prefix `__s' for stdio objects, typically
00023  * followed by a three-character attempt at a mnemonic.
00024  */
00025 
00026 #ifndef _STDIO_H_
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 #define _STDIO_H_
00031 
00032 #define _FSTDIO                 /* ``function stdio'' */
00033 
00034 #define __need_size_t
00035 #include <stddef.h>
00036 
00037 #define __need___va_list
00038 #include <stdarg.h>
00039 
00040 /*
00041  * <sys/reent.h> defines __sFILE, _fpos_t.
00042  * They must be defined there because struct _reent needs them (and we don't
00043  * want reent.h to include this file.
00044  */
00045 
00046 struct __sFile 
00047 {
00048   int unused;
00049 };
00050   
00051 typedef struct __sFILE FILE;
00052 
00053 #define __SLBF  0x0001          /* line buffered */
00054 #define __SNBF  0x0002          /* unbuffered */
00055 #define __SRD   0x0004          /* OK to read */
00056 #define __SWR   0x0008          /* OK to write */
00057         /* RD and WR are never simultaneously asserted */
00058 #define __SRW   0x0010          /* open for reading & writing */
00059 #define __SEOF  0x0020          /* found EOF */
00060 #define __SERR  0x0040          /* found error */
00061 #define __SMBF  0x0080          /* _buf is from malloc */
00062 #define __SAPP  0x0100          /* fdopen()ed in append mode - so must  write to end */
00063 #define __SSTR  0x0200          /* this is an sprintf/snprintf string */
00064 #define __SOPT  0x0400          /* do fseek() optimisation */
00065 #define __SNPT  0x0800          /* do not do fseek() optimisation */
00066 #define __SOFF  0x1000          /* set iff _offset is in fact correct */
00067 #define __SMOD  0x2000          /* true => fgetline modified _p text */
00068 #if defined(__CYGWIN__) || defined(__CYGWIN__)
00069 #define __SCLE        0x4000          /* convert line endings CR/LF <-> NL */
00070 #endif
00071 
00072 /*
00073  * The following three definitions are for ANSI C, which took them
00074  * from System V, which stupidly took internal interface macros and
00075  * made them official arguments to setvbuf(), without renaming them.
00076  * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
00077  *
00078  * Although these happen to match their counterparts above, the
00079  * implementation does not rely on that (so these could be renumbered).
00080  */
00081 #define _IOFBF  0               /* setvbuf should set fully buffered */
00082 #define _IOLBF  1               /* setvbuf should set line buffered */
00083 #define _IONBF  2               /* setvbuf should set unbuffered */
00084 
00085 #ifndef NULL
00086 #define NULL    0
00087 #endif
00088 
00089 #define BUFSIZ  1024
00090 #define EOF     (-1)
00091 
00092 #define FOPEN_MAX       20      /* must be <= OPEN_MAX <sys/syslimits.h> */
00093 #define FILENAME_MAX    1024    /* must be <= PATH_MAX <sys/syslimits.h> */
00094 #define L_tmpnam        1024    /* XXX must be == PATH_MAX */
00095 #ifndef __STRICT_ANSI__
00096 #define P_tmpdir        "/tmp"
00097 #endif
00098 
00099 #ifndef SEEK_SET
00100 #define SEEK_SET        0       /* set file offset to offset */
00101 #endif
00102 #ifndef SEEK_CUR
00103 #define SEEK_CUR        1       /* set file offset to current plus offset */
00104 #endif
00105 #ifndef SEEK_END
00106 #define SEEK_END        2       /* set file offset to EOF plus offset */
00107 #endif
00108 
00109 #define TMP_MAX         26
00110 
00111 #define stdin   (_impure_ptr->_stdin)
00112 #define stdout  (_impure_ptr->_stdout)
00113 #define stderr  (_impure_ptr->_stderr)
00114 
00115 #define _stdin_r(x)     ((x)->_stdin)
00116 #define _stdout_r(x)    ((x)->_stdout)
00117 #define _stderr_r(x)    ((x)->_stderr)
00118 
00119 /*
00120  * Functions defined in ANSI C standard.
00121  */
00122 
00123 #ifdef __GNUC__
00124 #define __VALIST __gnuc_va_list
00125 #else
00126 #define __VALIST char*
00127 #endif
00128 
00129 #ifndef _EXFUN
00130 # define _EXFUN(N,P) N P
00131 #endif
00132 
00133 int     _EXFUN(printf, (const char *, ...));
00134 int     _EXFUN(scanf, (const char *, ...));
00135 int     _EXFUN(sscanf, (const char *, const char *, ...));
00136 int     _EXFUN(vfprintf, (FILE *, const char *, __VALIST));
00137 int     _EXFUN(vprintf, (const char *, __VALIST));
00138 int     _EXFUN(vsprintf, (char *, const char *, __VALIST));
00139 int     _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST));
00140 int     _EXFUN(fgetc, (FILE *));
00141 char *  _EXFUN(fgets, (char *, int, FILE *));
00142 int     _EXFUN(fputc, (int, FILE *));
00143 int     _EXFUN(fputs, (const char *, FILE *));
00144 int     _EXFUN(getc, (FILE *));
00145 int     _EXFUN(getchar, (void));
00146 char *  _EXFUN(gets, (char *));
00147 int     _EXFUN(putc, (int, FILE *));
00148 int     _EXFUN(putchar, (int));
00149 int     _EXFUN(puts, (const char *));
00150 int     _EXFUN(ungetc, (int, FILE *));
00151 size_t  _EXFUN(fread, (void *, size_t _size, size_t _n, FILE *));
00152 size_t  _EXFUN(fwrite, (const void *, size_t _size, size_t _n, FILE *));
00153 
00154 int     _EXFUN(sprintf, (char *, const char *, ...));
00155 int     _EXFUN(snprintf, (char *, size_t, const char *, ...));
00156 
00157 #ifdef __cplusplus
00158 }
00159 #endif
00160 #endif /* _STDIO_H_ */



<ctype.h>
00001 
00024 #ifndef _CTYPE_H
00025 #define _CTYPE_H
00026 
00027 #include <nlibc.h>
00028 
00029 //------------------------------------------------------------------------------------------------
00059 #define isupper(c)  ((c) >= 'A' && (c) <= 'Z')                                                
00060 
00061 //------------------------------------------------------------------------------------------------
00096 #define islower(c) ((c)>=97 && (c)<=122)
00097 
00098 //------------------------------------------------------------------------------------------------
00135 #define isalpha(c) (isupper((c)) || islower((c)))                                            
00136 
00137 //--------------------------------------------------------------------------------------------
00170 #define isdigit(c) ((c)>='0' && (c)<='9')
00171 
00204 #define isalnum(c) ( (isalpha((c)) || isdigit((c)) )
00205 
00206 //-------------------------------------------------------------------------------------------------
00239 #define isblank(c) ((c)==' ' || (c)=='\t')
00240 
00241 //-------------------------------------------------------------------------------------------------
00274 #define isprint(c) (((c)>=32 && (c)<=126) || ((c)>=161 && (c)<=254))
00275 
00276 //-------------------------------------------------------------------------------------------------
00309 #define iscntrl(c) (!isprint(c))                                                              
00310 
00311 //-------------------------------------------------------------------------------------------------
00345 #define isgraph(c) (isprint(c) && (c)==' ')
00346 
00347 //-------------------------------------------------------------------------------------------------
00377 #define isspace(c) ((c)==' ' || (c)=='\f' || (c)=='\n' || (c)=='\r' || (c)=='\t' || (c)=='\v')
00378 
00379 //-------------------------------------------------------------------------------------------------
00411 #define ispunct(c) (isprint((c)) && !isalnum((c)) && !isspace((c)))
00412 
00413 //-------------------------------------------------------------------------------------------------
00442 #define isxdigit(c)  ( isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') )
00443 
00444 //-------------------------------------------------------------------------------------------------
00474 #ifndef __HAS_MAIN
00475 extern int tolower(int c);
00476 #else
00477 #if !defined(__cflow_processed) || defined(_uses_tolower_ctype_h)                              
00478 int tolower(int c)
00479 {                                                                                              
00480     return (c >= 'A' && c <= 'Z') ? (c+32) : (c);
00481 }
00482 #endif
00483 #endif // Has Main
00484 
00485 //-------------------------------------------------------------------------------------------------
00511 #if !defined(__cflow_processed) || defined(_uses_toupper_ctype_h)
00512 inline int toupper(int c)
00513 {
00514     return ( c >= 'a' && c <= 'z' ) ? (c-32) : c;
00515 }
00516 #endif
00517 
00518 #endif   /* ifndef _CTYPE_H  */
00519 
分享到:
评论

相关推荐

    在使用VSCode编写C程序时,出现错误:cannot open source file “stdio.h”

    配置好MinGW-W64和LLVM的环境变量后,在VSCode下载了C/C++插件,也重启了VSCode,但是编写的测试程序还是报错: #include int main(){ printf(helo world\n); return 0; } 将鼠标放上去发现错误,然后将鼠标移开...

    c语言课程设计_24点源代码

    根据给定的文件信息,以下是对“C语言课程设计_24点源代码”的相关知识点进行的详细解析。 ### C语言课程设计概述 本课程设计是利用C语言实现了一个经典的数学游戏——24点游戏。24点游戏是一种数学扑克牌游戏,其...

    C语言文件加密解密系统

    根据提供的文件信息,本文将对"C语言文件加密解密系统"进行详细解析,重点在于理解其功能、工作原理以及核心代码实现。 ### C语言文件加密解密系统 #### 概述 该系统是一个基于C语言编写的文件加密解密工具,能够...

    关键字const的用法

    #include &lt;stdio.h&gt; #include &lt;ctype.h&gt; void ChangeStr(const char *String); int main(void) { char str[] = "The C programme"; ChangeStr(str); printf("%s\n", str); return 0; } void ChangeStr(const ...

    opencv 脸部识别源程序

    OpenCV(Open Source Computer Vision Library)是一个开源的计算机视觉库,被广泛应用于图像处理、视频分析以及面部识别等多个领域。本篇文章将对一个具体的OpenCV面部识别源代码进行详细解析,帮助读者理解面部...

    linux全志R16的linux系统编译的资料_20170502_1655.7z

    rm /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/zconf.tab.c make[1]:正在离开目录 `/home/wwt/linux_r16/lichee/buildroot/package/config' # # configuration ...

    绿色版PocketDOS 和 绿色版TC3.0

    FILTER H - Header file for TASM2MSG.C and GREP2MSG.C GAME CPP - C example - simulated baseball game GETOPT C - Parses options in command line GREP2MSG C - Example program for Turbo C++ filters ...

    pingsource

    首先引入了一系列的头文件,如`sys/socket.h`, `sys/time.h`, `sys/signal.h`, `netdb.h`, `netinet/ip.h`, `netinet/ip_icmp.h`, `netinet/in.h`, `unistd.h`, `stdlib.h`, `string.h`, `stdio.h`, `ctype.h`, `...

    51快速上路.doc

    3. **添加源文件**:在项目中右键点击`SOURCE GROUP 1`,选择`ADD FILES TO GROUP 'SOURCE GROUP 1'`,加入之前创建的`.c`文件。 4. **配置调试选项**: - 右键点击`TARGET 1`,选择`OPTIONS FOR TARGET 'TARGET 1'...

    c代码-实现将字符串中的数字取出,并存入一个新的字符串中。 这里的例子是:将4G模块返回值中的时间和日期取出,存入新的字符串中。

    在C语言编程中,从字符串中提取特定字符或数字序列是一项常见的任务,特别是在处理设备返回值或日志数据时。本示例展示了如何从包含数字的字符串中将这些数字提取出来,并存储到一个新的字符串中。这有助于我们有效...

    图片中的人脸识别

    OpenCV(Open Source Computer Vision Library)是一个开源的计算机视觉库,支持多种编程语言,如C++、Python等,并且提供了丰富的计算机视觉功能,包括图像处理、视频分析以及机器学习等。 #### 二、关键技术点 #...

    易语言-最快的排序算法_桶排序

    #i nclude &lt;stdio&gt; #i nclude #i nclude #i nclude #i nclude &lt;ctype&gt; int main(){ int order[10000],total,*array,i; while( 1){ memset(order,0,sizeof(int)*10000); printf("\nPlease input the size of ...

Global site tag (gtag.js) - Google Analytics