Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 1/2" top margin 2 3 4 5 6 7 8 12345678901234567890123456789012345678901234567890123456789012345678901234567890 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Open-Printing Embedded Print (OPEP) Software Coding Specification Authored By: Glen Petrie Version: Version 0.01.00 Published Date: August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cover All Material Copyright (c) 2007 Open Printing. All Rights Reserved. 1/2" bottom margin 2 3 4 5 6 7 8 12345678901234567890123456789012345678901234567890123456789012345678901234567890 Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Open Printing Embedded Print Software Coding Specification Version 0.01.00 The Open Printing Embedded Print Software Coding Specification, Version 0.01.00, is intended as a guide to aid the developers, designers and architects. The existence of this specification does not in any respect preclude anyone, whether he or she has approved the specification or not, from using products, processes, or software not conforming to the specification. CAUTION ------------ THIS OPEN-PRINTING EMBEDDED PRINT DEVELOPMENT ACTIVITIES MAY BE REVISED OR WITHDRAWN AT ANY TIME. Printed in the United States of America ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ COPYRIGHT NOTICE Copyright (c) 2007 ??? All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The rights to use, copy, modify, merge, publish, distribute, and/or sell copies of this Software or any material modification there of shall not be further restricted by any means, including, but not limited to, the GNU General Public License. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TABLE OF CONTENTS ---------------------- 5 ... Introduction 5 ... Objective 5 ... Coding Generics 5 ....... Coding Standards 5 ....... Coding Concepts 6 ... File Layout 6 ....... Generic Layout 6 ....... Header 8 ........... API Numbering Scheme 8 ....... (Optional) Technical Description 9 ....... Declaration 11 ....... Body 13 ....... Footer 13 ... Code Standard 13 ....... Variable Types 13 ....... Naming Convention 13 ........... Variable Naming Convention 14 ........... Definition / Enumeration Naming Convention 14 ........... Subroutine Naming Convention 14 ........... Macro Definition Convention 15 ....... Statement Encoding 17 ... End of Document ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ REVISION HISTORY -------------------- Date Author Revisions 2007.07.24 Glen Petrie Original Document Suggested Modifications: 1. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Introduction ================================================================================ This document provides the software coding and formatting specification (CFS) for the development of Open Printing Embedded Print (OPEP) reference and testing software. Where applicable, this specification is applied to Application Programming Interfaces (APIs) specifications. The purpose of the OPEP CFS is to ensure maximum portability of all software along with providing a consistent encoding for ease-of-understanding. The intended target platform for OPEP is any Linux (POSIX) embedded environment. All attempts are made for CFS to be supported any platform and/or OS. However, if a conflict occurs between Linux and another environment, Linux will take precedence. Encoding, to support various environments, may include conditional compile statement(s), if practical. Those wishing to contribute code to OPEP software are encouraged to adhere to this software coding and formatting specification for the benefit of the OPEP development community. Objective ================================================================================ Consistency, Consistency, Consistency! Coding Generics ================================================================================ Coding Standards -------------------------------------------------------------------------------- The OPEP software encoding shall adhere to the following coding standards. 1. Software shall be encoded using ANSI Standard C with no compiler, tool and/or operating system extensions; 2. Software shall adhere to the structured formatting outlined in this document; 3. Software shall utilize consistent variable typing & naming as outlined in this document. Coding Concepts -------------------------------------------------------------------------------- The OPEP software encoding shall adhere to the following coding concepts 1. Software shall support non-floating-point encoding; 2. Software shall be encoded from top-down. That is, exposed API will appear at the top of files with helper or internal functions appearing at the bottom; 3. Software shall use pointer-to-functions for memory operations; specifically, opMalloc, opRealloc, opFree and opCalloc which will defined for individual computing environments; 4. Software shall utilize macro definition for in-line coding, where practical; 5. Software shall utilize the OPEP global link-list error struct variable called op_error, within single modules and between any modules; 6. Software shall define all subroutine to have no return parameter (i.e void fncfoo(arg1, … argn);) to support macro definition of API’s; 7. Software shall support three interfaces for each functional API; namely, static-libraries, dynamic-link-libraries, and client-service message-passage. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ File Layout ================================================================================ Generic Layout -------------------------------------------------------------------------------- The following layout specification shall apply to all files including code and related. 1. All software files shall contain a header, (optional) technical-description, declaration, body and footer sections. 2. Individual lines (code, comment and/or documentation) shall not exceed 80 printable characters. 3. All comment line, indented or otherwise, shall have a closing comments marks (‘*/’) at location 79 and 80; for example 1 2 7 8 12345678901234567890123…………………………………………….12345678901234567890 /* Comment lines shall end at position 79 & 80 */ /* no matter where they it starts */ /* and a comment cannot exceed the end */ /* position of 79 & 80 */ 4. All intents shall consist of multiples of four (4) spaces; no exceptions. The ‘Tab’ character shall not be used. Header -------------------------------------------------------------------------------- The Header section of any software and/or related file shall be used to identify the module, the author, copyright and related information. The Header shall have the following format. /*____________________________ < File Name > _____________________________*/ /* */ /* 1 2 3 4 5 6 7 */ /*3456789012345678901234567890123456789012345678901234567890123456789012345678*/ /**************************************|***************************************/ /* */ /* Copyright (c) < Year > < Name > All rights reserved. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, and/or sell copies of the Software, and to permit persons */ /* to whom the Software is furnished to do so, subject to the following */ /* conditions: */ /* */ /* The rights to use, copy, modify, merge, publish, distribute, and/or */ /* sell copies of this Software or any material modification thereof */ /* shall not be further restricted by any means, including, but not */ /* limited to, the GNU General Public License. */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* */ /* */ /**************************************|***************************************/ /* */ /* < Name of OPEP Subsystem this file is for > */ /* */ /* API- sssuuu void */ /* API- sssuuu void */ /* API- sssuuu (sssuuu is a unique id number for exposed API’s) */ /* API- sssuuu void */ /* */ /**************************************|***************************************/ /* */ /* Contributors: */ /* < Contributor Name / Company > */ /* < Contributor Address > */ /* */ /**************************************|***************************************/ /* */ /* Revision Log */ /* Date Who */ /* < yyyy.mm.dd > < who > */ /* # < change(s) that were made > */ /* < yyyy.mm.dd > < who > */ /* # < change(s) that were made > */ /* < yyyy.mm.dd > < who > */ /* # < change(s) that were made > */ /* */ /**************************************|***************************************/ /* */ /* Special Software and/or Usage Information */ /* */ /* # All exposed API’s in this file utilize the OPEP global link-list error */ /* structure with the global variable name of op_error. */ /* # */ /* */ /**************************************|***************************************/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ API Numbering Scheme ................................................................................ All exposed API’s shall have a unique identifier used for identification, debug and/or internal tracking. The API identifier number is composed of a major OPEP subsystem identifier and a unique number for the individual API’s. The specific format is: API – sssuuu ; where ‘sss’ is the subsystem number and ; where ‘uuu’ is the unique API identifier. The subsystem identifiers for OPEP are: Subsystem Open Printing Embedded Print Identifier Sub-Systems ------------ ----------------------------- 100 Print Manager 110 Data Spooler 120 Printer Driver 130 Status Monitor 140 Printer Capability 150 Job Ticket 160 Print Channel Manager 170 Printer Plug-and-Play 180 Transform : : : 900 Test Code – TBD (optional) Technical Description -------------------------------------------------------------------------------- The optional Technical Description section of any software and/or related file may be used to provide any level of technical detail and/or logical flow as the developer deems necessary to aid someone reviewing the body of code. /******************************************************************************//* */ /* Technical Description: */ /* */ /* */ /* */ /* */ /* */ /**************************************|***************************************/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Declaration -------------------------------------------------------------------------------- The Declaration section of any software and/or related file shall be used to declare external headers, local definitions, enumerations, local and exposed global variables along with internal function definitions. The Declaration section shall be defined into five subsections; namely, “Includes”, “Definitions”, “Application Global Variables”, “Local Global Variables”, “Local Functions”. Even if a specific subsection does not have any content, the subsection header should be included. All individual include files, defines, enumerations, macros, variables and function shall have a comment describing it; with no exceptions. To provide maximum readability encoding should be formatted in aligned columns with individual comments beginning at location 40. Additional Declaration sections may be included with in a file but is it not recommended. opGeneric.h is a noted exception to the following and includes additional sub-sections and headers. /* 1 2 3 4 5 6 7 */ /*3456789012345678901234567890123456789012345678901234567890123456789012345678*/ /*-------------------------------- Includes -------------------------------*/ /**************************************|***************************************/ #include /* System headers */ #include “opGeneric.h” /* Generic header file for OP */ #include “opFoo1.h” /* OP and User defined headers */ #include “opFoo2.h” /* OP and User defined headers */ #include “opFoo3.h” /* OP and User defined headers */ #include “opThisFile.h” /* Header for this C file */ /*------------------------------- Definitions -----------------------------*/ /**************************************|***************************************/ /* Title for this group of definitions */ /* -----------------------------------------------------------------------*/ #define FOO_DEF1 0x100 /* Local Individual definitions */ #define OP_FOO_DEF2 0x200 /* Each shall have a description */ /* Title for this group of definitions */ /* -----------------------------------------------------------------------*/ #define FOO_DEF3 0x300 /* Individual definitions */ /* Title for this group of enums */ /* -----------------------------------------------------------------------*/ typedef enum { /* Local Enumerations */ ENUM1 = 100, /* Each shall have a description */ ENUM2 , /* Each shall have a description */ ENUM_LAST /* Each shall have a description */ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /*--------------------------- Macro Definitions ----------------------------*/ /**************************************|***************************************/ /* Description for Macro 1 */ /* -----------------------------------------------------------------------*/ #define Macro1(arg) 3+(arg) /* Description for Macro 2 */ /* -----------------------------------------------------------------------*/ #define Macro2(arg) if (*(arg) == FOO_DEF1) { \ *(arg) += 20; \ } else { \ *(arg) -= 20; \ } \ op_error = OP_SUCCESSFUL /*--------------------------- Struct Definitions ---------------------------*/ /**************************************|***************************************/ /* Title for this group of definitions */ /* -----------------------------------------------------------------------*/ typedef _fooVar { /* Local Data struct definition */ OP_BIT32 var1; /* Each shall have a description */ OP_INT32 var2; /* Each shall have a description */ OP_BIT8* var3; /* Each shall have a description */ } fooVar; typedef fooVar* fooVarID; /* Pointer to struct */ /*---------------------- Application Global Variables ---------------------*/ /**************************************|***************************************/ /* Title for this group of Application Global Variables */ /* -----------------------------------------------------------------------*/ OP_BIT32 op_dataType; /* Each shall have a description */ OP_ERR op_error; /* OP Global Error Variable */ /*------------------------- Local Global Variables ------------------------*/ /**************************************|***************************************/ /* Title for this group of Local Global Variables */ /* -----------------------------------------------------------------------*/ OP_BIT32 status; /* Each shall have a description */ OP_INT16 localFlag /* Each shall have a description */ /*---------------------------- Local Functions ----------------------------*/ /**************************************|***************************************/ static OP_BIT32 InitialSubsystem(OP_BIT32, OP_BIT8, OP_BIT32*); static void ReleaseSybsystem(void); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Body -------------------------------------------------------------------------------- The body section of any software and/or related file shall contain the software encoding including the main and/or subroutines. Each routine shall consist of a header, routine declaration, variable declaration, routine-debug declaration, variable initialization, body and footer. The body section shall have the following form: 1 2 3 4 5 6 7 8 12345678901234567890123456789012345678901234567890123456789012345678901234567890 /**************************************|***************************************/ /* API-sssuuu */ /* Module : */ /* Description: <1 to 2 line description of routine> */ /* param >>: */ /* param >>: */ /* << param : */ /* << param : */ /* */ /**************************************|***************************************/ /* */ /* Revision Log */ /* Date Who */ /* < yyyy.mm.dd > < who > */ /* # < change(s) that were made > */ /* < yyyy.mm.dd > < who > */ /* # < change(s) that were made > */ /* < yyyy.mm.dd > < who > */ /* # < change(s) that were made > */ /* */ /**************************************|***************************************/ /* */ /* <(Optional) Detailed Description for routine> */ /* */ /**************************************|***************************************/ void ( , /* */ , /* */ , /* */ /* */ ) { /*** Declaration of Local Routine Variables */ ; /* */ OP_BIT32 idx; /* Simple Loop/Index variable */ /*** API Identifier Information for this Routine */ OP_API_REG(sssuuu, ); /*** Debug Flow Information for this Routine */ DebugFlowIn(””); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /*** Initialization of Local Routine Variables */ variable = 100; /* */ variable = 100; /* */ variable = 100; /* */ /***
*/ if () { DebugFlowError(””); return(); } /*** Release Local Dynamically Allocated Memory */ opFree(variable); /*** Return to Caller */ DebugFlowOut(””); return(); } All exposed API’s shall have a void return encoding. This allows for the substitution of macro definitions and actual subroutines. Errors from routines (macros or subroutines) are accomplished by use of the global error structure called op_error. Return of other values is done through variables in the argument list. (In the body header section parameters (“param”) denoted with ‘>>’ are used by the routine but not altered. Parameters (“param”) denoted with ‘<<’ may be used by the routine and are returned to the caller.) All variables used within the routine shall be declared in the variable declaration subsection; no exceptions. Each variable shall be on an individual line with the exception of simple loop/index variables. Variables shall not be initialized within the variable declaration section; variables must be initialized in the variable initialization subsection. The exception to initialization within a declaration is for constant strings. In the event of an error in the routine the routine should exit using the DebugFlowError macro. Within the DebugFlowError macro the name of the current subroutine is stored in the op_error structure. The DebugFlowError macro will also create a new link list entry for op_error. This allows developer to trace error to the source routine. Developer must use the DebugFlowError macro for the error tracing system to successfully trace errors. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Footer -------------------------------------------------------------------------------- The Footer section of any software and/or related file shall /*____________________________ < File Name > _____________________________*/ /* */ /*3456789012345678901234567890123456789012345678901234567890123456789012345678*/ /* 1 2 3 4 5 6 7 */ /**************************************|***************************************/ /*** End of File ** End of File ** End of File ** End of File ** End of File */ /**************************************|***************************************/ Code Standard ================================================================================ Variable Types -------------------------------------------------------------------------------- Only the following primitive variable types shall be used in the OP code. The explicit definitions are used to reduce confusion on the exact size and type of primitive data type. In addition, the header file opGeneric.h provides the necessary platform and/or OS mapping (typedef’s) to this set of primitive data types. OP Primitive Size Data Type Type (bits) Minimum Maximum ------------- ---------------- ------ ----------- --------------- OP_BOOL Logical 1 0 1 OP_BIT8 Unsigned Integer 8 0 255 OP_BIT16 Unsigned Integer 16 0 65,535 OP_BIT32 Unsigned Integer 32 0 4,294,967,295 OP_BIT64 Unsigned Integer 64 0 1.8 E19 OP_INT8 Signed Integer 8 -128 127 OP_INT16 Signed Integer 16 -32768 32767 OP_INT32 Signed Integer 32 -2147483648 2147483647 OP_INT64 Signed Integer 64 -9.2 E18 9.2 E18 Char String System Defined n/a n/a There are no floating point variable types (or variables) in OP. Naming Convention -------------------------------------------------------------------------------- Variable Naming Convention ................................................................................ All exposed module names shall begin with ‘op’. All exposed solution level variables shall begin with ‘op_’. The prefix may be extended by individual module specifications. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 13 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All variable names, exposed or not, shall be at least 3 characters in length and it recommended not to exceed 20 characters in length. Example; the variable ‘i’ is often used for simple loops; however, this small, single letter variable is difficult to read or can even be missed. Therefore, the recommended simple loop and/or index variables shall be named: adx, bdx, cdx, ddx, …., idx, jdx, kdx, ldx, …. xdx, ydx, zdx. Excessively long variable names make reading and/or encoding (typing) of code difficult and should be avoided. Since all variables require comments, the use of shorter variable names can be used without loss of understanding. Variable names, exposed or non-exposed variable, should have the first key word as a lower case character. Examples: Exposed Variables Non-Exposed Variables op_nextRowPosition rowPosition op_newJob job op_startPage pageStarted Definition / Enumeration Naming Convention ................................................................................ All simple #define variable and enum variables shall be capitalized with an underscore between key words. Examples: OP_LAST_ROW_POSITION ROW_POSITION PAGE_START OP_NEW_JOB Subroutine Naming Convention ................................................................................ All subroutine names shall capitalize the first letter of key word in the. Exposed Variables Non-Exposed Variables opComputeLines SetRowPosition opGetNewJob StartAJob opStartPage PageStartInit Macro Definition Convention ................................................................................ Macro definitions names shall use the same convention as the subroutine naming convention. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Statement Encoding -------------------------------------------------------------------------------- All encoding brackets (‘{‘ or ‘}’) shall place the start bracket (‘{‘} at the end of the statement the using it and the end bracket (‘)”) shall be placed on a new statement line at the same intent has the line with the start bracket. If the end bracket are more than 20 statements for the start bracket a comment is required at the end bracket identify the start statement. Examples: if (idx < jdx) { kdx = ldx; o o o } if (idx < jdx) { kdx = ldx; o o o } else { kdx = ldx; o o o } else { if (idx < jdx) { kdx = ldx; o o o } } else if (idx == ldx) { kdx = jdx; o o o } while (idx < jdx) { o o o } for (idx = 0; idx < 100; idx++) { o o o } switch (idx) { case FIRST_VALUE: idx = 100; o o o break; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 15 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ case LAST_VALUE: idx *= idx; o o o break; default: break; } The exception to this formatting is when the statement using the bracket and the content between the brackets will fit on a single 70 character line. Brackets are always required even for simple statement. Example; for (idx = 0; idx < 100; idx++) { jdx = 2*idx; kdx = idx + 3*jdx; } while (ptr < endPtr) {if (!strcmp(ptr, testString)) { break; } } if (idx == jdx) { ldx = 1; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 16 All Material Copyright (c) 2007 Open Printing. All Rights Reserved. Software Coding Specification Version 0.01.00 Open-Printing Embedded Print August 30, 2007 1/2" top margin 2 3 4 5 6 7 8 12345678901234567890123456789012345678901234567890123456789012345678901234567890 -------------------------------------------------------------------------------- Open-Printing Embedded Print (OPEP) Software Coding Specification Authored By: Glen Petrie EEEEEE NN NN DDDDD OO FFFFFF EE NNN NN DD DD OO OO FF EEEE NN NN NN DD DD OO OO FFFF EE NN NNN DD DD OO OO FF EEEEEE NN NN DDDDD OO FF ~~ END OF DOCUMENT ~~ END OF DOCUMENT ~~ END OF DOCUMENT ~~ END OF DOCUMENT ~~ DDDDD OO CCCC UU UU MM MM EEEEEE NN NN TTTTTT DD DD OO OO CC C UU UU MMM MMM EE NNN NN TT DD DD OO OO CC UU UU MM MM MM EEEE NN NN NN TT DD DD OO OO CC C UU UU MM MM EE NN NNN TT DDDDD OO CCCC UU MM MM EEEEEE NN NN TT -------------------------------------------------------------------------------- End Of Document All Material Copyright (c) 2007 Open Printing. All Rights Reserved. 1/2" bottom margin 2 3 4 5 6 7 8 12345678901234567890123456789012345678901234567890123456789012345678901234567890