Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Copyright 2006-2011 The Aricent Group. All Rights Reserved. No part of this ocument ma! "e repro uce # store in a retrie$a% s!stem# istri"ute or transmitte # in an! form# or "! an! means# e%ectronic or otherwise# inc%u ing photocop!ing# reprinting# or recor ing# for an! purpose# without the e&press prior written permission of The Aricent 'roup. Printed in ________ TRA !"AR#$% Aricent an the Aricent (ogo are mar)s an registere tra emar)s of The Aricent 'roup in the *.S. an certain other countries. The use of these tra emar)s without Aricent+s prior written consent is strict%! prohi"ite . ,ther thir part! tra emar)s reference are the propert! of their respecti$e owners. -%ease note that the a"o$e %ist is not a%%.inc%usi$e# an the a"sence of an! mar) from this %ist oes not mean that it is not an Aricent tra emar). &$C'A&"!R The information in this "oo) is pro$i e /AS . IS0# without warrant! of an! )in # e&press or imp%ie # inc%u ing "ut not %imite to a warrant! of merchanta"i%it!# fitness for an! particu%ar purpose# tit%e or non.infringement of thir part! rights# an Aricent specifica%%! isc%aims a%% other warranties# con itions or representations. This ocument is pro$i e for informationa% purposes on%!# an shou% not "e construe as a representation or a commitment on the part of Aricent. Information in this ocument is su"1ect to change without notice.
R!()!$T$ 2or information re3uests or for o"taining permission for the use of this wor)# p%ease su"mit a written re3uest to: Corporate 4ar)eting an (ega%# The Aricent 'roup# ,ne Tower Center 5ou%e$ar # 16th 2%oor# East 5runswic)# N7 06618# *SA. *C)"!+T +o.% AR&C!+T%
R!,&$&*+ -&$T*R.
Revision No. 0.1 Date Description of Change Draft 0.1 Author Shagun# Vasu ha 'o)ha%e# Ar$in Sharma# Amantu%%ah Af9a%# Sa%im 7a$e Reviewed & Approved By Rashi Arora
Contents
C A!"#R $% 1. &+TR* )CT&*+________________________________________________/ 1.1 -*R-,SE....................................................................................................... : 1.; SC,-E........................................................................................................... : 1.< DE2INITI,NS AND ACR,N=4S..........................................................................: 1.<.1 Definitions.................................................................................................. : 1.<.; Acron!ms.................................................................................................. 6 1.> RE2ERENCES................................................................................................. 6 1.? D,C*4ENT ,R'ANISATI,N.............................................................................6 1.8 A--R,VA(S AND A*T@,RIAATI,NS..................................................................6 1.: DISTRI5*TI,N................................................................................................ 6 2. -&G- '!,!' !$&G+___________________________________________0 ;.1 (EVE( 0 DESI'N DESCRI-TI,N.......................................................................B ;.1.1 Interface Description ..............................................................................10 ;.; (EVE( 1 DESI'N DESCRI-TI,N ....................................................................10 ;.;.1 4o u%e name: Authentication S!stemC(e$e%.0D.......................................11 ;.;.1.1 Decomposition Description.........................................................11 ;.;.1.1.1 4o u%e Description................................................................11 ;.;.1.; Depen enc! Description............................................................1; ;.< (EVE( ; DESI'N DESCRI-TI,N ....................................................................1< ;.<.1 4o u%e name: InputC(e$e%.1D...................................................................1< ;.<.1.1 Decomposition Description.........................................................1< ;.<.1.1.1 4o u%e Description................................................................1< ;.<.1.; Depen enc! Description...........................................................1> ;.<.; 4o u%e name: Authentication C(e$e%.;D...................................................1? ;.<.;.1 Decomposition Description.........................................................1? ;.<.;.1.1 4o u%e Description................................................................18 ;.<.;.; Depen enc! Description............................................................1: ;.> STR*CT*RE DIA'RA4...........................................................................1: ;.>.1 Structure name: *SER............................................................................1: ;.>.; Structure name: SERVER.......................................................................16 ;.>.< Structure name: threa Efun.....................................................................1B 1. A'T!R+AT! !$&G+ __________________________________________10 <.1 A(TERNATE DESI'NS...................................................................................1B <.; DESI'N EVA(*ATI,N RE-,RT ;0 <.< DESI'N (I4ITATI,NS....................................................................................;0 2. !TA&'! !$&G+____________________________________________20 >.1 Detai%e Data Design ...............................................................................;0 Ta"%e >.1.1: Data Design for 'enera% 4acros.................................................;1 Ta"%e : >.1.; Design for Error @an %ing 4acros..............................................;; ERR,R @AND(IN' 4ACR,S............................................................;; NA4E ;; DESCRI-TI,N.................................................................................;; VA(*E ;; 2I(EEN,TE,-EN.............................................................................;; If there is error opening a fi%e...............................................................;; 0 ;; 2I(EEN,TEC(,SE...........................................................................;; If there is error c%osing a fi%e.................................................................;;
1
C A!"#R &%
C A!"#R '%
C A!"#R (%
1 ;; *NEF-ECTEDEE,2.........................................................................;; If a fi%e reaches en of fi%e une&pecte %!.................................................;; ; ;; 4E4,R=E2AI(*RE..........................................................................;; If memor! is not a%%ocate ...................................................................;; < ;; READEERR,R.................................................................................;; If there is error in rea ing....................................................................;; > ;; GRITEEERR,R...............................................................................;; If there is error in writing.....................................................................;; ? ;; RECEIVEEC(IENT............................................................................;; If there is an error in recei$ing from c%ient...............................................;; 8 ;; RECEIVEESERVER..........................................................................;; If there is error in recei$ing from ser$er..................................................;; : ;; SENDEC(IENT.................................................................................;; If there is error in sen ing to c%ient........................................................;; 6 ;; SENDESERVER...............................................................................;; If there is erro in sen ing to ser$er........................................................;; B ;; >.1.1 Data Structure:Structure for user etai%s.................................................;< >.1 DETAI(ED 4,D*(E DESI'N ..........................................................................;>
*igures
2igure ;.1 : (e$e% 0 D2D: Conte&t Diagram HHHHHHHHHHHHHHHHHHHHHHHHHHH..0B 2igure ;.; : (e$e% 1 D2D: Conte&t Diagram HHHHHHHHHHHHHHHHHHHHHHHHHHH..10 2igure ;.<.1 : (e$e% ; D2D: Conte&t DiagramHHHHHHHHHHHHHHHHHHHHHHHHHHH1< 2igure ;.<.; : (e$e% ; D2D: Conte&t DiagramHHHHHHHHHHHHHHHHHHHHHHHHHHH1? 2igure ;.>.1 : Structure DiagramCuserD HHHHHHHHHHHHHHHHHHHHHHHHHHHHH..1: 2igure ;.>.1 : Structure DiagramCser$erDHHHHHHHHHHHHHHHHHHHHHHHHHHHHH16 2igure ;.>.1 : Structure DiagramCthrea EfunD..HHHHHHHHHHHHHHHHHHHHHHHHHH..16
"a12es
C A!"#R 3% C A!"#R 4% C A!"#R 5% C A!"#R 6% C A!"#R 7% C A!"#R $8% C A!"#R $$% C A!"#R $&%
TA3'! 1-1% !4&+&T&*+$ )$! TA3'! 1-1% !4&+&T&*+$ )$! TA3'! 1-2% ACR*+."$ )$! TA3'! 1-2% ACR*+."$ )$! TA3'! 1-1% APPR*,A'$ A+ TA3'! 1-1% APPR*,A'$ A+
A)T-*R&6AT&*+$_____________________5 A)T-*R&6AT&*+$_____________________5
Chapter
$
1.,ntroduction 1.1 !urpose
To imp%ement an Authentication S!stem# which isp%a!s a fi%e to the authenticate user.
1.2 Scope
AS imp%ementation ena"%es the user to $iew a fi%e present on the s!stem# if heIshe is authenticate to $iew that fi%e. AS s!stem registers new user an store the user etai%s in ata "ase "! using appropriate encr!ption a%gorithm to store the passwor .
1.1.2 Acronyms
T78le 1-2% Acrony9s )sed in this ocu9ent
Acrony9 AS !:pl7n7tion Authentication S!stem
1.2 References
www.wi)ipe ia.com
1./ Distri1ution
"a12e $9(% Distri1ution
Copy +o. 1. ;. -older<s esign7tion -ro1ect 4anager Team mem"ers &ssue 7te ;0.01.;01> ;0.01.;01>
8
Chapter
&
2. igh 0eve2 Design 2.1 0eve2 8 Design Description
Figure 2.1: Level 0 DFD: Context Diagram In this conte&t iagram# the user is represente authentication s!stem as a process. as an entit! an the
The user sen s the %ogin etai%s Cuser etai%sD to the authentication s!stem an recei$es the fi%e content if the user is authenticate .
AUTHENTICATION SYSTEM(AS)
$8
2.2.1.1
Decomposition Description
Authentication s!stem after successfu% connection with the user ta)es the user etai%s an chec)s whether the user is authenticate to $iew the content of the fi%e or not.5ase on the authentication resu%t it sen s the fi%e content to the user an terminates the connection after recei$ing ac)now%e gment from the user. @ence we ecompose the Authentication s!stem into fo%%owing processes that consists of the these functions. Connection Esta"%ishment Input Authentication Termination
"odule 2 % &nput This process gi$es user an option to %ogin CE&isting *serD an register CNew userD. 5ase on the choice it ta)es the user etai%s C*sername an passwor D an sen s the etai%s to the authentication process.
AUTHENTICATION SYSTEM(AS)
)ser det7ils % *ser name an -asswor *utput % It sen s the user etai%s to the authentication process.
"odule 1 % Authentic7tion This process ta)es the user etai%s an matches the user etai%s in the ata"ase. 5ase on the resu%t the fi%e is sent to the user an recei$es the ac)now%e gment from the user. 7t7 escription &nput % )ser et7ils% *sername an passwor .
2.2.1.2
Dependency Description
The Depen enc! Description is represente "! Structure Charts# which are use in esign to show how software is ecompose into mo u%es. Deri$e the Structure Charts from D2D of this %e$e%. This wi%% capture the epen enc! information.
$&
Figure 2.3.1: Level 2 DFD: Context Diagram The Input process in the %e$e%.1 D2D un ergoes ecomposition into man! su". processes each with a uni3ue functiona%it! in the %e$e%.; D2D.
2.1.1.1
Decomposition Description
Input process gi$es two option to the userCi.e. New user or E&isting userD .E&isting user wi%% enter username an passwor .New user wi%% ha$e to register "! gi$ing uni3ue username an passwor .*ser etai%s are then sent to the authentication process. @ence we ecompose the input into fo%%owing processes that consists of the these functions. (ogin Register
AUTHENTICATION SYSTEM(AS)
This process accepts the user etai%sCusername an passwor D from the e&isting user an sen s the same to the authentication process. 7t7 escription &nput % )ser det7ils% The input to this process is user etai%s Cusername an passwor D of e&isting user. *utput % The output of this process is user etai%s Cusername an passwor D of e&isting user. "odule 2 % Register This process a%%ows a new user to register with uni3ue username an passwor an sen s these etai%s to the authentication process for $a%i it!. 7t7 escription &nput % )ser det7ils% *ser name an -asswor of new user. *utput % It sen s the user etai%s to the authentication process.
$(
Figure 2.3.2: Level 2 DFD: Context Diagram The Authentication process in the %e$e%.1 D2D un ergoes ecomposition into man! su".processes each with a uni3ue functiona%it! in the %e$e%.; D2D.
2.1.2.1
Decomposition Description
The authentication process accepts username an passwor . It chec)s the a$ai%a"i%it! of the username an sen s the encr!pte passwor to the ata"ase. 2or correct user etai%s fi%e is sent to the user.
AUTHENTICATION SYSTEM(AS)
@ence we ecompose the Authentication process into fo%%owing processes that consists of the these functions. Chec) Encr!ption Sen fi%e
$4
2.1.2.2
Dependency Description
The Depen enc! Description is represente "! Structure Charts# which are use in esign to show how software is ecompose into mo u%es. Deri$e the Structure Charts from D2D of this %e$e%. This wi%% capture the epen enc! information.
i7gr79AuserB
AUTHENTICATION SYSTEM(AS)
$6
Chapter
'
1.A2ternate Design 1.1 A2ternate Designs
2or) can "e use to create separate processes in or er to han %e each c%inet instea of using threa .
AUTHENTICATION SYSTEM(AS)
Instea of creating a new threa for each c%ient threa poo% can "e use .
Chapter
(
2.Detai2ed Design
(.$ Detai2ed Data Design
&8
Table 4-1.1:
7t7
Gener7l "7cros +79e S*CCESS 2AI(*RE 5*2 4AF C@,ICE 4=-,RT 4AFSIAE escription If a function return successfu%%!# returns S*CCESS If a function not return successfu%%!# returns 2AI(*RE 4a&imum %ength of the "uffer 4a&imum %ength of the hash ta"%e T!pe of user. New or E&isting Stores the ser$er+s port num"er 4a&imum si9e of "uffer of each %ine of fi%e ,7lue 1 0 10;> 100 ;0 <8>? ?0
AUTHENTICATION SYSTEM(AS)
T78le % 2-1.2 Design for Error Handling Macros !RR*R -A+ '&+G "ACR*$ +A"! 4&'!_+*T_*P!+ 4&'!_+*T_C'*$! )+!CP!CT! _!*4 "!"*R._4A&')R! R!A _!RR*R DR&T!_!RR*R R!C!&,!_C'&!+T R!C!&,!_$!R,!R $!+ _C'&!+T $!+ _$!R,!R !$CR&PT&*+ &@ there is error opening 7 @ile &@ there is error closing 7 @ile &@ 7 @ile re7ches end o@ @ile une:pectedly &@ 9e9ory is not 7lloc7ted &@ there is error in re7ding &@ there is error in ?riting &@ there is 7n error in receiving @ro9 client &@ there is error in receiving @ro9 server &@ there is error in sending to client &@ there is erro in sending to server 0 1 2 1 2 ; 6 / 5 0 ,A')!
&&
TRAC&+G "ACR*$ +A"! N,ETRACE 5RIE2ETRACE DETAI(EDETRACE . CRITICA(EERR,R 4A7,REERR,R 4IN,REERR,R !$CR&PT&*+ If we want no tracing If we want tracing in a "rief manner If we want tracing in a etai%e manner If error is critica% If error is ma1or If error is minor ,A')! 1 ; < 1 ; <
G'*3A' ,AR&A3'!$ +A"! int gEerrorE%e$e% int gEtraceE%e$e% *ser JhashKL -threa Emute&Et mute Int s Int numEusers !$CR&PT&*+ Error han %ing %e$e% Tracing %e$e% '%o"a% hash ta"%e for storing ata"ase 2or putting a mute& %oc) on the $aria"%e mai% Soc)et escriptor of ser$er Count of num"er of authenticate users in the ata"ase
AUTHENTICATION SYSTEM(AS)
Char JusernameNIJ@o% s username of a userJI Char Jpasswor NIJ@o% s passwor of a userJI Char JuserEt!peNIJ@o% s weteher user is new or e&istingJI Struct user Jne&tN ON
ATA3A$!
int getdatabase()
(oa s the contents of the ata"ase fi%e into the hash ta"%e
memsetC"uffer#0#4AFSIAED fgetsC"uffer#4AFSIAE#fpD to)eniseC"uffer#wor D o"1 P Cuser JDma%%ocCsi9eofCuserDDN %en EnamePstr%enCwor K0LD o"1.Qusername P Cchar JDma%%ocC%enEnameJsi9eofCcharDD strncp!Co"1.Qusername#wor K0L#%enEnameD %en EpassPstr%enCwor K1LD o"1.Qpasswor P Cchar JDma%%ocC%enEpassJsi9eofCcharDD strncp!Co"1.Qpasswor #wor K1L#%enEpassD o"1.Qne&tPN*(( )Phashta"%eCo"1.QusernameD
ARICENT: AR,C#N" C)N*,D#N",A0
int numberofusers(FILE *)
2in s the num"er of %ines in the fi%e which correspon s to the num"er of users in the ata"ase NA 2i%e pointer Num"er of %ines is ca%cu%ate Num"er of users get ata"aseCD NA
-SE*D, C,DE 2*NCTI,N : int num"erofusersC2I(E JfpD 5E'IN : 1.0 ;.0 ;.1 ;.; ;.< ;.> ;.? <.0 user P 0 whi%eCen of fi%e not reache D memsetC"uffer#0#4AFSIAED fgetsC"uffer#4AFSIAE#fpD ifCen of fi%eD "rea) user P user R1 return user END
AUTHENTICATION SYSTEM(AS)
-urposeI Description -re. re3uisites InputCsD ,utputCsD Return Va%ueCsD Ca%%e 5! Ca%%s
To)enise the string "uffer an store it into wor NA ,rigina% string to "e to)eni9e "uffer an empt! to)eni9e string wor To)enise the string "uffer an store it into wor NA get ata"aseCD#threa EfunCD NA -SE*D, C,DE 2*NCTI,N : to)eniseCchar J"uffer#char Jwor KLD 5E'IN 1.0 ;.0 <.0 <.1 <.; >.0 iP0 wor KiLPstrto)C"uffer#0 Sn/D whi%eCwor KiL is not N*((D iRR wor KiLPstrto)CN*((#0 Sn/D END
"* )'! 2% -A$-rotot!pe -urposeI Description -re. re3uisites InputCsD ,utputCsD Return Va%ueCsD Ca%%e 5! Ca%%s
5E'IN 1.0: ;.0 <.0 <.1 >.0 ?.0 8.0 sum P 0 %en P str%enCstringD forCiP0 increments "! 1 ti%% %enD sum RP stringKiL in e&PsumT100 return in e& END
:.>.>.1 memsetC"uf#0#4AFD
AUTHENTICATION SYSTEM(AS)
:.>.>.; recei$eEuserEcre entia%Cconnf #"ufferD :.>.>.< to)eniseC"uffer#to)enD :.>.>.> insertEhashta"%eCto)enK1L#to)enK;LD :.>.>.? pthrea Emute&E%oc)CUmuteD :.>.>.8 f%agP1 :.>.>.: "rea) :.>.? e%se :.>.?.1 f%agP0 :.>.?.; chanceRR :.>.?.< pthrea Emute&Eun%oc)CUmuteD :.>.?.> continue :.? :.?.1 :.?.; :.?.< e%se retPauthenticationEchec)Cto)enK1L#to)enK;LD sen Eac)now%e gementEtoEuserCret#connf D ifCretPPS*CCESSD
:.?.<.1 f%agP; :.?.<.; sen EtoEc%ientCf #connf D :.?.<.< "rea) :.?.> e%se :.?.>.1 f%agP0 :.?.>.; iP0 :.?.>.< chanceRR 6.0 6.1 B.0 10.0 11.0 ifCf%agPP1D sen EtoEc%ientCf #connf D c%oseCconnf D pthrea Ee&itCN*((D END
&6
Ca%%s
Sen E%oginEcre entia%CD#rea Esoc)etCD -SE*D, C,DE 2*NCTI,N : int inputE%oginEcre entia%sCint s D 1.0 ;.0 ;.1 ;.; ;.< ;.<.1 ;.<.; ;.<.< ;.<.> ;.<.? ;.<.8 ;.<.: ;.<.6 ;.<.B 5E'IN whi%eC1D printfCinput 1 for new user an ; for e&isitingD scanfC/T 0#UchoiceD switchCchoiceD case 1 whi%eC<QchanceD strcp!Ct!peEuser#/NewEuser0D input username memsetC"uf#0#4AFD strcatC"uf#t!peEuserD strcatC"uf#0 /D strcatC"uf#usernameD strcatC"uf#0V0D
;.<.10 sen E%oginEcre entia%C"uf#s D ;.<.11 retPrea Esoc)etCs D ;.<.1; ifCretPPS*CCESSD ;.<.1< "rea) ;.<.1> e%se ;.<.1? chanceRR ;.<.18 ifCchanceP<D ;.<.1: return 2AI(*RE ;.<.16 memsetC"uf#0#4AFD ;.<.1B input passwor ;.<.;0 strcatC"uf#t!peEuserD ;.<.;1 strcatC"uf#0 /D ;.<.;; strcatC"uf#usernameD ;.<.;< strcatC"uf#0 /D ;.<.;> strcatC"uf#passwor D ;.<.;? strcatC"uf#0V0D ;.<.;8 sen E%oginEcre entia%C"uf#s D ;.> ;.>.1 ;.>.; ;.>.< ;.>.> ;.>.? case ; whi%eC<QchanceD strcp!Ct!peEuser#/E&isitingEuser0D input username memsetC"uf#0#4AFD strcatC"uf#t!peEuserD
AUTHENTICATION SYSTEM(AS)
;.>.10 strcatC"uf#0V0D ;.>.11 sen EuserEcre entia%C"uf#s D ;.>.1; retPrea Esoc)etCs D ;.>.1< ifCretPP2AI(*RED ;.>.1> f%agP0 ;.>.1? chanceRR ;.>.18 e%se ;.>.1: f%agP1 ;.>.16 "rea) ;.? ;.?.1 <.0 <.1 >.0 >.1 >.; efau%t printfCwrong choiceD ifCf%agWP1D return 2AI(*RE e%se return S*CCESS END
'8
>.0 whi%eC"!teswritten X %enD >.1 written P writeCs # "ufR"!teswritten# %en."!teswrittenD >.; ifC0 Q writtenD >.;.1 ?.0 ff%ushCst outD 8.0 return S*CCESS :.0 END return 2AI(*RE >.< "!teswritten P "!teswritten R written
AUTHENTICATION SYSTEM(AS)
-SE*D, C,DE 2*NCTI,N : $oi sen Eac)now%e gmentEtoEuserCint ret# int connf D 1.0 5E'IN ;.0 char "ufK10L <.0 memsetC"uf# 0# 10DN >.0 ifCS*CCESS PP retD >.1 strcp!C"uf# /S*CCESSV0DN >.; writeCconnf # "uf# str%enC"ufDDN ?.0 e%se ?.1 strcp!C"uf# /2AI(*REV0DN ?.; writeCconnf # "uf# str%enC"ufDDN 8.0 END
AUTHENTICATION SYSTEM(AS)
8.0 e%se ifC0 PP strcmpC"uf# /2AI(*RE0DD 8.1 return 2AI(*RE :.0 return S*CCESS 6.0 END
Va%ueCsD Ca%%e 5! Ca%%s threa EfunCD hashCD#writeEtoEfi%eCD -SE*D, C,DE 2*NCTI,N : $oi insertEhashta"%eCchar Jusername#char Jpasswor D ?.0 8.0 :.0 6.0 B.0 5E'IN user Jtemp %en P str%enCusernameD %enEpassPstr%enCpasswor D temp P Cuser JDma%%ocCsi9eofCuserDD
10.0 temp.QusernamePCcharJDma%%ocCC%enR1DJsi9eofCcharDD 11.0 strncp!Ctemp.Qusername#username#%enD 1;.0 temp.Qpasswor PCcharJDma%%ocCC%enEpassR1DJsi9eofCcharDD 1<.0 strncp!Ctemp.Qpasswor #passwor #%enEpassD 1>.0 temp.Qne&t P N*(( 1?.0 in e& P hashCusernameD 1; 1;.1 1;.; 1< 1<.1 1<.; 1<.< 1> 1? ifChashta"%eKin e&L is N*((D hashta"%eKin e&LPtemp numEusers RP1 e%se o"1.Qne&tPhashta"%eKin e&L hashta"%eKin e&LPtemp numEuser RP 1 writeEtoEfi%eCusername#passwor D END
AUTHENTICATION SYSTEM(AS)
5E'IN 1.0 ;.0 ;.1 <.0 <.1.1 <.1.; >.0 fp P fopenCopen fi%e in appen mo eD ifCfp is N*((D return 2AI(*RE e%se fprintfCusernameD fprintfCpasswor D return S*CCESS
10.0 END
'4
T* C'&!+T
2*NCTI,N : $oi sen EtoEc%ientCint f # int s D 1.0 5E'IN ;.0 struct stat s <.0 int si9e#n P 0#"!teswritten P 0#written P 0 >.0 fstatCf # UsD ?.0 si9e P s.stEsi9e 8.0 char J"uf :.0 "uf P Cchar JDma%%ocCCsi9eR1DJsi9eofCcharDD 6.0 ifCN*(( PP "ufD 6.1 printfC/Sn memor! not a$ai%a"%e in heap0D 6.; c%oseCs D 6.< pthrea Ee&itCN*((D B.0 memsetC"uf# 0# Csi9eR1DD 10.0 n P rea Cf # "uf# si9eR1D 11.0 "ufKn.1L P YV+ 1;.0 whi%eC"!teswritten X nD 1;.1 written P writeCs # "ufR"!teswritten# n."!teswrittenD 1;.; ifC0 Q writtenD 1;.;.1 printfC/SnError in writing to soc)et0D 1;.;.; c%oseCs D 1;.;.< pthrea Ee&itCN*((D 1;.< "!teswritten P "!teswritten R written 1;.0 END
AUTHENTICATION SYSTEM(AS)
re3uisites InputCsD ,utputCsD Return Va%ueCsD Ca%%e 5! Ca%%s Recei$es signa% SI'INT C%oses the ser$er soc)et an terminates the ser$er NA Ser$er 4ain function freeEuserCD -SE*D, C,DE 2*NCTI,N : $oi signa%Ehan %erCint signoD 1.0 ;.0 ;.1 ;.; ;.< <.0 5E'IN ifCsignoPPSI'INTD c%oseCs D freeEuserCD pthrea Ee&itCN*((D END
void free_user()
2rees the user mermor! a%%ocate
AUTHENTICATION SYSTEM(AS)
(8
EuserCD#get ata"aseCD#insertEhashEta"%eCD#authenticationEchec)CD#writeEtoEfi%eCD Ca%%s NA -SE*D, C,DE 2*NCTI,N : $oi errorEhan %erCint %e$e%#int erco eD 1.0 ;.0 ;.1 ;.1.1 <.0 5E'IN Char JstrKL PM ifferent error messegesO IfCgEerrorE%e$e% QP %e$e%D printfCstrKerco eLD END