CS300: Elements of Software Engineering



CS300: Elements of Software Engineering

Spring 2004

Instructor : Supreeth Venkataraman

TA: Bhuricha Sethanandha

PHASE II : Architecture and Detail Design

TEAM E

Members

Steve Borsay

Lisa Brueckner

Brian Ford

Shane Matthews

Date

May 17, 2004

Table of Contents

Table of Contents 2

Table of Figures 3

1 Introduction 4

2 Assumptions 4

3 Design Decisions 4

4 Architecture Design 4

4.1 Overview 4

4.1.1 Repository Subsystem 5

4.1.2 Processor Subsystem 6

4.1.3 Interface Subsystem 9

4.1.4 Traceability Matrix 12

5 User interface Design 12

5.1 Web Flow Design 12

5.2 Web pages design 13

5.2.1 13

5.3 Module Design 13

5.3.1 13

6 Detail Design 13

6.1 Web page Realization 13

6.1.1 14

6.2 Module Realization 14

6.2.1 Module Reader – Repository Subsystem 14

6.2.2 Module Writer – Repository Subsystem 17

6.2.3 Module Validation – Processor Subsystem 20

6.2.4 Module Requests – Processor Subsystem 22

6.2.5 Module Data – Processor Subsystem 24

6.2.6 Module Errors – Processor Subsystem 28

6.3 Error Messages 41

Table of Figures

Figure 1: E-LIB 3-Tiered Design 5

Figure 2: E-LIB Repository Subsystem 5

Figure 3: Processor - Requests Module 6

Figure 4: Processor - Validation Module 7

Figure 5: Processor - Errors Module 8

Figure 6: Processor - Data Module 9

Figure 7: Interface - Output Module 9

Figure 8: Interface - PageObjects Module 11

Figure 9: E-LIB Web Flow 12

Introduction

E-LIB is a web-accessible repository of electronic books. The system supports three types of users: non-members, members, and staff. Non-members are casual browsers who are able to search the repository to see what books it contains. Members are able to search the repository, check out, renew, and place holds on books, update their account info, view a history of their transactions and cancel their membership. Staff are able to recall books, change the system date, and print reports on books and members.

This document begins with the assumptions we have made about the system and its environment that have influenced our design decisions. From there we proceed to a brief discussion of the high-level design decision we made and the rationale for those decisions. Following that, we discuss the architectural design, including a presentation of our traceability matrix. Progressing to a more detailed aspect, we discuss at some length the interface of E-LIB and the design decisions related thereto. Finally, we present the detailed design of E-LIB complete with PDL for all the modules in the system

Assumptions

The repository comes stocked with book data and no functionality exists in the system for adding, modifying, or deleting book data.

Design Decisions

The system is implemented in the C programming language. An embeddable SQL library (SQLite) is used for persistent data. The cgic library is used for the web-based interface. The system will run on the Sun Solaris operating system and will be compatible with the Netscape internet browser. The system will be compatible with an Apache web server configured to allow CGI scripts and to automatically render files named index.cgi when the URL is a directory.

E-LIB has been designed to be secure, robust, portable, modular, efficient and extensible. The C programming language lends portability and efficiency. Authenticated member accounts provide secure access to E-LIB resources. The 3-tiered architecture was selected to enable easy replacement of either the database repository with a different database or the web interface with a traditional dialog based interface. The web interface was designed to be consistent and simple to use. Each page shows the same header and left side bar, from which the user can select all available functionality relevant in the particular context defined by the page. The header makes the search capability ubiquitous because that is assumed to be the most common activity at the site.

Architecture Design

1 Overview

The most basic architectural aspect of E-LIB is the 3-tiered design. This architectural style maximizes modularity and extensibility in the system by separating two of the most volatile components: data persistence machinery and the interface. Interfaces are the most variable and system dependent. The design of E-LIB supports quickly retargeting the application by simply building a new interface subsystem. Separation of the repository into a module provides for using different databases without affecting either the core functionality or the interface. See Figure 1.

[pic]

Figure 1: E-LIB 3-Tiered Design

1 Repository Subsystem

The Repository subsystem is structured as shown in Figure 2.

[pic]

Figure 2: E-LIB Repository Subsystem

1 Purpose

The Repository subsystem provides for persistence of E-LIB’s book, member, and transaction history data. The subsystem isolates the rest of E-LIB from details of data storage and retrieval and provides the potential for selecting different storage solutions. The subsystem is broadly divided into the functionality for adding data and for retrieving data. These are the Writer and Reader modules respectively.

2 Module breakdown

The Writer is further subdivided in the categories of data modification, namely adding, modifying, and deleting. Within these three categories, functions exist for member and transaction history data: addMember, addHistory, modifyMember, modifyHistory, deleteMember, deleteHistory.

The Reader module is divided into two basic categories: specific and simplified get functions that retrieve data based on the most common search key, and general purpose query functions that provide for specifying the search keys and criteria. Functions are provided for book, member, and transaction history data: getBook, getMember, getHistory, queryBook queryMember, queryHistory.

2 Processor Subsystem

The Processor subsystem is divided into four main modules: Requests, Validation, Errors, and Data. See Figure 3, Figure 4, Figure 5, Figure 6.

[pic]

Figure 3: Processor - Requests Module

1 Purpose

The Requests module is the access point for E-LIB. This module implements every possible URL request of E-LIB, to think of it in terms of the web-based interface. The subsystem handles validating incoming data, saving it to the repository, retrieving data from the repository, and utilizing the modules of the Interface subsystem to produce the next page for the user. Another way to look at this module is that it implements each feature that is available for each type of user as they interact with E-LIB.

2 Module breakdown

The Requests module is further broken down by the types of interaction. This roughly mimics the user types with the addition of a general category that spans the user types. The four groupings of modules are: general, non-member, member, and staff.

All users of L-LIB have the ability to display a homepage, search, advanced search. All types of users also will see the login form, since until a user attempts to login, E-LIB has no way to distinguish between a registered member and a casual browser. Under the general category then we have modules: index (homepage), search, advanced_search, and login.

Under the non-member category, we have the single module register as the only functionality unique to this type of user.

[pic]

Figure 4: Processor - Validation Module

3 Purpose

The Validation module exists to validate every potential data element that we can receive from the user.

4 Module breakdown

The Validation module provides for validating each data element we can receive. The functions of this module include: validName, validAddress, validTelephone, validEmail, validSSN (social security number), validMaidenName (mother’s maiden name), validUserName, and validPassword.

[pic]

Figure 5: Processor - Errors Module

5 Purpose

The Errors module provides a user-friendly error message for each type of error possible in the system. It also provides the functionality for the other parts of the system to easily create and iterate lists of errors.

6 Module breakdown

The Errors module is further decomposed into Types and Accessors. The Types module produces a user-friendly error message for all possible system errors. Functions of this module include: invalidName, invalidAddress, invalidTelephone, invalidEmail, invalidSSN, invalidMaidenName, invalidUserName, invalidPassword, invalidLogin, memberRecordNotFound, and memberNameInUse.

The Accessor module provides for creating and iterating lists of error messages. Functions of this module include: getFirstError, getNextError, newError, and addError.

[pic]

Figure 6: Processor - Data Module

7 Purpose

The Data module provides for collecting the data elements for a particular context into a single structure. The data elements from the interface are non-related. The functions of this module collect those to allow for treating them as a single group.

8 Module breakdown

The functions of the module correspond to the basic groupings of data in the system: getLoginData, getSearchData, getRegisterData, getAccountData.

3 Interface Subsystem

The Interface subsystem implements the construction of the web pages with which the user interacts. This subsystem is further broken down into two main modules: Output and PageObjects See Figure 7, Figure 8.

[pic]

Figure 7: Interface

[pic]

Figure 8: Interface - Output Module

1 Purpose

The purpose of the Output subsystem is to present information to the user of the system. The Output subsystem is concerned with the presentation of information processed in the Processor tier of the system. Information will be presented in the form of a webpage.

2 Module breakdown

The Output subsystem is further decomposed to group each module with the various types of outputs the each user of the system may need. The subsystems within the Output subsystem are Account, Books and Reports. The Output subsystem contains the module homepage.

The Accounts includes modules dealing with a member account. The modules are: history, register, updateInfo.

The Books subsystem consists of modules that deal with information regarding books. This subsystem contains the bookDetails and displayContents modules, and the subsystem Search. The Search deals with book searches. The modules in the Search subsystem are: searchResults, advancedSearch.

The Reports subsystem contains modules that will output reports to the staff member. The modules include: booklist, memberList.

[pic]

Figure 8: Interface - PageObjects Module

A Purpose

The purpose of the PageObjects subsystem is to provide consistent web page elements to the user. A consistent environment is essential in order for the system to be simple and not difficult for the user of the system. The PageObjects subsystem breaks down components that make up a web page. Each of these components is further broken down into the subsystems Forms, HTML, and Form Elements. This decomposition reduces redundancy considering that different modules need to output the same form or HTML.

B Module breakdown

Each module in the Forms, HTML and Form Elements subsystems will be repeatedly called within modules existing in the Output subsystem.

The Forms subsystem contains modules that output forms that will be repeatedly used. These include: loginForm, changeDateForm, searchBar.

The HTML subsystem includes modules that are used to create HTML web pages. These include: beginPage, endPage, header, staffNavigation, memberNavigation, nonMemberNavigation, date, table.

The Form Elements subsystem consists of modules that create forms and objects within a form. These include: beginForm, endForm, textbox, button, radioButton, checkbox, passwordBox, menu.

4 Traceability Matrix

|Requirement |#1 |

|Module Functions |

|getBook |

|This function returns a list of one or more book records based on a title search. |

|IN: |char title[MAX_TITLE] |the title of the book for which to search; ‘title’ does not need to |

| | |specify a complete title |

| |BookList **bookList |address of a pointer to receive the list of one or more books that match|

| | |the search criteria |

|RETURN: |ELIB_OK if books are found matching the search criteria |

| |ELIB_BOOKNOTFOUND if no books are found matching the criteria |

| |ELIB_DATAERROR if an error occurs accessing the database |

|SQL: |SELECT * FROM books WHERE title LIKE ; |

| |where will contain the value of the variable ‘title’ |

|allocate memory for an sql command string |

|construct the sql command |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|fill in data structure from records returned |

|return ELIB_OK |

|else if book not found |

|return ELIB_BOOKNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

|queryBook |

|This function returns a list of one or more book records based on a search of one or more book fields. |

|IN: |Book *search |a book data structure with 1 or more fields containing search criteria |

| |BookList **bookList |address of a pointer to receive the list of one or more books that match|

| | |the search criteria |

|RETURN: |ELIB_OK if books are found matching the search criteria |

| |ELIB_BOOKNOTFOUND if no books are found matching the criteria |

| |ELIB_DATAERROR if an error occurs accessing the database |

|SQL: |SELECT * FROM books WHERE title LIKE AND authors LIKE AND isbn LIKE AND publisher LIKE|

| | AND year LIKE ; |

| |where is one of the fields from ‘bookData’ |

|allocate memory for an sql command string |

|if all fields in bookData are empty |

|construct sql command to retrieve all books |

|else construct the sql command using all non-empty |

|fields in bookData; |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|fill in data structure from records returned |

|return ELIB_OK |

|else if book not found |

|return ELIB_BOOKNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

|getMember |

|This function returns a member record based on a member username search. |

|IN: |char name[MAX_UNAME] |the username of the member for which to search |

| |Member *memberData |pointer to Member structure to receive member info for ‘name’ |

|RETURN: |ELIB_OK if member is found with username ‘name’ |

| |ELIB_MEMBERNOTFOUND if no member is found |

| |ELIB_DATAERROR if an error occurs accessing the database |

|SQL: |SELECT * FROM members WHERE username LIKE ; |

| |where will contain the value of the variable ‘name’ |

|allocate memory for an sql command string |

|construct the sql command using member name |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|fill in data structure from records returned |

|return ELIB_OK |

|else if member not found |

|return ELIB_MEMBERNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

|queryMember |

|This function returns a list of one or more member records based on a search of one or more member fields |

|IN: |Member *search |A member data structure with 1 or more fields containing search criteria|

| |MemberList **memberList |address of pointer to receive the list of one or more member records |

| | |that match the search criteria |

|RETURN: |ELIB_OK if members are found matching the search criteria |

| |ELIB_MEMBERNOTFOUND if no members are found matching the search criteria |

| |ELIB_DATAERROR if an error occurs accessing the database |

|SQL: |SELECT * FROM members WHERE name LIKE AND address LIKE AND phone LIKE AND email LIKE |

| | AND maidenName LIKE ; |

| |where is one of the fields from ‘memberData’ |

|allocate memory for an sql command string |

|if all fields in memberData are empty |

|construct sql command to retrieve all members |

|else construct the sql command using all non-empty |

|fields in memberData; |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|fill in data structure from records returned |

|return ELIB_OK |

|else if member not found |

|return ELIB_MEMBERNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

|getHistory |

|This function returns a list of one or more history records for the given member username |

|IN: |char name[MAX_UNAME] |The username of the member for which to get history data |

| |HistoryList **historyList |address of a pointer to receive the list of one or more history records|

| | |that match the search criteria |

|RETURN: |ELIB_OK if history records are found matching the search criteria |

| |ELIB_HISTORYNOTFOUND if no history records are found matching the search criteria |

| |ELIB_MEMBERNOTFOUND if ‘name’ does not specify a valid username |

| |ELIB_DATAERROR if an error occurs accessing the database |

|SQL: |SELECT * FROM history WHERE username = ; |

| |where will be the value of the variable ‘name’ |

|allocate memory for an sql command string |

|construct the sql command using member name |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|fill in data structure from records returned |

|return ELIB_OK |

|else if member not found |

|return ELIB_MEMBERNOTFOUND |

|else if history not found |

|return ELIB_HISTORYNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

1 Data Retrieval

The data retrieval information, including the actual SQL statement used, is included in the information with each function.

5 Module Writer – Repository Subsystem

1 Implementation Elements

|Source File |writer.c |

|Module Functions |

|addMember |

|This function adds a member to the repository |

|IN: |Member *member |pointer to member data structure to add |

|RETURN: |ELIB_OK if the member is added successfully |

| |ELIB_MEMBEREXISTS if a user member with either this username or SSN already exists |

| |ELIB_DATAERROR if an error occurs adding the data to the database |

|SQL: |INSERT INTO members VALUES (, , , , , , , ); |

| |where is one of the fields from ‘member’ |

|allocate memory for an sql command string |

|construct the sql command using member fields |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|return ELIB_OK |

|else if username already exists |

|return ELIB_MEMBEREXISTS |

|else if data error |

|return ELIB_DATAERROR |

|addHistory |

|This function adds a history record to the repository |

|IN: |History *history |pointer to history data structure to add |

|RETURN: |ELIB_OK if the history record is added successfully |

| |ELIB_DATAERROR if an error occurs adding the data to the database |

|SQL: |INSERT INTO history VALUES (, ); |

| |where is one of the fields from ‘history’ |

|allocate memory for an sql command string |

|construct the sql command using history fields |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|return ELIB_OK |

|else if data error |

|return ELIB_DATAERROR |

|modifyMember |

|This function updates an existing member record with new data. The member’s username is the only field that cannot be updated. That|

|field is set for the life of this member’s registration. |

|IN: |char username[MAX_UNAME] |the username of the member whose data we are updating |

| |Member *member |pointer to member data structure with data to update repository |

|RETURN: |ELIB_OK if the member data is updated successfully |

| |ELIB_MEMBERNOTFOUND if the member specified by ‘name’ does not exist in the repository |

| |ELIB_DATAERROR if an error occurs updating the data |

|SQL: |UPDATE members SET name = , address = , phone = , email = , maidenName = |

| |, password = WHERE username = ; |

| |where in the SET clause comes from the field of ‘member’ and is the value of the variable |

| |‘username’ |

|allocate memory for an sql command string |

|construct the sql command using member fields and username |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|return ELIB_OK |

|else if username not found |

|return ELIB_MEMBERNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

|deleteMember |

|This function deletes the member record for the member specified by ‘name’ |

|IN: |char username[MAX_UNAME] |the username of the member whose record we are deleting |

|RETURN: |ELIB_OK if the specified member record is deleted |

| |ELIB_MEMBERNOTFOUND if no member with ‘name’ exists |

| |ELIB_DATAERROR if an error occurs when deleting the record |

|SQL: |DELETE FROM members WHERE username = ; |

| |where will be the value of the variable ‘username’ |

|allocate memory for an sql command string |

|construct the sql command using username |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|return ELIB_OK |

|else if username not found |

|return ELIB_MEMBERNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

|deleteHistory |

|This function deletes all history records for the member specified by member username ‘name’ |

|IN: |char username[MAX_UNAME] |the username of the member whose history records we are deleting |

|RETURN: |ELIB_OK if the history records are deleted |

| |ELIB_MEMBERNOTFOUND if no member with ‘name’ exists |

| |ELIB_DATAERROR if an error occurs when deleting the history records |

|SQL: |DELETE FROM history WHERE username = ; |

| |where will be the value of the variable ‘username’ |

|allocate memory for an sql command string |

|construct the sql command using username |

|execute the sql command |

|free memory for the sql command |

|if command successful |

|return ELIB_OK |

|else if username not found |

|return ELIB_MEMBERNOTFOUND |

|else if data error |

|return ELIB_DATAERROR |

2 Data Retrieval

The data retrieval information, including the actual SQL statement used, is included in the information with each function.

6 Module Validation – Processor Subsystem

1 Implementation Elements

|Source File |validate.c |

|Module Functions |

|validName |

|This function checks that the member name is valid. This is not the member’s username (used to log in) but is the member’s actual |

|name. |

|IN: |char name[MAX_NAME] |the name to validate |

|RETURN: |ELIB_OK if the name is valid |

| |ELIB_INVALID_NAME if the name is invalid |

|for each character in name |

|if character not in [a-zA-z.,'- ] |

|return ELIB_INVALID_NAME |

|return ELIB_OK |

|validAddress |

|This function checks that the address is valid |

|IN: |char address[MAX_ADDRESS] |the address to validate |

|RETURN: |ELIB_OK if the address is valid |

| |ELIB_INVALID_ADDRESS if the address is invalid |

|for each character in address |

|if character not in [a-zA-Z0-9 \n#.-'] |

|return ELIB_INVALID_ADDRESS |

|return ELIB_OK |

|validTelephone |

|This function checks that the telephone is valid |

|IN: |char phone[MAX_PHONE] |the phone number to validate |

|RETURN: |ELIB_OK if the phone is valid |

| |ELIB_INVALID_TELEPHONE if the phone is invalid |

|if character at index 0 is not '(' |

|or character at index 4 is not ')' |

|or character at index 8 is not '-' |

|return ELIB_INVALIDPHONE |

|for characters at indices [1,2,3,5,6,7,9,10,11,12] |

|if character is not in [0-9] |

|return ELIB_INVALID_PHONE |

|return ELIB_OK |

|validEmail |

|This function checks that the email is valid |

|IN: |char email[MAX_EMAIL] |the email address to validate |

|RETURN: |ELIB_OK if the email is valid |

| |ELIB_INVALID_EMAIL if the email is invalid |

|for each character in email |

|if character not in [a-z0-9@] |

|return ELIB_INVALID_EMAIL |

|return ELIB_OK |

|validSSN |

|This function checks that the social security number is valid |

|IN: |char ssn[MAX_SSN] |the social security number to validate |

|RETURN: |ELIB_OK if the social security number is valid |

| |ELIB_INVALID_SSN if the social security number is invalid |

|if character at index 3 is not '-' |

|or characher at index 6 is not '-' |

|return ELIB_INVALIDSSN |

|for characters at indices [0,1,2,4,5,7,8,9,10] |

|if character is not in [0-9] |

|return ELIB_INVALID_SSN |

|return ELIB_OK |

|validMaidenName |

|This function checks that the mother’s maiden name is valid |

|IN: |char name[MAX_MNAME] |the maiden name to validate |

|RETURN: |ELIB_OK if the maiden name is valid |

| |ELIB_INVALID_MAIDENNAME if the maiden name is invalid |

|for each character in maidenName |

|if character not in [a-zA-Z.,'- ] |

|return ELIB_INVALID_MAIDENNAME |

|return ELIB_OK |

|validUserName |

|This function checks that the username is valid |

|IN: |char name[MAX_UNAME] |the username to validate |

|RETURN: |ELIB_OK if the username is valid |

| |ELIB_INVALID_USERNAME if the username is invalid |

|for each character in maidenName |

|if character not in [a-zA-Z0-9] |

|return ELIB_INVALID_USERNAME |

|return ELIB_OK |

|validPassword |

|This function checks that the password is valid |

|IN: |char password[MAX_PASSWORD] |the password to validate |

|RETURN: |ELIB_OK if the password is valid |

| |ELIB_INVALID_PASSWORD if the password is invalid |

|for each character in maidenName |

|if character is not printable |

|or character is white space |

|return ELIB_INVALID_PASSWORD |

|return ELIB_OK |

7 Module Requests – Processor Subsystem

All the functions of this module are actually stand-alone cgi programs. These are the requests from the user’s browser and entry points to the functionality of E-LIB. As such, each function is actually main, which is the entry point of a C program. Each function has parameters: int argc, char *argv[]. Each function has return type int and returns the value 0 to indicate to the web server that it has successfully completed. The details below list the source file, executable file, and pseudo code for each request component.

1 Implementation Elements

|Source File |index.c |

|Executable File |index.cgi |

|This program responds to the HTTP request for the main or home page of the web site. |

|call homepage |

|Source File |search.c |

|Executable File |search.cgi |

|This program responds to the HTTP request to quick search the repository based on book title only. |

|get search parameters from CGI parameters |

|call getBook |

|call searchResults |

|Source File |advancedSearch.c |

|Executable File |advancedSearch.cgi |

|This program responds to the HTTP request to search the repository based on any of the book fields. |

|get search parameters from CGI parameters |

|call getBook |

|call searchResults |

|Source File |bookDetail.c |

|Executable File |bookDetail.cgi |

|This program responds to the HTTP request to display book details for a specified book. |

|get book title from CGI parameters |

|call getBook |

|call bookDetails |

|Source File |login.c |

|Executable File |login.cgi |

|This program responds to the HTTP request to log in to E-LIB. |

|get login parameters from CGI parameters |

|if login credentials not valid |

|generate error message |

|call homepage |

| |

|Source File |register.c |

|Executable File |register.cgi |

|This program responds to the HTTP request to register as a new user at E-LIB. |

|get register parameters from CGI parameters |

|for each register parameter |

|validate parameter |

|if parameter is not valid |

|add error message |

|call homepage |

| |

|Source File |checkOutBook.c |

|Executable File |checkOutBook.cgi |

|This program responds to the HTTP request to check out a book. |

|change book status to checked out |

|call bookDetails |

|Source File |holdBook.c |

|Executable File |holdBook.cgi |

|This program responds to the HTTP request to place a hold on a book. |

|change book status to held |

|call bookDetails |

|Source File |renewBook.c |

|Executable File |renewBook.cgi |

|This program responds to the HTTP request to renew a book that this member has checked out. |

|change book status to checked out with new date |

|call bookDetails |

|Source File |updateAccount.c |

|Executable File |updateAccount.cgi |

|This program responds to the HTTP request to update the member’s account information. |

|get member info parameters from CGI parameters |

|call modifyMember |

|call homepage |

|Source File |viewHistory.c |

|Executable File |viewHistory.cgi |

|This program responds to the HTTP request to view the transaction history for a specified member. |

|get username from CGI parameters |

|call getHistory |

|call history |

|Source File |forgotPassword.c |

|Executable File |forgotPassword.cgi |

|This program responds to the HTTP request from a member to reset their password if they have forgotten it. |

|validate user info |

|call changePassword |

|Source File |cancelMembership.c |

|Executable File |cancelMembership.cgi |

|This program responds to the HTTP request from a member to cancel their membership. |

|deleteMember |

|call homepage |

|Source File |advanceDate.c |

|Executable File |advanceDate.cgi |

|This program responds to the HTTP request to advance the E-LIB system date. |

|advance system date |

|call homepage |

|Source File |recallBook.c |

|Executable File |recallBook.cgi |

|This program responds to the HTTP request to recall a book on checked-out status. |

|change book status to available |

|call homepage |

|Source File |reportOnBooks.c |

|Executable File |reportOnBooks.cgi |

|This program responds to the HTTP request to display a listing of all books in E-LIB. |

|getBook |

|call bookList |

|Source File |reportOnMembers.c |

|Executable File |reportOnMembers.cgi |

|This program responds to the HTTP request to display a listing of all members at E-LIB. |

|getMember |

|call memberList |

8 Module Data – Processor Subsystem

1 Implementation Elements

|Source File |data.c |

|Module Functions |

|getLoginData |

|This function gathers the login data from the CGI request into a single data structure. The function allocates memory for the |

|structure. The client is responsible for freeing the memory when no longer needed. |

|IN: |Login **loginData |pointer to address of login data structure. The pointer will be set to |

| | |the allocated memory for the login data structure |

|RETURN: |ELIB_OK if the memory is allocated and the data fields set |

| |ELIB_NOMEMORY if unable to allocate memory for the structure |

|allocate memory for login data structure |

|if allocation fails |

|return ELIB_NOMEMORY |

|for each field in the login data structure |

|if field is in CGI parameters |

|copy CGI parameter value to field |

|set client pointer to allocated memory |

|return ELIB_OK |

|getSearchData |

|This function gathers the book search data from the CGI request into a single data structure. The function allocates memory for the|

|structure. The client is responsible for freeing the memory when no longer needed. |

|IN: | | |

|RETURN: |ELIB_OK if the memory is allocated and the data fields set |

| |ELIB_NOMEMORY if unable to allocate memory for the structure |

|allocate memory for search data structure |

|if allocation fails |

|return ELIB_NOMEMORY |

|for each field in the search data structure |

|if field is in CGI parameters |

|copy CGI parameter value to field |

|set client pointer to allocated memory |

|return ELIB_OK |

|getMemberData |

|This function gathers the update member data from the CGI request into a single data structure. The function allocates memory for |

|the structure. The client is responsible for freeing the memory when no longer needed. |

|IN: | | |

|RETURN: |ELIB_OK if the memory is allocated and the data fields set |

| |ELIB_NOMEMORY if unable to allocate memory for the structure |

|allocate memory for account data structure |

|if allocation fails |

|return ELIB_NOMEMORY |

|for each field in the register data structure |

|if field is in CGI parameters |

|copy CGI parameter value to field |

|set client pointer to allocated memory |

|return ELIB_OK |

|getUserType |

|This function checks for whether a user is logged in and if so whether the user is a member or a staff |

|IN: |None | |

|RETURN: |ELIB_NONMEMBER if no user is logged in |

| |ELIB_MEMBER if the logged in user is a member |

| |ELIB_STAFF if the logged in user is a staff |

|if CGI parameter ‘ELIB_USER’ exists |

|call getMember with value of ELIB_USER |

|return memberType |

|return ELIB_NONMEMBER |

|getUserName |

|This function checks for whether a user is logged in and if so returns the user’s name |

|IN: |None | |

|RETURN: |NULL if no user is logged in |

| |Otherwise a pointer to a character buffer containing the user’s name |

|if CGI parameter ‘ELIB_USER’ exists |

|call getMember with value of ELIB_USER |

|return memberType |

|return ELIB_NONMEMBER |

|getFirstBook |

|This function returns the first book in the book list |

|IN: |BookList *bookList |a pointer to a BookList structure containing one or more books |

|RETURN: |NULL if bookList is NULL or if bookList does not contain any books |

| |Otherwise, a pointer to a Book structure |

|if bookList is NULL |

|return NULL |

|else if bookList is empty |

|return NULL |

|else |

|set current flag to first entry |

|return data from first entry |

|getNextBook |

|This function returns the next book in the book list or NULL if there are no more books |

|IN: |BookList *bookList |a pointer to a BookList structure containing one or more books |

|RETURN: |NULL if bookList is NULL or if bookList does not contain any more books |

| |Otherwise, a pointer to a Book structure |

|if bookList is NULL |

|return NULL |

|else if bookList is empty |

|return NULL |

|else if bookList contains no more books |

|return NULL |

|else |

|increment current flag to next entry |

|return data from first entry |

|getFirstMember |

|This function returns the first member in the member list |

|IN: |MemberList *memberList |a pointer to a MemberList structure containing one or more members |

|RETURN: |NULL if memberList is NULL or if memberList does not contain any members |

| |Otherwise, a pointer to a Member structure |

|if memberList is NULL |

|return NULL |

|else if memberList is empty |

|return NULL |

|else |

|set current flag to first entry |

|return data from first entry |

|getNextMember |

|This function returns the next member in the member list or NULL if there are no more members |

|IN: |MemberList *memberList |a pointer to a MemberList structure containing one or more members |

|RETURN: |NULL if memberList is NULL or if memberList does not contain any more members |

| |Otherwise, a pointer to a Member structure |

|if memberList is NULL |

|return NULL |

|else if memberList is empty |

|return NULL |

|else if memberList contains no more books |

|return NULL |

|else |

|increment current flag to next entry |

|return data from first entry |

|getFirstHistory |

|This function returns the first history record in the history list |

|IN: |HistoryList *historyList |a pointer to a HistoryList structure containing one or more history |

| | |records |

|RETURN: |NULL if historyList is NULL or if historyList does not contain any history records |

| |Otherwise, a pointer to a History structure |

|if historyList is NULL |

|return NULL |

|else if historyList is empty |

|return NULL |

|else |

|set current flag to first entry |

|return data from first entry |

|getNextHistory |

|This function returns the next history record in the history list or NULL if there are no more history records |

|IN: |HistoryList *historyList |a pointer to a HistoryList structure containing one or more history |

| | |records |

|RETURN: |NULL if historyList is NULL or if historyList does not contain any history records |

| |Otherwise, a pointer to a History structure |

|if historyList is NULL |

|return NULL |

|else if historyList is empty |

|return NULL |

|else if historyList contains no more books |

|return NULL |

|else |

|increment current flag to next entry |

|return data from first entry |

9 Module Errors – Processor Subsystem

1 Implementation Elements

|Source File |errors.c |

|Module Functions |

|getFirstError |

|This function takes a pointer to an Error data structure and returns a pointer to a character array containing a user-friendly |

|textual error. The pointer is to an internal buffer so successive calls to this function overwrite the contents of the buffer. The |

|client function should not change the contents of the buffer. |

|IN: |Error *errorList |A pointer to an error data structure created with calls to ‘addError’ |

|RETURN: |NULL if errorList is NULL or if it contains no error code or if it contains an invalid error code |

| |Otherwise, a pointer to a character array containing the text for this error |

|if errorList is NULL |

|return NULL |

|else if errorList is empty |

|return NULL |

|else |

|set current flag to first entry |

|return data from first entry |

|getNextError |

|This function takes a pointer to an Error data structure and returns a pointer to a character array containing a user-friendly |

|textual error. The pointer is to an internal buffer so successive calls to this function overwrite the contents of the buffer. The |

|client function should not change the contents of the buffer. |

|IN: |Error *errorList |A pointer to an error data structure created with calls to ‘addError’ |

|RETURN: |NULL if errorList is NULL or if it contains an invalid error code or if there are no more error codes in the |

| |list |

| |Otherwise, a pointer to a character array containing the text for this error |

|if errorList is NULL |

|return NULL |

|else if errorList is empty |

|return NULL |

|else if errorList contains no more books |

|return NULL |

|else |

|increment current flag to next entry |

|return data from first entry |

|mapError |

|This function maps an error code to a user-friendly textual error. The function is used by ‘getFirstError’ and ‘getNextError’ |

|internally and is not intended for use by any other functions. |

|IN: |int errorCode |the error code being mapped to error text |

|RETURN: |a pointer to an internal character buffer containing a textual error message for ‘errorCode’ |

| |

|addError |

|This function adds an error code to and Error data structure. If the Error data structure does not exist, it allocates memory for |

|it. When the Error data structure is no longer needed, the memory should be freed with a call to freeError |

|IN: |int errorCode |the error code to add to the Error data structure |

| |Error **errorData |a pointer to an address of an Error data structure. If the contents of |

| | |the pointer is NULL, memory is allocated for the structure and the |

| | |pointer is set to the allocated memory |

|RETURN: |ELIB_OK if the error code is added or if the memory for a new Error data structure is allocated |

| |ELIB_NOMEMORY if the attempt to allocate memory for the new error or a new Error data structure fails |

| |

|freeError |

|This function frees the memory associated with an Error data structure and sets the contents of the pointer to the structure to |

|NULL. |

|IN: |Error **errorData |a pointer to an address of an Error data structure |

|RETURN: |This function is void, it returns no value |

| |

|invalidName |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_NAME |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidAddress |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_ADDRESS |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidTelephone |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_PHONE |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidEmail |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_EMAIL |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidSSN |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_SSN |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidMaidenName |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error |

|ELIB_INVALID_MAIDENNAME |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidUserName |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_USERNAME |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidPassword |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_PASSWORD |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|invalidLogin |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_INVALID_LOGIN |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|memberRecordNotFound |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_MEMBERNOTFOUND |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|memberNameInUse |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_MEMBEREXISTS |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|bookRecordNotFound |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_BOOKNOTFOUND |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

|noMemory |

|This function returns a pointer to a character buffer containing a user-friendly error message for the error ELIB_NOMEMORY |

|RETURN: |a pointer to a character buffer containing the error text |

|return pointer to error text |

|Please refer to 6.3 for the text of this error |

10 Module Interface– Output Subsystem

1 Implementation Elements

|output.c |

|homepage |

|This module outputs the homepage to the user. A different homepage will be output if the user is logged off, a member logged in, or|

|staff member logged in |

|IN: |ErrorData *ed |a pointer to a error type |

| |integer setLoggedIn |determines if user is logged in |

| | | |

|RETURN: |A pointer to an error type |

| |

|call beginPage |

| |

|if setLoggedIn is true |

|set cookie |

| |

|if member type is member |

|output “Welcome“ |

|get user name |

|output user name |

|else if member type is logged-in staff output “Welcome Administrator” |

|call changeDateForm |

|else if member type is non-member |

|then output welcome message |

|else |

|set error |

|output error |

| |

|call endPage |

|return error |

| |

|displayContents |

|This module outputs the contents of a book to the user |

|IN: |ErrorData *ed |a pointer to an error type |

| |Book *b |a pointer to book data |

| | | |

|RETURN: |a pointer to an error type |

|call beginPage |

| |

|if member type = member |

|if Book != Null |

|display book contents |

|else |

|set error |

|output error |

|else |

|set error |

|output error |

| |

|call endPage |

|return error |

| |

|bookDetails |

|This module outputs the detail of a book to the user |

|IN: |ErrorData *ed |a pointer to an error type |

| |Book *b |a pointer to book data |

| | | |

|RETURN: |a pointer to an error type |

|call beginPage |

| |

|if Book != Null |

|display book contents |

|if member type = member |

|output checkout/Hold link |

|if member type = staff |

|output recall link |

|else |

|set error |

|output error |

| |

|call endPage |

|return error |

| |

|searchResults |

|IN: |ErrorData *ed |a pointer to an error type |

| |Book *b |a pointer to the data of a book |

| | | |

|RETURN: |a pointer to an error type |

|call beginPage |

|if book data = null |

|output message |

|else |

|while book data != null |

|output book data |

|get next book data |

| |

|call endPage |

|return error |

| |

|advancedSearch |

|IN: |ErrorData *ed |a pointer to an error type |

| | | |

| | | |

|RETURN: |a pointer to an error type |

|call beginPage |

| |

|output forms for advanced search |

| |

|call endPage |

|return error |

| |

|bookList |

|IN: |ErrorData *ed |a pointer to an error type |

| |BookList *bl |a pointer to a list of book data |

| | | |

|RETURN: |a pointer to an error type |

|call beginPage |

| |

|if member type = staff |

|while book data != null |

|output book info |

|get next book |

|else |

|set error |

|output error |

| |

| |

|call endPage |

|return error |

| |

|memberList |

|IN: |ErrorData *ed |a pointer to an error type |

| |memberList *ac |a pointer to member data |

|RETURN: |a pointer to an error type |

|call beginPage |

| |

|if member type = staff |

|get first member data |

|while account data != null |

|output account data |

|get next account data |

|else |

|set error |

|output error |

| |

|call endPage |

|return error |

| |

|history |

|IN: |ErrorData *ed |a pointer to an error type |

| |HistoryList *hl |a pointer to list of history data |

|RETURN: |a pointer to an error type |

| |

|call beginPage |

| |

|if history data != NULL |

|get first history data |

|while history data != null |

|output history |

|get next history item |

|else |

|set error |

|output error |

| |

|call endPage |

|return error |

| |

|register |

|IN: |ErrorData *ed |a pointer to an error type |

| |MemberData *md |a pointer to account data |

| | | |

|RETURN: |a pointer to an error type |

|call beginPage |

| |

|if account data = null |

|output blank form |

|else |

|output form and data |

| |

|call endPage |

|return error |

| |

|updateInfo |

|IN: |ErrorData *ed |a pointer to an error type |

| |MemberData *md |a pointer to account data |

| | | |

|RETURN: |a pointer to an error type |

|call beginPage |

| |

|output non-changeable data |

|output data and change form |

| |

|call endPage |

|return error |

11 Module Interface– Forms Subsystem

1 Implementation Elements

|Forms.c |

|searchBar |

|This module outputs a search bar |

|IN: |VOID | |

| | | |

| | | |

|RETURN: |VOID |

|begin table, row and column |

|begin form |

|output textbox for search |

|output button for submit |

|end form |

| |

|output link for advanced search |

| |

|end table row, column |

| |

|loginForm |

|This module outputs a login form |

|IN: |VOID | |

|RETURN: |VOID |

|begin table, row column |

| |

|begin form |

|output textbox for login name |

|output password box for password |

|output button for submit |

|end form |

| |

|output link for forgot password |

|output link for register |

| |

|end row, column, table |

| |

|changeDateForm |

|This module inputs the change data information for a staff member |

|IN: |VOID | |

|RETURN: VOID |

|if member = staff |

|begin form |

|output textbox for change date |

|output button for submit |

12 Module Interface – HTML Subsystem

1 Implementation Elements

|HTML.c |

|beginPage |

|This module begin the creation of a webpage |

|IN: |ErrorData *ed |a pointer to an error type |

| | | |

| | | |

|RETURN: |return an ErrorData pointer |

|output HTML tags to begin page |

|output the begining of a table, row, column |

| |

|if user = member |

|call memberNavigation |

|else if user = staff |

|call staffNavigation |

|else if user = non-member |

|call nonMemberNavigation |

|else |

|set error |

|output error |

| |

|while error != Null |

|output error |

|get next error |

| |

|return error |

| |

|staffNavigation |

|This module outputs a navigation pane for a staff member |

|IN: |VOID | |

|RETURN: |VOID |

|output home link |

|output reports links |

|output logout links |

| |

|memberNavigation |

|This module outputs the member navigation pane |

|IN: |VOID | |

|RETURN: VOID |

|output home link |

|output history link |

|output update account link |

|output logout link |

|output cancel membership link |

|nonMemberNavigation |

|This module outputs the non-member navigation pane |

|IN: |VOID | |

|RETURN: VOID |

|output home link |

|call loginForm |

| |

|date |

|This module outputs the date |

|IN: |VOID | |

|RETURN: VOID |

|get system date |

|output date |

| |

|header |

|This module outputs the header |

|IN: |VOID | |

|RETURN: VOID |

|Output e-lib logo |

|call searchBar |

| |

|header |

|This module outputs the elements to end the HTML page |

|IN: |VOID | |

|RETURN: VOID |

|Output end column, row, table |

|Output ending HTML statement |

13 Module Interface –Form Elements Subsystem

1 Implementation Elements

|FormElements.c |

|beginform |

|This module begins a form |

|IN: |char *method |pointer to an array the gives the method |

| |char *value |pointer to an array that gives the value |

| | | |

|RETURN: |VOID |

|Output begin elements of a form |

| |

|endForm |

|This module end a form |

|IN: |VOID | |

|RETURN: |VOID |

|output element to end form |

| |

|textBox |

|This module outputs a textbox |

|IN: |char *name |a pointer to an array containing the name of the text box |

| | | |

| | | |

| | | |

|RETURN: VOID |

|output textbox |

| |

|button |

|This module outputs a button |

|IN: |char *value | a pointer to an array with the value |

|RETURN: VOID |

|output buton |

| |

|radioButton |

|This module outputs a radio button |

|IN: |VOID | |

|RETURN: VOID |

|output radio button |

| |

|checkBox |

|This module outputs a check box |

|IN: |VOID | |

|RETURN: VOID |

|Output check box |

| |

|menu |

|This module outputs a menu |

|IN: |VOID | |

|RETURN: VOID |

|output menu |

2 Error Messages

Here we provide a list of error constants used throughout E-LIB code along with the error text associated with each code if relevant. Technically, this first constant, ELIB_OK, does not indicate an error condition and there is no associated text, but it is included here for completeness.

|ELIB_OK | |

|ELIB_BOOKNOTFOUND |Your book was not located |

|ELIB_MEMBERNOTFOUND |Your membership information was not found |

|ELIB_HISTORYNOTFOUND |No history available on requested user |

|ELIB_MEMBEREXISTS |No record of member present in database |

|ELIB_DATAERROR |Error was encountered while retrieving data |

|ELIB_NOMEMORY |No available memory resources remain |

|ELIB_INVALID_NAME |Name is not valid |

|ELIB_INVALID_ADDRESS |Address is no valid |

|ELIB_INVALID_PHONE |Phone number is not valid |

|ELIB_INVALID_EMAIL |Email is not valid |

|ELIB_INVALID_SSN |Social security number is not valid |

|ELIB_INVALID_MAIDENNAME |Maiden name is not valid |

|ELIB_INVALID_USERNAME |Username is not valid |

|ELIB_INVALID_PASSWORD |Password is not valid |

|ELIB_INVALID_LOGIN |Invalid Login |

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches