ckcplm.txt
资源名称:cku197.tar.Z [点击查看]
上传用户:dufan58
上传日期:2007-01-05
资源大小:3407k
文件大小:94k
源码类别:
通讯/手机编程
开发平台:
Windows_Unix
- CKCPLM.TXT Feb 2000
- C-KERMIT PROGRAM LOGIC MANUAL
- As of C-Kermit version: 7.0.197
- This file last updated: Tue Feb 8 16:30:55 2000
- Author: Frank da Cruz, Columbia University
- E-Mail: fdc@columbia.edu
- Copyright (C) 1985, 2000,
- Trustees of Columbia University in the City of New York.
- All rights reserved. See the C-Kermit COPYING.TXT file or the
- copyright text in the ckcmai.c module for disclaimer and permissions.
- INTRODUCTION
- The Kermit Protocol is specified in the book "Kermit, A File Transfer
- Protocol" by Frank da Cruz, Digital Press / Butterworth Heinemann, Newton, MA,
- USA (1987), 379 pages, ISBN 0-932376-88-6. It is assumed the reader is
- familiar with the Kermit protocol specification.
- This file attempts to describe the relationship among the modules and
- functions of C-Kermit 5A and later. Before reading this file, please read the
- file CKAAAA.TXT for an overview of C-Kermit file naming conventions.
- C-Kermit is designed to be portable to any kind of computer that has a C
- compiler. The source code is broken into many files that are grouped
- according to their function. There are several major groups: 1 (the protocol
- kernel), 2 (the user interface), 3 (system-dependent primitives), 4 (network
- support), and 5 (formatted screen support).
- CONTENTS:
- FILES
- SOURCE CODE PORTABILITY GUIDE
- GROUP 0 Library functions
- GROUP 1 System-independent file transfer protocol
- GROUP 1.5 Character set translation
- GROUP 2 User Interface
- GROUP 3 File & communications i/o and other system dependencies
- GROUP 4 Network support
- GROUP 5 Formatted screen support
- APPENDIX I File Permissions
- WARNING: C-Kermit 6.1 is probably the last version preserving this
- organization and naming. The next major release after 6.1 will apply some
- lessons we have learned about modularity and separation, and allow easier
- integration of the code with other applications and/or user interfaces.
- FILES
- C-Kermit source files begin with the two letters CK (lowercase on UNIX
- systems, uppercase on most others). The third character denotes something
- about the function group and the expected level of portability. See the file
- CKAAAA.TXT for details of file naming conventions and organization.
- One hint before proceeding: functions are scattered all over the ckc*.c
- and ckuu*.c modules, where function size has begun to take precedence over
- the desirability of grouping related functions together, the aim being to
- keep any particular module from growing disproportionately large. The easiest
- way (in UNIX) to find out what source file a given function is defined in is
- like this (where the desired function is foo()...):
- grep ^foo ck*.c
- This works because the coding convention has been to make function names
- always start on the left margin with their contents indented, for example:
- static char *
- foo(x,y) int x, y; {
- ...
- }
- Also please note the style for bracket placement. This allows
- bracket-matching text editors (such as EMACS) to help you make sure you know
- which opening bracket a closing bracket matches, particularly when it is no
- longer visible on the screen, and it also makes it easy to find the end of a
- function (search for '}' on the right margin).
- Of course EMACS tags work nicely with this format too:
- $ cd <kermit-source-directory>
- $ etags ck[cu]*.[ch]
- $ emacs
- Esc-X Visit-Tags-Table<CR><CR>
- (but remember that the source file for ckcpro.c is ckcpro.w!)
- SOURCE CODE PORTABILITY GUIDE
- When writing code for the system-indendent C-Kermit modules, please stick to
- the following coding conventions to ensure portability to the widest possible
- variety of C preprocessors, compilers, and linkers, as well as certain network
- and/or email transports:
- . Tabs should be set every 8 spaces, as on a VT100.
- . All lines must no more than 79 characters wide after tab expansion.
- . Note the distinction between physical tabs (ASCII 9) and the indentation
- conventions, which are: 4 for block contents, 2 for most other stuff.
- . Try to keep variable and function names unique within 6 characters,
- especially if they are used across modules, since 6 is the maximum for
- some linkers. (Actually, I think the last system that had this limitation
- was turned off in the 1980s -- remember SIXBIT? -- no now maybe it's 8?)
- . Keep preprocessor symbols unique within 8 characters.
- . Don't put #include directives inside functions or { blocks }.
- . Don't use the #if preprocessor construction, only use #ifdef, #ifndef, #undef
- . Put tokens after #endif in comment brackets, e.g. #endif /* FOO */.
- . Don't indent preprocessor statements - # must always be first char on line.
- . Don't put whitespace after # in preprocessor statements.
- . Don't use #pragma, even within #ifdefs - it makes some preprocessors give up.
- . Same goes for #module, #if, etc - #ifdefs do NOT protect them.
- . Don't use logical operators in preprocessor constructions.
- . Avoid #ifdefs inside argument list to function calls.
- . Always cast strlen() in expressions to int: "if ((int)strlen(foo) < x)...".
- . Any variable whose value might exceed 16383 should be declared as long,
- or if that is not possible, then as unsigned.
- . Unsigned long is not portable.
- . Don't use initializers with automatic arrays or structs.
- . Don't assume that struct assignment performs a copy.
- . Don't put prototypes for static functions into header files that are used
- by modules that don't contain that function.
- . Avoid the construction *++p -- the order of evaluation varies.
- . Reportedly, some compilers even mess up with *(++p).
- . Don't use triple assignments, like a = b = c = 0; (or quadruple, etc).
- Some compilers generate bad code for these, or crash, etc.
- . Structure members may not have the same names as other identifiers.
- . Avoid huge switch() statements with many cases.
- . Don't have a switch() statement with no cases (e.g. because of #ifdefs).
- . Don't put anything between "switch() {" and case: -- switch blocks are not
- like other blocks.
- . Don't make character-string constants longer than about 250.
- . Don't write into character-string constants even when you know you are not
- writing past the end because the compiler or linker might have put them into
- read-only and/or shared memory, and/or coalesced multiple equal constants
- so if you change one you change them all.
- . Don't depend on 'r' being carriage return.
- . Don't depend on 'n' being linefeed or for that matter any SINGLE character.
- . Don't depend on 'r' and 'n' being different (e.g. in switch() statements).
- . In other words, don't use n or r to stand for specific characters;
- use