slapi-plugin.h 286 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628
  1. /* BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2009 Red Hat, Inc.
  36. * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
  37. * All rights reserved.
  38. *
  39. * Contributors:
  40. * Hewlett-Packard Development Company, L.P.
  41. * Bugfix for bug #195302
  42. *
  43. * END COPYRIGHT BLOCK */
  44. /*! \file slapi-plugin.h
  45. * \brief Public Directory Server plugin interface.
  46. *
  47. * The SLAPI plugin interface allows complex plugins to be created
  48. * for Directory Server.
  49. */
  50. #ifndef _SLAPIPLUGIN
  51. #define _SLAPIPLUGIN
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. #include "prtypes.h"
  56. #include "ldap.h"
  57. #include "prprf.h"
  58. #include "nspr.h"
  59. NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...)
  60. #ifdef __GNUC__
  61. __attribute__ ((format (printf, 3, 4)));
  62. #else
  63. ;
  64. #endif
  65. NSPR_API(char*) PR_smprintf(const char *fmt, ...)
  66. #ifdef __GNUC__
  67. __attribute__ ((format (printf, 1, 2)));
  68. #else
  69. ;
  70. #endif
  71. NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...)
  72. #ifdef __GNUC__
  73. __attribute__ ((format (printf, 2, 3)));
  74. #else
  75. ;
  76. #endif
  77. NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...)
  78. #ifdef __GNUC__
  79. __attribute__ ((format (printf, 2, 3)));
  80. #else
  81. ;
  82. #endif
  83. /* NSPR uses the print macros a bit differently than ANSI C. We
  84. * need to use ll for a 64-bit integer, even when a long is 64-bit.
  85. */
  86. #define NSPRIu64 "llu"
  87. #define NSPRI64 "ll"
  88. /* OpenLDAP uses unsigned long for ber_tag_t and ber_len_t but mozldap uses unsigned int */
  89. /* use this macro for printf statements for ber_tag_t and ber_len_t */
  90. #if defined(USE_OPENLDAP)
  91. #define BERTAG_T "lu"
  92. #define BERLEN_T "lu"
  93. #else
  94. #define BERTAG_T "u"
  95. #define BERLEN_T "u"
  96. #endif
  97. #define DEFINETOSTR(xxx) #xxx
  98. #define STRINGIFYDEFINE(xxx) DEFINETOSTR(xxx)
  99. /* Common check on berval before accessing the contents. */
  100. /* bv is a struct berval *bv */
  101. #define BV_HAS_DATA(bv) ((bv != NULL) && (bv->bv_len > 0) && (bv->bv_val != NULL))
  102. /*
  103. * The slapi_attr_get_flags() routine returns a bitmap that contains one or
  104. * more of these values.
  105. *
  106. * Note that the flag values 0x0010, 0x0020, 0x4000, and 0x8000 are reserved.
  107. */
  108. /**
  109. * Flag indicating that an attribtue is single-valued.
  110. *
  111. * \see slapi_attr_flag_is_set()
  112. * \see slapi_attr_set_flags()
  113. */
  114. #define SLAPI_ATTR_FLAG_SINGLE 0x0001 /* single-valued attribute */
  115. /**
  116. * Flag indicating than an attribute is operational.
  117. *
  118. * \see slapi_attr_flag_is_set()
  119. * \see slapi_attr_set_flags()
  120. */
  121. #define SLAPI_ATTR_FLAG_OPATTR 0x0002 /* operational attribute */
  122. /**
  123. * Flag indicating than an attribute is read-only.
  124. *
  125. * \see slapi_attr_flag_is_set()
  126. * \see slapi_attr_set_flags()
  127. */
  128. #define SLAPI_ATTR_FLAG_READONLY 0x0004 /* read from shipped config file */
  129. /**
  130. * Flag indicating than an attribute is read-only.
  131. *
  132. * This is an alias for #SLAPI_ATTR_FLAG_READONLY.
  133. * \see slapi_attr_flag_is_set()
  134. * \see slapi_attr_set_flags()
  135. */
  136. #define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY /* alias for read only */
  137. /**
  138. * Flag indicating than an attribute is obsolete.
  139. *
  140. * \see slapi_attr_flag_is_set()
  141. * \see slapi_attr_set_flags()
  142. */
  143. #define SLAPI_ATTR_FLAG_OBSOLETE 0x0040 /* an outdated definition */
  144. /**
  145. * Flag indicating that an attribute is collective.
  146. *
  147. * \warning Collective attributes are not supported, so this
  148. * flag has no effect.
  149. * \see slapi_attr_flag_is_set()
  150. * \see slapi_attr_set_flags()
  151. */
  152. #define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080 /* collective (not supported) */
  153. /**
  154. * Flag indicating that an attribute is not modifiable over LDAP.
  155. *
  156. * \see slapi_attr_flag_is_set()
  157. * \see slapi_attr_set_flags()
  158. */
  159. #define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100 /* can't be modified over LDAP */
  160. /**
  161. * Flag to indicate that the attribute value is normalized.
  162. *
  163. * \see slapi_value_set_flags()
  164. * \see slapi_values_set_flags()
  165. */
  166. /* the attr value is normalized */
  167. #define SLAPI_ATTR_FLAG_NORMALIZED \
  168. (SLAPI_ATTR_FLAG_NORMALIZED_CES|SLAPI_ATTR_FLAG_NORMALIZED_CIS)
  169. #define SLAPI_ATTR_FLAG_NORMALIZED_CES 0x0200 /* the attr value is normalized,
  170. but not case-normalized.
  171. Used for DN. */
  172. #define SLAPI_ATTR_FLAG_NORMALIZED_CIS 0x0400 /* the attr value is normalized
  173. including case.
  174. Used for DN. */
  175. /**
  176. * Flag to indicate that the attribute value is not exposed if specified.
  177. *
  178. * \see slapi_value_set_flags()
  179. * \see slapi_values_set_flags()
  180. */
  181. #define SLAPI_ATTR_FLAG_NOEXPOSE 0x0800 /* the attr value is not exposed */
  182. /* operation flags */
  183. #define SLAPI_OP_FLAG_INTERNAL 0x00020 /* An operation generated by the core server or a plugin. */
  184. #define SLAPI_OP_FLAG_NEVER_CHAIN 0x00800 /* Do not chain the operation */
  185. #define SLAPI_OP_FLAG_NO_ACCESS_CHECK 0x10000 /* Do not check for access control - bypass them */
  186. #define SLAPI_OP_FLAG_BYPASS_REFERRALS 0x40000 /* Useful for performing internal operations on read-only replica */
  187. #define SLAPI_OC_FLAG_REQUIRED 0x0001
  188. #define SLAPI_OC_FLAG_ALLOWED 0x0002
  189. /*
  190. * access control levels
  191. */
  192. #define SLAPI_ACL_COMPARE 0x01
  193. #define SLAPI_ACL_SEARCH 0x02
  194. #define SLAPI_ACL_READ 0x04
  195. #define SLAPI_ACL_WRITE 0x08
  196. #define SLAPI_ACL_DELETE 0x10
  197. #define SLAPI_ACL_ADD 0x20
  198. #define SLAPI_ACL_SELF 0x40
  199. #define SLAPI_ACL_PROXY 0x80
  200. #define SLAPI_ACL_ALL 0x7f
  201. /*
  202. * filter types
  203. * openldap defines these, but not mozldap
  204. */
  205. #ifndef LDAP_FILTER_AND
  206. #define LDAP_FILTER_AND 0xa0L
  207. #endif
  208. #ifndef LDAP_FILTER_OR
  209. #define LDAP_FILTER_OR 0xa1L
  210. #endif
  211. #ifndef LDAP_FILTER_NOT
  212. #define LDAP_FILTER_NOT 0xa2L
  213. #endif
  214. #ifndef LDAP_FILTER_EQUALITY
  215. #define LDAP_FILTER_EQUALITY 0xa3L
  216. #endif
  217. #ifndef LDAP_FILTER_SUBSTRINGS
  218. #define LDAP_FILTER_SUBSTRINGS 0xa4L
  219. #endif
  220. #ifndef LDAP_FILTER_GE
  221. #define LDAP_FILTER_GE 0xa5L
  222. #endif
  223. #ifndef LDAP_FILTER_LE
  224. #define LDAP_FILTER_LE 0xa6L
  225. #endif
  226. #ifndef LDAP_FILTER_PRESENT
  227. #define LDAP_FILTER_PRESENT 0x87L
  228. #endif
  229. #ifndef LDAP_FILTER_APPROX
  230. #define LDAP_FILTER_APPROX 0xa8L
  231. #endif
  232. #ifndef LDAP_FILTER_EXTENDED
  233. #ifdef LDAP_FILTER_EXT
  234. #define LDAP_FILTER_EXTENDED LDAP_FILTER_EXT
  235. #else
  236. #define LDAP_FILTER_EXTENDED 0xa9L
  237. #endif
  238. #endif
  239. #ifndef LBER_END_OF_SEQORSET
  240. #define LBER_END_OF_SEQORSET ((ber_tag_t) -2) /* 0xfffffffeU */
  241. #endif
  242. #ifndef LDAP_CHANGETYPE_ADD
  243. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_ADD
  244. #define LDAP_CHANGETYPE_ADD LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_ADD
  245. #else
  246. #define LDAP_CHANGETYPE_ADD 1
  247. #endif
  248. #endif
  249. #ifndef LDAP_CHANGETYPE_DELETE
  250. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_DELETE
  251. #define LDAP_CHANGETYPE_DELETE LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_DELETE
  252. #else
  253. #define LDAP_CHANGETYPE_DELETE 2
  254. #endif
  255. #endif
  256. #ifndef LDAP_CHANGETYPE_MODIFY
  257. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_MODIFY
  258. #define LDAP_CHANGETYPE_MODIFY LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_MODIFY
  259. #else
  260. #define LDAP_CHANGETYPE_MODIFY 4
  261. #endif
  262. #endif
  263. #ifndef LDAP_CHANGETYPE_MODDN
  264. #ifdef LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_RENAME
  265. #define LDAP_CHANGETYPE_MODDN LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_RENAME
  266. #else
  267. #define LDAP_CHANGETYPE_MODDN 8
  268. #endif
  269. #endif
  270. #ifndef LDAP_CHANGETYPE_ANY
  271. #define LDAP_CHANGETYPE_ANY (1|2|4|8)
  272. #endif
  273. #ifndef LDAP_CONTROL_PERSISTENTSEARCH
  274. #ifdef LDAP_CONTROL_PERSIST_REQUEST
  275. #define LDAP_CONTROL_PERSISTENTSEARCH LDAP_CONTROL_PERSIST_REQUEST
  276. #else
  277. #define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3"
  278. #endif
  279. #endif
  280. #ifndef LDAP_CONTROL_ENTRYCHANGE
  281. #ifdef LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE
  282. #define LDAP_CONTROL_ENTRYCHANGE LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE
  283. #else
  284. #define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7"
  285. #endif
  286. #endif
  287. #ifndef LDAP_CONTROL_PWEXPIRED
  288. #define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4"
  289. #endif
  290. #ifndef LDAP_CONTROL_PWEXPIRING
  291. #define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5"
  292. #endif
  293. #ifndef LDAP_X_CONTROL_PWPOLICY_REQUEST
  294. #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
  295. #define LDAP_X_CONTROL_PWPOLICY_REQUEST LDAP_CONTROL_PASSWORDPOLICYREQUEST
  296. #else
  297. #define LDAP_X_CONTROL_PWPOLICY_REQUEST "1.3.6.1.4.1.42.2.27.8.5.1"
  298. #endif
  299. #endif
  300. #ifndef LDAP_X_CONTROL_PWPOLICY_RESPONSE
  301. #ifdef LDAP_CONTROL_PASSWORDPOLICYRESPONSE
  302. #define LDAP_X_CONTROL_PWPOLICY_RESPONSE LDAP_CONTROL_PASSWORDPOLICYRESPONSE
  303. #else
  304. #define LDAP_X_CONTROL_PWPOLICY_RESPONSE "1.3.6.1.4.1.42.2.27.8.5.1"
  305. #endif
  306. #endif
  307. #ifndef LDAP_CONTROL_PROXYAUTH
  308. #define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" /* version 1 */
  309. #endif
  310. #ifndef LDAP_CONTROL_PROXIEDAUTH
  311. #ifdef LDAP_CONTROL_PROXY_AUTHZ
  312. #define LDAP_CONTROL_PROXIEDAUTH LDAP_CONTROL_PROXY_AUTHZ
  313. #else
  314. #define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" /* version 2 */
  315. #endif
  316. #endif
  317. #ifndef LDAP_CONTROL_AUTH_REQUEST
  318. #define LDAP_CONTROL_AUTH_REQUEST "2.16.840.1.113730.3.4.16"
  319. #endif
  320. /* Read Entry Controls - PRE & POST */
  321. #ifndef LDAP_CONTROL_PRE_READ_ENTRY
  322. #define LDAP_CONTROL_PRE_READ_ENTRY "1.3.6.1.1.13.1"
  323. #endif
  324. #ifndef LDAP_CONTROL_POST_READ_ENTRY
  325. #define LDAP_CONTROL_POST_READ_ENTRY "1.3.6.1.1.13.2"
  326. #endif
  327. #ifndef LDAP_SORT_CONTROL_MISSING
  328. #define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */
  329. #endif
  330. #ifndef LDAP_INDEX_RANGE_ERROR
  331. #define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */
  332. #endif
  333. /* openldap does not use this */
  334. #ifndef LBER_OVERFLOW
  335. #define LBER_OVERFLOW ((ber_tag_t) -3) /* 0xfffffffdU */
  336. #endif
  337. #ifndef LDAP_MAXINT
  338. /* RFC 4511: maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
  339. #define LDAP_MAXINT (2147483647)
  340. #endif
  341. /* for mozldap builds */
  342. #ifndef LDAP_CANCELLED
  343. #define LDAP_CANCELLED 0x76
  344. #endif
  345. /*
  346. * Sequential access types
  347. */
  348. #define SLAPI_SEQ_FIRST 1
  349. #define SLAPI_SEQ_LAST 2
  350. #define SLAPI_SEQ_PREV 3
  351. #define SLAPI_SEQ_NEXT 4
  352. /*
  353. * return codes from a backend API call
  354. */
  355. #define SLAPI_FAIL_GENERAL -1
  356. #define SLAPI_FAIL_DISKFULL -2
  357. /*
  358. * return codes used by BIND functions
  359. */
  360. #define SLAPI_BIND_SUCCESS 0 /* front end will send result */
  361. #define SLAPI_BIND_FAIL 2 /* back end should send result */
  362. #define SLAPI_BIND_ANONYMOUS 3 /* front end will send result */
  363. /* commonly used attributes names */
  364. #define SLAPI_ATTR_UNIQUEID "nsuniqueid"
  365. #define SLAPI_ATTR_OBJECTCLASS "objectclass"
  366. #define SLAPI_ATTR_VALUE_TOMBSTONE "nsTombstone"
  367. #define SLAPI_ATTR_VALUE_PARENT_UNIQUEID "nsParentUniqueID"
  368. #define SLAPI_ATTR_NSCP_ENTRYDN "nscpEntryDN"
  369. #define SLAPI_ATTR_ENTRYUSN "entryusn"
  370. #define SLAPI_ATTR_ENTRYDN "entrydn"
  371. /* opaque structures */
  372. /**
  373. * Contains name-value pairs, known as parameter blocks, that you can get or set for
  374. * each LDAP operation.
  375. *
  376. * #Slapi_PBlock contains name-value pairs that you can use to retrieve information
  377. * from the server and set information to be used by the server.
  378. *
  379. * For most types of plug-in functions, the server passes in a #Slapi_PBlock
  380. * structure that typically includes data relevant to the operation being processed.
  381. * You can get the value of a parameter by calling the slapi_pblock_get() function.
  382. *
  383. * For example, when the plug-in function for an LDAP bind operation is called, the
  384. * server puts the DN and credentials in the #SLAPI_BIND_TARGET and
  385. * #SLAPI_BIND_CREDENTIALS parameters of the Slapi_PBlock structure. You can
  386. * call slapi_pblock_get() to get the DN and credentials of the client requesting
  387. * authentication.
  388. *
  389. * For plug-in initialization functions, you can use the #Slapi_PBlock structure to
  390. * pass information to the server, such as the description of your plug-in and the
  391. * names of your plug-in functions. You can set the value of a parameter by calling
  392. * the slapi_pblock_set() function.
  393. *
  394. * For example, in order to register a pre-operation bind plug-in function, you need to
  395. * call slapi_pblock_set() to set the version number, description, and name of the
  396. * plug-in function as the #SLAPI_PLUGIN_VERSION, #SLAPI_PLUGIN_DESCRIPTION,
  397. * and #SLAPI_PLUGIN_PRE_BIND_FN parameters.
  398. *
  399. * The available parameters that you can use depends on the type of plug-in function
  400. * you are writing.
  401. */
  402. typedef struct slapi_pblock Slapi_PBlock;
  403. /**
  404. * Represents an entry in the directory.
  405. *
  406. * #Slapi_Entry is the data type for an opaque structure that represents an entry in
  407. * the directory. In certain cases, your server plug-in may need to work with an entry
  408. * in the directory.
  409. */
  410. typedef struct slapi_entry Slapi_Entry;
  411. /**
  412. * Represents an attribute in an entry.
  413. *
  414. * #Slapi_Attr is the data type for an opaque structure that represents an attribute
  415. * in a directory entry. In certain cases, your server plug-in may need to work with
  416. * an entry’s attributes.
  417. */
  418. typedef struct slapi_attr Slapi_Attr;
  419. /**
  420. * Represents the value of the attribute in a directory entry.
  421. *
  422. * #Slapi_Value is the data type for an opaque structure that represents the value of
  423. * an attribute in a directory entry.
  424. */
  425. typedef struct slapi_value Slapi_Value;
  426. /**
  427. * Represents a set of Slapi_Value (or a list of Slapi_Value).
  428. *
  429. * #Slapi_ValueSet is the data type for an opaque structure that represents set of
  430. * #Slapi_Value (or a list of #Slapi_Value).
  431. */
  432. typedef struct slapi_value_set Slapi_ValueSet;
  433. /**
  434. * Represents a search filter.
  435. *
  436. * #Slapi_Filter is the data type for an opaque structure that represents an search
  437. * filter.
  438. */
  439. typedef struct slapi_filter Slapi_Filter;
  440. /**
  441. * Represents a backend operation in the server plug-in.
  442. *
  443. * #Slapi_Backend is the data type for an opaque structure that represents a backend
  444. * operation.
  445. */
  446. typedef struct backend Slapi_Backend;
  447. /**
  448. * Represents the unique identifier of a directory entry.
  449. *
  450. * #Slapi_UniqueID is the data type for an opaque structure that represents the
  451. * unique identifier of a directory entry. All directory entries contain a unique
  452. * identifier. Unlike the distinguished name (DN), the unique identifier of an entry
  453. * never changes, providing a good way to refer unambiguously to an entry in a
  454. * distributed/replicated environment.
  455. */
  456. typedef struct _guid_t Slapi_UniqueID;
  457. /**
  458. * Represents an operation pending from an LDAP client.
  459. *
  460. * #Slapi_Operation is the data type for an opaque structure that represents an
  461. * operation pending from an LDAP client.
  462. */
  463. typedef struct op Slapi_Operation;
  464. /**
  465. * Represents a connection.
  466. *
  467. * #Slapi_Connection is the data type for an opaque structure that represents a
  468. * connection.
  469. */
  470. typedef struct conn Slapi_Connection;
  471. /**
  472. * Represents a distinguished name in a directory entry.
  473. *
  474. * #Slapi_DN is the data type for an opaque structure that represents a distinguished
  475. * name in the server plug-in.
  476. */
  477. typedef struct slapi_dn Slapi_DN;
  478. /**
  479. * Represents a relative distinguished name in a directory entry.
  480. *
  481. * #Slapi_RDN is the data type for an opaque structure that represents a relative
  482. * distinguished name in the server plug-in.
  483. */
  484. typedef struct slapi_rdn Slapi_RDN;
  485. /**
  486. * Represents a single LDAP modification to a directory entry.
  487. *
  488. * #Slapi_Mod is the data type for an opaque structure that represents LDAPMod
  489. * modifications to an attribute in a directory entry.
  490. */
  491. typedef struct slapi_mod Slapi_Mod;
  492. /**
  493. * Represents two or more LDAP modifications to a directory entry
  494. *
  495. * #Slapi_Mods is the data type for an opaque structure that represents LDAPMod
  496. * manipulations that can be made to a directory entry.
  497. */
  498. typedef struct slapi_mods Slapi_Mods;
  499. /**
  500. * Represents a the component ID in a directory entry.
  501. *
  502. * #Slapi_ComponentId is the data type for an opaque structure that represents the
  503. * component ID in a directory entry.
  504. */
  505. typedef struct slapi_componentid Slapi_ComponentId;
  506. /**
  507. * Represents an integral counter.
  508. *
  509. * Provides 64-bit integers with support for atomic operations, even on 32-bit
  510. * systems. This lets your plug-in have global integers that can be updated by
  511. * multiple worker threads in a thread-safe manner.
  512. *
  513. * The #Slapi_Counter structure is a wrapper around the actual counter value
  514. */
  515. typedef struct slapi_counter Slapi_Counter;
  516. /* Online tasks interface (to support import, export, etc) */
  517. #define SLAPI_TASK_PUBLIC 1 /* tell old plugins that the task api is now public */
  518. /**
  519. * An opaque structure that represents a task that has been initiated.
  520. *
  521. * Common Directory Server tasks, including importing, exporting, and indexing
  522. * databases, can be initiated through a special task configuration entry in
  523. * cn=tasks,cn=config. These task operations are managed using the #Slapi_Task
  524. * structure.
  525. */
  526. typedef struct slapi_task Slapi_Task;
  527. typedef struct passwordpolicyarray Slapi_PWPolicy;
  528. /**
  529. * Defines a callback used specifically by Slapi_Task structure cancel and
  530. * destructor functions.
  531. *
  532. * \param task The task that is being cancelled or destroyed.
  533. */
  534. typedef void (*TaskCallbackFn)(Slapi_Task *task);
  535. /*
  536. * The default thread stacksize for nspr21 is 64k (except on IRIX! It's 32k!).
  537. * For OSF, we require a larger stacksize as actual storage allocation is
  538. * higher i.e pointers are allocated 8 bytes but lower 4 bytes are used.
  539. * The value 0 means use the default stacksize.
  540. *
  541. * larger stacksize (256KB) is needed on IRIX due to its 4KB BUFSIZ.
  542. * (@ pthread IRIX porting -- 01/11/99)
  543. *
  544. * HP-UX on PA-RISC uses 64KB default stack size. Just set to 256K for all
  545. * HP-UX.
  546. */
  547. #if ( defined( irix ))
  548. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  549. #elif ( defined ( OSF1 ))
  550. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  551. #elif ( defined ( AIX ))
  552. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  553. #elif ( defined ( hpux ))
  554. #define SLAPD_DEFAULT_THREAD_STACKSIZE 262144L
  555. #else
  556. /* All other platforms use the default stack size */
  557. #define SLAPD_DEFAULT_THREAD_STACKSIZE 0
  558. #endif
  559. /*---------------------------
  560. * parameter block routines
  561. *--------------------------*/
  562. /**
  563. * Creates a new parameter block.
  564. *
  565. * \return This function returns a pointer to the new parameter block.
  566. * \warning The pblock pointer allocated with this function must always be freed by
  567. * slapi_pblock_destroy(). The use of other memory deallocators (for example,
  568. * <tt>free()</tt>) is not supported and may lead to crashes or memory leaks.
  569. * \see slapi_pblock_destroy()
  570. */
  571. Slapi_PBlock *slapi_pblock_new( void ); /* allocate and initialize */
  572. /**
  573. * Initializes an existing parameter block for re-use.
  574. *
  575. * \param pb The parameter block to initialize.
  576. * \warning The parameter block that you wish to free must have been created using
  577. * slapi_pblock_new(). When you are finished with the parameter block, you
  578. * must free it using the slapi_pblock_destroy() function.
  579. *
  580. * \warning Note that search results will not be freed from the parameter block by
  581. * slapi_pblock_init(). You must free any internal search results with the
  582. * slapi_free_search_results_internal() function prior to calling
  583. * slapi_pblock_init(), otherwise the search results will be leaked.
  584. * \see slapi_pblock_new()
  585. * \see slapi_pblock_destroy()
  586. * \see slapi_free_search_results_internal()
  587. */
  588. void slapi_pblock_init( Slapi_PBlock *pb ); /* clear out for re-use */
  589. /**
  590. * Gets the value of a name-value pair from a parameter block.
  591. *
  592. * \param pb Parameter block.
  593. * \param arg ID of the name-value pair that you want to get.
  594. * \param value Pointer to the value retrieved from the parameter block.
  595. * \return \c 0 if successful.
  596. * \return \c -1 if an error occurs (for example, if an invalid ID is specified).
  597. * \todo Document valid values for the ID.
  598. * \warning The <tt>void *value</tt> argument should always be a pointer to the
  599. * type of value you are retrieving:
  600. * \code
  601. * int connid = 0;
  602. * ...
  603. * retval = slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
  604. * \endcode
  605. *
  606. * \warning #SLAPI_CONN_ID is an integer value, so you will pass in a pointer
  607. * to/address of an integer to get the value. Similarly, for a
  608. * <tt>char *</tt> value (a string), pass in a pointer to/address of the value.
  609. * For example:
  610. * \code
  611. * char *binddn = NULL;
  612. * ...
  613. * retval = slapi_pblock_get(pb, SLAPI_CONN_DN, &binddn);
  614. * \endcode
  615. *
  616. * \warning With certain compilers on some platforms, you may have to cast the
  617. * value to <tt>(void *)</tt>.
  618. *
  619. * \warning We recommend that you set the value to \c 0 or \c NULL before calling
  620. * slapi_pblock_get() to avoid reading from uninitialized memory, in
  621. * case the call to slapi_pblock_get() fails.
  622. *
  623. * \warning In most instances, the caller should not free the returned value.
  624. * The value will usually be freed internally or through the call to
  625. * slapi_pblock_destroy(). The exception is if the value is explicitly
  626. * set by the caller through slapi_pblock_set(). In this case, the caller
  627. * is responsible for memory management. If the value is freed, it is
  628. * strongly recommended that the free is followed by a call to
  629. * slapi_pblock_set() with a value of \c NULL. For example:
  630. * \code
  631. * char *someparam = NULL;
  632. * ...
  633. * someparam = slapi_ch_strdup(somestring);
  634. * slapi_pblock_set(pb, SOME_PARAM, someparam);
  635. * someparam = NULL;
  636. * ...
  637. * slapi_pblock_get(pb, SOME_PARAM, &someparam);
  638. * slapi_pblock_set(pb, SOME_PARAM, NULL);
  639. * slapi_ch_free_string(&someparam);
  640. * ...
  641. * \endcode
  642. *
  643. * \warning Some internal functions may change the value passed in, so it is
  644. * recommended to use slapi_pblock_get() to retrieve the value again,
  645. * rather than relying on a potential dangling pointer. This is shown
  646. * in the example above, which sets someparam to \c NULL after setting
  647. * it in the pblock.
  648. *
  649. * \see slapi_pblock_destroy()
  650. * \see slapi_pblock_set()
  651. */
  652. int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
  653. /**
  654. * Sets the value of a name-value pair in a parameter block.
  655. *
  656. * \param pb Parameter block.
  657. * \param arg ID of the name-value pair that you want to get.
  658. * \param value Pointer to the value you want to set in the parameter block.
  659. * \return \c 0 if successful.
  660. * \return \c -1 if an error occurs (for example, if an invalid ID is specified).
  661. * \warning The value to be passed in must always be a pointer, even for integer
  662. * arguments. For example, if you wanted to do a search with the
  663. * \c ManageDSAIT control:
  664. * \code
  665. * int managedsait = 1;
  666. * ...
  667. * slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, &managedsait);
  668. * \endcode
  669. *
  670. * \warning A call similar to the following example will cause a crash:
  671. * \code
  672. * slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, 1);
  673. * \endcode
  674. *
  675. * \warning However, for values which are already pointers, (<tt>char * string</tt>,
  676. * <tt>char **arrays</tt>, <tt>#Slapi_Backend *</tt>, etc.), you can pass
  677. * in the value directly. For example:
  678. * \code
  679. * Slapi_DN *target_sdn = slapi_sdn_dup(some_sdn);
  680. * slapi_pblock_set(pb, SLAPI_TARGET_SDN, target_sdn);
  681. * \endcode
  682. *
  683. * \warning or
  684. * \code
  685. * slapi_pblock_set(pb, SLAPI_TARGET_SDN, NULL);
  686. * \endcode
  687. *
  688. * \warning With some compilers, you will have to cast the value argument to
  689. * <tt>(void *)</tt>. If the caller allocates the memory passed in, the
  690. * caller is responsible for freeing that memory. Also, it is recommended
  691. * to use slapi_pblock_get() to retrieve the value to free, rather than
  692. * relying on a potentially dangling pointer. See the slapi_pblock_get()
  693. * example for more details.
  694. *
  695. * \warning When setting parameters to register a plug-in, the plug-in type must
  696. * always be set first, since many of the plug-in parameters depend on
  697. * the type. For example, set the #SLAPI_PLUGIN_TYPE to extended
  698. * operation before setting the list of extended operation OIDs for
  699. * the plug-in.
  700. *
  701. * \see slapi_pblock_get()
  702. */
  703. int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
  704. /**
  705. * Frees the specified parameter block from memory.
  706. *
  707. * \param pb Parameter block you want to free.
  708. * \warning The parameter block that you wish to free must have been created
  709. * using slapi_pblock_new(). Use of this function with parameter
  710. * blocks allocated on the stack (for example, <tt>#Slapi_PBlock pb;</tt>)
  711. * or using another memory allocator is not supported and may lead to
  712. * memory errors and memory leaks. For example:
  713. * \code
  714. * Slapi_PBlock *pb = malloc(sizeof(Slapi_PBlock));
  715. * \endcode
  716. *
  717. * \warning After calling this function, you should set the parameter block
  718. * pointer to \c NULL to avoid reusing freed memory in your function
  719. * context, as in the following:
  720. * \code
  721. * slapi_pblock_destroy(pb);
  722. * pb =NULL;
  723. * \endcode
  724. *
  725. * \warning If you reuse the pointer in this way, it makes it easier to
  726. * identify a Segmentation Fault, rather than using some difficult
  727. * method to detect memory leaks or other abnormal behavior.
  728. *
  729. * \warning It is safe to call this function with a \c NULL pointer. For
  730. * example:
  731. * \code
  732. * Slapi_PBlock *pb = NULL;
  733. * slapi_pblock_destroy(pb);
  734. * \endcode
  735. *
  736. * \warning This saves the trouble of checking for \c NULL before calling
  737. * slapi_pblock_destroy().
  738. *
  739. * \see slapi_pblock_new()
  740. */
  741. void slapi_pblock_destroy( Slapi_PBlock *pb );
  742. /*----------------
  743. * entry routines
  744. *---------------*/
  745. /**
  746. * Converts an LDIF description of a directory entry (a string value) into
  747. * an entry of the #Slapi_Entry type.
  748. *
  749. * A directory entry can be described by a string in LDIF format. Calling
  750. * the slapi_str2entry() function converts a string description in this
  751. * format to a #Slapi_Entry structure, which you can pass to other API
  752. * functions.
  753. *
  754. * \param s Description of an entry that you want to convert to a #Slapi_Entry.
  755. * \param flags One or more flags specifying how the entry should be generated.
  756. * The valid values of the \c flags argument are:
  757. * \arg #SLAPI_STR2ENTRY_REMOVEDUPVALS
  758. * \arg #SLAPI_STR2ENTRY_ADDRDNVALS
  759. * \arg #SLAPI_STR2ENTRY_BIGENTRY
  760. * \arg #SLAPI_STR2ENTRY_TOMBSTONE_CHECK
  761. * \arg #SLAPI_STR2ENTRY_IGNORE_STATE
  762. * \arg #SLAPI_STR2ENTRY_INCLUDE_VERSION_STR
  763. * \arg #SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES
  764. * \arg #SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF
  765. * \arg #SLAPI_STR2ENTRY_NO_SCHEMA_LOCK
  766. * \arg #SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT
  767. * \arg #SLAPI_STR2ENTRY_NO_ENTRYDN
  768. * \arg #SLAPI_STR2ENTRY_DN_NORMALIZED
  769. *
  770. * \return A pointer to the #Slapi_Entry structure representing the entry.
  771. * \return \c NULL if the string cannot be converted; for example, if no DN is
  772. * specified in the string.
  773. * \warning This function modifies the string argument s. If you still need to
  774. * use this string value, you should make a copy of this string before
  775. * calling slapi_str2entry().
  776. *
  777. * \warning When you are done working with the entry, you should call the
  778. * slapi_entry_free() function.
  779. *
  780. * \note To convert an entry to a string description, call the slapi_entry2str()
  781. * function.
  782. *
  783. * \see slapi_entry_free()
  784. * \see slapi_entry2str()
  785. */
  786. Slapi_Entry *slapi_str2entry( char *s, int flags );
  787. /*
  788. * Same as slapi_str2entry except passing optional dn and rdn structure as argument
  789. */
  790. Slapi_Entry *slapi_str2entry_ext( const char *dn, const Slapi_RDN *srdn, char *s, int flags );
  791. /*-----------------------------
  792. * Flags for slapi_str2entry()
  793. *----------------------------*/
  794. /**
  795. * Removes any duplicate values in the attributes of the entry.
  796. *
  797. * \see slapi_str2entry()
  798. */
  799. #define SLAPI_STR2ENTRY_REMOVEDUPVALS 1
  800. /**
  801. * Adds the relative distinguished name (RDN) components (for example,
  802. * \c uid=bjensen) as attributes of the entry.
  803. *
  804. * \see slapi_str2entry()
  805. */
  806. #define SLAPI_STR2ENTRY_ADDRDNVALS 2
  807. /**
  808. * Provide a hint that the entry is large. This enables some optimizations
  809. * related to large entries.
  810. *
  811. * \see slapi_str2entry()
  812. */
  813. #define SLAPI_STR2ENTRY_BIGENTRY 4
  814. /**
  815. * Check to see if the entry is a tombstone. If so, set the tombstone flag
  816. * (#SLAPI_ENTRY_FLAG_TOMBSTONE).
  817. *
  818. * \see slapi_str2entry()
  819. */
  820. #define SLAPI_STR2ENTRY_TOMBSTONE_CHECK 8
  821. /**
  822. * Ignore entry state information if present.
  823. *
  824. * \see slapi_str2entry()
  825. */
  826. #define SLAPI_STR2ENTRY_IGNORE_STATE 16
  827. /**
  828. * Return entries that have a <tt>version: 1</tt> line as part of the LDIF
  829. * representation.
  830. *
  831. * \see slapi_str2entry()
  832. */
  833. #define SLAPI_STR2ENTRY_INCLUDE_VERSION_STR 32
  834. /**
  835. * Add any missing ancestor values based on the object class hierarchy.
  836. *
  837. * \see slapi_str2entry()
  838. */
  839. #define SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES 64
  840. /**
  841. * Inform slapi_str2entry() that the LDIF input is not well formed.
  842. *
  843. * Well formed LDIF has no duplicate attribute values, already has the RDN
  844. * as an attribute of the entry, and has all values for a given attribute
  845. * type listed contiguously.
  846. *
  847. * \see slapi_str2entry()
  848. */
  849. #define SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF 128
  850. /**
  851. * Don't acquire the schema lock.
  852. *
  853. * You should use this flag if you are sure that the lock is already held,
  854. * or if the server has not started it's threads yet during startup.
  855. *
  856. * \see slapi_str2entry()
  857. */
  858. #define SLAPI_STR2ENTRY_NO_SCHEMA_LOCK 256
  859. /**
  860. * Normalize DN using obsolete DN normalizer.
  861. *
  862. * This marco is used only for the upgrading dn format tool.
  863. *
  864. * \see slapi_str2entry()
  865. */
  866. #define SLAPI_STR2ENTRY_USE_OBSOLETE_DNFORMAT 512
  867. /**
  868. * Do not include entrydn attribute value in the in-memory entry
  869. *
  870. * If this flag is set, entrydn in the source string is ignored.
  871. *
  872. * \see slapi_str2entry()
  873. */
  874. #define SLAPI_STR2ENTRY_NO_ENTRYDN 1024
  875. /**
  876. * Passed DN is already normalized.
  877. *
  878. * If this flag is set, str2entry assumes passed DN is already normalized.
  879. *
  880. * \see slapi_str2entry()
  881. */
  882. #define SLAPI_STR2ENTRY_DN_NORMALIZED 2048
  883. /**
  884. * Generates a description of an entry as an LDIF string.
  885. *
  886. * This function behaves much like slapi_entry2str(); however, you can specify
  887. * output options with this function.
  888. *
  889. * This function generates an LDIF string value conforming to the following syntax:
  890. * \code
  891. * dn: dn\n
  892. * [attr: value\n]*
  893. * \endcode
  894. *
  895. * For example:
  896. * \code
  897. * dn: uid=jdoe, ou=People, dc=example,dc=com
  898. * cn: Jane Doe
  899. * sn: Doe
  900. * ...
  901. * \endcode
  902. *
  903. * To convert an entry described in LDIF string format to an LDAP entry using
  904. * the #Slapi_Entry data type, call the slapi_str2entry() function.
  905. *
  906. * \param e Entry that you want to convert into an LDIF string.
  907. * \param len Length of the LDIF string returned by this function.
  908. * \param options An option set that specifies how you want the string
  909. * converted. You can \c OR together any of the following options
  910. * when you call this function:
  911. * \arg #SLAPI_DUMP_STATEINFO
  912. * \arg #SLAPI_DUMP_UNIQUEID
  913. * \arg #SLAPI_DUMP_NOOPATTRS
  914. * \arg #SLAPI_DUMP_NOWRAP
  915. * \arg #SLAPI_DUMP_MINIMAL_ENCODING
  916. * \return The LDIF string representation of the entry you specify.
  917. * \return \c NULL if an error occurs.
  918. * \warning When you no longer need to use the string, you should free it
  919. * from memory by calling the slapi_ch_free_string() function.
  920. *
  921. * \see slapi_entry2str()
  922. * \see slapi_str2entry()
  923. */
  924. char *slapi_entry2str_with_options( Slapi_Entry *e, int *len, int options );
  925. /*---------------------------------------------
  926. * Options for slapi_entry2str_with_options()
  927. *--------------------------------------------*/
  928. /**
  929. * Output entry with replication state info.
  930. *
  931. * This allows access to the internal data used by multi-master replication.
  932. *
  933. * \see slapi_entry2str_with_options()
  934. */
  935. #define SLAPI_DUMP_STATEINFO 1 /* replication state */
  936. /**
  937. * Output entry with uniqueid.
  938. *
  939. * This option is used when creating an LDIF file to be used to initialize
  940. * a replica. Each entry will contain the nsuniqueID operational attribute.
  941. *
  942. * \see slapi_entry2str_with_options()
  943. */
  944. #define SLAPI_DUMP_UNIQUEID 2 /* unique ID */
  945. /**
  946. * Output entry without operational attributes.
  947. *
  948. * By default, certain operational attributes (such as \c creatorsName,
  949. * \c modifiersName, \c createTimestamp, \c modifyTimestamp) may be
  950. * included in the output. With this option, no operational attributes
  951. * will be included.
  952. *
  953. * \see slapi_entry2str_with_options()
  954. */
  955. #define SLAPI_DUMP_NOOPATTRS 4 /* suppress operational attrs */
  956. /**
  957. * Output entry without LDIF line wrapping.
  958. *
  959. * By default, lines will be wrapped as defined in the LDIF specification.
  960. * With this option, line wrapping is disabled.
  961. *
  962. * \see slapi_entry2str_with_options()
  963. */
  964. #define SLAPI_DUMP_NOWRAP 8 /* no line breaks */
  965. /**
  966. * Output entry with less base64 encoding.
  967. *
  968. * Uses as little base64 encoding as possible in the output.
  969. *
  970. * \see slapi_entry2str_with_options()
  971. */
  972. #define SLAPI_DUMP_MINIMAL_ENCODING 16 /* use less base64 encoding */
  973. /**
  974. * Output rdn based entry instead of dn based. Introduced for subtree rename.
  975. *
  976. * \see slapi_entry2str_with_options()
  977. */
  978. #define SLAPI_DUMP_RDN_ENTRY 32 /* rdn based entry */
  979. /**
  980. * Generates an LDIF string description of an LDAP entry.
  981. *
  982. * This function generates an LDIF string value conforming to the following syntax:
  983. * \code
  984. * dn: dn\n
  985. * [attr: value\n]*
  986. * \endcode
  987. *
  988. * For example:
  989. * \code
  990. * dn: uid=jdoe, ou=People, dc=example,dc=com
  991. * cn: Jane Doe
  992. * sn: Doe
  993. * ...
  994. * \endcode
  995. *
  996. * To convert an entry described in LDIF string format to an LDAP entry using
  997. * the #Slapi_Entry data type, call the slapi_str2entry() function.
  998. *
  999. * \param e Entry that you want to convert into an LDIF string.
  1000. * \param len Length of the LDIF string returned by this function.
  1001. * \return The LDIF string representation of the entry you specify.
  1002. * \return \c NULL if an error occurs.
  1003. * \warning When you no longer need to use the string, you should free it
  1004. * from memory by calling the slapi_ch_free_string() function.
  1005. *
  1006. * \see slapi_entry2str_with_options()
  1007. * \see slapi_str2entry()
  1008. */
  1009. char *slapi_entry2str( Slapi_Entry *e, int *len );
  1010. /**
  1011. * Allocates memory for a new entry of the data type #Slapi_Entry.
  1012. *
  1013. * This function returns an empty #Slapi_Entry structure. You can call other
  1014. * front-end functions to set the DN and attributes of this entry.
  1015. *
  1016. * When you are no longer using the entry, you should free it from memory by
  1017. * calling the slapi_entry_free() function.
  1018. *
  1019. * \return This function returns a pointer to the newly allocated entry of the
  1020. * data type #Slapi_Entry. If space cannot be allocated, e.g., no more
  1021. * virtual memory exists, the \c ns-slapd program terminates.
  1022. * \warning When you no longer use the entry, free it from memory by calling the
  1023. * slapi_entry_free() function.
  1024. *
  1025. * \see slapi_entry_dup()
  1026. * \see slapi_entry_free()
  1027. */
  1028. Slapi_Entry *slapi_entry_alloc(void);
  1029. /**
  1030. * Initializes the values of an entry with the DN and attribute value pairs you
  1031. * supply.
  1032. *
  1033. * This function initializes the attributes and the corresponding attribute values
  1034. * of an entry. Also, during the course of processing, the unique ID of the entry
  1035. * is set to \c NULL, and the flag value is set to \c 0.
  1036. *
  1037. * Use this function to initialize a #Slapi_Entry pointer.
  1038. *
  1039. * \param e The entry you want to initialize.
  1040. * \param dn The DN of the entry you are initializing.
  1041. * \param a Initialization list of attribute value pairs, supplied as a
  1042. * #Slapi_Attr data value.
  1043. * \warning This function should always be used after slapi_entry_alloc() and
  1044. * never otherwise. For example:
  1045. * \code
  1046. * Slapi_Entry *e = slapi_entry_alloc();
  1047. * slapi_entry_init(e, NULL, NULL);
  1048. * \endcode
  1049. *
  1050. * \warning To set the DN in the entry:
  1051. * \code
  1052. * slapi_sdn_set_dn_passin(slapi_entry_get_sdn(e), dn);
  1053. * \endcode
  1054. *
  1055. * \warning In this case, the dn argument is not copied but is consumed by the
  1056. * function. To copy the argument, see the following example:
  1057. * \code
  1058. * char *dn = slapi_ch_strdup(some_dn);
  1059. * Slapi_Entry *e = slapi_entry_alloc();
  1060. * slapi_entry_init(e, dn, NULL);
  1061. * \endcode
  1062. *
  1063. * \warning The \c dn argument is not freed in this context but will eventually
  1064. * be freed when slapi_entry_free() is called.
  1065. *
  1066. * \see slapi_entry_free()
  1067. * \see slapi_entry_alloc()
  1068. */
  1069. void slapi_entry_init(Slapi_Entry *e, char *dn, Slapi_Attr *a);
  1070. /*
  1071. * Initializes the values of an entry with the Slapi_DN and attribute value
  1072. * pairs you supply.
  1073. */
  1074. void slapi_entry_init_ext(Slapi_Entry *e, Slapi_DN *sdn, Slapi_Attr *a);
  1075. /**
  1076. * Frees an entry, its DN, and its attributes from memory.
  1077. *
  1078. * Call this function to free an entry that you have allocated by using the
  1079. * slapi_entry_alloc() function or the slapi_entry_dup() function.
  1080. *
  1081. * \param e Entry that you want to free. If \c NULL, no action occurs.
  1082. * \warning To free entries, always use this function instead of using
  1083. * slapi_ch_free() or free().
  1084. *
  1085. * \see slapi_entry_alloc()
  1086. * \see slapi_entry_dup()
  1087. */
  1088. void slapi_entry_free( Slapi_Entry *e );
  1089. /**
  1090. * Makes a copy of an entry, its DN, and its attributes.
  1091. *
  1092. * This function returns a copy of an existing #Slapi_Entry structure. You can
  1093. * call other front-end functions to change the DN and attributes of this entry.
  1094. *
  1095. * \param e Entry that you want to copy.
  1096. * \return This function returns the new copy of the entry. If the structure
  1097. * cannot be duplicated, for example, if no more virtual memory exists,
  1098. * the \c ns-slapd program terminates.
  1099. * \warning When you are no longer using the entry, free it from memory by
  1100. * calling the slapi_entry_free() function.
  1101. * \see slapi_entry_alloc()
  1102. * \see slapi_entry_free()
  1103. */
  1104. Slapi_Entry *slapi_entry_dup( const Slapi_Entry *e );
  1105. /**
  1106. * Gets the distinguished name (DN) of the specified entry.
  1107. *
  1108. * \param e Entry from which you want to get the DN.
  1109. * \return This function returns the DN of the entry. This returns a pointer
  1110. * to the actual DN in the entry, not a copy of the DN. You should not
  1111. * free the DN unless you plan to replace it by calling slapi_entry_set_dn().
  1112. * \warning Use slapi_ch_free_string() if you are replacing the DN with
  1113. * slapi_entry_set_dn().
  1114. * \see slapi_ch_free_string()
  1115. * \see slapi_entry_set_dn()
  1116. */
  1117. char *slapi_entry_get_dn( Slapi_Entry *e );
  1118. /**
  1119. * Returns the normalized DN from the entry that you specify.
  1120. *
  1121. * \param e Entry from which you want to obtain the normalized DN.
  1122. * \return This function returns the normalized DN from the entry that you
  1123. * specify. If the entry you specify does not contain a normalized DN,
  1124. * one is created through the processing of this function.
  1125. * \warning Never free the returned value.
  1126. * \see slapi_entry_get_dn()
  1127. */
  1128. char *slapi_entry_get_ndn( Slapi_Entry *e );
  1129. /**
  1130. * Returns as a \c const the value of the #Slapi_DN object from the entry
  1131. * that you specify.
  1132. *
  1133. * \param e Entry from which you want to get the #Slapi_DN object.
  1134. * \return Returns as a \c const the #Slapi_DN object from the entry that you
  1135. * specify.
  1136. * \warning Never free the returned value. If you need a copy, use
  1137. * slapi_sdn_dup().
  1138. * \see slapi_sdn_dup()
  1139. * \see slapi_entry_get_sdn()
  1140. */
  1141. const Slapi_DN *slapi_entry_get_sdn_const( const Slapi_Entry *e );
  1142. /**
  1143. * Returns the #Slapi_DN object from the entry that you specify.
  1144. *
  1145. * \param e Entry from which you want to get the #Slapi_DN object.
  1146. * \return Returns the #Slapi_DN object from the entry that you specify.
  1147. * \warning Never free the returned value. If you need a copy, use
  1148. * slapi_sdn_dup().
  1149. * \see slapi_entry_get_sdn_const()
  1150. * \see slapi_sdn_dup()
  1151. */
  1152. Slapi_DN *slapi_entry_get_sdn( Slapi_Entry *e );
  1153. /**
  1154. * Returns as a \c const the value of the #Slapi_RDN from the entry
  1155. * that you specify.
  1156. *
  1157. * \param e Entry from which you want to get the #Slapi_RDN object.
  1158. * \return Returns as a \c const the #Slapi_RDN object from the entry that you
  1159. * specify.
  1160. * \warning Never free the returned value. If you need a copy, use
  1161. * slapi_sdn_dup().
  1162. * \see slapi_sdn_dup()
  1163. * \see slapi_entry_get_sdn()
  1164. */
  1165. const Slapi_RDN *slapi_entry_get_srdn_const( const Slapi_Entry *e );
  1166. /**
  1167. * Returns the #Slapi_RDN object from the entry that you specify.
  1168. *
  1169. * \param e Entry from which you want to get the #Slapi_RDN object.
  1170. * \return Returns the #Slapi_RDN object from the entry that you specify.
  1171. * \warning Never free the returned value. If you need a copy, use
  1172. * slapi_sdn_dup().
  1173. * \see slapi_entry_get_srdn_const()
  1174. * \see slapi_sdn_dup()
  1175. */
  1176. Slapi_RDN * slapi_entry_get_srdn( Slapi_Entry *e );
  1177. /**
  1178. * Returns as a \c const the DN value of the entry that you specify.
  1179. *
  1180. * \param e Entry from which you want to get the DN as a constant.
  1181. * \return This function returns one of the following values:
  1182. * \arg The DN of the entry that you specify. The DN is returned
  1183. * as a const; you are not able to modify the DN value.
  1184. * \arg The NDN value of Slapi_DN if the DN of the Slapi_DN object is NULL.
  1185. * \warning Never free the returned value.
  1186. * \see slapi_entry_set_sdn()
  1187. */
  1188. const char *slapi_entry_get_dn_const( const Slapi_Entry *e );
  1189. /**
  1190. * Returns as a \c const the RDN value of the entry that you specify.
  1191. *
  1192. * \param e Entry from which you want to get the RDN as a constant.
  1193. * \return This function returns one of the following values:
  1194. * \arg The RDN of the entry that you specify. The RDN is returned
  1195. * as a const; you are not able to modify the RDN value.
  1196. * \warning Never free the returned value.
  1197. * \see slapi_entry_set_srdn()
  1198. */
  1199. const char *slapi_entry_get_rdn_const( const Slapi_Entry *e );
  1200. /**
  1201. * Returns as a \c const the Normalized RDN value of the entry that you specify.
  1202. *
  1203. * \param e Entry from which you want to get the Normalized RDN as a constant.
  1204. * \return This function returns one of the following values:
  1205. * \arg The Normalized RDN of the entry that you specify.
  1206. * The Normalized RDN is returned as a const;
  1207. * you are not able to modify the Normalized RDN value.
  1208. * \warning Never free the returned value.
  1209. * \see slapi_entry_set_srdn()
  1210. */
  1211. const char *slapi_entry_get_nrdn_const( const Slapi_Entry *e );
  1212. /**
  1213. * Sets the distinguished name (DN) of an entry.
  1214. *
  1215. * This function sets the DN pointer in the specified entry to the DN that you supply.
  1216. *
  1217. * \param e Entry to which you want to assign the DN.
  1218. * \param dn Distinguished name you want assigned to the entry.
  1219. * \warning The dn will be freed eventually when slapi_entry_free() is called.
  1220. * \warning A copy of dn should be passed. For example:
  1221. * \code
  1222. * char *dn = slapi_ch_strdup(some_dn):
  1223. * slapi_entry_set_dn(e, dn);
  1224. * \endcode
  1225. *
  1226. * \warning The old dn will be freed as a result of this call. Do not pass in
  1227. * a \c NULL value.
  1228. * \see slapi_entry_free()
  1229. * \see slapi_entry_get_dn()
  1230. */
  1231. void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
  1232. /**
  1233. * Sets the normalized distinguished name (DN) of an entry.
  1234. *
  1235. * This function sets the DN pointer in the specified entry to the DN that you supply. The DN should have been normalized.
  1236. *
  1237. * \param e Entry to which you want to assign the DN.
  1238. * \param dn Distinguished name you want assigned to the entry.
  1239. * \warning The dn will be freed eventually when slapi_entry_free() is called.
  1240. * \warning A copy of dn should be passed. For example:
  1241. *
  1242. * \warning The old dn will be freed as a result of this call. Do not pass in
  1243. * a \c NULL value.
  1244. * \see slapi_entry_free()
  1245. * \see slapi_entry_get_dn()
  1246. */
  1247. void slapi_entry_set_normdn( Slapi_Entry *e, char *normdn );
  1248. /**
  1249. * Sets the relative distinguished name (RDN) of an entry.
  1250. *
  1251. * This function sets the RDN pointer in the specified entry to the RDN that
  1252. * you supply.
  1253. *
  1254. * \param e Entry to which you want to assign the RDN.
  1255. * \param rdn Relatie distinguished name you want assigned to the entry.
  1256. * If dn is given here, the first rdn part is set to the RDN.
  1257. * \warning The rdn will be copied in slapi_entry_set_rdn.
  1258. */
  1259. void slapi_entry_set_rdn( Slapi_Entry *e, char *rdn );
  1260. /**
  1261. * Sets the Slapi_DN value in an entry.
  1262. *
  1263. * This function sets the value for the #Slapi_DN object in the entry you specify.
  1264. *
  1265. * \param e Entry to which you want to set the value of the #Slapi_DN.
  1266. * \param sdn The specified #Slapi_DN value that you want to set.
  1267. * \warning This function makes a copy of the \c sdn parameter.
  1268. * \see slapi_entry_get_sdn()
  1269. */
  1270. void slapi_entry_set_sdn( Slapi_Entry *e, const Slapi_DN *sdn );
  1271. /**
  1272. * Sets the Slapi_DN value containing RDN in an entry.
  1273. *
  1274. * This function sets the value for the #Slapi_DN object containing RDN in the entry you specify.
  1275. *
  1276. * \param e Entry to which you want to set the value of the #Slapi_DN.
  1277. * \param srdn The specified #Slapi_DN value that you want to set.
  1278. * \warning This function makes a copy of the \c srdn parameter.
  1279. * \see slapi_entry_get_srdn()
  1280. */
  1281. void slapi_entry_set_srdn( Slapi_Entry *e, const Slapi_RDN *srdn );
  1282. /**
  1283. * Determines if an entry contains the specified attribute.
  1284. *
  1285. * If the entry contains the attribute, the function returns a pointer to
  1286. * the attribute.
  1287. *
  1288. * \param e Entry that you want to check.
  1289. * \param type Name of the attribute that you want to check.
  1290. * \param attr Pointer to the attribute, if the attribute is found in the
  1291. * entry.
  1292. * \return \c 0 if the entry contains the specified attribute.
  1293. * \return \c -1 if the entry does not contain the specified attribute.
  1294. * \warning Do not free the returned \c attr. It is a pointer to the internal
  1295. * entry data structure. It is usually wise to make a copy of the
  1296. * returned attribute, using slapi_attr_dup(), to avoid dangling pointers
  1297. * if the entry is freed while the pointer to attr is still being used.
  1298. * \see slapi_attr_dup()
  1299. */
  1300. int slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **attr );
  1301. /**
  1302. * Finds the first attribute in an entry.
  1303. *
  1304. * If you want to iterate through the attributes in an entry, use this function
  1305. * in conjunction with the slapi_entry_next_attr() function.
  1306. *
  1307. * \param e Entry from which you want to get the attribute.
  1308. * \param attr Pointer to the first attribute in the entry.
  1309. * \return Returns 0 when successful; any other value returned signals failure.
  1310. * \warning Do not free the returned \c attr. This is a pointer into the
  1311. * internal entry data structure. If you need a copy, use slapi_attr_dup().
  1312. * \see slapi_entry_next_attr()
  1313. * \see slapi_attr_dup()
  1314. */
  1315. int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr );
  1316. /**
  1317. * Finds the next attribute after \c prevattr in an entry.
  1318. *
  1319. * To iterate through the attributes in an entry, use this function in conjunction
  1320. * with the slapi_entry_first_attr() function.
  1321. *
  1322. * \param e Entry from which you want to get the attribute.
  1323. * \param prevattr Previous attribute in the entry.
  1324. * \param attr Pointer to the next attribute after \c prevattr in the entry.
  1325. * \return \c 0 if successful.
  1326. * \return \c -1 if \c prevattr was the last attribute in the entry.
  1327. * \warning Do not free the returned \c attr. This is a pointer into the
  1328. * internal entry data structure. If you need a copy, use slapi_attr_dup().
  1329. * \see slapi_entry_first_attr()
  1330. * \see slapi_entry_dup()
  1331. */
  1332. int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
  1333. /**
  1334. * Gets the unique ID value of the entry.
  1335. *
  1336. * \param e Entry from which you want to obtain the unique ID.
  1337. * \return This function returns the unique ID value of the entry specified.
  1338. * \warning Never free this value. If you need a copy, use slapi_ch_strdup().
  1339. * \see slapi_entry_set_uniqueid()
  1340. * \see slapi_ch_strdup()
  1341. */
  1342. const char *slapi_entry_get_uniqueid( const Slapi_Entry *e );
  1343. /**
  1344. * Replaces the unique ID value of an entry with the unique ID value that you
  1345. * supply.
  1346. *
  1347. * This function replaces the unique ID value of the entry with the \c uniqueid
  1348. * value that you specify. In addition, the function adds #SLAPI_ATTR_UNIQUEID to
  1349. * the attribute list and gives it the unique ID value supplied. If the entry
  1350. * already contains a #SLAPI_ATTR_UNIQUEID attribute, its value is updated with
  1351. * the new value supplied.
  1352. *
  1353. * \param e Entry for which you want to generate a unique ID.
  1354. * \param uniqueid The unique ID value that you want to assign to the entry.
  1355. * \warning Do not free the \c uniqueid after calling this function. The value
  1356. * will eventually be freed when slapi_entry_free() is called.
  1357. *
  1358. * \warning You should pass in a copy of the value because this function will
  1359. * consume the value passed in. For example:
  1360. * \code
  1361. * char *uniqueid = slapi_ch_strdup(some_uniqueid);
  1362. * slapi_entry_set_uniqueid(e, uniqueid);
  1363. * \endcode
  1364. *
  1365. * \warning Do not pass in a \c NULL for \c uniqueid.
  1366. * \see slapi_entry_get_uniqueid()
  1367. * \see slapi_entry_free()
  1368. */
  1369. void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid );
  1370. /**
  1371. * Determines whether the specified entry complies with the schema for its object
  1372. * class.
  1373. *
  1374. * \param pb Parmeter block.
  1375. * \param e Entry that you want to check.
  1376. * \return \c 0 if the entry complies with the schema or if schema checking is
  1377. * turned off. The function also returns \c 0 if the entry has additional
  1378. * attributes not allowed by the schema and has the object class
  1379. * \c extensibleObject.
  1380. * \return \c 1 if the entry is missing the \c objectclass attribute, if it is missing
  1381. * any required attributes, if it has any attributes not allowed by the schema
  1382. * but does not have the object class \c extensibleObject, or if the entry has
  1383. * multiple values for a single-valued attribute.
  1384. * \warning The \c pb argument can be \c NULL. It is only used to get the
  1385. * #SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no schema
  1386. * checking is done.
  1387. */
  1388. int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e );
  1389. /**
  1390. * Determines whether the specified entry complies with the schema for its object
  1391. * class.
  1392. *
  1393. * Like slapi_entry_schema_check() with one additional parameter to enforce schema
  1394. * checking for replicated operations.
  1395. * \param check_repl Set to 1 if replicted operations should be checked
  1396. */
  1397. int slapi_entry_schema_check_ext( Slapi_PBlock *pb, Slapi_Entry *e, int check_repl );
  1398. /**
  1399. * Determines whether the specified entry complies with the syntax rules imposed
  1400. * by it's attribute types.
  1401. *
  1402. * \param pb Parameter block.
  1403. * \param e Entry that you want to check.
  1404. * \param override Flag to override the server configuration and force syntax checking
  1405. * to be performed.
  1406. * \return \c 0 if the entry complies with the syntax rules or if syntax checking
  1407. * is disabled.
  1408. * \return \c 1 if the entry has any attribute values that violate the syntax rules
  1409. * imposed by the associated attribute type. If the \c pb parameter was
  1410. * passed in, an error message describing the syntax violations will be
  1411. * set in the #SLAPI_PB_RESULT_TEXT paramter.
  1412. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1413. * message with details of any syntax violations. The \c pb paramter
  1414. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1415. * set. If that flag is present, no syntax checking is performed.
  1416. */
  1417. int slapi_entry_syntax_check( Slapi_PBlock *pb, Slapi_Entry *e, int override );
  1418. /**
  1419. * Determines if the DN violates the Distinguished Name syntax rules.
  1420. *
  1421. * \param pb Parameter block.
  1422. * \param dn The dn string you want to check.
  1423. * \param override Flag to override the server configuration and force syntax checking
  1424. * to be performed.
  1425. * \return \c 0 if the DN complies with the Distinguished Name syntax rules or if
  1426. * syntax checking is disabled.
  1427. * \return \c 1 if the DN violates the Distinguished Name syntax rules. If the \c pb
  1428. * parameter was passed in, an error message will be set in the
  1429. * #SLAPI_PB_RESULT_TEXT parameter.
  1430. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1431. * message with details of any syntax violations. The \c pb paramter
  1432. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1433. * set. If that flag is present, no syntax checking is performed.
  1434. */
  1435. int slapi_dn_syntax_check( Slapi_PBlock *pb, const char *dn, int override );
  1436. /**
  1437. * Determines if any values being added to an entry violate the syntax rules
  1438. * imposed by the associated attribute type.
  1439. *
  1440. * \param pb Parameter block.
  1441. * \param mods Array of mods that you want to check.
  1442. * \param override Flag to override the server configuration and force syntax checking
  1443. * to be performed.
  1444. * \return \c 0 if the mods comply with the syntax rules or if syntax checking
  1445. * is disabled.
  1446. * \return \c 1 if the mods are adding any new attribute values that violate the
  1447. * syntax rules imposed by the associated attribute type. If the \c pb
  1448. * parameter was passed in, an error message describing the syntax violations
  1449. * will be set in the #SLAPI_PB_RESULT_TEXT paramter.
  1450. * \warning The \c pb parameter can be \c NULL. It is used to store an error
  1451. * message with details of any syntax violations. The \c pb paramter
  1452. * is also used to check if the #SLAPI_IS_REPLICATED_OPERATION flag is
  1453. * set. If that flag is present, no syntax checking is performed.
  1454. */
  1455. int slapi_mods_syntax_check( Slapi_PBlock *pb, LDAPMod **mods, int override );
  1456. /**
  1457. * Determines whether the values in an entry’s relative distinguished name (RDN)
  1458. * are also present as attribute values.
  1459. *
  1460. * For example, if the entry’s RDN is <tt>cn=Barbara Jensen</tt>, the function determines
  1461. * if the entry has the \c cn attribute with the value <tt>Barbara Jensen</tt>.
  1462. *
  1463. * \param e Entry that you want to check for RDN values.
  1464. * \return \c 1 if the values in the RDN are present in the attributes of the entry.
  1465. * \return \c 0 if the values are not present.
  1466. */
  1467. int slapi_entry_rdn_values_present( const Slapi_Entry *e );
  1468. /**
  1469. * Adds the components in an entry’s relative distinguished name (RDN) to the entry
  1470. * as attribute values.
  1471. *
  1472. * For example, if the entry’s RDN is <tt>uid=bjensen</tt>, the function adds
  1473. * <tt>uid=bjensen</tt> to the entry as an attribute value.
  1474. *
  1475. * \param e Entry to which you want to add the RDN attributes.
  1476. * \return \c LDAP_SUCCESS if the values were successfully added to the entry. The
  1477. * function also returns \c LDAP_SUCCESS if the entry is \c NULL, if the
  1478. * entry’s DN is \c NULL, or if the entry’s RDN is \c NULL.
  1479. * \return \c LDAP_INVALID_DN_SYNTAX if the DN of the entry cannot be parsed.
  1480. * \warning Free the entry from memory by using the slapi_entry_free() function, if the
  1481. * entry was allocated by the user.
  1482. * \see slapi_entry_free()
  1483. */
  1484. int slapi_entry_add_rdn_values( Slapi_Entry *e );
  1485. /**
  1486. * Deletes an attribute (and all its associated values) from an entry.
  1487. *
  1488. * \param e Entry from which you want to delete the attribute.
  1489. * \param type Attribute type that you want to delete.
  1490. * \return \c 0 if successful.
  1491. * \return \c 1 if the specified attribute is not part of the entry.
  1492. * \return \c -1 if an error occurred.
  1493. */
  1494. int slapi_entry_attr_delete( Slapi_Entry *e, const char *type );
  1495. /**
  1496. * Gets the values of a multi-valued attribute of an entry.
  1497. *
  1498. * This function is very similar to slapi_entry_attr_get_charptr(), except that it
  1499. * returns a <tt>char **</tt> array for multi-valued attributes. The array and all
  1500. * values are copies. Even if the attribute values are not strings, they will still
  1501. * be \c NULL terminated so that they can be used safely in a string context. If there
  1502. * are no values, \c NULL will be returned. Because the array is \c NULL terminated,
  1503. * the usage should be similar to the sample shown below:
  1504. *
  1505. * \code
  1506. * char **ary = slapi_entry_attr_get_charray(e, someattr);
  1507. * int ii;
  1508. * for (ii = 0; ary && ary[ii]; ++ii) {
  1509. * char *strval = ary[ii];
  1510. * ...
  1511. * }
  1512. * slapi_ch_array_free(ary);
  1513. * \endcode
  1514. *
  1515. * \param e Entry from which you want to get the values.
  1516. * \param type Attribute type from which you want to get the values.
  1517. * \return A copy of all the values of the attribute.
  1518. * \return \c NULL if the entry does not contain the attribute or if the attribute
  1519. * has no values.
  1520. * \warning When you are done working with the values, free them from memory by calling
  1521. * the slapi_ch_array_free() function.
  1522. * \see slapi_entry_attr_get_charptr()
  1523. */
  1524. char **slapi_entry_attr_get_charray(const Slapi_Entry* e, const char *type);
  1525. /**
  1526. * Gets the values of a multi-valued attribute of an entry.
  1527. *
  1528. * This function is very similar to slapi_entry_attr_get_charptr(), except that it
  1529. * returns a <tt>char **</tt> array for multi-valued attributes. The array and all
  1530. * values are copies. Even if the attribute values are not strings, they will still
  1531. * be \c NULL terminated so that they can be used safely in a string context. If there
  1532. * are no values, \c NULL will be returned. Because the array is \c NULL terminated,
  1533. * the usage should be similar to the sample shown below:
  1534. *
  1535. * \code
  1536. * char **ary = slapi_entry_attr_get_charray(e, someattr);
  1537. * int ii;
  1538. * for (ii = 0; ary && ary[ii]; ++ii) {
  1539. * char *strval = ary[ii];
  1540. * ...
  1541. * }
  1542. * slapi_ch_array_free(ary);
  1543. * \endcode
  1544. *
  1545. * \param e Entry from which you want to get the values.
  1546. * \param type Attribute type from which you want to get the values.
  1547. * \param numVals The number of attribute values will be stored in this variable.
  1548. * \return A copy of all the values of the attribute.
  1549. * \return \c NULL if the entry does not contain the attribute or if the attribute
  1550. * has no values.
  1551. * \warning When you are done working with the values, free them from memory by calling
  1552. * the slapi_ch_array_free() function.
  1553. * \see slapi_entry_attr_get_charptr()
  1554. */
  1555. char **slapi_entry_attr_get_charray_ext( const Slapi_Entry* e, const char *type, int *numVals);
  1556. /**
  1557. * Gets the first value of an attribute of an entry as a string.
  1558. *
  1559. * \param e Entry from which you want to get the string value.
  1560. * \param type Attribute type from which you want to get the value.
  1561. * \return A copy of the first value in the attribute.
  1562. * \return \c NULL if the entry does not contain the attribute.
  1563. * \warning When you are done working with this value, free it from memory by calling the
  1564. * slapi_ch_free_string() function.
  1565. * \see slapi_entry_attr_get_charray()
  1566. */
  1567. char *slapi_entry_attr_get_charptr(const Slapi_Entry* e, const char *type);
  1568. /**
  1569. * Gets the first value of an attribute in an entry as an integer.
  1570. *
  1571. * \param e Entry from which you want to get the integer value.
  1572. * \param type Attribute type from which you want to get the value.
  1573. * \return The first value of the attribute converted to an integer.
  1574. * \return \c 0 if the entry does not contain the attribute.
  1575. */
  1576. int slapi_entry_attr_get_int(const Slapi_Entry* e, const char *type);
  1577. /**
  1578. * Gets the first value of an attribute in an entry as an unsigned integer data type.
  1579. *
  1580. * \param e Entry from which you want to get the integer value.
  1581. * \param type Attribute type from which you want to get the value.
  1582. * \return The first value of the attribute converted to an unsigned integer.
  1583. * \return \c 0 if the entry does not contain the attribute.
  1584. */
  1585. unsigned int slapi_entry_attr_get_uint(const Slapi_Entry* e, const char *type);
  1586. /**
  1587. * Gets the first value of an attribute in an entry as a long data type.
  1588. *
  1589. * \param e Entry from which you want to get the long value.
  1590. * \param type Attribute type from which you want to get the value.
  1591. * \return The first value of the attribute converted to a \c long type.
  1592. * \return \c 0 if the entry does not contain the attribute.
  1593. */
  1594. long slapi_entry_attr_get_long( const Slapi_Entry* e, const char *type);
  1595. /**
  1596. * Gets the first value of an attribute in an entry as an unsigned long
  1597. * data type.
  1598. *
  1599. * \param e Entry from which you want to get the unsigned long value.
  1600. * \param type Attribute type from which you want to get the value.
  1601. * \return The first value of the attribute converted to an <tt>
  1602. * unsigned long</tt>.
  1603. * \return \c 0 if the entry does not contain the attribute.
  1604. */
  1605. unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry* e, const char *type);
  1606. /**
  1607. * Gets the first value of an attribute in an entry as a long long data type.
  1608. *
  1609. * \param e Entry from which you want to get the long long value.
  1610. * \param type Attribute type from which you want to get the value.
  1611. * \return The first value of the attribute converted to a <tt>long long</tt>.
  1612. * \return \c 0 if the entry does not contain the attribute.
  1613. */
  1614. long long slapi_entry_attr_get_longlong( const Slapi_Entry* e, const char *type);
  1615. /**
  1616. * Gets the first value of an attribute in an entry as an unsigned
  1617. * long long data type.
  1618. *
  1619. * \param e Entry from which you want to get the unsigned long long value.
  1620. * \param type Attribute type from which you want to get the value.
  1621. * \return The first value of the attribute converted to an <tt>unsigned
  1622. * long long</tt>.
  1623. * \return \c 0 if the entry does not contain the attribute.
  1624. */
  1625. unsigned long long slapi_entry_attr_get_ulonglong( const Slapi_Entry* e, const char *type);
  1626. /**
  1627. * Gets the value of a given attribute of a given entry as a boolean value.
  1628. *
  1629. * Comparisons are case-insensitive (\c TRUE, \c trUe, and \c true are all the
  1630. * same), and unique substrings can be matched (\c t and \c tr will be interpreted
  1631. * as \c true). If the attribute value is a number, then non-zero numbers are
  1632. * interpreted as \c true, and \c 0 is interpreted as \c false.
  1633. *
  1634. * \param e Entry from which you want to get the boolean value.
  1635. * \param type Attribute type from which you want to get the value.
  1636. * \return \c PR_TRUE | \c PR_FALSE
  1637. */
  1638. PRBool slapi_entry_attr_get_bool( const Slapi_Entry* e, const char *type);
  1639. /**
  1640. * Replaces the value or values of an attribute in an entry with a specified string
  1641. * value.
  1642. *
  1643. * \param e Entry in which you want to set the value.
  1644. * \param type Attribute type in which you want to set the value.
  1645. * \param value String value that you want to assign to the attribute.
  1646. * \warning This function makes a copy of the parameter \c value. The \c value
  1647. * parameter can be \c NULL; if so, this function is roughly equivalent
  1648. * to slapi_entry_attr_delete().
  1649. * \see slapi_entry_attr_delete()
  1650. */
  1651. void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
  1652. /**
  1653. * Replaces the value or values of an attribute in an entry with a specified integer
  1654. * data value.
  1655. *
  1656. * This function will replace the value or values of an attribute with the
  1657. * integer value that you specify. If the attribute does not exist, it is created
  1658. * with the integer value that you specify.
  1659. *
  1660. * \param e Entry in which you want to set the value.
  1661. * \param type Attribute type in which you want to set the value.
  1662. * \param l Integer value that you want to assign to the attribute.
  1663. */
  1664. void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l);
  1665. /**
  1666. * Replaces the value or values of an attribute in an entry with a specified
  1667. * unsigned integer data type value.
  1668. *
  1669. * This function will replace the value or values of an attribute with the
  1670. * unsigned integer value that you specify. If the attribute does not exist,
  1671. * it is created with the unsigned integer value you specify.
  1672. *
  1673. * \param e Entry in which you want to set the value.
  1674. * \param type Attribute type in which you want to set the value.
  1675. * \param l Unsigned integer value that you want to assign to the attribute.
  1676. */
  1677. void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l);
  1678. /**
  1679. * Replaces the value or values of an attribute in an entry with a specified long data
  1680. * type value.
  1681. *
  1682. * \param e Entry in which you want to set the value.
  1683. * \param type Attribute type in which you want to set the value.
  1684. * \param l Long integer value that you want to assign to the attribute.
  1685. */
  1686. void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
  1687. /**
  1688. * Replaces the value or values of an attribute in an entry with a specified unsigned
  1689. * long data type value.
  1690. *
  1691. * This function will replace the value or values of an attribute with the unsigned
  1692. * long value that you specify. If the attribute does not exist, it is created with the
  1693. * unsigned long value that you specify.
  1694. *
  1695. * \param e Entry in which you want to set the value.
  1696. * \param type Attribute type in which you want to set the value.
  1697. * \param l Unsigned long value that you want to assign to the attribute.
  1698. */
  1699. void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
  1700. /**
  1701. * Determines if an attribute in an entry contains a specified value.
  1702. *
  1703. * The syntax of the attribute type is taken into account when checking
  1704. * for the specified value.
  1705. *
  1706. * \param e Entry that you want to check.
  1707. * \param type Attribute type that you want to test for the value specified.
  1708. * \param value Value that you want to find in the attribute.
  1709. * \return \c 1 if the attribute contains the specified value.
  1710. * \return \c 0 if the attribute does not contain the specified value.
  1711. * \warning \c value must not be \c NULL.
  1712. */
  1713. int slapi_entry_attr_has_syntax_value(const Slapi_Entry *e, const char *type, const Slapi_Value *value);
  1714. /**
  1715. * This function determines if the specified entry has child entries.
  1716. *
  1717. * \param e Entry that you want to test for child entries.
  1718. * \return \c 1 if the entry you supply has child entries.
  1719. * \return \c 0 if the entry you supply has child entries.
  1720. */
  1721. int slapi_entry_has_children(const Slapi_Entry *e);
  1722. /**
  1723. * This function determines if an entry is the root DSE.
  1724. *
  1725. * The root DSE is a special entry that contains information about the Directory
  1726. * Server, including its capabilities and configuration.
  1727. *
  1728. * \param dn The DN that you want to test to see if it is the root DSE entry.
  1729. * \return \c 1 if \c dn is the root DSE.
  1730. * \return \c 0 if \c dn is not the root DSE.
  1731. */
  1732. int slapi_is_rootdse( const char *dn );
  1733. /**
  1734. * This function returns the approximate size of an entry, rounded to the nearest 1k.
  1735. *
  1736. * This can be useful for checking cache sizes, estimating storage needs, and so on.
  1737. *
  1738. * When determining the size of an entry, only the sizes of the attribute values are
  1739. * counted; the size of other entry values (such as the size of attribute names,
  1740. * variously-normalized DNs, or any metadata) are not included in the size
  1741. * returned. It is assumed that the size of the metadata, et al., is well enough
  1742. * accounted for by the rounding of the size to the next largest 1k . This holds true
  1743. * especially in larger entries, where the actual size of the attribute values far
  1744. * outweighs the size of the metadata.
  1745. *
  1746. * When determining the size of the entry, both deleted values and deleted
  1747. * attributes are included in the count.
  1748. *
  1749. * \param e Entry from which you want the size returned.
  1750. * \return The size of the entry, rounded to the nearest 1k. The value returned is a
  1751. * size_t data type with a u_long value.
  1752. * \return A size of 1k if the entry is empty.
  1753. * \warning The \c e parameter must not be \c NULL.
  1754. */
  1755. size_t slapi_entry_size(Slapi_Entry *e);
  1756. /**
  1757. * Adds an array of #Slapi_Value data values to the existing attribute values in
  1758. * an entry.
  1759. *
  1760. * If the attribute does not exist, it is created with the #Slapi_Value specified.
  1761. *
  1762. * \param e Entry to which you want to add values.
  1763. * \param type Attribute type to which you want to add values.
  1764. * \param vals \c NULL terminated array of #Slapi_Value data values you want to add.
  1765. * \return This function returns \c 0 if successful; any other value returned
  1766. * signals failure.
  1767. * \warning This function makes a copy of the parameter \c vals. The \c vals
  1768. * parameter can be \c NULL.
  1769. */
  1770. int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1771. /**
  1772. * Adds and array of #Slapi_Value data values to the specified attribute in an entry.
  1773. *
  1774. * This function adds an array of #Slapi_Value data values to an attribute. If the
  1775. * attribute does not exist, it is created and given the value contained in the
  1776. * #Slapi_Value array.
  1777. *
  1778. * \param e Entry to which you want to add values.
  1779. * \param type Attribute type to which you want to add values.
  1780. * \param vals \c NULL terminated array of #Slapi_Value data values you want to add.
  1781. * \return \c LDAP_SUCCESS if the #Slapi_Value array if successfully added to the
  1782. * attribute.
  1783. * \return \c LDAP_TYPE_OR_VALUE_EXISTS if any values you are trying to add duplicate
  1784. * an existing value in the attribute.
  1785. * \return \c LDAP_OPERATIONS_ERROR if there are pre-existing duplicate values in the
  1786. * attribute.
  1787. * \warning This function makes a copy of the parameter \c vals. The \c vals
  1788. * parameter can be \c NULL.
  1789. */
  1790. int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1791. /**
  1792. * Add a Slapi_ValueSet data value to the specified attribute in an entry.
  1793. *
  1794. * This function adds a set of values to an attribute in an entry. The values added
  1795. * are in the form of a #Slapi_ValueSet data type. If the entry does not contain the
  1796. * attribute specified, it is created with the specified #Slapi_ValueSet values.
  1797. *
  1798. * \param e Entry to which you want to add values.
  1799. * \param type Attribute type to which you want to add values.
  1800. * \param vs #Slapi_ValueSet data value that you want to add to the entry.
  1801. * \return \c 0 when successful; any other value returned signals failure.
  1802. * \warning This function makes a copy of the parameter \c vs. The \c vs
  1803. * parameter can be \c NULL.
  1804. */
  1805. int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
  1806. /**
  1807. * Removes an array of Slapi_Value data values from an attribute in an entry.
  1808. *
  1809. * This function removes an attribute/valueset from an entry. Both the attribute
  1810. * and its #Slapi_Value data values are removed from the entry. If you supply a
  1811. * #Slapi_Value whose value is \c NULL, the function will delete the specified
  1812. * attribute from the entry. In either case, the function returns \c LDAP_SUCCESS.
  1813. *
  1814. * \param e Entry from which you want to delete values.
  1815. * \param type Attribute type from which you want to delete values.
  1816. * \param vals \c NULL terminated array of #Slapi_Value data values that you
  1817. * want to delete.
  1818. * \return \c LDAP_SUCCESS if the specified attribute and the array of #Slapi_Value
  1819. * data values are deleted from the entry.
  1820. * \return If the specified attribute contains a \c NULL value, the attribute is
  1821. * deleted from the attribute list, and the function returns
  1822. * \c LDAP_NO_SUCH_ATTRIBUTE. As well, if the attribute is not found in the
  1823. * list of attributes for the specified entry, the function returns
  1824. * \c LDAP_NO_SUCH_ATTRIBUTE.
  1825. * \return If there is an operational error during the processing of this call such
  1826. * as a duplicate value found, the function will return
  1827. * \c LDAP_OPERATIONS_ERROR.
  1828. * \warning The \c vals parameter can be \c NULL, in which case this function does
  1829. * nothing.
  1830. */
  1831. int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1832. /**
  1833. * Merges (adds) and array of #Slapi_Value data values to a specified attribute in
  1834. * an entry.
  1835. *
  1836. * This function adds additional #Slapi_Value data values to the existing values
  1837. * contained in an attribute. If the attribute type does not exist, it is created.
  1838. *
  1839. * If the specified attribute exists in the entry, the function merges the value
  1840. * specified and returns \c LDAP_SUCCESS. If the attribute is not found in the entry,
  1841. * the function creates it with the #Slapi_Value specified and returns \c
  1842. * LDAP_NO_SUCH_ATTRIBUTE.
  1843. *
  1844. * If this function fails, it leaves the values for \c type within a pointer to
  1845. * \c e in an indeterminate state. The present valueset may be truncated.
  1846. *
  1847. * \param e Entry into which you want to merge values.
  1848. * \param type Attribute type that you want to merge the values into.
  1849. * \param vals \c NULL terminated array of #Slapi_Value values that you want to merge
  1850. * into the entry.
  1851. * \return \c LDAP_SUCCESS
  1852. * \return \c LDAP_NO_SUCH_ATTRIBUTE
  1853. * \warning This function makes a copy of \c vals. The \c vals parameter
  1854. * can be \c NULL.
  1855. */
  1856. int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1857. /**
  1858. * Replaces the values of an attribute with the #Slapi_Value data value you specify.
  1859. *
  1860. * This function replaces existing attribute values in a specified entry with a single
  1861. * #Slapi_Value data value. The function first deletes the existing attribute from the
  1862. * entry, then replaces it with the new value specified.
  1863. *
  1864. * \param e Entry in which you want to replace values.
  1865. * \param type Attribute type which will receive the replaced values
  1866. * \param vals \c NULL terminated array of #Slapi_Value valyes that should replace
  1867. * the existing values of the attribute.
  1868. * \return \c 0 when successful; any other value returned signals failure.
  1869. * \warning This function makes a copy of \c vals. The \c vals parameter
  1870. * can be \c NULL.
  1871. */
  1872. int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
  1873. /**
  1874. * Adds a specified #Slapi_Value data value to an attribute in an entry.
  1875. *
  1876. * This function adds a #Slapi_Value data value to the existing attribute values in an
  1877. * entry. If the specified attribute does not exist in the entry, the attribute is
  1878. * created with the #Slapi_Value specified. The function doesn’t check for duplicate
  1879. * values, meaning it does not check if the value being added is already there.
  1880. *
  1881. * \param e Entry to which you want to add a value.
  1882. * \param type Attribute to which you want to add a value.
  1883. * \param value The #Slapi_Value data value you want to add to the entry.
  1884. * \return \c 0 when successful; any other value returned signals failure.
  1885. * \warning This function makes a copy of \c value. The \c value parameter
  1886. * can be \c NULL.
  1887. */
  1888. int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value);
  1889. /**
  1890. * Adds a string value to an attribute in an entry.
  1891. *
  1892. * This function adds a string value to the existing attribute values in an entry. If
  1893. * the specified attribute does not exist in the entry, the attribute is created with
  1894. * the string value specified. The function doesn’t check for duplicate values; it
  1895. * does not check if the string value being added is already there.
  1896. *
  1897. * \param e Entry to which you want to add a string value.
  1898. * \param type Attribute to which you want to add a string value.
  1899. * \param value String value you want to add.
  1900. * \return \c 0 when successful; any other value returned signals failure.
  1901. * \warning This function makes a copy of \c value. The \c value parameter
  1902. * can be \c NULL.
  1903. */
  1904. int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value);
  1905. /**
  1906. * Deletes a string value from an attribute in an entry.
  1907. *
  1908. * \param e Entry from which you want the string deleted.
  1909. * \param type Attribute type from which you want the string deleted.
  1910. * \param value Value of string to delete.
  1911. * \return \c 0 when successful; any other value returned signals failure.
  1912. */
  1913. int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
  1914. /**
  1915. * Find differences between two entries.
  1916. *
  1917. * Compares two #Slapi_Entry entries and determines the difference between them. The
  1918. * differences are returned as the modifications needed to the first entry to make it
  1919. * match the second entry.
  1920. *
  1921. * \param smods An empty #Slapi_Mods that will be filled in with the modifications
  1922. * needed to make \c e1 the same as \c e2.
  1923. * \param e1 The first entry you want to compare.
  1924. * \param e2 The second entry you want to compare.
  1925. * \param diff_ctrl Allows you to skip comparing operational attributes by passing
  1926. * #SLAPI_DUMP_NOOPATTRS. Pass \c 0 if you want to compare the
  1927. * operational attributes.
  1928. * \warning The caller must allocate the #Slapi_Mods that is passed in as \c smods.
  1929. * This must be an empty #Slapi_Mods, otherwise the contents will be leaked.
  1930. * \warning It is up to the caller to free \c smods when they are finished using them
  1931. * by calling slapi_mods_free() or slapi_mods_done() if \c smods was allocated
  1932. * on the stack.
  1933. */
  1934. void slapi_entry_diff(Slapi_Mods *smods, Slapi_Entry *e1, Slapi_Entry *e2, int diff_ctrl);
  1935. /**
  1936. * Applies an array of \c LDAPMod modifications to a Slapi_Entry.
  1937. *
  1938. * \param e Entry to which you want to apply the modifications.
  1939. * \param mods \c NULL terminated array of \c LDAPMod modifications that you
  1940. * want to apply to the specified entry.
  1941. * \return \c LDAP_SUCCESS if the mods applied to the entry cleanly, otherwise an
  1942. * LDAP error is returned.
  1943. * \warning It is up to the caller to free the \c LDAPMod array after the mods have
  1944. * been applied.
  1945. */
  1946. int slapi_entry_apply_mods(Slapi_Entry *e, LDAPMod **mods);
  1947. /**
  1948. * Applies a single \c LDAPMod modification to a Slapi_Entry.
  1949. *
  1950. * \param e Entry to which you want to apply the modification.
  1951. * \param mod A pointer to the \c LDAPMod modification that you
  1952. * want to apply to the specified entry.
  1953. * \return \c LDAP_SUCCESS if the mod applied to the entry cleanly, otherwise
  1954. * an LDAP error is returned.
  1955. * \warning It is up to the caller to free the \c LDAPMod after the mod has
  1956. * been applied.
  1957. */
  1958. int slapi_entry_apply_mod(Slapi_Entry *e, LDAPMod *mod);
  1959. /**
  1960. * Renames a Slapi_Entry.
  1961. *
  1962. * This function will rename an existing \c Slapi_Entry, similar to what
  1963. * would happen with a \c MODRDN operation. New RDN values will be added
  1964. * as attributes to the entry and old RDN values will be deleted if requested.
  1965. *
  1966. * \param e Entry that you want to rename.
  1967. * \param newrdn The new RDN value to be used for renaming the entry. This must
  1968. * not be \c NULL.
  1969. * \param deleteoldrdn Will delete the old RDN values from the entry if set to \c 1.
  1970. * \param newsuperior The new superior DN to use when renaming the entry. Set this
  1971. * to \c NULL if you do not want to move the entry.
  1972. * \return \c LDAP_SUCCESS if the rename was successful, otherwise an LDAP error
  1973. * is returned.
  1974. */
  1975. int slapi_entry_rename(Slapi_Entry *e, const char *newrdn, int deleteoldrdn, Slapi_DN *newsuperior);
  1976. /*------------------------
  1977. * Entry flags.
  1978. *-----------------------*/
  1979. /**
  1980. * Flag that signifies that an entry is a tombstone entry
  1981. *
  1982. * \see slapi_entry_flag_is_set()
  1983. * \see slapi_entry_set_flag()
  1984. * \see slapi_entry_clear_flag()
  1985. */
  1986. #define SLAPI_ENTRY_FLAG_TOMBSTONE 1
  1987. /**
  1988. * Determines if certain flags are set for a specified entry.
  1989. *
  1990. * \param e Entry for which you want to check for the specified flag.
  1991. * \param flag The flag whose presense you want to check for. Valid flags are:
  1992. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  1993. * \return \c 0 if the flag is not set.
  1994. * \return The value of the flag if it is set.
  1995. * \see slapi_entry_clear_flag()
  1996. * \see slapi_entry_set_flag()
  1997. */
  1998. int slapi_entry_flag_is_set( const Slapi_Entry *e, unsigned char flag );
  1999. /**
  2000. * Sets a flag for a specified entry.
  2001. *
  2002. * \param e Entry for which you want to set the flag.
  2003. * \param flag Flag that you want to set. Valid flags are:
  2004. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  2005. * \see slapi_entry_clear_flag()
  2006. * \see slapi_entry_flag_is_set()
  2007. */
  2008. void slapi_entry_set_flag( Slapi_Entry *e, unsigned char flag);
  2009. /**
  2010. * Clears a flag for a specified entry.
  2011. *
  2012. * \param e Entry for which you want to clear the flag.
  2013. * \param flag Flag that you want to clear. Valid flags are:
  2014. * \arg #SLAPI_ENTRY_FLAG_TOMBSTONE
  2015. * \see slapi_entry_flag_is_set()
  2016. * \see slapi_entry_set_flag()
  2017. */
  2018. void slapi_entry_clear_flag( Slapi_Entry *e, unsigned char flag);
  2019. /*------------------------------
  2020. * exported vattrcache routines
  2021. *------------------------------*/
  2022. /**
  2023. * Check if an entry is current in the virtual attribute cache.
  2024. *
  2025. * \param e The entry for which you want to check the virtual attribute cache
  2026. * validity.
  2027. * \return \c 1 if the entry is valid in the cache.
  2028. * \return \c 0 if the entry is invalid in the cache.
  2029. */
  2030. int slapi_entry_vattrcache_watermark_isvalid(const Slapi_Entry *e);
  2031. /**
  2032. * Mark an entry as valid in the virtual attribute cache.
  2033. *
  2034. * \param e The entry that you want to mark as valid.
  2035. */
  2036. void slapi_entry_vattrcache_watermark_set(Slapi_Entry *e);
  2037. /**
  2038. * Mark an entry as invalid in the virtual attribute cache.
  2039. *
  2040. * \param e The entry that you want to mark as invalid.
  2041. */
  2042. void slapi_entry_vattrcache_watermark_invalidate(Slapi_Entry *e);
  2043. /**
  2044. * Apply mod and store the result in the entry extension
  2045. *
  2046. * \param e The entry to apply mod.
  2047. * \param mod The mod to apply on entry.
  2048. * \param modcnt The count of values in mod.
  2049. *
  2050. * \return \c 1 if mod is applied and stored in extension.
  2051. * \return \c -1 if mod is applied and failed
  2052. * \return \c 0 if mod is nothing to do with extension
  2053. */
  2054. int slapi_entry_apply_mod_extension(Slapi_Entry *e, const LDAPMod *mod, int modcnt);
  2055. /**
  2056. * Invalidate all entries in the virtual attribute cache.
  2057. */
  2058. void slapi_entrycache_vattrcache_watermark_invalidate(void);
  2059. /*
  2060. * Slapi_DN routines
  2061. */
  2062. /**
  2063. * Creates a new \c Slapi_DN structure.
  2064. *
  2065. * This function will allocate the necessary memory for a \c Slapi_DN
  2066. * and initialize both the DN and normalized DN values to \c NULL.
  2067. *
  2068. * \return A pointer to the newly allocated, and still empty,
  2069. * \c Slapi_DN structure.
  2070. * \see slapi_sdn_free()
  2071. * \see slapi_sdn_copy()
  2072. * \see slapi_sdn_done()
  2073. */
  2074. Slapi_DN *slapi_sdn_new( void );
  2075. /**
  2076. * Creates a new \c Slapi_DN structure and intializes it's DN to a requested value.
  2077. *
  2078. * The DN of the new structure will point to a copy of the string pointed to by \c dn.
  2079. * The DN value is passed in to the parameter by value.
  2080. *
  2081. * \param dn The DN value to be set in the new \c Slapi_DN structure.
  2082. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2083. * a DN value set to the content of \c dn.
  2084. * \warning The \c dn value is copied by the function itself. The caller
  2085. * is still responsible for the memory used by \c dn.
  2086. * \see slapi_sdn_new_dn_byref()
  2087. * \see slapi_sdn_new_dn_passin()
  2088. * \see slapi_sdn_free()
  2089. * \see slapi_sdn_copy()
  2090. * \see slapi_sdn_done()
  2091. */
  2092. Slapi_DN *slapi_sdn_new_dn_byval(const char *dn);
  2093. /**
  2094. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2095. *
  2096. * The normalized DN of the new structure will point to a copy of the string pointed to by
  2097. * \c ndn. The normalized DN value is passed in to the parameter by value.
  2098. *
  2099. * \param ndn The normalized DN value to be set in the new \c Slapi_DN structure.
  2100. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2101. * the normalized DN value set to the content of \c ndn.
  2102. * \warning The \c ndn value is copied by the function itself. The caller
  2103. * is still responsible for the memory used by \c ndn.
  2104. * \see slapi_sdn_new_ndn_byref()
  2105. * \see slapi_sdn_new_ndn_passin()
  2106. * \see slapi_sdn_free()
  2107. * \see slapi_sdn_copy()
  2108. * \see slapi_sdn_done()
  2109. */
  2110. Slapi_DN *slapi_sdn_new_ndn_byval(const char *ndn);
  2111. /**
  2112. * Creates a new \c Slapi_DN structure and intializes it's DN to a requested value.
  2113. *
  2114. * The DN of the new structure will point to the same string pointed to by \c dn.
  2115. * The DN value is passed in to the parameter by reference.
  2116. *
  2117. * \param dn The DN value to be set in the new \c Slapi_DN structure.
  2118. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2119. * a DN value set to the content of \c dn.
  2120. * \warning The caller is still responsible for the memory used by \c dn. This
  2121. * memory should not be freed until the returned \c Slapi_DN has been
  2122. * disposed of or reinitialized.
  2123. * \see slapi_sdn_new_dn_byval()
  2124. * \see slapi_sdn_new_dn_passin()
  2125. * \see slapi_sdn_free()
  2126. * \see slapi_sdn_copy()
  2127. * \see slapi_sdn_done()
  2128. */
  2129. Slapi_DN *slapi_sdn_new_dn_byref(const char *dn);
  2130. /**
  2131. * Creates a new \c Slapi_DN structure and intializes it's normalized and case ignored DN to a requested value.
  2132. *
  2133. * The normalized and case ignored DN of the new structure will point to the same string pointed to by \c ndn.
  2134. * The normalized and case ignored DN value is passed in to the parameter by reference.
  2135. *
  2136. * \param ndn The normalized and case ignored DN value to be set in the new \c Slapi_DN structure.
  2137. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2138. * the normalized and case ignored DN value set to the content of \c ndn.
  2139. * \warning The caller is still responsible for the memory used by \c ndn. This
  2140. * memory should not be freed until the returned \c Slapi_DN has been
  2141. * disposed of or reinitialized.
  2142. * \see slapi_sdn_new_ndn_byval()
  2143. * \see slapi_sdn_new_ndn_passin()
  2144. * \see slapi_sdn_free()
  2145. * \see slapi_sdn_copy()
  2146. * \see slapi_sdn_done()
  2147. */
  2148. Slapi_DN *slapi_sdn_new_ndn_byref(const char *ndn);
  2149. /**
  2150. * Creates a new \c Slapi_DN structure and intializes it's normalized and case ignored DN to a requested value.
  2151. *
  2152. * The normalized and case ignored DN of the new structure will point to the same string pointed to by \c ndn.
  2153. * Ownership of the memory pointed to by \c ndn is tranferred to the Slapi_DN.
  2154. *
  2155. * \param ndn The normalized and case ignored DN value to be set in the new \c Slapi_DN structure.
  2156. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2157. * the normalized and case ignored DN value set to the content of \c ndn.
  2158. * \see slapi_sdn_new_ndn_byval()
  2159. * \see slapi_sdn_new_ndn_byref()
  2160. * \see slapi_sdn_free()
  2161. * \see slapi_sdn_copy()
  2162. * \see slapi_sdn_done()
  2163. */
  2164. Slapi_DN *slapi_sdn_new_ndn_passin(const char *ndn);
  2165. /**
  2166. * Creates a new \c Slapi_DN structure and intializes it's DN to a requested value.
  2167. *
  2168. * The DN of the new structure will point to the same string pointed to by \c dn.
  2169. * Ownership of the memory pointed to by \c dn is tranferred to the Slapi_DN.
  2170. *
  2171. * \param dn The DN value to be set in the new \c Slapi_DN structure.
  2172. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2173. * a DN value set to the content of \c dn.
  2174. * \warning The caller is no longer responsible for the memory used by \c dn.
  2175. * This memory should not be freed directly. It will be freed when
  2176. * the \c Slapi_DN is properly disposed of.
  2177. * \see slapi_sdn_new_dn_byval()
  2178. * \see slapi_sdn_new_dn_byref()
  2179. * \see slapi_sdn_free()
  2180. * \see slapi_sdn_copy()
  2181. * \see slapi_sdn_done()
  2182. */
  2183. Slapi_DN *slapi_sdn_new_dn_passin(const char *dn);
  2184. /**
  2185. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2186. *
  2187. * The DN of the new structure will point to the same string pointed to by \c normdn.
  2188. * The normalized DN value is passed in to the parameter by reference.
  2189. *
  2190. * \param normdn The normalized DN value to be set in the new \c Slapi_DN structure.
  2191. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2192. * the normalized DN value set to the content of \c normdn.
  2193. * \warning The caller is still responsible for the memory used by \c normdn.
  2194. * This memory should not be freed until the returned \c Slapi_DN
  2195. * has been disposed of or reinitialized.
  2196. * \see slapi_sdn_free()
  2197. * \see slapi_sdn_copy()
  2198. * \see slapi_sdn_done()
  2199. */
  2200. Slapi_DN *slapi_sdn_new_normdn_byref(const char *normdn);
  2201. /**
  2202. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2203. *
  2204. * The DN of the new structure will point to the same string pointed to by \c normdn.
  2205. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2206. *
  2207. * \param normdn The DN value to be set in the new \c Slapi_DN structure.
  2208. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2209. * a DN value set to the content of \c dn.
  2210. * \warning The caller is no longer responsible for the memory used by \c dn.
  2211. * This memory should not be freed directly. It will be freed when
  2212. * the \c Slapi_DN is properly disposed of.
  2213. * \see slapi_sdn_free()
  2214. * \see slapi_sdn_copy()
  2215. * \see slapi_sdn_done()
  2216. */
  2217. Slapi_DN *slapi_sdn_new_normdn_passin(const char *dn);
  2218. /**
  2219. * Creates a new \c Slapi_DN structure and intializes it's normalized DN to a requested value.
  2220. *
  2221. * The DN of the new structure will point to the duplicated string of \c normdn.
  2222. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2223. *
  2224. * \param normdn The copy of the DN value to be set in the new \c Slapi_DN structure.
  2225. * \return A pointer to the newly allocated \c Slapi_DN structure with
  2226. * a DN value set to the content of \c dn.
  2227. * \warning The caller is no longer responsible for the memory used by \c dn.
  2228. * This memory should not be freed directly. It will be freed when
  2229. * the \c Slapi_DN is properly disposed of.
  2230. * \see slapi_sdn_free()
  2231. * \see slapi_sdn_copy()
  2232. * \see slapi_sdn_done()
  2233. */
  2234. Slapi_DN *slapi_sdn_new_normdn_byval(const char *dn);
  2235. /**
  2236. * Sets a DN value in a \c Slapi_DN structure.
  2237. *
  2238. * The DN of the structure will point to a copy of the string pointed to by
  2239. * \c dn. The DN value is passed in to the parameter by value.
  2240. *
  2241. * \param sdn The target \c Slapi_DN structure.
  2242. * \param dn The DN value to be set in \c sdn.
  2243. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2244. * \warning The \c dn value is copied by the function itself. The caller
  2245. * is still responsible for the memory used by \c dn.
  2246. * \see slapi_sdn_set_dn_byref()
  2247. * \see slapi_sdn_set_dn_passin()
  2248. */
  2249. Slapi_DN *slapi_sdn_set_dn_byval(Slapi_DN *sdn, const char *dn);
  2250. /**
  2251. * Sets a DN value in a \c Slapi_DN structure.
  2252. *
  2253. * The DN of the structure will point to the same string pointed to by \c dn.
  2254. * The DN value is passed in to the parameter by reference.
  2255. *
  2256. * \param sdn The target \c Slapi_DN structure.
  2257. * \param dn The DN value to be set in \c sdn.
  2258. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2259. * \warning The caller is still responsible for the memory used by \c dn. This
  2260. * memory should not be freed until the returned \c Slapi_DN has been
  2261. * disposed of or reinitialized.
  2262. * \see slapi_sdn_set_dn_byval()
  2263. * \see slapi_sdn_set_dn_passin()
  2264. */
  2265. Slapi_DN *slapi_sdn_set_dn_byref(Slapi_DN *sdn, const char *dn);
  2266. /**
  2267. * Sets a DN value in a \c Slapi_DN structure.
  2268. *
  2269. * The DN of the structure will point to the same string pointed to by \c dn.
  2270. * Ownership of the memory pointed to by \c dn is tranferred to the Slapi_DN.
  2271. *
  2272. * \param sdn The target \c Slapi_DN structure.
  2273. * \param dn The DN value to be set in \c sdn.
  2274. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2275. * \warning The caller is no longer responsible for the memory used by \c dn.
  2276. * This memory should not be freed directly. It will be freed when
  2277. * the \c Slapi_DN is properly disposed of.
  2278. * \see slapi_sdn_set_dn_byval()
  2279. * \see slapi_sdn_set_dn_byref()
  2280. */
  2281. Slapi_DN *slapi_sdn_set_dn_passin(Slapi_DN *sdn, const char *dn);
  2282. /**
  2283. * Sets a normalized DN value in a \c Slapi_DN structure.
  2284. *
  2285. * The DN of the structure will point to the same string pointed to by \c normdn.
  2286. * The normalized DN value is passed in to the parameter by reference.
  2287. *
  2288. * \param sdn The target \c Slapi_DN structure.
  2289. * \param normdn The normalized DN value to be set in \c sdn.
  2290. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2291. * \warning The caller is still responsible for the memory used by \c normdn.
  2292. * This memory should not be freed until the returned \c Slapi_DN
  2293. * has been disposed of or reinitialized.
  2294. * \see slapi_sdn_set_dn_byref()
  2295. */
  2296. Slapi_DN *slapi_sdn_set_normdn_byref(Slapi_DN *sdn, const char *normdn);
  2297. /**
  2298. * Sets a normalized DN value in a \c Slapi_DN structure.
  2299. *
  2300. * The DN of the structure will point to the same string pointed to by \c normdn.
  2301. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2302. *
  2303. * \param sdn The target \c Slapi_DN structure.
  2304. * \param normdn The normalized DN value to be set in \c sdn.
  2305. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2306. * \warning The caller is no longer responsible for the memory used by \c normdn.
  2307. * This memory should not be freed directly. It will be freed when
  2308. * the \c Slapi_DN is properly disposed of.
  2309. * \see slapi_sdn_set_dn_passin()
  2310. */
  2311. Slapi_DN *slapi_sdn_set_normdn_passin(Slapi_DN *sdn, const char *dn);
  2312. /**
  2313. * Sets a normalized DN value in a \c Slapi_DN structure.
  2314. *
  2315. * The normalized DN of the structure will point to a copy of the string
  2316. * pointed to by \c dn. The normalized DN value is passed in to the parameter
  2317. * by value.
  2318. * Ownership of the memory pointed to by \c normdn is tranferred to the Slapi_DN.
  2319. *
  2320. * \param sdn The target \c Slapi_DN structure.
  2321. * \param normdn The normalized DN value to be set in \c sdn.
  2322. * \return A pointer to the \c Slapi_DN structure containing the new DN value.
  2323. * \warning The caller is no longer responsible for the memory used by \c normdn.
  2324. * This memory should not be freed directly. It will be freed when
  2325. * the \c Slapi_DN is properly disposed of.
  2326. * \see slapi_sdn_set_dn_passin()
  2327. */
  2328. Slapi_DN *slapi_sdn_set_normdn_byval(Slapi_DN *sdn, const char *dn);
  2329. /**
  2330. * Sets a normalized and case ignored DN value in a \c Slapi_DN structure.
  2331. *
  2332. * The normalized DN of the structure will point to a copy of the string
  2333. * pointed to by \c ndn. The normalized DN value is passed in to the parameter
  2334. * by value.
  2335. *
  2336. * \param sdn The target \c Slapi_DN structure.
  2337. * \param ndn The normalized DN value to be set in \c sdn.
  2338. * \return A pointer to the \c Slapi_DN structure containing the new normalized DN value.
  2339. * \warning The \c ndn value is copied by the function itself. The caller
  2340. * is still responsible for the memory used by \c ndn.
  2341. * \see slapi_sdn_set_ndn_byref()
  2342. * \see slapi_sdn_set_ndn_passin()
  2343. */
  2344. Slapi_DN *slapi_sdn_set_ndn_byval(Slapi_DN *sdn, const char *ndn);
  2345. /**
  2346. * Sets a normalized DN value in a \c Slapi_DN structure.
  2347. *
  2348. * The normalized DN of the structure will point to the same string pointed to
  2349. * by \c ndn. The normalized DN value is passed in to the parameter by reference.
  2350. *
  2351. * \param sdn The target \c Slapi_DN structure.
  2352. * \param ndn The normalized DN value to be set in \c sdn.
  2353. * \return A pointer to the \c Slapi_DN structure containing the new normalized DN value.
  2354. * \warning The caller is still responsible for the memory used by \c ndn. This
  2355. * memory should not be freed until the returned \c Slapi_DN has been
  2356. * disposed of or reinitialized.
  2357. * \see slapi_sdn_set_ndn_byval()
  2358. * \see slapi_sdn_set_ndn_passin()
  2359. */
  2360. Slapi_DN *slapi_sdn_set_ndn_byref(Slapi_DN *sdn, const char *ndn);
  2361. /**
  2362. * Sets a normalized DN value in a \c Slapi_DN structure.
  2363. *
  2364. * The normalized DN of the structure will point to the same string pointed to
  2365. * by \c ndn.
  2366. * Ownership of the memory pointed to by \c ndn is tranferred to the Slapi_DN.
  2367. *
  2368. * \param sdn The target \c Slapi_DN structure.
  2369. * \param ndn The normalized DN value to be set in \c sdn.
  2370. * \return A pointer to the \c Slapi_DN structure containing the new normalized DN value.
  2371. * \see slapi_sdn_set_ndn_byval()
  2372. * \see slapi_sdn_set_ndn_byref()
  2373. */
  2374. Slapi_DN *slapi_sdn_set_ndn_passin(Slapi_DN *sdn, const char *ndn);
  2375. /**
  2376. * Clears the contents of a Slapi_DN structure.
  2377. *
  2378. * Both the DN and the normalized DN are freed if the \c Slapi_DN structure
  2379. * owns the memory. Both pointers are then set to \c NULL.
  2380. *
  2381. * \param sdn Pointer to the \c Slapi_DN to clear.
  2382. * \see slapi_sdn_free()
  2383. */
  2384. void slapi_sdn_done(Slapi_DN *sdn);
  2385. /**
  2386. * Frees a \c Slapi_DN structure.
  2387. *
  2388. * Both the DN and the normalized DN are freed if the \c Slapi_DN structure
  2389. * owns the memory. The \c Slapi_DN structure itself is then freed.
  2390. *
  2391. * \param sdn Pointer to the pointer of the \c Slapi_DN structure to be freed.
  2392. * \see slapi_sdn_done()
  2393. * \see slapi_sdn_new()
  2394. */
  2395. void slapi_sdn_free(Slapi_DN **sdn);
  2396. /**
  2397. * Retrieves the normalized DN value of a \c Slapi_DN structure.
  2398. *
  2399. * If the structure does not contain a normalized DN yet, it will normalize
  2400. * the un-normalized DN and set it in the structure.
  2401. *
  2402. * \param sdn The \c Slapi_DN strucure containing the DN value.
  2403. * \return A pointer to the DN value if one is set.
  2404. * \return A pointer to the normalized and case ignored DN value if one is set and no
  2405. * DN value is set.
  2406. * \return \c NULL if no normalized DN or normalized and case ignored DN value is set.
  2407. * \warning The pointer returned is the actual value from the structure, not a copy.
  2408. * \see slapi_sdn_get_ndn()
  2409. * \see slapi_sdn_get_udn()
  2410. */
  2411. const char * slapi_sdn_get_dn(const Slapi_DN *sdn);
  2412. /**
  2413. * Retrieves the normalized and case ignored DN value of a \c Slapi_DN structure.
  2414. *
  2415. * If the structure does not contain a normalized and case ignored DN yet,
  2416. * it will normalize and case ignore the DN and set it in the structure.
  2417. *
  2418. * \param sdn The \c Slapi_DN strucure containing the normalized and case ignored DN value.
  2419. * \return The normalized DN value.
  2420. * \return \c NULL if no DN or normalized DN value is set.
  2421. * \warning The pointer returned is the actual value from the structure, not a copy.
  2422. * \see slapi_sdn_get_dn()
  2423. * \see slapi_sdn_get_udn()
  2424. */
  2425. const char * slapi_sdn_get_ndn(const Slapi_DN *sdn);
  2426. /**
  2427. * Retrieves the un-normalized DN value of a \c Slapi_DN structure.
  2428. *
  2429. * \param sdn The \c Slapi_DN strucure containing the DN value.
  2430. * \return A pointer to the DN value if one is set.
  2431. * \return A pointer to the normalized DN value if one is set and no
  2432. * DN value is set.
  2433. * \return \c NULL if no DN or normalized DN value is set.
  2434. * \warning The pointer returned is the actual value from the structure, not a copy.
  2435. * \see slapi_sdn_get_dn()
  2436. * \see slapi_sdn_get_ndn()
  2437. */
  2438. const char * slapi_sdn_get_udn(const Slapi_DN *sdn);
  2439. /**
  2440. * Fills in an existing \c Slapi_DN structure with the parent DN of the passed in \c Slapi_DN.
  2441. *
  2442. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2443. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2444. * The existing contents (if any) will be cleared before the new DN value is set.
  2445. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2446. * \see slapi_sdn_get_backend_parent()
  2447. */
  2448. void slapi_sdn_get_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent);
  2449. /**
  2450. * Fills in an existing \c Slapi_DN structure with the parent DN of the passed in \c Slapi_DN.
  2451. *
  2452. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2453. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2454. * The existing contents (if any) will be cleared before the new DN value is set.
  2455. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  2456. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2457. * \see slapi_sdn_get_backend_parent()
  2458. */
  2459. void slapi_sdn_get_parent_ext(const Slapi_DN *sdn,Slapi_DN *sdn_parent,int is_tombstone);
  2460. /**
  2461. * Fills in an existing \c Slapi_DN structure with the parent DN of an entry within a specific backend.
  2462. *
  2463. * The parent DN is returned in \c sdn_parent, unless \c sdn is empty or is a suffix of the backend
  2464. * itself. In this case, \c sdn_parent is empty.
  2465. *
  2466. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2467. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2468. * The existing contents (if any) will be cleared before the new DN value is set.
  2469. * \param backend Backend to search for the parent of \c sdn.
  2470. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2471. * \see slapi_sdn_get_parent()
  2472. */
  2473. void slapi_sdn_get_backend_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent,const Slapi_Backend *backend);
  2474. /**
  2475. * Fills in an existing \c Slapi_DN structure with the parent DN of an entry within a specific backend.
  2476. *
  2477. * The parent DN is returned in \c sdn_parent, unless \c sdn is empty or is a suffix of the backend
  2478. * itself. In this case, \c sdn_parent is empty.
  2479. *
  2480. * \param sdn Pointer to the \c Slapi_DN structure containing the DN whose parent is desired.
  2481. * \param sdn_parent Pointer to the \c Slapi_DN structure where the parent DN is returned.
  2482. * The existing contents (if any) will be cleared before the new DN value is set.
  2483. * \param backend Backend to search for the parent of \c sdn.
  2484. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  2485. * \warning A \c Slapi_DN structure for \c sdn_parent must be allocated before calling this function.
  2486. * \see slapi_sdn_get_parent()
  2487. */
  2488. void slapi_sdn_get_backend_parent_ext(const Slapi_DN *sdn,Slapi_DN *sdn_parent,const Slapi_Backend *backend,int is_tombstone);
  2489. /**
  2490. * Return the size of a \c Slapi_DN structure.
  2491. *
  2492. * \param sdn Pointer to the \c Slapi_DN structure to get the size.
  2493. */
  2494. size_t slapi_sdn_get_size(const Slapi_DN *sdn);
  2495. /**
  2496. * Duplicates a \c Slapi_DN structure.
  2497. *
  2498. * \param sdn Pointer to the \c Slapi_DN structure to duplicate.
  2499. * \return A pointer to a duplicate of \c sdn.
  2500. * \see slapi_sdn_copy()
  2501. * \see slapi_sdn_new()
  2502. * \see slapi_sdn_free()
  2503. */
  2504. Slapi_DN * slapi_sdn_dup(const Slapi_DN *sdn);
  2505. /**
  2506. * Copies the contents of a \c Slapi_DN to another \c existing Slapi_DN.
  2507. *
  2508. * \param from A pointer to the \c Slapi_DN structure to copy from.
  2509. * \param to A pointer to the \c Slapi_DN structure to copy to.
  2510. * \warning You must allocate \c to before calling this function.
  2511. * \see slapi_sdn_dup()
  2512. */
  2513. void slapi_sdn_copy(const Slapi_DN *from, Slapi_DN *to);
  2514. /**
  2515. * Compares two \c Slapi_DN structures.
  2516. *
  2517. * Performs a case-sensitive comparison of two \c Slapi_DN structures.
  2518. *
  2519. * \param sdn1 A pointer to the first \c Slapi_DN structure to compare.
  2520. * \param sdn2 A pointer to the second \c Slapi_DN structure to compare.
  2521. * \return \c 0 if \c sdn1 is equal to \c sdn2.
  2522. * \return \c -1 if \c sdn1 is \c NULL.
  2523. * \return \c 1 if \c sdn2 is \c NULL and \c sdn1 is not \c NULL.
  2524. */
  2525. int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 );
  2526. /**
  2527. * Checks if a DN or normalized DN is set in a \c Slapi_DN.
  2528. *
  2529. * \param sdn A pointer to the \c Slapi_DN structure to check.
  2530. * \return \c 1 if there is no DN or normalized DN set in \c sdn.
  2531. * \return \c 0 if \c sdn is not empty.
  2532. * \see slapi_sdn_done()
  2533. */
  2534. int slapi_sdn_isempty( const Slapi_DN *sdn);
  2535. /**
  2536. * Checks whether a \c Slapi_DN structure contains a suffix of another \c Slapi_DN structure.
  2537. *
  2538. * \param sdn A pointer to the \c Slapi_DN structure to check.
  2539. * \param suffixsdn A pointer to the \c Slapi_DN structure of the suffix.
  2540. * \return \c 1 if the DN in \c suffixsdn is a suffix of \c sdn.
  2541. * \return \c 0 if the DN in \c suffixsdn is not a suffix of \c sdn.
  2542. * \see slapi_sdn_isparent()
  2543. * \see slapi_sdn_isgrandparent()
  2544. */
  2545. int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn);
  2546. /**
  2547. * Checks whether a DN is the parent of a given DN.
  2548. *
  2549. * \param parent A pointer to the \c Slapi_DN structure containing the DN
  2550. * which claims to be the parent of the DN in \c child.
  2551. * \param child A pointer to the Slapi_DN structure containing the DN of the
  2552. * supposed child of the DN in the structure pointed to by \c parent.
  2553. * \return \c 1 if the DN in \c parent is the parent of the DN in \c child.
  2554. * \return \c 0 if the DN in \c parent is not the parent of the DN in \c child.
  2555. * \see slapi_sdn_isgrandparent()
  2556. * \see slapi_sdn_issuffix()
  2557. * \see slapi_sdn_get_parent()
  2558. */
  2559. int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child );
  2560. /**
  2561. * Checks whether a DN is the grandparent of a given DN.
  2562. *
  2563. * \param parent A pointer to the \c Slapi_DN structure containing the DN
  2564. * which claims to be the grandparent of the DN in \c child.
  2565. * \param child A pointer to the Slapi_DN structure containing the DN of the
  2566. * supposed grandchild of the DN in the structure pointed to by \c parent.
  2567. * \return \c 1 if the DN in \c parent is the grandparent of the DN in \c child.
  2568. * \return \c 0 if the DN in \c parent is not the grandparent of the DN in \c child.
  2569. * \see slapi_sdn_isparent()
  2570. * \see slapi_sdn_issuffix()
  2571. * \see slapi_sdn_get_parent()
  2572. */
  2573. int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child );
  2574. /**
  2575. * Gets the length of the normalized DN of a Slapi_DN structure.
  2576. *
  2577. * This function normalizes \c sdn if it has not already been normalized.
  2578. *
  2579. * \param sdn A pointer to the \c Slapi_DN structure containing the DN value.
  2580. * \return The length of the normalized DN.
  2581. */
  2582. int slapi_sdn_get_ndn_len(const Slapi_DN *sdn);
  2583. /**
  2584. * Checks if a DN is within a specified scope under a specified base DN.
  2585. *
  2586. * \param dn A pointer to the \c Slapi_DN structure to test.
  2587. * \param base The base DN against which \c dn is going to be tested.
  2588. * \param scope The scope tested. Valid scopes are:
  2589. * \arg \c LDAP_SCOPE_BASE
  2590. * \arg \c LDAP_SCOPE_ONELEVEL
  2591. * \arg \c LDAP_SCOPE_SUBTREE
  2592. * \return non-zero if \c dn matches the scoping criteria given by \c base and \c scope.
  2593. * \see slapi_sdn_compare()
  2594. * \see slapi_sdn_isparent()
  2595. * \see slapi_sdn_issuffix()
  2596. */
  2597. int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
  2598. /**
  2599. * Checks if a DN is within a specified scope under a specified base DN.
  2600. * This api adjusts tombstoned DN when comparing with the base dn.
  2601. *
  2602. * \param dn A pointer to the \c Slapi_DN structure to test.
  2603. * \param base The base DN against which \c dn is going to be tested.
  2604. * \param scope The scope tested. Valid scopes are:
  2605. * \arg \c LDAP_SCOPE_BASE
  2606. * \arg \c LDAP_SCOPE_ONELEVEL
  2607. * \arg \c LDAP_SCOPE_SUBTREE
  2608. * \param flags 0 or SLAPI_ENTRY_FLAG_TOMBSTONE
  2609. * \return non-zero if \c dn matches the scoping criteria given by \c base and \c scope.
  2610. * \see slapi_sdn_compare()
  2611. * \see slapi_sdn_isparent()
  2612. * \see slapi_sdn_issuffix()
  2613. */
  2614. int slapi_sdn_scope_test_ext( const Slapi_DN *dn, const Slapi_DN *base, int scope, int flags );
  2615. /**
  2616. * Retreives the RDN from a given DN.
  2617. *
  2618. * This function takes the DN stored in the \c Slapi_DN structure pointed to
  2619. * by \c sdn and fills in it's RDN within the \c Slapi_RDN structure pointed
  2620. * to by \c rdn.
  2621. *
  2622. * \param sdn A pointer to the \c Slapi_DN structure containing the DN.
  2623. * \param rdn A pointer to the \c Slapi_RDN structure where the RDN is filled in.
  2624. * \warning The caller must allocate \c rdn before calling this function.
  2625. * \see slapi_sdn_get_dn()
  2626. * \see slapi_sdn_set_rdn()
  2627. * \see slapi_sdn_add_rdn()
  2628. * \see slapi_sdn_is_rdn_component()
  2629. */
  2630. void slapi_sdn_get_rdn(const Slapi_DN *sdn,Slapi_RDN *rdn);
  2631. /**
  2632. * Sets a new RDN for a given DN.
  2633. *
  2634. * This function changes the RDN of \c sdn by adding the value from
  2635. * \c rdn to the parent DN of \c sdn.
  2636. *
  2637. * \param sdn The DN that you want to rename.
  2638. * \param rdn The new RDN.
  2639. * \return A pointer to the \c Slapi_DN structure that has been renamed.
  2640. * \see slapi_sdn_get_rdn()
  2641. */
  2642. Slapi_DN *slapi_sdn_set_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  2643. /**
  2644. * Sets a new parent for a given DN.
  2645. *
  2646. * This function keeps the RDN of the original DN and adds it to the
  2647. * specified parent DN.
  2648. *
  2649. * \param sdn The \c Slapi_DN structure containing the DN whose parent you want to change.
  2650. * \param parentdn The \c Slapi_DN structure containing the new parent DN.
  2651. * \return A pointer to the \c Slapi_DN structure that contains the new DN.
  2652. * \see slapi_sdn_isparent()
  2653. * \see slapi_sdn_get_parent()
  2654. */
  2655. Slapi_DN *slapi_sdn_set_parent(Slapi_DN *sdn, const Slapi_DN *parentdn);
  2656. /**
  2657. * Builds a new DN out of a new RDN and the DN of the new parent.
  2658. *
  2659. * The new DN is worked out by adding the new RDN in \c newrdn to a
  2660. * parent DN. The parent will be the value in \c newsuperiordn if different
  2661. * from \c NULL, and will otherwise be taken from \c dn_olddn by removing
  2662. * the old RDN (the parent of the entry will still be the same as the new DN).
  2663. *
  2664. * \param dn_olddn The old DN value.
  2665. * \param newrdn The new RDN value.
  2666. * \param newsuperiordn If not \c NULL, will be the DN of the future superior
  2667. * entry of the new DN, which will be worked out by adding the value
  2668. * in \c newrdn in front of the content of this parameter.
  2669. * \return The new DN for the entry whose previous DN was \c dn_olddn.
  2670. */
  2671. char * slapi_moddn_get_newdn(Slapi_DN *dn_olddn, const char *newrdn, const char *newsuperiordn);
  2672. Slapi_DN *slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  2673. /*
  2674. * Slapi_RDN functions
  2675. */
  2676. /**
  2677. * Creates a new \c Slapi_RDN structure.
  2678. *
  2679. * Allocates the necessary memory and initializes both the
  2680. * RDN value and the array of split RDNs to \c NULL.
  2681. *
  2682. * \return A pointer to the newly allocated, and still empty, \c Slapi_RDN structure.
  2683. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2684. * when you are finished using it.
  2685. * \see slapi_rdn_init()
  2686. * \see slapi_rdn_done()
  2687. * \see slapi_rdn_free()
  2688. */
  2689. Slapi_RDN *slapi_rdn_new( void );
  2690. /**
  2691. * Creates a new \c Slapi_RDN structure and initializes it from a string.
  2692. *
  2693. * \param dn The DN value whose RDN will be used to initialize the new
  2694. * \c Slapi_RDN structure.
  2695. * \return A pointer to the newly allocated and initialized \c Slapi_RDN structure.
  2696. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2697. * when you are finished using it.
  2698. * \see slapi_rdn_new_sdn()
  2699. * \see slapi_rdn_new_rdn()
  2700. * \see slapi_rdn_free()
  2701. */
  2702. Slapi_RDN *slapi_rdn_new_dn(const char *dn);
  2703. /**
  2704. * Creates a new \c Slapi_RDN structure and initializes it from a \c Slapi_DN.
  2705. *
  2706. * \param sdn The \c Slapi_DN structure whose RDN will be used to initialize
  2707. * the new \c Slapi_RDN structure.
  2708. * \return A pointer to the newly allocated and initialized \c Slapi_RDN structure.
  2709. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2710. * when you are finished using it.
  2711. * \see slapi_rdn_new_dn()
  2712. * \see slapi_rdn_new_rdn()
  2713. * \see slapi_rdn_free()
  2714. */
  2715. Slapi_RDN *slapi_rdn_new_sdn(const Slapi_DN *sdn);
  2716. /**
  2717. * Creates a new \c Slapi_RDN structure and initializes it from a \c Slapi_RDN.
  2718. *
  2719. * \param fromrdn The \c Slapi_RDN structure whose RDN will be used to initialize
  2720. * the new \c Slapi_RDN structure.
  2721. * \return A pointer to the newly allocated and initialized \c Slapi_RDN structure.
  2722. * \warning You must free the returned \c Slapi_RDN structure by calling \c slapi_rdn_free()
  2723. * when you are finished using it.
  2724. * \see slapi_rdn_new_dn()
  2725. * \see slapi_rdn_new_sdn()
  2726. * \see slapi_rdn_free()
  2727. */
  2728. Slapi_RDN *slapi_rdn_new_rdn(const Slapi_RDN *fromrdn);
  2729. /**
  2730. * Clears out a \c Slapi_RDN structure.
  2731. *
  2732. * Sets both the RDN value and the array of split RDNs to \c NULL.
  2733. *
  2734. * \param rdn The \c Slapi_RDN structure to be initialized.
  2735. * \warning The previous contents of \c rdn are not freed. It is
  2736. * up to the caller to do this first if necessary.
  2737. * \see slapi_rdn_new()
  2738. * \see slapi_rdn_free()
  2739. * \see slapi_rdn_done()
  2740. */
  2741. void slapi_rdn_init(Slapi_RDN *rdn);
  2742. /**
  2743. * Initializes a \c Slapi_RDN structure from a string.
  2744. *
  2745. * \param rdn The \c Slapi_RDN structure to be initialized.
  2746. * \param dn The DN value whose RDN will be used to initialize \c rdn.
  2747. * \warning The previous contents of \c rdn are not freed. It is
  2748. * up to the caller to do this first if necessary.
  2749. * \see slapi_rdn_done()
  2750. * \see slapi_rdn_init_sdn()
  2751. * \see slapi_rdn_init_rdn()
  2752. */
  2753. void slapi_rdn_init_dn(Slapi_RDN *rdn,const char *dn);
  2754. /**
  2755. * Initializes a \c Slapi_RDN structure from a \c Slapi_DN.
  2756. *
  2757. * \param rdn The \c Slapi_RDN structure to be initialized.
  2758. * \param sdn The \c Slapi_DN whose RDN will be used to initialize \c rdn.
  2759. * \warning The previous contents of \c rdn are not freed. It is
  2760. * up to the caller to do this first if necessary.
  2761. * \see slapi_rdn_done()
  2762. * \see slapi_rdn_init_dn()
  2763. * \see slapi_rdn_init_rdn()
  2764. */
  2765. void slapi_rdn_init_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  2766. /**
  2767. * Initializes a \c Slapi_RDN structure from another \c Slapi_RDN.
  2768. *
  2769. * \param rdn The \c Slapi_RDN structure to be initialized.
  2770. * \param fromrdn The \c Slapi_RDN structure that will be used to
  2771. * initialize \c rdn.
  2772. * \warning The previous contents of \c rdn are not freed. It is
  2773. * up to the caller to do this first if necessary.
  2774. * \see slapi_rdn_done()
  2775. * \see slapi_rdn_init_dn()
  2776. * \see slapi_rdn_init_sdn()
  2777. */
  2778. void slapi_rdn_init_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  2779. /**
  2780. * Sets the RDN value in a \c Slapi_RDN structure from a string.
  2781. *
  2782. * The previous contents of the \c rdn are freed before
  2783. * the new RDN is set.
  2784. *
  2785. * \param rdn The target \c Slapi_RDN structure.
  2786. * \param dn The DN value whose RDN will be set in \c rdn.
  2787. * \see slapi_rdn_set_sdn()
  2788. * \see slapi_rdn_set_rdn()
  2789. */
  2790. void slapi_rdn_set_dn(Slapi_RDN *rdn,const char *dn);
  2791. Slapi_RDN *slapi_rdn_new_all_dn(const char *dn);
  2792. int slapi_rdn_init_all_dn(Slapi_RDN *rdn, const char *dn);
  2793. int slapi_rdn_init_all_sdn(Slapi_RDN *rdn, const Slapi_DN *sdn);
  2794. /**
  2795. * Sets the RDN value in a \c Slapi_RDN structure from a \c Slapi_DN.
  2796. *
  2797. * The previous contents of the \c rdn are freed before
  2798. * the new RDN is set.
  2799. *
  2800. * \param rdn The target \c Slapi_RDN structure.
  2801. * \param sdn The \c Slapi_DN value whose RDN will be set in \c rdn.
  2802. * \see slapi_rdn_set_dn()
  2803. * \see slapi_rdn_set_rdn()
  2804. */
  2805. void slapi_rdn_set_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
  2806. /**
  2807. * Sets the RDN value in a \c Slapi_RDN structure from a \c Slapi_RDN.
  2808. *
  2809. * The previous contents of the \c rdn are freed before
  2810. * the new RDN is set.
  2811. *
  2812. * \param rdn The target \c Slapi_RDN structure.
  2813. * \param fromrdn The \c Slapi_RDN value whose RDN will be set in \c rdn.
  2814. * \see slapi_rdn_set_dn()
  2815. * \see slapi_rdn_set_sdn()
  2816. */
  2817. void slapi_rdn_set_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
  2818. /**
  2819. * Frees a \c Slapi_RDN structure and it's contents from memory.
  2820. *
  2821. * \param rdn A pointer to a pointer of the \c Slapi_RDN strucure to be freed.
  2822. * \see slapi_rdn_new()
  2823. * \see slapi_rdn_done()
  2824. */
  2825. void slapi_rdn_free(Slapi_RDN **rdn);
  2826. /**
  2827. * Checks if the value of ipAddress is a IPv6 address
  2828. *
  2829. * \param ipAddress is a string that is either an IPv4 or IPv6 address
  2830. * \return 1 if address is an IPv6 address
  2831. * \return 0 if address is an IPv4 address
  2832. */
  2833. int slapi_is_ipv6_addr( const char *ipAddress);
  2834. /**
  2835. * Returns the length of a ber-encoded ldap operation
  2836. *
  2837. * \param bv is the berval of the encoded ldap operation
  2838. * \param strict set to 0 if "bv" does not contain the entire LDAP encoding
  2839. * \return -1 if the length can not be determined
  2840. * \return length
  2841. */
  2842. ber_len_t slapi_berval_get_msg_len(struct berval *bv, int strict);
  2843. /**
  2844. * Frees and clears the contents of a \c Slapi_RDN structure from memory.
  2845. *
  2846. * Both the RDN value and the array of split RDNs are freed. Those pointers
  2847. * are then set to \c NULL.
  2848. *
  2849. * \param rdn A pointer to the \c Slapi_RDN strucure to clear.
  2850. * \see slapi_rdn_free()
  2851. * \see slapi_rdn_init()
  2852. */
  2853. void slapi_rdn_done(Slapi_RDN *rdn);
  2854. /**
  2855. * Gets the first RDN stored in a \c Slapi_RDN structure.
  2856. *
  2857. * The type and the value of the first RDN are retrieved.
  2858. *
  2859. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2860. * \param type Address to return a pointer to the type of the first RDN. If
  2861. * this is \c NULL at the return of the function, it means that \c rdn
  2862. * is empty.
  2863. * \param value Address to return a pointer to the value of the first RDN.
  2864. * If this is \c NULL at the return of the function, it means that
  2865. * \c rdn is empty.
  2866. * \return \c -1 if \c rdn is empty.
  2867. * \return \c 1 if the operation is successful.
  2868. * \warning Do not free the returned type or value.
  2869. * \see slapi_rdn_get_next()
  2870. * \see slapi_rdn_get_rdn()
  2871. */
  2872. int slapi_rdn_get_first(Slapi_RDN *rdn, char **type, char **value);
  2873. /**
  2874. * Gets the next RDN stored in a \c Slapi_RDN structure.
  2875. *
  2876. * The type/value pair for the RDN at the position following that indicated
  2877. * by \c index will be retrieved.
  2878. *
  2879. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2880. * \param index Indicates the position that precedes that of the desired RDN.
  2881. * For example, pass 1 if you would like the second RDN.
  2882. * \param type Address to return a pointer to the type of the next RDN. If
  2883. * this is \c NULL at the return of the function, it means that \c rdn
  2884. * is empty.
  2885. * \param value Address to return a pointer to the value of the next RDN.
  2886. * If this is \c NULL at the return of the function, it means that
  2887. * \c rdn is empty.
  2888. * \return \c -1 if no RDN exists at the index position.
  2889. * \return The position (\c index + \c 1) of the retrieved RDN if the operation is successful.
  2890. * \see slapi_rdn_get_first()
  2891. * \see slapi_rdn_get_rdn()
  2892. */
  2893. int slapi_rdn_get_next(Slapi_RDN *rdn, int index, char **type, char **value);
  2894. /**
  2895. * Finds a RDN in a \c Slapi_RDN structure and returns it's index.
  2896. *
  2897. * The \c Slapi_RDN structure will be searched for a RDN matching
  2898. * the given type and value.
  2899. *
  2900. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2901. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  2902. * \param value Value of the RDN that is searched for.
  2903. * \param length Gives the length of the value that should be taken into
  2904. * account for the string comparisons when searching for the RDN.
  2905. * \return The index of the RDN that matches \c type and \c value.
  2906. * \return \c -1 if no RDN stored in \c rdn matches \c type and \c value.
  2907. * \see slapi_rdn_get_index_attr()
  2908. * \see slapi_rdn_contains()
  2909. */
  2910. int slapi_rdn_get_index(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  2911. /**
  2912. * Finds a RDN for a given type in a \c Slapi_RDN structure and returns it's index.
  2913. *
  2914. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2915. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  2916. * \param value Address to return a pointer to the value of the next RDN.
  2917. * If this is \c NULL at the return of the function, it means that
  2918. * no matching RDN exist in \c rdn.
  2919. * \return The index of the RDN that matches \c type.
  2920. * \return \c -1 if no RDN stored in \c rdn matches \c type.
  2921. * \see slapi_rdn_get_index()
  2922. */
  2923. int slapi_rdn_get_index_attr(Slapi_RDN *rdn, const char *type, char **value);
  2924. /**
  2925. * Checks if a RDN exists in a \c Slapi_RDN structure.
  2926. *
  2927. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2928. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  2929. * \param value Value of the RDN that is searched for.
  2930. * \param length Gives the length of the value that should be taken into
  2931. * account for the string comparisons when searching for the RDN.
  2932. * \return \c 1 if \c rdn contains a RDN that matches \c type and \c value.
  2933. * \return \c 0 if no RDN stored in \c rdn matches \c type and \c value.
  2934. * \see slapi_rdn_get_index()
  2935. * \see slapi_rdn_contains_attr()
  2936. */
  2937. int slapi_rdn_contains(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
  2938. /**
  2939. * Checks if a RDN for a given type exists in a \c Slapi_RDN structure.
  2940. *
  2941. * \param rdn The \c Slapi_RDN structure containing the RDN value(s).
  2942. * \param type Type (\c cn, \c o, \c ou, etc.) of the RDN that is searched for.
  2943. * \param value Address to return a pointer to the value of the next RDN.
  2944. * If this is \c NULL at the return of the function, it means that
  2945. * no matching RDN exist in \c rdn.
  2946. * \return \c 1 if \c rdn contains a RDN that matches \c type.
  2947. * \return \c 0 if no RDN stored in \c rdn matches \c type.
  2948. * \see slapi_rdn_get_index_attr()
  2949. * \see slapi_rdn_contains()
  2950. */
  2951. int slapi_rdn_contains_attr(Slapi_RDN *rdn, const char *type, char **value);
  2952. /**
  2953. * Adds a new RDN to a \c Slapi_RDN structure.
  2954. *
  2955. * A new type/value pair will be added to an existing RDN, or the type/value
  2956. * pair will be set as the new RDN if \c rdn is empty. This function resets the
  2957. * FLAG_RDNS flags, which means that the RDN array with-in the \c Slapi_RDN
  2958. * structure is no longer current with the new RDN.
  2959. *
  2960. * \param rdn The target \c Slapi_RDN structure.
  2961. * \param type The type (\c cn, \c o, \c ou, etc.) of the RDN to be added.
  2962. * This parameter cannot be \c NULL.
  2963. * \param value The value of the RDN to be added. This parameter cannot
  2964. * be \c NULL.
  2965. * \return Always returns 1.
  2966. * \see slapi_rdn_get_num_components()
  2967. */
  2968. int slapi_rdn_add(Slapi_RDN *rdn, const char *type, const char *value);
  2969. /**
  2970. * Removes a RDN from a \c Slapi_RDN structure at a given position.
  2971. *
  2972. * \param rdn The target \c Slapi_RDN structure.
  2973. * \param atindex The index of the RDN type/value pair to remove.
  2974. * \return \c 1 if the RDN is removed from \c rdn.
  2975. * \return \c 0 if no RDN is removed because either \c rdn is empty
  2976. * or \c atindex goes beyond the number of RDNs present.
  2977. * \see slapi_rdn_remove()
  2978. * \see slapi_rdn_remove_attr()
  2979. */
  2980. int slapi_rdn_remove_index(Slapi_RDN *rdn, int atindex);
  2981. /**
  2982. * Removes a RDN from a \c Slapi_RDN structure matching a given type/value pair.
  2983. *
  2984. * \param rdn The target \c Slapi_RDN structure.
  2985. * \param type The type (\c cn, \c o, \c ou, etc.) of the RDN to be removed.
  2986. * \param value The value of the RDN to be removed.
  2987. * \param length Gives the length of the value that should be taken into
  2988. * account for the string comparisons when searching for the RDN.
  2989. * \return \c 1 if the RDN is removed from \c rdn.
  2990. * \return \c 0 if no RDN is removed.
  2991. * \see slapi_rdn_remove_attr()
  2992. * \see slapi_rdn_remove_index()
  2993. */
  2994. int slapi_rdn_remove(Slapi_RDN *rdn, const char *type, const char *value, size_t length);
  2995. /**
  2996. * Removes a RDN from a \c Slapi_RDN structure matching a given type.
  2997. *
  2998. * \param rdn The target \c Slapi_RDN structure.
  2999. * \param type The type (\c cn, \c o, \c ou, etc.) of the RDN to be removed.
  3000. * \return \c 1 if the RDN is removed from \c rdn.
  3001. * \return \c 0 if no RDN is removed.
  3002. * \see slapi_rdn_remove()
  3003. * \see slapi_rdn_remove_index()
  3004. */
  3005. int slapi_rdn_remove_attr(Slapi_RDN *rdn, const char *type);
  3006. /**
  3007. * Checks whether a RDN value is stored in a \c Slapi_RDN structure.
  3008. *
  3009. * \param rdn The target \c Slapi_RDN structure.
  3010. * \return \c 1 if there is no RDN value present.
  3011. * \return \c 0 if rdn contains a value.
  3012. * \see slapi_rdn_init()
  3013. * \see slapi_rdn_done()
  3014. * \see slapi_rdn_free()
  3015. */
  3016. int slapi_rdn_isempty(const Slapi_RDN *rdn);
  3017. /**
  3018. * Gets the number of RDN type/value pairs present in a \c Slapi_RDN structure.
  3019. *
  3020. * \param rdn The target \c Slapi_RDN structure.
  3021. * \return The number of RDN type/value pairs present in \c rdn.
  3022. * \see slapi_rdn_add()
  3023. */
  3024. int slapi_rdn_get_num_components(Slapi_RDN *rdn);
  3025. /**
  3026. * Compares two \c Slapi_RDN structures.
  3027. *
  3028. * For RDNs to be considered equal, the order of their components
  3029. * do not have to be the same.
  3030. *
  3031. * \param rdn1 The first RDN to compare.
  3032. * \param rdn2 The second RDN to compare.
  3033. * \return \c 0 if \c rdn1 and \c rdn2 have the same RDN components.
  3034. * \return \c -1 if they do not have the same components.
  3035. */
  3036. int slapi_rdn_compare(Slapi_RDN *rdn1, Slapi_RDN *rdn2);
  3037. /**
  3038. * Gets the RDN from a \c Slapi_RDN structure.
  3039. *
  3040. * \param rdn The \c Slapi_RDN structure holding the RDN value.
  3041. * \return The RDN value.
  3042. * \warning Do not free the returned RDN value.
  3043. */
  3044. const char *slapi_rdn_get_rdn(const Slapi_RDN *rdn);
  3045. /**
  3046. * Adds a RDN from a \c Slapi_RDN structure to a DN in a \c Slapi_DN structure.
  3047. *
  3048. * The RDN in the \c Slapi_RDN structure will be appended to the DN
  3049. * value in \c sdn.
  3050. *
  3051. * \param sdn \c Slapi_DN structure containing the value to which
  3052. * a new RDN is to be added.
  3053. * \param rdn \c Slapi_RDN structure containing the RDN value
  3054. * that is to be added to the DN value.
  3055. * \return The \c Slapi_DN structure with the new DN.
  3056. * \see slapi_sdn_set_rdn()
  3057. */
  3058. Slapi_DN *slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
  3059. /* Function: slapi_rdn_set_all_dn
  3060. Description: this function sets exploded RDNs of DN to Slapi_RDN
  3061. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3062. dn - distinguished name which is to be exploded into RDNs and
  3063. set to Slapi_RDN
  3064. Return: none
  3065. */
  3066. void slapi_rdn_set_all_dn(Slapi_RDN *rdn,const char *dn);
  3067. /**
  3068. * Gets the normalized RDN from a \c Slapi_RDN structure
  3069. *
  3070. * \param rdn The \c Slapi_RDN structure holding the RDN value.
  3071. * \return The normalized RDN value.
  3072. */
  3073. const char *slapi_rdn_get_nrdn(Slapi_RDN *srdn);
  3074. /* Function: slapi_rdn_get_first_ext
  3075. Description: this function returns the first RDN in RDN array. The RDN
  3076. array is supposed to store all the RDNs of DN.
  3077. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3078. firstrdn - a container to store the address of the first RDN.
  3079. The caller should not free the returned address.
  3080. flag - type of the returned RDN. one of the followings:
  3081. FLAG_ALL_RDNS -- raw (not normalized)
  3082. FLAG_ALL_NRDNS -- normalized
  3083. Return: the index of the first rdn 0, if function succeeds.
  3084. -1, if it fails.
  3085. */
  3086. int slapi_rdn_get_first_ext(Slapi_RDN *srdn, const char **firstrdn, int flag);
  3087. /* Function: slapi_rdn_get_last_ext
  3088. Description: this function returns the last RDN in RDN array. The RDN
  3089. array is supposed to store all the RDNs of DN.
  3090. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3091. lastrdn - a container to store the address of the last RDN.
  3092. The caller should not free the returned address.
  3093. flag - type of the returned RDN. one of the followings:
  3094. FLAG_ALL_RDNS -- raw (not normalized)
  3095. FLAG_ALL_NRDNS -- normalized
  3096. Return: the index of the last rdn, if function succeeds.
  3097. -1, if it fails.
  3098. */
  3099. int slapi_rdn_get_last_ext(Slapi_RDN *srdn, const char **lastrdn, int flag);
  3100. /* Function: slapi_rdn_get_prev_ext
  3101. Description: this function returns the previous RDN of the given index (idx)
  3102. in RDN array.
  3103. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3104. idx - a return value of the previous slapi_rdn_get_last_ext
  3105. or slapi_rdn_get_prev_ext or slapi_rdn_get_next_ext call.
  3106. prevrdn - a container to store the address of the previous RDN.
  3107. The caller should not free the returned address.
  3108. flag - type of the returned RDN. one of the followings:
  3109. FLAG_ALL_RDNS -- raw (not normalized)
  3110. FLAG_ALL_NRDNS -- normalized
  3111. Return: the index of the returned rdn, if function succeeds.
  3112. -1, if it fails.
  3113. */
  3114. int slapi_rdn_get_prev_ext(Slapi_RDN *srdn, int idx, const char **prevrdn, int flag);
  3115. /* Function: slapi_rdn_get_next_ext
  3116. Description: this function returns the next RDN of the given index (idx)
  3117. in RDN array.
  3118. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3119. idx - a return value of the previous slapi_rdn_get_prev_ext
  3120. or slapi_rdn_get_next_ext call.
  3121. nextrdn - a container to store the address of the next RDN.
  3122. The caller should not free the returned address.
  3123. flag - type of the returned RDN. one of the followings:
  3124. FLAG_ALL_RDNS -- raw (not normalized)
  3125. FLAG_ALL_NRDNS -- normalized
  3126. Return: the index of the returned rdn, if function succeeds.
  3127. -1, if it fails.
  3128. */
  3129. int slapi_rdn_get_next_ext(Slapi_RDN *srdn, int idx, const char **nextrdn, int flag);
  3130. /* Function: slapi_rdn_add_rdn_to_all_rdns
  3131. Description: this function appends the given RDN to the RDN array in
  3132. Slapi_RDN.
  3133. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3134. addrdn - an RDN string to append.
  3135. byref - non 0, then the passed addrdn is put in the RDN array.
  3136. 0, then the duplicated addrdn is put in the RDN array.
  3137. Return: 0, if the function succeeds.
  3138. -1, if it fails.
  3139. */
  3140. int slapi_rdn_add_rdn_to_all_rdns(Slapi_RDN *srdn, char *addrdn, int byref);
  3141. /* Function: slapi_rdn_add_srdn_to_all_rdns
  3142. Description: this function appends the given Slapi_RDN to the RDN array in
  3143. Slapi_RDN.
  3144. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3145. addsrdn - Slapi_RDN to append.
  3146. Return: 0, if the function succeeds.
  3147. -1, if it fails.
  3148. */
  3149. int slapi_rdn_add_srdn_to_all_rdns(Slapi_RDN *srdn, Slapi_RDN *addsrdn);
  3150. /* Function: slapi_rdn_get_dn
  3151. Description: this function generates DN string if it stores RDNs in its
  3152. all_rdns field.
  3153. Parameters: srdn - a pointer to Slapi_RDN which stores RDN array
  3154. dn -- a container to store the address of DN; dn is allocated
  3155. in this function.
  3156. Return: 0, if the function succeeds.
  3157. -1, if it fails (e.g., srdn is NULL, dn is NULL, or srdn does not
  3158. have RDN array in it.
  3159. */
  3160. int slapi_rdn_get_dn(Slapi_RDN *srdn, char **dn);
  3161. /* Function: slapi_srdn_copy
  3162. Description: this function copies "from" Slapi_RDN structure to "to"
  3163. Parameters: from - a pointer to source Slapi_RDN
  3164. to -- an address to store the copied Slapi_RDN.
  3165. Return: 0, if the function succeeds.
  3166. -1, if it fails
  3167. */
  3168. int slapi_srdn_copy(const Slapi_RDN *from, Slapi_RDN *to);
  3169. /* Function: slapi_srdn_copy
  3170. Description: this function replaces the rdn in Slapi_RDN with new_rdn
  3171. Parameters: srdn - a pointer to Slapi_RDN
  3172. new_rdn -- new rdn set to Slapi_RDN
  3173. Return: 0, if the function succeeds.
  3174. -1, if it fails
  3175. */
  3176. int slapi_rdn_replace_rdn(Slapi_RDN *srdn, char *new_rdn);
  3177. /* Function: slapi_rdn_partial_dup
  3178. Description: this function partially duplicates "from" Slapi_RDN structure and set it to "to"
  3179. Parameters: from - a pointer to source Slapi_RDN
  3180. to -- an address to store the partially copied Slapi_RDN.
  3181. idx -- index from which the duplicate begins
  3182. Return: 0, if the function succeeds.
  3183. -1, if it fails
  3184. */
  3185. int slapi_rdn_partial_dup(Slapi_RDN *from, Slapi_RDN **to, int idx);
  3186. /**
  3187. * Return the size of the RDN
  3188. *
  3189. * \param srdn A pointer to Slapi_RDN to calculate the size
  3190. * \return The size of the given RDN.
  3191. */
  3192. size_t slapi_rdn_get_size(Slapi_RDN *srdn);
  3193. /**
  3194. * Return the value of the RDN
  3195. *
  3196. * \param rdn A pointer to rdn to get the value.
  3197. * \return The value of the given RDN.
  3198. */
  3199. char * slapi_rdn_get_value(const char *rdn);
  3200. /*
  3201. * utility routines for dealing with DNs
  3202. */
  3203. /**
  3204. * Does nothing. (DEPRECATED)
  3205. *
  3206. * \param dn The DN to normalize.
  3207. * \return The normalized DN.
  3208. * \deprecated Use slapi_dn_normalized_ext.
  3209. */
  3210. char *slapi_dn_normalize( char *dn );
  3211. /**
  3212. * Does nothing. (DEPRECATED)
  3213. *
  3214. * \param dn The DN value to normalize.
  3215. * \param end Pointer to the end of what will be normalized from the DN
  3216. * value in \c dn. If this parameter is \c NULL, the DN value
  3217. * will be wholly normalized.
  3218. * \return The normalized DN.
  3219. * \deprecated Use slapi_dn_normalized_ext.
  3220. */
  3221. char *slapi_dn_normalize_to_end( char *dn, char *end );
  3222. /**
  3223. * Normalizes a DN.
  3224. *
  3225. * \param src The DN to normalize.
  3226. * \param src_len The length of src DN to normalize. If 0 is given, strlen(src) is used.
  3227. * \param dest The normalized DN.
  3228. * \param dest The length of the normalized DN dest.
  3229. * \return \c 0 if successful. The dest DN is normalized in line. Caller must not free dest.
  3230. * \return \c 1 if successful. The dest DN is allocated. Caller must free dest.
  3231. * \return \c -1 if an error occurs (for example, if the src DN cannot be normalized)
  3232. */
  3233. int slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len);
  3234. /**
  3235. * Normalizes a DN (in lower-case characters).
  3236. *
  3237. * \param src The DN to normalize.
  3238. * \param src_len The length of src DN to normalize. If 0 is given, strlen(src) is used internally.
  3239. * \param dest The normalized DN with the cases lowered.
  3240. * \param dest_len The length of the normalized DN dest.
  3241. * \return \c 0 if successful. The dest DN is normalized in line. Caller must not free dest. The string is NOT NULL terminated.
  3242. * \return \c 1 if successful. The dest DN is allocated. Caller must free dest.
  3243. * \return \c -1 if an error occurs (for example, if src DN cannot be normalized)
  3244. */
  3245. int slapi_dn_normalize_case_ext(char *src, size_t src_len, char **dest, size_t *dest_len);
  3246. /**
  3247. * Generate a valid DN string.
  3248. *
  3249. * \param fmt The format used to generate a DN string.
  3250. * \param ... The arguments to generate a DN string.
  3251. * \return A pointer to the generated DN.
  3252. * \return NULL if failed.
  3253. * \note When a DN needs to be internally created, this function is supposed to be called. This function allocates the enough memory for the normalized DN and returns it filled with the normalized DN.
  3254. */
  3255. char *slapi_create_dn_string(const char *fmt, ...);
  3256. /**
  3257. * Generates a valid DN string (in lower-case characters).
  3258. *
  3259. * \param fmt The format used to generate a DN string.
  3260. * \param ... The arguments to generate a DN string.
  3261. * \return A pointer to the generated DN.
  3262. * \return NULL if failed.
  3263. */
  3264. char *slapi_create_dn_string_case(const char *fmt, ...);
  3265. /**
  3266. * Generates a valid value of RDN string
  3267. *
  3268. * \param fmt The format used to generate a value of RDN string.
  3269. * \param ... The arguments to generate an RDN string.
  3270. * \return A pointer to the generated RDN value.
  3271. * \return NULL if failed.
  3272. */
  3273. char *slapi_create_rdn_value(const char *fmt, ...);
  3274. /**
  3275. * Converts a DN to lowercase.
  3276. *
  3277. * \param dn The DN to convert.
  3278. * \return A pointer to the converted DN.
  3279. * \deprecated Use slapi_sdn_get_ndn() instead to normalize the case,
  3280. * or use slapi_sdn_compare() to compare regardless of case.
  3281. */
  3282. char *slapi_dn_ignore_case( char *dn );
  3283. /**
  3284. * Converts a DN to canonical format and converts all characters to lowercase.
  3285. *
  3286. * \param dn DN that you want to normalize and convert to lowercase.
  3287. * \return The normalized and converted DN.
  3288. * \note The \c dn parameter is converted in place.
  3289. */
  3290. char *slapi_dn_normalize_case( char *dn );
  3291. /**
  3292. * Get a copy of the parent DN of a DN.
  3293. *
  3294. * \param pb A parameter block with the backend set.
  3295. * \param dn The DN whose parent is desired.
  3296. * \return A pointer to the parent DN of \c dn.
  3297. * \return \c NULL if the DN is a suffix of the backend.
  3298. * \warning The caller must free the returned DN when finished with it.
  3299. * \deprecated Use slapi_sdn_get_backend_parent() instead.
  3300. */
  3301. char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
  3302. /**
  3303. * Finds the parent DN of a DN within the same string.
  3304. *
  3305. * \param dn The DN whose parent DN is desired.
  3306. * \return A pointer to the parent DN within \c dn.
  3307. */
  3308. const char *slapi_dn_find_parent( const char *dn );
  3309. /**
  3310. * Finds the parent DN of a DN within the same string.
  3311. *
  3312. * \param dn The DN whose parent DN is desired.
  3313. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  3314. * \return A pointer to the parent DN within \c dn.
  3315. */
  3316. const char *slapi_dn_find_parent_ext( const char *dn, int is_tombstone );
  3317. /**
  3318. * Gets the parent DN of a given DN.
  3319. *
  3320. * \param dn The DN whose parent is desired.
  3321. * \return A pointer to the parent DN of \c dn.
  3322. * \warning The caller must free the returned DN when finished with it.
  3323. * \deprecated Use slapi_sdn_get_parent() instead.
  3324. */
  3325. char *slapi_dn_parent( const char *dn );
  3326. /**
  3327. * Gets the parent DN of a given DN.
  3328. *
  3329. * \param dn The DN whose parent is desired.
  3330. * \param is_tombstone If non-zero, the special leaf rdn "nsuniqueid=.." is ignored.
  3331. * \return A pointer to the parent DN of \c dn.
  3332. * \warning The caller must free the returned DN when finished with it.
  3333. * \deprecated Use slapi_sdn_get_parent() instead.
  3334. */
  3335. char *slapi_dn_parent_ext( const char *dn, int is_tombstone );
  3336. /**
  3337. * Checks if a DN belongs to a suffix.
  3338. *
  3339. * \param dn The DN to check.
  3340. * \param suffix The suffix to check.
  3341. * \return \c 1 if \c dn belongs to \c suffix
  3342. * \return \c 0 if \c dn does not belong to \c suffix.
  3343. * \warning Both \c dn and \c suffix must be normalized before calling this function.
  3344. * \deprecated Use slapi_sdn_issuffix() instead.
  3345. */
  3346. int slapi_dn_issuffix( const char *dn, const char *suffix );
  3347. /**
  3348. * Checks if a DN is the parent of another DN.
  3349. *
  3350. * \param parentdn The DN of the supposed parent.
  3351. * \param childdn The DN of the supposed child.
  3352. * \return non-zero if \c parentdn is the parent of \c childdn.
  3353. * \return \c 0 if \c parentdn is not the paret of \c childdn.
  3354. * \deprecated Use slapi_sdn_isparent() instead.
  3355. */
  3356. int slapi_dn_isparent( const char *parentdn, const char *childdn );
  3357. /**
  3358. * Determines is a DN is the root DN.
  3359. *
  3360. * \param dn The DN to check
  3361. * \return \c 1 if the DN is the root DN.
  3362. * \return \c 0 if the DN is not the root DN.
  3363. * \warning You must normalize \c dn before calling this function.
  3364. */
  3365. int slapi_dn_isroot( const char *dn );
  3366. /**
  3367. * Checks if a DN is the backend suffix.
  3368. *
  3369. * \param pb A parameter block with the backend set.
  3370. * \param dn The DN to check.
  3371. * \return \c 1 if \c dn is the backend suffix.
  3372. * \return \c 0 if \c dn is not the backend suffix.
  3373. * \deprecated slapi_be_issuffix()
  3374. */
  3375. int slapi_dn_isbesuffix( Slapi_PBlock *pb, const char *dn );
  3376. /**
  3377. * Checks if writes to a particular DN need to send a referral.
  3378. *
  3379. * \param target_sdn The target DN that you want to check.
  3380. * \param referral The address of a pointer to receive a referral
  3381. * if one is needed.
  3382. * \return \c 1 if a referral needs to be sent.
  3383. * \return \c 0 if no referral is needed.
  3384. * \warning The referral entry must be freed when it is no longer
  3385. * being used.
  3386. */
  3387. int slapi_dn_write_needs_referral(Slapi_DN *target_sdn, Slapi_Entry **referral);
  3388. /**
  3389. * Converts the second RDN type value to the berval value.
  3390. *
  3391. * Returns the new RDN value as a berval value in \c bv. This function
  3392. * can be used for creating the RDN as an attribute value since it returns
  3393. * the value of the RDN in the berval structure.
  3394. *
  3395. * \param rdn Second RDN value.
  3396. * \param type Address of a pointer to receive the attribute type
  3397. * of the second RDN.
  3398. * \param bv A pointer to the berval structure to receive the value.
  3399. */
  3400. int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv );
  3401. /**
  3402. * Adds a RDN to a DN.
  3403. *
  3404. * \param dn The DN to add the RDN to.
  3405. * \param rdn the new RDN to add to the DN.
  3406. * \return A pointer to the new DN.
  3407. * \warning The caller must free the returnd DN when finished with it.
  3408. * \deprecated Use slapi_sdn_add_rdn() instead.
  3409. */
  3410. char *slapi_dn_plus_rdn(const char *dn, const char *rdn);
  3411. /**
  3412. * Create an Slapi_DN that is a common ancestor of given 2 Slapi_DN's
  3413. *
  3414. * \param dn1 The first DN
  3415. * \param dn2 the second DN
  3416. * \return A pointer to the new Slapi_DN that is a common ancestor of dn1 and dn2
  3417. * \warning The caller must free the returnd Slapi_DN
  3418. */
  3419. Slapi_DN *slapi_sdn_common_ancestor(Slapi_DN *dn1, Slapi_DN *dn2);
  3420. /*
  3421. * thread safe random functions
  3422. */
  3423. /**
  3424. * Generate a pseudo-random integer with optional seed.
  3425. *
  3426. * \param seed A seed to use when generating the pseudo random number.
  3427. * \return A pseudo random number.
  3428. * \see slapi_rand()
  3429. * \see slapi_rand_array()
  3430. */
  3431. int slapi_rand_r(unsigned int * seed);
  3432. /* Generate a pseudo-random integer in an array.
  3433. *
  3434. * \param randx The array you want filled with the random number.
  3435. * \param len The length of the array you want filled with the random number.
  3436. * \see slapi_rand()
  3437. * \see slapi_rand_r()
  3438. */
  3439. void slapi_rand_array(void *randx, size_t len);
  3440. /**
  3441. * Generate a pseudo-random integer.
  3442. *
  3443. * \return A pseudo random number.
  3444. * \see slapi_rand_r()
  3445. * \see slapi_rand_array()
  3446. */
  3447. int slapi_rand(void);
  3448. /**
  3449. * Escape special characters in a search filter value
  3450. *
  3451. * \param filter_str A ldap search filter value (cn=VALUE_TO_BE_ESCAPED)
  3452. * \param len length of the search filter value. -1 indicates the string is null terminated
  3453. * \param buf the buffer to store the escaped filter value string
  3454. * \return the escaped filter value string
  3455. */
  3456. char* slapi_escape_filter_value(char* filter_str, int len);
  3457. #define ESC_NEXT_VAL "__ESC__NEXT__VAL__"
  3458. #define NORM_NEXT_VAL "__NORM__NEXT__VAL__"
  3459. #define ESC_AND_NORM_NEXT_VAL "__ESC__AND__NORM__NEXT__VAL__"
  3460. char* slapi_filter_sprintf(const char *fmt, ...);
  3461. /*
  3462. * attribute routines
  3463. */
  3464. /**
  3465. * Create a new empty attribute.
  3466. *
  3467. * \return A pointer to the newly created attribute.
  3468. * \warning You must free the returned attribute using slapi_attr_free().
  3469. * \see slapi_attr_init()
  3470. * \see slapi_attr_dup()
  3471. * \see slapi_attr_free()
  3472. */
  3473. Slapi_Attr *slapi_attr_new( void );
  3474. /**
  3475. * Initializes an attribute with an attribute type.
  3476. *
  3477. * \param a The attribute to initialize.
  3478. * \param type The attribute type to set.
  3479. * \return A pointer to the initialized attribute.
  3480. */
  3481. Slapi_Attr *slapi_attr_init(Slapi_Attr *a, const char *type);
  3482. /**
  3483. * Frees an attribute from memory.
  3484. *
  3485. * \param a Address of a pointer to the attribute to be freed.
  3486. * \see slapi_attr_init()
  3487. * \see slapi_attr_dup()
  3488. * \see slapi_attr_new()
  3489. */
  3490. void slapi_attr_free( Slapi_Attr **a );
  3491. /**
  3492. * Make a copy of an attribute.
  3493. *
  3494. * \param attr The attribute to be duplicated.
  3495. * \return The newly created copy of the attribute.
  3496. * \warning You must free the returned attribute using slapi_attr_free().
  3497. * \see slapi_attr_new()
  3498. * \see slapi_attr_init()
  3499. * \see slapi_attr_free()
  3500. */
  3501. Slapi_Attr *slapi_attr_dup(const Slapi_Attr *attr);
  3502. /**
  3503. * Adds a value to an attribute.
  3504. *
  3505. * \param a The attribute that will contain the values.
  3506. * \param v Value to be added to the attribute.
  3507. * \return Always returns 0.
  3508. * \see slapi_attr_first_value()
  3509. * \see slapi_attr_next_value()
  3510. * \see slapi_attr_get_numvalues()
  3511. * \see slapi_attr_value_cmp()
  3512. * \see slapi_attr_value_find()
  3513. */
  3514. int slapi_attr_add_value(Slapi_Attr *a, const Slapi_Value *v);
  3515. /**
  3516. * Find syntax plugin associated with an attribute type.
  3517. *
  3518. * \param type Type of attribute for which you want to get the plugin.
  3519. * \param pi Address to receive a pointer to the plugin structure.
  3520. * \return \c 0 if successful.
  3521. * \return \c -1 if the plugin is not found.
  3522. * \deprecated This function was necessary in order to call syntax plugin
  3523. * filter and indexing functions - there are new functions
  3524. * to use instead, such as slapi_attr_values2keys, etc.
  3525. * This function is still used by internal APIs, but new
  3526. * code should not use this function
  3527. * \see slapi_attr_get_type()
  3528. * \see slapi_attr_type_cmp()
  3529. * \see slapi_attr_types_equivalent()
  3530. * \see slapi_attr_basetype()
  3531. */
  3532. int slapi_attr_type2plugin( const char *type, void **pi );
  3533. /**
  3534. * Get the name of the attribute type from a specified attribute.
  3535. *
  3536. * \param attr Attribute for which you want to get the type.
  3537. * \param type Address to receive a pointer to the attribute type.
  3538. * \return Always returns \c 0.
  3539. * \warning Do not free the returned attribute type. The type is a part
  3540. * if the actual attribute data, not a copy.
  3541. * \see slapi_attr_type2plugin()
  3542. * \see slapi_attr_type_cmp()
  3543. * \see slapi_attr_types_equivalent()
  3544. * \see slapi_attr_basetype()
  3545. */
  3546. int slapi_attr_get_type( Slapi_Attr *attr, char **type );
  3547. /**
  3548. * Get the attribute type OID of a particular attribute.
  3549. *
  3550. * \param attr Attribute that contains the desired OID.
  3551. * \param oidp Address to receive a pointer to a copy of the
  3552. * attribute type OID.
  3553. * \return \c 0 if the attribute type is found.
  3554. * \return \c -1 if the attribute type is not found.
  3555. * \warning The returned OID should be freed by calling the
  3556. * slapi_ch_free_string() function.
  3557. * \see slapi_attr_get_syntax_oid_copy()
  3558. */
  3559. int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
  3560. /*
  3561. * Get the syntax OID of a particular attribute.
  3562. *
  3563. * \param a Attribute that contains the desired OID.
  3564. * \param oidp Address to receive a pointer to a copy of the
  3565. * syntax OID.
  3566. * \return \c 0 if the syntax OID is found.
  3567. * \return \c -1 if the syntax OID is not found.
  3568. * \warning The returned OID should be freed by calling the
  3569. * slapi_ch_free_string() function.
  3570. * \see slapi_attr_get_oid_copy()
  3571. */
  3572. int slapi_attr_get_syntax_oid_copy( const Slapi_Attr *a, char **oidp );
  3573. /**
  3574. * Checks if the attribute uses a DN syntax or not.
  3575. *
  3576. * \param attr The attribute to be checked.
  3577. * \return \c non 0 if the attribute uses a DN syntax.
  3578. * \return \c 0 if the attribute does not use a DN syntax.
  3579. */
  3580. int slapi_attr_is_dn_syntax_attr(Slapi_Attr *attr);
  3581. int slapi_attr_is_dn_syntax_type(char *type);
  3582. /**
  3583. * Get the flags associated with a particular attribute.
  3584. *
  3585. * Valid flags are:
  3586. * \arg #SLAPI_ATTR_FLAG_SINGLE
  3587. * \arg #SLAPI_ATTR_FLAG_OPATTR
  3588. * \arg #SLAPI_ATTR_FLAG_READONLY
  3589. * \arg #SLAPI_ATTR_FLAG_OBSOLETE
  3590. * \arg #SLAPI_ATTR_FLAG_COLLECTIVE
  3591. * \arg #SLAPI_ATTR_FLAG_NOUSERMOD
  3592. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  3593. * \arg #SLAPI_ATTR_FLAG_NOEXPOSE
  3594. *
  3595. * \param attr Attribute for which you want to get the flags.
  3596. * \param flags Address of an integer that you want to reveive the flags.
  3597. * \return \c Always returns 0.
  3598. * \see slapi_attr_flag_is_set()
  3599. */
  3600. int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags );
  3601. /**
  3602. * Checks if certain flags are set for a particular attribute.
  3603. *
  3604. * Valid flags are:
  3605. * \arg #SLAPI_ATTR_FLAG_SINGLE
  3606. * \arg #SLAPI_ATTR_FLAG_OPATTR
  3607. * \arg #SLAPI_ATTR_FLAG_READONLY
  3608. * \arg #SLAPI_ATTR_FLAG_OBSOLETE
  3609. * \arg #SLAPI_ATTR_FLAG_COLLECTIVE
  3610. * \arg #SLAPI_ATTR_FLAG_NOUSERMOD
  3611. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  3612. * \arg #SLAPI_ATTR_FLAG_NOEXPOSE
  3613. *
  3614. * \param attr Attribute that you want to check.
  3615. * \param flag Flags to check in the attribute.
  3616. * \return \c 1 if the specified flags are set.
  3617. * \return \c 0 if the specified flags are not set.
  3618. * \see slapi_attr_get_flags()
  3619. */
  3620. int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag );
  3621. /**
  3622. * Comare two bervals for a given attribute.
  3623. *
  3624. * \param attr Attribute used to determine how these values are compared; for
  3625. * example, the syntax of the attribute may perform case-insensitive
  3626. * comparisons.
  3627. * \param v1 Pointer to the \c berval structure containing the first value
  3628. * that you want to compare.
  3629. * \param v2 Pointer to the \c berval structure containing the second value
  3630. * that you want to compare.
  3631. * \return \c 0 if the values are equal.
  3632. * \return \c -1 if the values are not equal.
  3633. * \see slapi_attr_add_value()
  3634. * \see slapi_attr_first_value()
  3635. * \see slapi_attr_next_value()
  3636. * \see slapi_attr_get_numvalues()
  3637. * \see slapi_attr_value_find()
  3638. */
  3639. int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, const struct berval *v2 );
  3640. /**
  3641. * Comare two values for a given attribute.
  3642. *
  3643. * \param attr Attribute used to determine how these values are compared; for
  3644. * example, the syntax of the attribute may perform case-insensitive
  3645. * comparisons.
  3646. * \param v1 Pointer to the \c Slapi_Value structure containing the first value
  3647. * that you want to compare.
  3648. * \param v2 Pointer to the \c Slapi_Value structure containing the second value
  3649. * that you want to compare.
  3650. * \return \c 0 if the values are equal.
  3651. * \return \c -1 if the values are not equal.
  3652. * \see slapi_attr_add_value()
  3653. * \see slapi_attr_first_value()
  3654. * \see slapi_attr_next_value()
  3655. * \see slapi_attr_get_numvalues()
  3656. * \see slapi_attr_value_find()
  3657. * \see slapi_attr_value_cmp()
  3658. */
  3659. int slapi_attr_value_cmp_ext(const Slapi_Attr *a, Slapi_Value *v1, Slapi_Value *v2);
  3660. /**
  3661. * Determine if an attribute contains a given value.
  3662. *
  3663. * \param a Attribute that you want to check.
  3664. * \param v Pointer to the \c berval structure containing the value for
  3665. * which you want to search.
  3666. * \return \c 0 if the attribute contains the specified value.
  3667. * \return \c -1 if the attribute does not contain the specified value.
  3668. * \see slapi_attr_add_value()
  3669. * \see slapi_attr_first_value()
  3670. * \see slapi_attr_next_value()
  3671. * \see slapi_attr_get_numvalues()
  3672. * \see slapi_attr_value_cmp()
  3673. */
  3674. int slapi_attr_value_find( const Slapi_Attr *a, const struct berval *v );
  3675. /**
  3676. * Compare two attribute types.
  3677. *
  3678. * \param t1 Name of the first attribute type to compare.
  3679. * \param t2 Name of the second attribute type to compare.
  3680. * \param opt One of the following options:
  3681. * \arg #SLAPI_TYPE_CMP_EXACT
  3682. * \arg #SLAPI_TYPE_CMP_BASE
  3683. * \arg #SLAPI_TYPE_CMP_SUBTYPE
  3684. * \return \c 0 if the type names are equal.
  3685. * \return A non-zero value if the type names are not equal.
  3686. * \see slapi_attr_type2plugin()
  3687. * \see slapi_attr_get_type()
  3688. * \see slapi_attr_types_equivalent()
  3689. * \see slapi_attr_basetype()
  3690. */
  3691. int slapi_attr_type_cmp( const char *t1, const char *t2, int opt );
  3692. /* Mode of operation (opt) values for slapi_attr_type_cmp() */
  3693. /**
  3694. * Compare the types as-is.
  3695. *
  3696. * \see slapi_attr_type_cmp()
  3697. */
  3698. #define SLAPI_TYPE_CMP_EXACT 0
  3699. /**
  3700. * Compare only the base names of the types.
  3701. *
  3702. * \see slapi_attr_type_cmp()
  3703. */
  3704. #define SLAPI_TYPE_CMP_BASE 1
  3705. /**
  3706. * Ignore any subtypes in the second type that are not in the first subtype.
  3707. *
  3708. * \see slapi_attr_type_cmp()
  3709. */
  3710. #define SLAPI_TYPE_CMP_SUBTYPE 2
  3711. /**
  3712. * Compare two attribute names to determine if they represent the same value.
  3713. *
  3714. * \param t1 Pointer to the first attribute you want to compare.
  3715. * \param t2 Pointer to the second attribute you want to compare.
  3716. * \return \c 1 if \c t1 and \c t2 represent the same attribute.
  3717. * \return \c 0 if \c t1 and \c t2 do not represent the same attribute.
  3718. * \see slapi_attr_type_cmp()
  3719. * \see slapi_attr_get_type()
  3720. * \see slapi_attr_basetype()
  3721. */
  3722. int slapi_attr_types_equivalent(const char *t1, const char *t2);
  3723. /**
  3724. * Get the base type of an attribute.
  3725. *
  3726. * For example, if given \c cn;lang-jp, returns \c cn.
  3727. *
  3728. * \param type Attribute type from which you want to get the base type.
  3729. * \param buf Buffer to hold the returned base type.
  3730. * \param bufsiz Size of the buffer.
  3731. * \return \c NULL if the base type fits in the buffer.
  3732. * \return A pointer to a newly allocated base type if the buffer is
  3733. * too small to hold it.
  3734. * \warning If a base type is returned, if should be freed by calling
  3735. * slapi_ch_free_string().
  3736. * \see slapi_attr_get_type()
  3737. * \see slapi_attr_type_cmp()
  3738. * \see slapi_attr_types_equivalent()
  3739. */
  3740. char *slapi_attr_basetype( const char *type, char *buf, size_t bufsiz );
  3741. /**
  3742. * Get the first value of an attribute.
  3743. *
  3744. * This is part of a set of functions to enumerate over a
  3745. * \c Slapi_Attr structure.
  3746. *
  3747. * \param a Attribute containing the desired value.
  3748. * \param v Holds the first value of the attribute.
  3749. * \return \c 0, which is the index of the first value.
  3750. * \return \c -1 if \c NULL or if the value is not found.
  3751. * \warning Do not free the returned value. It is a part
  3752. * of the attribute structure and not a copy.
  3753. * \see slapi_attr_next_value()
  3754. * \see slapi_attr_get_num_values()
  3755. */
  3756. int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v );
  3757. /**
  3758. * Get the next value of an attribute.
  3759. *
  3760. * The value of an attribute associated with an index is placed into
  3761. * a value. This is pare of a set of functions to enumerate over a
  3762. * \c Slapi_Attr structure.
  3763. *
  3764. * \param a Attribute containing the desired value.
  3765. * \param hint Index of the value to be returned.
  3766. * \param v Holds the value of the attribute.
  3767. * \return \c hint plus \c 1 if the value is found.
  3768. * \return \c -1 if \c NULL or if a value at \c hint is not found.
  3769. * \warning Do not free the returned value. It is a part
  3770. * of the attribute structure and not a copy.
  3771. * \see slapi_attr_first_value()
  3772. * \see slapi_attr_get_num_values()
  3773. */
  3774. int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v );
  3775. /**
  3776. * Get the number of values present in an attribute.
  3777. *
  3778. * Counts the number of values in an attribute and places that
  3779. * count in an integer.
  3780. *
  3781. * \param a Attribute containing the values to be counted.
  3782. * \param numValues Integer to hold the counted values.
  3783. * \see slapi_attr_first_value()
  3784. * \see slapi_attr_next_value()
  3785. */
  3786. int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues);
  3787. /**
  3788. * Copy existing values contained in an attribute into a valueset.
  3789. *
  3790. * \param a Attribute containing the values to be placed into
  3791. * a valueset.
  3792. * \param vs Receives the values from the attribute.
  3793. * \return Always returns \c 0.
  3794. * \warning Free the returned valueset with slapi_valueset_free()
  3795. * when finished using it.
  3796. * \see slapi_entry_add_valueset()
  3797. * \see slapi_valueset_new()
  3798. * \see slapi_valueset_free()
  3799. * \see slapi_valueset_init()
  3800. * \see slapi_valueset_done()
  3801. * \see slapi_valueset_add_value()
  3802. * \see slapi_valueset_first_value()
  3803. * \see slapi_valueset_next_value()
  3804. * \see slapi_valueset_count()
  3805. */
  3806. int slapi_attr_get_valueset(const Slapi_Attr *a, Slapi_ValueSet **vs);
  3807. /**
  3808. * Sets the valueset in an attribute.
  3809. *
  3810. * Intializes a valueset in a \c Slapi_Attr structure from a specified
  3811. * \c Slapi_ValueSet structure. The valueset in the \c Slapi_Attr
  3812. * will be \c vs, not a copy.
  3813. *
  3814. * \param a The attribute to set the valueset in.
  3815. * \param vs The valueset that you want to set in the attribute.
  3816. * \return Always returns \c 0.
  3817. * \warning Do not free \c vs. Ownership of \c vs is tranferred to
  3818. * the attribute.
  3819. * \see slapi_valueset_set_valueset()
  3820. */
  3821. int slapi_attr_set_valueset(Slapi_Attr *a, const Slapi_ValueSet *vs);
  3822. /**
  3823. * Set the attribute type of an attribute.
  3824. *
  3825. * \param a The attribute whose type you want to set.
  3826. * \param type The attribute type you want to set.
  3827. * \return \c 0 if the type was set.
  3828. * \return \c -1 if the type was not set.
  3829. * \warning The passed in type is copied, so ownership of \c type
  3830. * remains with the caller.
  3831. * \see slapi_attr_get_type()
  3832. */
  3833. int slapi_attr_set_type(Slapi_Attr *a, const char *type);
  3834. /**
  3835. * Copy the values from an attribute into a berval array.
  3836. *
  3837. * \param a Attribute that contains the desired values.
  3838. * \param vals Pointer to an array of berval structure pointers to
  3839. * hold the desired values.
  3840. * \return \c 0 if values are found.
  3841. * \return \c -1 if \c NULL.
  3842. * \warning You should free the array using ber_bvecfree() from the
  3843. * Mozilla LDAP C SDK.
  3844. */
  3845. int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals );
  3846. /**
  3847. * Normalize an attribute type.
  3848. *
  3849. * The attribute type will be looked up in the defined syntaxes to
  3850. * get the normalized form. If it is not found, the passed in type
  3851. * will be normalized.
  3852. *
  3853. * \param s The attribute type that you want to normalize.
  3854. * \return A normalized copy of the passed in attribute type.
  3855. * \warning You should free the returned string using slapi_ch_free_string().
  3856. * \see slapi_ch_free_string()
  3857. */
  3858. char * slapi_attr_syntax_normalize( const char *s );
  3859. /**
  3860. * Normalize an attribute type.
  3861. *
  3862. * The attribute type will be looked up in the defined syntaxes to
  3863. * get the normalized form. If it is not found, the passed in type
  3864. * will be normalized. If ATTR_SYNTAX_NORM_ORIG_ATTR is set to flags,
  3865. * the upper and lower cases are kept but trailing spaces are chopped
  3866. * from the original attribute type.
  3867. *
  3868. * \param s The attribute type that you want to normalize.
  3869. * \param flags 0 or ATTR_SYNTAX_NORM_ORIG_ATTR
  3870. * \return A normalized copy of the passed in attribute type.
  3871. * \warning You should free the returned string using slapi_ch_free_string().
  3872. * \see slapi_ch_free_string()
  3873. */
  3874. char * slapi_attr_syntax_normalize_ext( char *s, int flags );
  3875. /*
  3876. * value routines
  3877. */
  3878. /**
  3879. * Create a new empty \c Slapi_Value structure.
  3880. *
  3881. * \return A pointer to the newly allocated \c Slapi_Value structure.
  3882. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  3883. * \warning When you are no longer using the value, free it from memory
  3884. * by calling slapi_value_free()
  3885. * \see slapi_value_free()
  3886. * \see slapi_value_dup()
  3887. * \see slapi_value_new_berval()
  3888. * \see slapi_value_new_string()
  3889. * \see slapi_value_new_string_passin()
  3890. */
  3891. Slapi_Value *slapi_value_new( void );
  3892. /**
  3893. * Create a new \c Slapi_value structure and initialize it's value.
  3894. *
  3895. * \param bval Pointer to the \c berval structure used to initialize
  3896. * the newly allocated \c Slapi_value.
  3897. * \return A pointer to the newly allocated and initialized value.
  3898. * \warning The passed in \c berval structure will be copied. Ownership
  3899. * of \c bval remains with the caller.
  3900. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  3901. * \warning When you are no longer using the value, free it from memory
  3902. * by calling slapi_value_free()
  3903. * \see slapi_value_free()
  3904. * \see slapi_value_new()
  3905. * \see slapi_value_new_string()
  3906. * \see slapi_value_new_string_passin()
  3907. * \see slapi_value_dup()
  3908. */
  3909. Slapi_Value *slapi_value_new_berval(const struct berval *bval);
  3910. /**
  3911. * Duplicate a \c Slapi_Value structure.
  3912. *
  3913. * \param v The value to duplicate.
  3914. * \return A pointer to the copy of the value.
  3915. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  3916. * \warning When you are no longer using the value, free it from memory
  3917. * by calling slapi_value_free()
  3918. * \warning This function is identical to slapi_value_dup().
  3919. * \see slapi_value_dup()
  3920. * \see slapi_value_free()
  3921. */
  3922. Slapi_Value *slapi_value_new_value(const Slapi_Value *v);
  3923. /**
  3924. * Create a new \c Slapi_value structure and initialize it's value.
  3925. *
  3926. * \param s A \c NULL terminated string used to initialize
  3927. * the newly allocated \c Slapi_value.
  3928. * \return A pointer to the newly allocated and initialized value.
  3929. * \warning The passed in string will be copied. Ownership of \c s
  3930. * remains with the caller.
  3931. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  3932. * \warning When you are no longer using the value, free it from memory
  3933. * by calling slapi_value_free()
  3934. * \see slapi_value_free()
  3935. * \see slapi_value_new()
  3936. * \see slapi_value_new_berval()
  3937. \see slapi_value_new_string_passin()
  3938. * \see slapi_value_dup()
  3939. */
  3940. Slapi_Value *slapi_value_new_string(const char *s);
  3941. /**
  3942. * Create a new \c Slapi_value structure and initialize it's value.
  3943. *
  3944. * \param s A \c NULL terminated string used to initialize
  3945. * the newly allocated \c Slapi_value.
  3946. * \return A pointer to the newly allocated and initialized value.
  3947. * \warning The passed in string will be used directly as the value.
  3948. * It will not be copied. Ownership of \c s is transferred
  3949. * to the new \c Slapi_Value structure, so it should not be
  3950. * freed by the caller.
  3951. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  3952. * \warning When you are no longer using the value, free it from memory
  3953. * by calling slapi_value_free()
  3954. * \see slapi_value_free()
  3955. * \see slapi_value_new()
  3956. * \see slapi_value_new_berval()
  3957. * \see slapi_value_new_string()
  3958. * \see slapi_value_dup()
  3959. */
  3960. Slapi_Value *slapi_value_new_string_passin(char *s);
  3961. /**
  3962. * Initialize a \c Slapi_Value structure.
  3963. *
  3964. * All fields of the passed in \c Slapi_Value will be reset to zero.
  3965. *
  3966. * \param v The value to initialize.
  3967. * \return A pointer to the initialized value.
  3968. * \warning The passed in value must not be \c NULL.
  3969. * \see slapi_value_init_berval()
  3970. * \see slapi_value_init_string()
  3971. * \see slapi_value_init_string_passin()
  3972. */
  3973. Slapi_Value *slapi_value_init(Slapi_Value *v);
  3974. /**
  3975. * Initialize a \c Slapi_Value structure from the value contained in a \c berval structure.
  3976. *
  3977. * \param v The value to initialize.
  3978. * \param bval The \c berval structure to be used to intialize the value.
  3979. * \return A pointer to the initialized value.
  3980. * \warning The passed in \c Slapi_Value must not be \c NULL.
  3981. * \warning The content of the \c berval structure is duplicated. It is up
  3982. * to the caller to manage the memory used by the \c berval.
  3983. * \see slapi_value_init()
  3984. * \see slapi_value_init_string()
  3985. * \see slapi_value_init_string_passin()
  3986. */
  3987. Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
  3988. /**
  3989. * Initialize a \c Slapi_Value with a copy of the value contained in a string.
  3990. *
  3991. * \param v The value to initialize.
  3992. * \param s The null-terminated string to be used to initialize the value.
  3993. * \return A pointer to the initialized value.
  3994. * \warning The passed in \c Slapi_Value must not be \c NULL.
  3995. * \warning The passed in string is duplicated. It is up to the caller to
  3996. * manage the memory used by the passed in string.
  3997. * \see slapi_value_init()
  3998. * \see slapi_value_init_berval()
  3999. * \see slapi_value_init_string_passin()
  4000. */
  4001. Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s);
  4002. /* Initialize a \c Slapi_Value with the value contained in a string.
  4003. *
  4004. * \param v The value to initialize.
  4005. * \param s The null-terminated string to be used to initialize the value.
  4006. * \return A pointer to the initialized value.
  4007. * \warning The passed in \c Slapi_Value must not be \c NULL.
  4008. * \warning The passed in string is not duplicated. Responsibility for the
  4009. * memory used by the string is handed over to the \c Slapi_Value
  4010. * structure.
  4011. * \warning The passed in string must not be freed. It will be freed when
  4012. * the \c Slapi_Value structure is freed by calling \c slapi_value_free().
  4013. * \see slapi_value_free()
  4014. * \see slapi_value_init()
  4015. * \see slapi_value_init_berval()
  4016. * \see slapi_value_init_string()
  4017. */
  4018. Slapi_Value *slapi_value_init_string_passin(Slapi_Value *v, char *s);
  4019. /**
  4020. * Duplicate a \c Slapi_Value structure.
  4021. *
  4022. * \param v The value to duplicate.
  4023. * \return A pointer to the copy of the value.
  4024. * \warning If space can not be allocated, the \c ns-slapd program terminates.
  4025. * \warning When you are no longer using the value, free it from memory
  4026. * by calling slapi_value_free()
  4027. * \warning This function is identical to slapi_value_new_value().
  4028. * \see slapi_value_new_value()
  4029. * \see slapi_value_free()
  4030. */
  4031. Slapi_Value *slapi_value_dup(const Slapi_Value *v);
  4032. /**
  4033. * Sets the flags in a \c Slapi_Value structure.
  4034. *
  4035. * Valid flags are:
  4036. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  4037. *
  4038. * \param v Pointer to the \c Slapi_Value structure for which to
  4039. * set the flags.
  4040. * \param flags The flags you want to set.
  4041. * \warning The flags support bit-wise operations.
  4042. * \see slapi_values_set_flags()
  4043. * \see slapi_value_get_flags()
  4044. */
  4045. void slapi_value_set_flags(Slapi_Value *v, unsigned long flags);
  4046. /**
  4047. * Sets the flags in an array of \c Slapi_Value structures.
  4048. *
  4049. * Valid flags are:
  4050. * \arg #SLAPI_ATTR_FLAG_NORMALIZED
  4051. *
  4052. * \param vs Pointer to the \c Slapi_Value array for which you
  4053. * want to set the flags.
  4054. * \param flags The flags you want to set.
  4055. * \warning The flags support bit-wise operations.
  4056. * \see slapi_value_set_flags()
  4057. * \see slapi_value_get_flags()
  4058. */
  4059. void slapi_values_set_flags(Slapi_Value **vs, unsigned long flags);
  4060. /**
  4061. * Retrieves the flags from a \c Slapi_Value structure.
  4062. *
  4063. * \param v Pointer to the \c Slapi_Value structure from which the
  4064. * flags are to be retrieved.
  4065. * \return The flags that are set in the value.
  4066. * \see slapi_value_set_flags()
  4067. * \see slapi_values_set_flags()
  4068. */
  4069. unsigned long slapi_value_get_flags(Slapi_Value *v);
  4070. /**
  4071. * Frees a \c Slapi_Value structure from memory.
  4072. *
  4073. * The contents of the value will be freed along with the \c Slapi_Value
  4074. * structure itself. The pointer will also be set to \c NULL.
  4075. *
  4076. * \param value Address of the pointer to the \c Slapi_Value structure
  4077. * you wish to free.
  4078. * \see slapi_value_new()
  4079. */
  4080. void slapi_value_free(Slapi_Value **value);
  4081. /**
  4082. * Gets the \c berval structure of the value.
  4083. *
  4084. * \param value Pointer to the \c Slapi_Value of which you wish
  4085. * to get the \c berval.
  4086. * \return A pointer to the \c berval structure contained in the
  4087. * \c Slapi_Value.
  4088. * \warning The returned pointer point to the actual \c berval structure
  4089. * inside of the value, not a copy.
  4090. * \warning You should not free the returned \c berval structure unless
  4091. * you plan to replace it by calling \c slapi_value_set_berval().
  4092. * \see slapi_value_set_berval()
  4093. */
  4094. const struct berval *slapi_value_get_berval( const Slapi_Value *value );
  4095. /**
  4096. * Sets the value of a \c Slapi_Value structure from a \c berval structure.
  4097. *
  4098. * The value is duplicated from the passed in \c berval structure.
  4099. *
  4100. * \param value Pointer to the \c Slapi_Value structure in which to
  4101. * set the value.
  4102. * \param bval Pointer to the \c berval value to be copied.
  4103. * \return Pointer to the \c Slapi_Value structure passed in as \c value.
  4104. * \return NULL if the passed in value was \c NULL.
  4105. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4106. * nothing is done, and the function returns \c NULL.
  4107. * \warning If the \c Slapi_Value structure already contains a value, it
  4108. * is freed from memory before the new one is set.
  4109. * \warning When you are no longer using the \c Slapi_Value structure, you
  4110. * should free it from memory by valling \c slapi_value_free().
  4111. * \see slapi_value_free()
  4112. * \see slapi_value_get_berval()
  4113. */
  4114. Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval );
  4115. /**
  4116. * Sets the value of a \c Slapi_Value structure from another \c Slapi_Value structure.
  4117. *
  4118. * The value is duplicated from the supplied \c Slapi_value structure.
  4119. *
  4120. * \param value Pointer to the \c Slapi_Value structure in which to set
  4121. * the value.
  4122. * \param vfrom Pointer to the \c Slapi_Value structure from which to
  4123. * get the value.
  4124. * \return Pointer to the \c Slapi_Value structure passed as the \c value paramter.
  4125. * \return \c NULL if the \c value parameter was \c NULL.
  4126. * \warning The \c vfrom parameter must not be \c NULL.
  4127. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4128. * nothing is done, and the function returns \c NULL.
  4129. * \warning If the \c Slapi_Value structure already contains a value, it
  4130. * is freed from memory before the new one is set.
  4131. * \warning When you are no longer using the \c Slapi_Value structure, you
  4132. * should free it from memory by valling \c slapi_value_free().
  4133. * \see slapi_value_free()
  4134. */
  4135. Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom);
  4136. /**
  4137. * Sets the value of a \c Slapi_Value structure.
  4138. *
  4139. * The value is a duplicate of the data pointed to by \c val and the
  4140. * length \c len.
  4141. *
  4142. * \param value Pointer to the \c Slapi_Value structure in which to set
  4143. * the value.
  4144. * \param val Pointer to the value.
  4145. * \param len Length of the value.
  4146. * \return Pointer to the \c Slapi_Value structure with the value set.
  4147. * \return \c NULL if the supplied \c Slapi_Value is \c NULL.
  4148. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4149. * nothing is done, and the function returns \c NULL.
  4150. * \warning If the \c Slapi_Value structure already contains a value, it
  4151. * is freed from memory before the new one is set.
  4152. * \warning When you are no longer using the \c Slapi_Value structure, you
  4153. * should free it from memory by valling \c slapi_value_free().
  4154. * \see slapi_value_free()
  4155. */
  4156. Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len);
  4157. /**
  4158. * Sets the value of a \c Slapi_Value structure from a string.
  4159. *
  4160. * The value is duplicated from a supplied string.
  4161. *
  4162. * \param value Pointer to the \c Slapi_Value structure in which to set
  4163. * the value.
  4164. * \param strVal The string containing the value to set.
  4165. * \return \c 0 if the value is set.
  4166. * \return \c -1 if the pointer to the \c Slapi_Value is \c NULL.
  4167. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4168. * nothing is done, and the function returns \c -1.
  4169. * \warning If the \c Slapi_Value structure already contains a value, it
  4170. * is freed from memory before the new one is set.
  4171. * \warning When you are no longer using the \c Slapi_Value structure, you
  4172. * should free it from memory by valling \c slapi_value_free().
  4173. * \see slapi_value_free()
  4174. * \see slapi_value_set_string_passin()
  4175. */
  4176. int slapi_value_set_string(Slapi_Value *value, const char *strVal);
  4177. /**
  4178. * Sets the value of a \c Slapi_Value structure from a string.
  4179. *
  4180. * The supplied string is used as the value within the \c Slapi_Value
  4181. * structure.
  4182. *
  4183. * \param value Pointer to the \c Slapi_Value structure in which to set
  4184. * the value.
  4185. * \param strVal The string containing the value to set.
  4186. * \return \c 0 if the value is set.
  4187. * \return \c -1 if the pointer to the \c Slapi_Value is \c NULL.
  4188. * \warning Do not free the passed in string pointer to by \c strVal.
  4189. * Responsibility for the memory used by the string is handed
  4190. * over to the \c Slapi_Value structure.
  4191. * \warning When you are no longer using the \c Slapi_Value structure, you
  4192. * should free it from memory by valling \c slapi_value_free().
  4193. * \see slapi_value_free()
  4194. * \see slapi_value_set_string()
  4195. */
  4196. int slapi_value_set_string_passin(Slapi_Value *value, char *strVal);
  4197. /**
  4198. * Sets the value of a \c Slapi_Value structure from an integer.
  4199. *
  4200. * \param value Pointer to the \c Slapi_Value structure in which to set
  4201. * the value.
  4202. * \param intVal The integer containing the value to set.
  4203. * \return \c 0 if the value is set.
  4204. * \return \c -1 if the pointer to the \c Slapi_Value is \c NULL.
  4205. * \warning If the pointer to the \c Slapi_Value structure is \c NULL,
  4206. * nothing is done, and the function returns \c -1.
  4207. * \warning If the \c Slapi_Value structure already contains a value, it
  4208. * is freed from memory before the new one is set.
  4209. * \warning When you are no longer using the \c Slapi_Value structure, you
  4210. * should free it from memory by valling \c slapi_value_free().
  4211. * \see slapi_value_free()
  4212. */
  4213. int slapi_value_set_int(Slapi_Value *value, int intVal);
  4214. /**
  4215. * Retrieves the value of a \c Slapi_Value structure as a string.
  4216. *
  4217. * \param value Pointer to the value you wish to get as a string.
  4218. * \return A string containing the value.
  4219. * \return \c NULL if there is no value.
  4220. * \warning The returned string is the actual value, not a copy. You
  4221. * should not free the returned string unless you plan to
  4222. * replace it by calling slapi_value_set_string().
  4223. * \see slapi_value_set_string()
  4224. */
  4225. const char*slapi_value_get_string(const Slapi_Value *value);
  4226. /**
  4227. * Retrieves the value of a \c Slapi_Value structure as an integer.
  4228. *
  4229. * \param value Pointer to the value you wish to get as an integer.
  4230. * \return An integer that corresponds to the value stored in the
  4231. * \c Slapi_Value structure.
  4232. * \return \c 0 if there is no value.
  4233. * \see slapi_value_get_uint()
  4234. * \see slapi_value_get_long()
  4235. * \see slapi_value_get_ulong()
  4236. * \see slapi_value_get_longlong()
  4237. * \see slapi_value_get_ulonglong()
  4238. */
  4239. int slapi_value_get_int(const Slapi_Value *value);
  4240. /**
  4241. * Retrieves the value of a \c Slapi_Value structure as an unsigned integer.
  4242. *
  4243. * \param value Pointer to the value you wish to get as an unsigned integer.
  4244. * \return An unsigned integer that corresponds to the value stored in
  4245. * the \c Slapi_Value structure.
  4246. * \return \c 0 if there is no value.
  4247. * \see slapi_value_get_int()
  4248. * \see slapi_value_get_long()
  4249. * \see slapi_value_get_ulong()
  4250. * \see slapi_value_get_longlong()
  4251. * \see slapi_value_get_ulonglong()
  4252. */
  4253. unsigned int slapi_value_get_uint(const Slapi_Value *value);
  4254. /**
  4255. * Retrieves the value of a \c Slapi_Value structure as a long integer.
  4256. *
  4257. * \param value Pointer to the value you wish to get as a long integer.
  4258. * \return A long integer that corresponds to the value stored in the
  4259. * \c Slapi_Value structure.
  4260. * \return \c 0 if there is no value.
  4261. * \see slapi_value_get_int()
  4262. * \see slapi_value_get_uint()
  4263. * \see slapi_value_get_ulong()
  4264. * \see slapi_value_get_longlong()
  4265. * \see slapi_value_get_ulonglong()
  4266. */
  4267. long slapi_value_get_long(const Slapi_Value *value);
  4268. /**
  4269. * Retrieves the value of a \c Slapi_Value structure as an unsigned long integer.
  4270. *
  4271. * \param value Pointer to the value you wish to get as an unsigned long integer.
  4272. * \return An unsigned long integer that corresponds to the value stored in the
  4273. * \c Slapi_Value structure.
  4274. * \return \c 0 if there is no value.
  4275. * \see slapi_value_get_int()
  4276. * \see slapi_value_get_uint()
  4277. * \see slapi_value_get_long()
  4278. * \see slapi_value_get_longlong()
  4279. * \see slapi_value_get_ulonglong()
  4280. */
  4281. unsigned long slapi_value_get_ulong(const Slapi_Value *value);
  4282. /**
  4283. * Retrieves the value of a \c Slapi_Value structure as a long long integer.
  4284. *
  4285. * \param value Pointer to the value you wish to get as a long long integer.
  4286. * \return A long long integer that corresponds to the value stored in the
  4287. * \c Slapi_Value structure.
  4288. * \return \c 0 if there is no value.
  4289. * \see slapi_value_get_int()
  4290. * \see slapi_value_get_uint()
  4291. * \see slapi_value_get_long()
  4292. * \see slapi_value_get_ulong()
  4293. * \see slapi_value_get_ulonglong()
  4294. */
  4295. long long slapi_value_get_longlong(const Slapi_Value *value);
  4296. /**
  4297. * Retrieves the value of a \c Slapi_Value structure as an unsigned long long integer.
  4298. *
  4299. * \param value Pointer to the value you wish to get as an unsigned long long integer.
  4300. * \return An unsigned long long integer that corresponds to the value stored in the
  4301. * \c Slapi_Value structure.
  4302. * \return \c 0 if there is no value.
  4303. * \see slapi_value_get_int()
  4304. * \see slapi_value_get_uint()
  4305. * \see slapi_value_get_long()
  4306. * \see slapi_value_get_ulong()
  4307. * \see slapi_value_get_longlong()
  4308. */
  4309. unsigned long long slapi_value_get_ulonglong(const Slapi_Value *value);
  4310. /**
  4311. * Retrieves the value of a \c Slapi_Value structure as a long integer.
  4312. *
  4313. * \param value Pointer to the value you wish to get as a long integer.
  4314. * The value could end with D or d for days, H or h for hours,
  4315. * M or m for minutes, S or s for seconds, or no extension.
  4316. * \return A long integer that corresponds to the value stored in the
  4317. * \c Slapi_Value structure.
  4318. * \return \c 0 if there is no value.
  4319. * \return \c -1 if the given value is invalid.
  4320. * \see slapi_value_get_int()
  4321. * \see slapi_value_get_uint()
  4322. * \see slapi_value_get_ulong()
  4323. * \see slapi_value_get_longlong()
  4324. * \see slapi_value_get_ulonglong()
  4325. */
  4326. long slapi_value_get_timelong(const Slapi_Value *value);
  4327. /**
  4328. * Gets the length of a value contained in a \c Slapi_Value structure.
  4329. *
  4330. * \param value Pointer to the value of which you wish to get the length.
  4331. * \return The length of the value.
  4332. * \return \c 0 if there is no value.
  4333. */
  4334. size_t slapi_value_get_length(const Slapi_Value *value);
  4335. /**
  4336. * Compares two \c Slapi_Value structures
  4337. *
  4338. * The matching rule associated with the supplied attribute \c a is used
  4339. * to compare the two values.
  4340. *
  4341. * \param a A pointer to an attribute used to determine how the
  4342. * two values will be compared.
  4343. * \param v1 Pointer to the \c Slapi_Value structure containing the first
  4344. * value to compare.
  4345. * \param v2 Pointer to the \c Slapi_Value structure containing the second
  4346. * value to compare.
  4347. * \return \c 0 if the two values are equal.
  4348. * \return \c -1 if \c v1 is smaller than \c v2.
  4349. * \return \c 1 if \c v1 is greater than \c v2.
  4350. */
  4351. int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2);
  4352. /**
  4353. * Free and initialize the contents of the berval without freeing the
  4354. * struct berval * itself. This is useful when you use struct berval
  4355. * which are allocated on the stack e.g.
  4356. * \code
  4357. * struct berval bv = {0, NULL};
  4358. * slapi_ber_bvcpy(&bv, someotherbvp);
  4359. * // use bv
  4360. * slapi_ber_bvdone(&bv);
  4361. * \endcode
  4362. * You must only call slapi_ber_bvdone() if the bv_val member has been
  4363. * allocated with malloc() or is NULL.
  4364. *
  4365. * \param bvp A struct berval * you want to free the contents of
  4366. * \return \c void
  4367. */
  4368. void slapi_ber_bvdone(struct berval *bvp);
  4369. /**
  4370. * Copy the contents of the berval without allocating a new struct berval*
  4371. * This is useful when you use struct berval which are allocated on the stack e.g.
  4372. * \code
  4373. * struct berval bv = {0, NULL};
  4374. * slapi_ber_bvcpy(&bv, someotherbvp);
  4375. * // use bv
  4376. * slapi_ber_bvdone(&bv);
  4377. * \endcode
  4378. * The bvs source berval to copy from can either be allocated on the heap
  4379. * or the stack.
  4380. *
  4381. * \param bvd A struct berval * you want copy to
  4382. * \param bvs A struct berval * you want to copy from
  4383. * \return \c void
  4384. */
  4385. void slapi_ber_bvcpy(struct berval *bvd, const struct berval *bvs);
  4386. /*
  4387. * Valueset functions.
  4388. */
  4389. /**
  4390. * Flag that indicates that the value should be used by reference.
  4391. *
  4392. * \see slapi_valueset_add_value_ext()
  4393. */
  4394. #define SLAPI_VALUE_FLAG_PASSIN 0x1
  4395. #define SLAPI_VALUE_FLAG_IGNOREERROR 0x2
  4396. #define SLAPI_VALUE_FLAG_PRESERVECSNSET 0x4
  4397. #define SLAPI_VALUE_FLAG_USENEWVALUE 0x8 /* see valueset_remove_valuearray */
  4398. #define SLAPI_VALUE_FLAG_DUPCHECK 0x10 /* used in valueset_add... */
  4399. /**
  4400. * Creates an empty \c Slapi_ValueSet structure.
  4401. *
  4402. * \return Pointer to the newly allocated \c Slapi_ValueSet structure.
  4403. * \warning If no space can be allocated (for example, if no more virtual
  4404. * memory exists), the \c ns-slapd program terminates.
  4405. * \warning When you are no longer using the valueset, you should free it
  4406. * from memory by calling \c slapi_valueset_free().
  4407. * \see slapi_valueset_free()
  4408. */
  4409. Slapi_ValueSet *slapi_valueset_new( void );
  4410. /**
  4411. * Free a \c Slapi_ValueSet structure from memory.
  4412. *
  4413. * Call this function when you are done working with the structure.
  4414. * All members of the valueset will be freed as well if they are not
  4415. * \c NULL.
  4416. *
  4417. * \param vs Pointer to the \c Slapi_ValueSet to free.
  4418. * \see slapi_valueset_done()
  4419. */
  4420. void slapi_valueset_free(Slapi_ValueSet *vs);
  4421. /**
  4422. * Initializes a \c Slapi_ValueSet structure.
  4423. *
  4424. * All values inside of the structure will be cleared (set to \c 0).
  4425. * The values will not be freed by this function. To free the values
  4426. * first, call \c slapi_valueset_done().
  4427. *
  4428. * \param vs Pointer to the \c Slapi_ValueSet to initialize.
  4429. * \warning When you are no longer using the \c Slapi_ValueSet structure,
  4430. * you should free it from memory by calling \c slapi_valueset_free().
  4431. * \see slapi_valueset_done()
  4432. * \see slapi_valueset_free()
  4433. */
  4434. void slapi_valueset_init(Slapi_ValueSet *vs);
  4435. /**
  4436. * Frees the values contained in a \c Slapi_ValueSet structure.
  4437. *
  4438. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4439. * you want to free its values.
  4440. * \warning Use this function when you are no longer using the values
  4441. * but you want to re-use the \c Slapi_ValueSet structure for
  4442. * a new set of values.
  4443. * \see slapi_valueset_init()
  4444. */
  4445. void slapi_valueset_done(Slapi_ValueSet *vs);
  4446. /**
  4447. * Adds a value to a \c Slapi_ValueSet structure.
  4448. *
  4449. * \param vs Pointer to the \c Slapi_ValueSet structure to which to
  4450. * add the value.
  4451. * \param addval Pointer to the \c Slapi_Value structure to add to
  4452. * the \c Slapi_ValueSet.
  4453. * \warning The value is duplicated from the \c Slapi_Value structure,
  4454. * which can be freed frmo memory without altering the
  4455. * \c Slapi_ValueSet structure.
  4456. * \warning This function does not verify if the value is already present
  4457. * in the \c Slapi_ValueSet structure. You can manually check
  4458. * this using \c slapi_valueset_first_value() and
  4459. * \c slapi_valueset_next_value().
  4460. * \see slapi_valueset_first_value()
  4461. * \see slapi_valueset_next_value()
  4462. */
  4463. void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
  4464. /**
  4465. * Adds a value to a \c Slapi_ValueSet structure with optional flags.
  4466. *
  4467. * This function is similar to \c slapi_valueset_add_value(), but it
  4468. * allows optional flags to be specified to allow the new value to be
  4469. * used by reference.
  4470. *
  4471. * \param vs Pointer to the \c Slapi_ValueSet structure to which to
  4472. * add the value.
  4473. * \param addval Pointer to the \c Slapi_Value structure to add to
  4474. * the \c Slapi_ValueSet.
  4475. * \param flags If #SLAPI_VALUE_FLAG_PASSIN bit is set in the flags,
  4476. * the function will take over the ownership of the new value
  4477. * to be added without duplicating it.
  4478. * \warning This function does not verify if the value is already present
  4479. * in the \c Slapi_ValueSet structure. You can manually check
  4480. * this using \c slapi_valueset_first_value() and
  4481. * \c slapi_valueset_next_value().
  4482. * \see slapi_valueset_add_value()
  4483. * \see slapi_valueset_first_value()
  4484. * \see slapi_valueset_next_value()
  4485. */
  4486. void slapi_valueset_add_value_ext(Slapi_ValueSet *vs, const Slapi_Value *addval, unsigned long flags);
  4487. int slapi_valueset_add_attr_value_ext(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *addval, unsigned long flags);
  4488. /**
  4489. * Gets the first value in a \c Slapi_ValueSet structure.
  4490. *
  4491. * This function can be used with \c slapi_valueset_next_value() to
  4492. * iterate through all values in a \c Slapi_ValueSet structure.
  4493. *
  4494. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4495. * you wish to get the value.
  4496. * \param v Address of the pointer to the \c Slapi_Value structure
  4497. * for the returned value.
  4498. * \return The index of the value in the Slapi_ValueSet structure.
  4499. * \return \c -1 if there was no value.
  4500. * \warning This function gives a pointer to the actual value within
  4501. * the \c Slapi_ValueSet structure. You should not free it
  4502. * from memory.
  4503. * \warning You will need to pass this index to slapi_valueset_next_value()
  4504. * if you wish to iterate through all values in the valueset.
  4505. * \see slapi_valueset_next_value().
  4506. */
  4507. int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v );
  4508. /**
  4509. * Gets the next value in a \c Slapi_ValueSet structure.
  4510. *
  4511. * This is part of a pair of iterator functions. It should be
  4512. * called after first calling \c slapi_valueset_first_value().
  4513. *
  4514. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4515. * you wish to get the value.
  4516. * \param index Value returned by the previous call to \c slapi_valueset_first_value()
  4517. * or \c slapi_valueset_next_value().
  4518. * \param v Address of the pointer to the \c Slapi_Value structure
  4519. * for the returned value.
  4520. * \return The index of the value in the Slapi_ValueSet structure.
  4521. * \return \c -1 if there was no value.
  4522. * \warning This function gives a pointer to the actual value within
  4523. * the \c Slapi_ValueSet structure. You should not free it
  4524. * from memory.
  4525. * \warning You will need to pass this index to slapi_valueset_next_value()
  4526. * if you wish to iterate through all values in the valueset.
  4527. * \see slapi_valueset_first_value()
  4528. */
  4529. int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
  4530. /**
  4531. * Returns the number of values contained in a \c Slapi_ValueSet structure.
  4532. *
  4533. * \param vs Pointer to the \c Slapi_ValueSet structure of which
  4534. * you wish to get the count.
  4535. * \return The number of values contained in the \c Slapi_ValueSet structure.
  4536. */
  4537. int slapi_valueset_count( const Slapi_ValueSet *vs);
  4538. /**
  4539. * Checks if a \c Slapi_ValueSet structure has values
  4540. *
  4541. * \param vs Pointer to the \c Slapi_ValueSet structure of which
  4542. * you wish to get the count.
  4543. * \return 1 if there are no values contained in the \c Slapi_ValueSet structure.
  4544. * \return 0 if there are values contained in the \c Slapi_ValueSet structure.
  4545. */
  4546. int slapi_valueset_isempty( const Slapi_ValueSet *vs);
  4547. /**
  4548. * Initializes a \c Slapi_ValueSet with copies of the values of a \c Slapi_Mod structure.
  4549. *
  4550. * \param vs Pointer to the \c Slapi_ValueSet structure into which
  4551. * you wish to copy the values.
  4552. * \param smod Pointer to the \c Slapi_Mod structure from which you
  4553. * want to copy the values.
  4554. * \warning This function does not verify that the \c Slapi_ValueSet
  4555. * structure already contains values, so it is your responsibility
  4556. * to verify that there are no values prior to calling this function.
  4557. * If you do not verify this, the allocated memory space will leak.
  4558. * You can free existing values by calling slapi_valueset_done().
  4559. * \see slapi_valueset_done()
  4560. */
  4561. void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
  4562. /**
  4563. * Initializes a \c Slapi_ValueSet with copies of the values of another \c Slapi_ValueSet.
  4564. *
  4565. * \param vs1 Pointer to the \c Slapi_ValueSet structure into which
  4566. * you wish to copy the values.
  4567. * \param vs2 Pointer to the \c Slapi_ValueSet structure from which
  4568. * you want to copy the values.
  4569. * \warning This function does not verify that the \c Slapi_ValueSet
  4570. * structure already contains values, so it is your responsibility
  4571. * to verify that there are no values prior to calling this function.
  4572. * If you do not verify this, the allocated memory space will leak.
  4573. * You can free existing values by calling slapi_valueset_done().
  4574. * \see slapi_valueset_done()
  4575. */
  4576. void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  4577. void slapi_valueset_join_attr_valueset(const Slapi_Attr *a, Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
  4578. /**
  4579. * Finds a requested value in a valueset.
  4580. *
  4581. * The syntax of a supplied attribute will be used to compare the values.
  4582. * This function can be used to check for duplicate values in a valueset.
  4583. *
  4584. * \param a Pointer to the attribute. This is used to determine the
  4585. * syntax of the values and how to match them.
  4586. * \param vs Pointer to the \c Slapi_ValueSet structure from which
  4587. * you wish to find the value.
  4588. * \param v Pointer to the \c Slapi_Value structure containing the
  4589. * value that you wish to find.
  4590. * \return Pointer to the value in the valueset if the value was found.
  4591. * \return \c NULL if the value was not found.
  4592. * \warning The returned pointer points to the actual value in the
  4593. * \c Slapi_ValueSet structure. It should not be freed.
  4594. */
  4595. Slapi_Value *slapi_valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v);
  4596. /* TODO - Pickup Doxygen work here */
  4597. /*
  4598. * operation routines
  4599. */
  4600. int slapi_op_abandoned( Slapi_PBlock *pb );
  4601. unsigned long slapi_op_get_type(Slapi_Operation * op);
  4602. void slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag);
  4603. void slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag);
  4604. int slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag);
  4605. int slapi_op_reserved(Slapi_PBlock *pb);
  4606. void slapi_operation_set_csngen_handler ( Slapi_Operation *op, void *callback );
  4607. void slapi_operation_set_replica_attr_handler ( Slapi_Operation *op, void *callback );
  4608. int slapi_operation_get_replica_attr ( Slapi_PBlock *pb, Slapi_Operation *op, const char *type, void *value );
  4609. char *slapi_op_type_to_string(unsigned long type);
  4610. int slapi_op_internal( Slapi_PBlock *pb );
  4611. /*
  4612. * connection routines
  4613. */
  4614. int slapi_connection_acquire(Slapi_Connection *conn);
  4615. int slapi_connection_remove_operation( Slapi_PBlock *pb, Slapi_Connection *conn, Slapi_Operation *op, int release);
  4616. /*
  4617. * LDAPMod manipulation routines
  4618. */
  4619. Slapi_Mods* slapi_mods_new( void );
  4620. void slapi_mods_init(Slapi_Mods *smods, int initCount);
  4621. void slapi_mods_init_byref(Slapi_Mods *smods, LDAPMod **mods);
  4622. void slapi_mods_init_passin(Slapi_Mods *smods, LDAPMod **mods);
  4623. void slapi_mods_free(Slapi_Mods **smods);
  4624. void slapi_mods_done(Slapi_Mods *smods);
  4625. void slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos);
  4626. void slapi_mods_insert_smod_at(Slapi_Mods *smods, Slapi_Mod *smod, int pos);
  4627. void slapi_mods_insert_before(Slapi_Mods *smods, LDAPMod *mod);
  4628. void slapi_mods_insert_smod_before(Slapi_Mods *smods, Slapi_Mod *smod);
  4629. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  4630. void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
  4631. void slapi_mods_add( Slapi_Mods *smods, int modtype, const char *type, unsigned long len, const char *val);
  4632. void slapi_mods_add_ldapmod(Slapi_Mods *smods, LDAPMod *mod);
  4633. void slapi_mods_add_modbvps( Slapi_Mods *smods, int modtype, const char *type, struct berval **bvps );
  4634. void slapi_mods_add_mod_values( Slapi_Mods *smods, int modtype, const char *type, Slapi_Value **va );
  4635. void slapi_mods_add_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  4636. void slapi_mods_add_string( Slapi_Mods *smods, int modtype, const char *type, const char *val);
  4637. void slapi_mods_remove(Slapi_Mods *smods);
  4638. LDAPMod *slapi_mods_get_first_mod(Slapi_Mods *smods);
  4639. LDAPMod *slapi_mods_get_next_mod(Slapi_Mods *smods);
  4640. Slapi_Mod *slapi_mods_get_first_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  4641. Slapi_Mod *slapi_mods_get_next_smod(Slapi_Mods *smods, Slapi_Mod *smod);
  4642. void slapi_mods_iterator_backone(Slapi_Mods *smods);
  4643. LDAPMod **slapi_mods_get_ldapmods_byref(Slapi_Mods *smods);
  4644. LDAPMod **slapi_mods_get_ldapmods_passout(Slapi_Mods *smods);
  4645. int slapi_mods_get_num_mods(const Slapi_Mods *smods);
  4646. void slapi_mods_dump(const Slapi_Mods *smods, const char *text);
  4647. Slapi_Mod* slapi_mod_new( void );
  4648. void slapi_mod_init(Slapi_Mod *smod, int initCount);
  4649. void slapi_mod_init_byval(Slapi_Mod *smod, const LDAPMod *mod);
  4650. void slapi_mod_init_byref(Slapi_Mod *smod, LDAPMod *mod);
  4651. void slapi_mod_init_passin(Slapi_Mod *smod, LDAPMod *mod);
  4652. /* init a mod and set the mod values to be a copy of the given valueset */
  4653. void slapi_mod_init_valueset_byval(Slapi_Mod *smod, int op, const char *type, const Slapi_ValueSet *svs);
  4654. void slapi_mod_add_value(Slapi_Mod *smod, const struct berval *val);
  4655. void slapi_mod_remove_value(Slapi_Mod *smod);
  4656. struct berval *slapi_mod_get_first_value(Slapi_Mod *smod);
  4657. struct berval *slapi_mod_get_next_value(Slapi_Mod *smod);
  4658. const char *slapi_mod_get_type(const Slapi_Mod *smod);
  4659. int slapi_mod_get_operation(const Slapi_Mod *smod);
  4660. void slapi_mod_set_type(Slapi_Mod *smod, const char *type);
  4661. void slapi_mod_set_operation(Slapi_Mod *smod, int op);
  4662. int slapi_mod_get_num_values(const Slapi_Mod *smod);
  4663. const LDAPMod *slapi_mod_get_ldapmod_byref(const Slapi_Mod *smod);
  4664. LDAPMod *slapi_mod_get_ldapmod_passout(Slapi_Mod *smod);
  4665. void slapi_mod_free(Slapi_Mod **smod);
  4666. void slapi_mod_done(Slapi_Mod *mod);
  4667. int slapi_mod_isvalid(const Slapi_Mod *mod);
  4668. void slapi_mod_dump(LDAPMod *mod, int n);
  4669. /* helper functions to translate between entry and a set of mods */
  4670. int slapi_mods2entry(Slapi_Entry **e, const char *dn, LDAPMod **attrs);
  4671. int slapi_entry2mods(const Slapi_Entry *e, char **dn, LDAPMod ***attrs);
  4672. #if defined(USE_OLD_UNHASHED)
  4673. int is_type_forbidden(const char *type);
  4674. #endif
  4675. /*
  4676. * routines for dealing with filters
  4677. */
  4678. int slapi_filter_get_choice( Slapi_Filter *f );
  4679. int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
  4680. int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
  4681. int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
  4682. char ***any, char **final );
  4683. Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
  4684. Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
  4685. Slapi_Filter *slapi_str2filter( char *str );
  4686. Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1,
  4687. Slapi_Filter *f2 );
  4688. Slapi_Filter *slapi_filter_join_ex( int ftype, Slapi_Filter *f1,
  4689. Slapi_Filter *f2, int recurse_always );
  4690. void slapi_filter_free( Slapi_Filter *f, int recurse );
  4691. int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  4692. int verify_access );
  4693. int slapi_vattr_filter_test( Slapi_PBlock *pb, Slapi_Entry *e,
  4694. struct slapi_filter *f, int verify_access);
  4695. int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f);
  4696. char *slapi_find_matching_paren( const char *str );
  4697. int slapi_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  4698. int verify_access , int only_test_access);
  4699. int slapi_vattr_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
  4700. int verify_access , int only_test_access);
  4701. int slapi_filter_compare(struct slapi_filter *f1, struct slapi_filter *f2);
  4702. Slapi_Filter *slapi_filter_dup(Slapi_Filter *f);
  4703. int slapi_filter_changetype(Slapi_Filter *f, const char *newtype);
  4704. /**
  4705. * Normalize in-place the given filter. Normalizes the attribute types always.
  4706. * If norm_values is true, will also normalize the values.
  4707. *
  4708. * \param f the filter to normalize
  4709. * \param norm_values if true, normalize the values in addition to the type names
  4710. */
  4711. void slapi_filter_normalize(Slapi_Filter *f, PRBool norm_values);
  4712. /**
  4713. * Check whether a given attribute type is defined in schema or not
  4714. *
  4715. * \param attribute type name to be checked
  4716. * \return \c 0 if the attribute type is not defined in schema
  4717. * \return non-0 if the attribute type is defined in schema
  4718. */
  4719. int slapi_attr_syntax_exists(const char *type);
  4720. /**
  4721. * Reload internally registered attribute syntaxes.
  4722. *
  4723. * \param none
  4724. * \return \c 0 if the reload was successful.
  4725. * \return non-0 if the reload failed.
  4726. */
  4727. int slapi_reload_internal_attr_syntax(void);
  4728. /*
  4729. * slapi_filter_apply() is used to apply a function to each simple filter
  4730. * component within a complex filter. A 'simple filter' is anything other
  4731. * than AND, OR or NOT.
  4732. */
  4733. typedef int (*FILTER_APPLY_FN)( Slapi_Filter *f, void *arg);
  4734. int slapi_filter_apply( struct slapi_filter *f, FILTER_APPLY_FN fn, void *arg,
  4735. int *error_code );
  4736. /*
  4737. * Possible return values for slapi_filter_apply() and FILTER_APPLY_FNs.
  4738. * Note that a FILTER_APPLY_FN should return _STOP or _CONTINUE only.
  4739. */
  4740. #define SLAPI_FILTER_SCAN_STOP -1 /* premature abort */
  4741. #define SLAPI_FILTER_SCAN_ERROR -2 /* an error occurred */
  4742. #define SLAPI_FILTER_SCAN_NOMORE 0 /* success */
  4743. #define SLAPI_FILTER_SCAN_CONTINUE 1 /* continue scanning */
  4744. /* Error codes that slapi_filter_apply() may set in *error_code */
  4745. #define SLAPI_FILTER_UNKNOWN_FILTER_TYPE 2
  4746. /*
  4747. * Bit-Twiddlers
  4748. */
  4749. unsigned char slapi_setbit_uchar(unsigned char f,unsigned char bitnum);
  4750. unsigned char slapi_unsetbit_uchar(unsigned char f,unsigned char bitnum);
  4751. int slapi_isbitset_uchar(unsigned char f,unsigned char bitnum);
  4752. unsigned int slapi_setbit_int(unsigned int f,unsigned int bitnum);
  4753. unsigned int slapi_unsetbit_int(unsigned int f,unsigned int bitnum);
  4754. int slapi_isbitset_int(unsigned int f,unsigned int bitnum);
  4755. /*
  4756. * routines for sending entries and results to the client
  4757. */
  4758. int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
  4759. LDAPControl **ectrls, char **attrs, int attrsonly );
  4760. void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched,
  4761. char *text, int nentries, struct berval **urls );
  4762. int slapi_send_ldap_referral( Slapi_PBlock *pb, Slapi_Entry *e,
  4763. struct berval **refs, struct berval ***urls );
  4764. int slapi_send_ldap_intermediate( Slapi_PBlock *pb, LDAPControl **ectrls,
  4765. char *responseName, struct berval *responseValue);
  4766. typedef int (*send_ldap_search_entry_fn_ptr_t)( Slapi_PBlock *pb,
  4767. Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly );
  4768. typedef void (*send_ldap_result_fn_ptr_t)( Slapi_PBlock *pb, int err,
  4769. char *matched, char *text, int nentries, struct berval **urls );
  4770. typedef int (*send_ldap_referral_fn_ptr_t)( Slapi_PBlock *pb,
  4771. Slapi_Entry *e, struct berval **refs, struct berval ***urls );
  4772. /*
  4773. * matching rule
  4774. */
  4775. typedef int (*mrFilterMatchFn) (void* filter, Slapi_Entry*, Slapi_Attr* vals);
  4776. /* returns: 0 filter matched
  4777. * -1 filter did not match
  4778. * >0 an LDAP error code
  4779. */
  4780. int slapi_mr_indexer_create(Slapi_PBlock* opb);
  4781. int slapi_mr_filter_index(Slapi_Filter* f, Slapi_PBlock* pb);
  4782. int slapi_berval_cmp(const struct berval* L, const struct berval* R);
  4783. #define SLAPI_BERVAL_EQ(L,R) ((L)->bv_len == (R)->bv_len && \
  4784. ! memcmp ((L)->bv_val, (R)->bv_val, (L)->bv_len))
  4785. typedef struct slapi_matchingRuleEntry {
  4786. char *mr_oid; /* the official oid */
  4787. char *mr_oidalias; /* not currently used */
  4788. char *mr_name; /* the official name */
  4789. char *mr_desc; /* a description */
  4790. char *mr_syntax; /* the assertion syntax OID */
  4791. int mr_obsolete; /* is mr obsolete? */
  4792. char **mr_compat_syntax; /* list of OIDs of other syntaxes that can use this matching rule */
  4793. } slapi_matchingRuleEntry;
  4794. typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;
  4795. Slapi_MatchingRuleEntry *slapi_matchingrule_new(void);
  4796. void slapi_matchingrule_free(Slapi_MatchingRuleEntry **mrEntry,
  4797. int freeMembers);
  4798. int slapi_matchingrule_get(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  4799. int slapi_matchingrule_set(Slapi_MatchingRuleEntry *mr, int arg, void *value);
  4800. int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrEntry);
  4801. int slapi_matchingrule_unregister(char *oid);
  4802. /**
  4803. * Is the given matching rule an ordering matching rule and is it
  4804. * compatible with the given syntax?
  4805. *
  4806. * \param name_or_oid Name or OID of a matching rule
  4807. * \param syntax_oid OID of a syntax
  4808. * \return \c TRUE if the matching rule is an ordering rule and can be used by the given syntax
  4809. * \return \c FALSE otherwise
  4810. */
  4811. int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid);
  4812. /**
  4813. * Can the given syntax OID use the given matching rule name/OID? A
  4814. * matching rule can apply to more than one syntax. Use this function
  4815. * to determine if the given syntax can use the given matching rule.
  4816. *
  4817. * \param mr_name_or_oid Name or OID of a matching rule
  4818. * \param syntax_oid OID of a syntax
  4819. * \return \c TRUE if the syntax can be used with the matching rule
  4820. * \return \c FALSE otherwise
  4821. */
  4822. int slapi_matchingrule_is_compat(const char *mr_oid_or_name, const char *syntax_oid);
  4823. /**
  4824. * In certain cases, we can just use a simple compare function to
  4825. * generate index keys. The compare function is usually provided
  4826. * by the syntax plugin. If this is the case, we can skip generating
  4827. * an indexer in the index config code.
  4828. *
  4829. * \param mr_name_or_oid Name or OID of a matching rule
  4830. * \return \c TRUE if the matching rule can use a simple compare function
  4831. * \return \c FALSE otherwise
  4832. */
  4833. int slapi_matchingrule_can_use_compare_fn(const char *mr_oid_or_name);
  4834. /*
  4835. * access control
  4836. */
  4837. int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr,
  4838. struct berval *val, int access );
  4839. int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e,
  4840. LDAPMod **mods, char **errbuf );
  4841. int slapi_acl_verify_aci_syntax(Slapi_PBlock *pb, Slapi_Entry *e, char **errbuf);
  4842. /*
  4843. * attribute stuff
  4844. */
  4845. int slapi_value_find( void *plugin, struct berval **vals, struct berval *v );
  4846. /*
  4847. * password handling
  4848. */
  4849. #define SLAPI_USERPWD_ATTR "userpassword"
  4850. int slapi_pw_find_sv( Slapi_Value **vals, const Slapi_Value *v );
  4851. /* value encoding encoding */
  4852. /* checks if the value is encoded with any known algorithm*/
  4853. int slapi_is_encoded(char *value);
  4854. /* encode value with the specified algorithm */
  4855. char* slapi_encode(char *value, char *alg);
  4856. /* encode value with the specified algorithm, or with local algorithm if pb
  4857. * and sdn are specified instead, or global algorithm if pb and sdn are null */
  4858. char* slapi_encode_ext(Slapi_PBlock *pb, const Slapi_DN *sdn, char *value, char *alg);
  4859. /* UTF8 related */
  4860. int slapi_has8thBit(unsigned char *s);
  4861. unsigned char *slapi_utf8StrToLower(unsigned char *s);
  4862. void slapi_utf8ToLower(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  4863. int slapi_utf8isUpper(unsigned char *s);
  4864. unsigned char *slapi_utf8StrToUpper(unsigned char *s);
  4865. void slapi_utf8ToUpper(unsigned char *s, unsigned char *d, int *ssz, int *dsz);
  4866. int slapi_utf8isLower(unsigned char *s);
  4867. int slapi_utf8casecmp(unsigned char *s0, unsigned char *s1);
  4868. int slapi_utf8ncasecmp(unsigned char *s0, unsigned char *s1, int n);
  4869. unsigned char *slapi_UTF8STRTOLOWER(char *s);
  4870. void slapi_UTF8TOLOWER(char *s, char *d, int *ssz, int *dsz);
  4871. int slapi_UTF8ISUPPER(char *s);
  4872. unsigned char *slapi_UTF8STRTOUPPER(char *s);
  4873. void slapi_UTF8TOUPPER(char *s, char *d, int *ssz, int *dsz);
  4874. int slapi_UTF8ISLOWER(char *s);
  4875. int slapi_UTF8CASECMP(char *s0, char *s1);
  4876. int slapi_UTF8NCASECMP(char *s0, char *s1, int n);
  4877. /*
  4878. * Interface to the API broker service
  4879. *
  4880. * The API broker allows plugins to publish an API that may be discovered
  4881. * and used dynamically at run time by other subsystems e.g. other plugins.
  4882. */
  4883. /* Function: slapi_apib_register
  4884. Description: this function allows publication of an interface
  4885. Parameters: guid - a string constant that uniquely identifies the
  4886. interface (must exist for the life of the server)
  4887. api - a vtable for the published api (must exist for the
  4888. life of the server or until the reference count,
  4889. if it exists, reaches zero)
  4890. Return: 0 if function succeeds
  4891. non-zero otherwise
  4892. */
  4893. int slapi_apib_register(char *guid, void **api); /* publish an interface */
  4894. /* Function: slapi_apib_unregister
  4895. Description: this function allows removal of a published interface
  4896. Parameters: guid - a string constant that uniquely identifies the interface
  4897. Return: 0 if function succeeds
  4898. non-zero otherwise
  4899. */
  4900. int slapi_apib_unregister(char *guid); /* remove interface from published list */
  4901. /* Function: slapi_apib_get_interface
  4902. Description: this function allows retrieval of a published interface,
  4903. if the api reference counted, then the reference
  4904. count is incremented
  4905. Parameters: guid - a string constant that uniquely identifies the
  4906. interface requested
  4907. api - the retrieved vtable for the published api (must NOT
  4908. be freed)
  4909. Return: 0 if function succeeds
  4910. non-zero otherwise
  4911. */
  4912. int slapi_apib_get_interface(char *guid, void ***api); /* retrieve an interface for use */
  4913. /* Function: slapi_apib_get_interface_all
  4914. Description: this function allows retrieval of a published interface,
  4915. if the api reference counted, then the reference
  4916. count is incremented
  4917. This will return all published interfaces for a given guid
  4918. Parameters: guid - a string constant that uniquely identifies the
  4919. interface requested
  4920. apilist - the retrieved list of vtables for the published api - caller
  4921. must free the apilist, but not the apilist elements
  4922. Return: 0 if function succeeds
  4923. non-zero otherwise
  4924. */
  4925. int slapi_apib_get_interface_all(char *guid, void ****apilist); /* retrieve all interfaces for guid */
  4926. /* Function: slapi_apib_make_reference_counted
  4927. Description: this function makes an interface a reference counted interface
  4928. it must be called prior to registering the interface
  4929. Parameters: api - the api to make a reference counted api
  4930. callback - if non-zero, this must be a pointer to a function
  4931. which the api broker will call when the ref count for
  4932. the api reaches zero. This function must return 0 if
  4933. it deregisters the api, non-zero otherwise
  4934. api - the retrieved vtable for the published api (must NOT
  4935. be freed)
  4936. Return: 0 if function succeeds
  4937. non-zero otherwise
  4938. */
  4939. typedef int (*slapi_apib_callback_on_zero)(void **api);
  4940. int slapi_apib_make_reference_counted(void **api,
  4941. slapi_apib_callback_on_zero callback);
  4942. /* Function: slapi_apib_addref
  4943. Description: this function adds to the reference count of an api - a
  4944. call to this function should be paired with a call
  4945. to slapi_apib_release
  4946. - ONLY FOR REFERENCE COUNTED APIS
  4947. Parameters: api - the api to add a reference to
  4948. Return: the new reference count
  4949. */
  4950. int slapi_apib_addref(void **api);
  4951. /* Function: slapi_apib_release
  4952. Description: this function adds to the reference count of an api - a
  4953. call to this function should be paired with a prior call
  4954. to slapi_apib_addref or slapi_apib_get_interface
  4955. - ONLY FOR REFERENCE COUNTED APIS
  4956. Parameters: api - the api to add a reference to
  4957. Return: the new reference count
  4958. */
  4959. int slapi_apib_release(void **api);
  4960. /**** End of API broker interface. *******************************************/
  4961. /* thread_data.c */
  4962. int slapi_td_init(int indexType);
  4963. int slapi_td_set_val(int indexType, void *value);
  4964. void slapi_td_get_val(int indexType, void **value);
  4965. int slapi_td_dn_init(void);
  4966. int slapi_td_set_dn(char *dn);
  4967. void slapi_td_get_dn(char **dn);
  4968. /* Thread Local Storage Index Types */
  4969. #define SLAPI_TD_REQUESTOR_DN 1
  4970. /*
  4971. * routines for dealing with controls
  4972. */
  4973. int slapi_control_present( LDAPControl **controls, char *oid,
  4974. struct berval **val, int *iscritical );
  4975. void slapi_register_supported_control( char *controloid,
  4976. unsigned long controlops );
  4977. LDAPControl * slapi_dup_control( LDAPControl *ctrl );
  4978. #define SLAPI_OPERATION_BIND 0x00000001UL
  4979. #define SLAPI_OPERATION_UNBIND 0x00000002UL
  4980. #define SLAPI_OPERATION_SEARCH 0x00000004UL
  4981. #define SLAPI_OPERATION_MODIFY 0x00000008UL
  4982. #define SLAPI_OPERATION_ADD 0x00000010UL
  4983. #define SLAPI_OPERATION_DELETE 0x00000020UL
  4984. #define SLAPI_OPERATION_MODDN 0x00000040UL
  4985. #define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
  4986. #define SLAPI_OPERATION_COMPARE 0x00000080UL
  4987. #define SLAPI_OPERATION_ABANDON 0x00000100UL
  4988. #define SLAPI_OPERATION_EXTENDED 0x00000200UL
  4989. #define SLAPI_OPERATION_ANY 0xFFFFFFFFUL
  4990. #define SLAPI_OPERATION_NONE 0x00000000UL
  4991. int slapi_get_supported_controls_copy( char ***ctrloidsp,
  4992. unsigned long **ctrlopsp );
  4993. int slapi_build_control( char *oid, BerElement *ber,
  4994. char iscritical, LDAPControl **ctrlp );
  4995. int slapi_build_control_from_berval( char *oid, struct berval *bvp,
  4996. char iscritical, LDAPControl **ctrlp );
  4997. /* Given an array of controls e.g. LDAPControl **ctrls, add the given
  4998. control to the end of the array, growing the array with realloc
  4999. e.g. slapi_add_control_ext(&ctrls, newctrl, 1);
  5000. if ctrls is NULL, the array will be created with malloc
  5001. if copy is true, the given control will be copied
  5002. if copy is false, the given control will be used and owned by the array
  5003. if copy is false, make sure the control can be freed by ldap_controls_free
  5004. */
  5005. void slapi_add_control_ext( LDAPControl ***ctrlsp, LDAPControl *newctrl, int copy );
  5006. /* Given an array of controls e.g. LDAPControl **ctrls, add all of the given
  5007. controls in the newctrls array to the end of ctrls, growing the array with realloc
  5008. if ctrls is NULL, the array will be created with malloc
  5009. if copy is true, each given control will be copied
  5010. if copy is false, each given control will be used and owned by the array
  5011. if copy is false, make sure each control can be freed by ldap_controls_free
  5012. */
  5013. void slapi_add_controls( LDAPControl ***ctrlsp, LDAPControl **newctrls, int copy );
  5014. /*
  5015. * routines for dealing with extended operations
  5016. */
  5017. char **slapi_get_supported_extended_ops_copy( void );
  5018. /*
  5019. * bind, including SASL
  5020. */
  5021. void slapi_register_supported_saslmechanism( char *mechanism );
  5022. char ** slapi_get_supported_saslmechanisms_copy( void );
  5023. void slapi_add_auth_response_control( Slapi_PBlock *pb, const char *binddn );
  5024. int slapi_add_pwd_control( Slapi_PBlock *pb, char *arg, long time );
  5025. int slapi_pwpolicy_make_response_control (Slapi_PBlock *pb, int seconds, int logins, int error);
  5026. /* Password Policy Response Control stuff - the error argument above */
  5027. #define LDAP_PWPOLICY_PWDEXPIRED 0
  5028. #define LDAP_PWPOLICY_ACCTLOCKED 1
  5029. #define LDAP_PWPOLICY_CHGAFTERRESET 2
  5030. #define LDAP_PWPOLICY_PWDMODNOTALLOWED 3
  5031. #define LDAP_PWPOLICY_MUSTSUPPLYOLDPWD 4
  5032. #define LDAP_PWPOLICY_INVALIDPWDSYNTAX 5
  5033. #define LDAP_PWPOLICY_PWDTOOSHORT 6
  5034. #define LDAP_PWPOLICY_PWDTOOYOUNG 7
  5035. #define LDAP_PWPOLICY_PWDINHISTORY 8
  5036. /*
  5037. * Password Policy API
  5038. */
  5039. /**
  5040. * Gets the password policy object for a given entry
  5041. *
  5042. * \param dn The dn of the entry whose password policy object you
  5043. * want returned
  5044. *
  5045. * \return A pointer to an opaque password policy object
  5046. * \return \c NULL if there is a problem getting the policy object
  5047. * \warning The caller should free the returned password policy
  5048. * object when finished by calling the slapi_pwpolicy_free()
  5049. * function.
  5050. * \see slapi_pwpolicy_free()
  5051. */
  5052. Slapi_PWPolicy *slapi_get_pwpolicy(Slapi_DN *dn);
  5053. /**
  5054. * Free a password policy object from memory
  5055. *
  5056. * \param pwpolicy The password policy object that you want to free
  5057. * \see slapi_get_pwpolicy()
  5058. */
  5059. void slapi_pwpolicy_free(Slapi_PWPolicy *pwpolicy);
  5060. /**
  5061. * Checks a password policy object to see if the password is expired
  5062. *
  5063. * \param pwpolicy The password policy object that you want to check
  5064. * \param e The entry that you want to check
  5065. * \param expire_time Fills in the expiration time if the password has not expired yet.
  5066. * You can pass \c NULL if you are not interested in the expiration time.
  5067. * \param remaining_grace Fills in the number of grace logins remaining if the password
  5068. * has already expired. You can pass \c NULL if you are not interested in the
  5069. * number of remaining grace logins.
  5070. *
  5071. * \return \c 1 if the password has expired
  5072. * \return \c 0 if the password has not expired
  5073. */
  5074. int slapi_pwpolicy_is_expired(Slapi_PWPolicy *pwpolicy, Slapi_Entry *e, time_t *expire_time, int *remaining_grace);
  5075. /**
  5076. * Checks a password policy to see if an account is locked
  5077. *
  5078. * \param pwpolicy The password policy object that you want to check
  5079. * \param e The entry that you want to check
  5080. * \param unlock_time Fills in the time the account will be unlocked if the account
  5081. * is currently locked. You can pass \c NULL if you are not interested in the
  5082. * unlock time.
  5083. *
  5084. * \return \c 1 if the account is locked
  5085. * \return \c 0 if the account is not locked
  5086. */
  5087. int slapi_pwpolicy_is_locked(Slapi_PWPolicy *pwpolicy, Slapi_Entry *e, time_t *unlock_time);
  5088. /**
  5089. * Checks a password policy to see if a password has been reset
  5090. *
  5091. * \param pwpolicy The password policy object that you want to check
  5092. * \param e The entry that you want to check
  5093. *
  5094. * \return \c 1 if the password has been reset
  5095. * \return \c 0 if the password has not been reset
  5096. */
  5097. int slapi_pwpolicy_is_reset(Slapi_PWPolicy *pwpolicy, Slapi_Entry *e);
  5098. /**
  5099. * Free an array of strings from memory
  5100. *
  5101. * \param array The array that you want to free
  5102. * \see slapi_ch_array_add()
  5103. * \see slapi_ch_array_dup()
  5104. */
  5105. void slapi_ch_array_free( char **array );
  5106. /**
  5107. * Duplicate an array of strings
  5108. *
  5109. * \param array The array that you want to duplicate
  5110. * \return A newly allocated copy of \c array
  5111. * \return \c NULL if there is a problem duplicating the array
  5112. * \warning The caller should free the returned array when finished
  5113. * by calling the slapi_ch_array_free() function.
  5114. * \see slapi_ch_array_free()
  5115. */
  5116. char ** slapi_ch_array_dup( char **array );
  5117. /**
  5118. * Add a string to an array of strings
  5119. *
  5120. * \param array The array to add the string to
  5121. * \param string The string to add to the array
  5122. * \warning The \c string parameter is not copied. If you do not
  5123. * want to hand the memory used by \c string over to the
  5124. * array, you should duplicate it first by calling the
  5125. * slapi_ch_strdup() function.
  5126. * \warning If \c *a is \c NULL, a new array will be allocated.
  5127. * \see slapi_ch_array_free()
  5128. */
  5129. void slapi_ch_array_add( char ***array, char *string );
  5130. /**
  5131. * Add a string to an array of strings
  5132. *
  5133. * \param array The array to add the string to
  5134. * \param string The string to add to the array
  5135. * \warning The \c string parameter is not copied. If you do not
  5136. * want to hand the memory used by \c string over to the
  5137. * array, you should duplicate it first by calling the
  5138. * slapi_ch_strdup() function.
  5139. * \warning If \c *a is \c NULL, a new array will be allocated.
  5140. * \see slapi_ch_array_free()
  5141. * \return the total number of elements in the array.
  5142. */
  5143. int slapi_ch_array_add_ext(char ***array, char *string);
  5144. /**
  5145. * Find a string in an array of strings
  5146. *
  5147. * \param array The array of strings
  5148. * \param string The string to look for in the array
  5149. * \return NULL if there is no match
  5150. * \return 1 if there is a match
  5151. */
  5152. int slapi_ch_array_utf8_inlist(char **array, char *string);
  5153. /**
  5154. * Returns the error string of an ldap result code, but it can also handle
  5155. * library errors(negative result codes)
  5156. *
  5157. * \param result The result code
  5158. * \return The error text string of the result code
  5159. */
  5160. char *slapi_err2string(int result);
  5161. /**
  5162. * Check if the server has started shutting down
  5163. *
  5164. * \return 1 if the server is shutting down
  5165. */
  5166. int slapi_is_shutting_down(void);
  5167. /*
  5168. * checking routines for allocating and freeing memory
  5169. */
  5170. char * slapi_ch_malloc( unsigned long size );
  5171. char * slapi_ch_realloc( char *block, unsigned long size );
  5172. char * slapi_ch_calloc( unsigned long nelem, unsigned long size );
  5173. char * slapi_ch_strdup( const char *s );
  5174. void slapi_ch_free( void **ptr );
  5175. void slapi_ch_free_string( char **s );
  5176. struct berval* slapi_ch_bvdup(const struct berval*);
  5177. struct berval** slapi_ch_bvecdup(struct berval**);
  5178. void slapi_ch_bvfree(struct berval** v);
  5179. char * slapi_ch_smprintf(const char *fmt, ...)
  5180. #ifdef __GNUC__
  5181. __attribute__ ((format (printf, 1, 2)));
  5182. #else
  5183. ;
  5184. #endif
  5185. /*
  5186. * syntax plugin routines
  5187. * THESE ARE DEPRECATED - the first argument is the syntax plugin
  5188. * we do not support that style of call anymore - use the slapi_attr_
  5189. * versions below instead
  5190. */
  5191. int slapi_call_syntax_values2keys_sv( void *vpi, Slapi_Value **vals,
  5192. Slapi_Value ***ivals, int ftype );
  5193. int slapi_call_syntax_values2keys_sv_pb( void *vpi, Slapi_Value **vals,
  5194. Slapi_Value ***ivals, int ftype, Slapi_PBlock *pb );
  5195. int slapi_call_syntax_assertion2keys_ava_sv( void *vpi, Slapi_Value *val,
  5196. Slapi_Value ***ivals, int ftype );
  5197. int slapi_call_syntax_assertion2keys_sub_sv( void *vpi, char *initial,
  5198. char **any, char *final, Slapi_Value ***ivals );
  5199. int slapi_attr_values2keys_sv( const Slapi_Attr *sattr, Slapi_Value **vals,
  5200. Slapi_Value ***ivals, int ftype );
  5201. int slapi_attr_values2keys_sv_pb( const Slapi_Attr *sattr, Slapi_Value **vals,
  5202. Slapi_Value ***ivals, int ftype, Slapi_PBlock *pb );
  5203. int slapi_attr_assertion2keys_ava_sv( const Slapi_Attr *sattr, Slapi_Value *val,
  5204. Slapi_Value ***ivals, int ftype );
  5205. int slapi_attr_assertion2keys_sub_sv( const Slapi_Attr *sattr, char *initial,
  5206. char **any, char *final, Slapi_Value ***ivals );
  5207. /**
  5208. * Normalize the given value using the syntax associated with the
  5209. * given attribute. It will attempt to normalize the value in place.
  5210. * If it cannot, it will return the normalized value in retval. If
  5211. * trim_spaces is true, whitepace characters will be trimmed from the
  5212. * ends of the string. If sattr is NULL, the type will be used to look
  5213. * up the attribute syntax. If sattr is not NULL, type is ignored. If
  5214. * retval is set, the caller is responsible for freeing it.
  5215. *
  5216. * \param pb Slapi_PBlock to use
  5217. * \param sattr attribute to get the syntax from
  5218. * \param type attribute to get the syntax from if sattr is NULL
  5219. * \param val value to normalize in place - must be NULL terminated
  5220. * \param trim_spaces trim whitespace from ends of string
  5221. * \param retval if value could not be normalized in place, this is the malloc'd memory containg the new value - caller must free
  5222. */
  5223. void slapi_attr_value_normalize(
  5224. Slapi_PBlock *pb,
  5225. const Slapi_Attr *sattr, /* if sattr is NULL, type must be attr type name */
  5226. const char *type,
  5227. char *val,
  5228. int trim_spaces,
  5229. char **retval
  5230. );
  5231. /**
  5232. * Normalize the given value using the matching rule associated with the
  5233. * given attribute and given filter type. It will attempt to normalize
  5234. * the value in place. If it cannot, it will return the normalized value
  5235. * in retval. If trim_spaces is true, whitepace characters will be trimmed
  5236. * from the ends of the string. If sattr is NULL, the type will be used to look
  5237. * up the attribute syntax. If sattr is not NULL, type is ignored. If
  5238. * retval is set, the caller is responsible for freeing it. The filter_type
  5239. * corresponds to the matching rule to use - LDAP_FILTER_GE or LDAP_FILTER_LE
  5240. * will use the ORDERING matching rule normalization function - LDAP_FILTER_EQUALITY
  5241. * will use the EQUALITY matching rule normalization function - LDAP_FILTER_SUBSTRINGS
  5242. * will use the SUBSTRINGS matching rule normalization function. If the given
  5243. * filter_type is 0, or some other value other than specified above, or there is no
  5244. * matching rule corresponding to the given filter type, the default normalization
  5245. * function provided by the attribute syntax will be used.
  5246. *
  5247. * \param pb Slapi_PBlock to use
  5248. * \param sattr attribute to get the syntax from
  5249. * \param type attribute to get the syntax from if sattr is NULL
  5250. * \param val value to normalize in place - must be NULL terminated
  5251. * \param trim_spaces trim whitespace from ends of string
  5252. * \param retval if value could not be normalized in place, this is the malloc'd memory containg the new value - caller must free
  5253. * \param filter_type one of the values specified above, or 0
  5254. */
  5255. void slapi_attr_value_normalize_ext(
  5256. Slapi_PBlock *pb,
  5257. const Slapi_Attr *sattr, /* if sattr is NULL, type must be attr type name */
  5258. const char *type,
  5259. char *val,
  5260. int trim_spaces,
  5261. char **retval,
  5262. unsigned long filter_type
  5263. );
  5264. /*
  5265. * internal operation and plugin callback routines
  5266. */
  5267. typedef void (*plugin_result_callback)(int rc, void *callback_data);
  5268. typedef int (*plugin_referral_entry_callback)(char * referral,
  5269. void *callback_data);
  5270. typedef int (*plugin_search_entry_callback)(Slapi_Entry *e,
  5271. void *callback_data);
  5272. void slapi_free_search_results_internal(Slapi_PBlock *pb);
  5273. /*
  5274. * The following functions can be used for internal operations based on DN
  5275. * as well as on uniqueid. These functions should be used by all new plugins
  5276. * and preferrably old plugins should be changed to use them to take
  5277. * advantage of new plugin configuration capabilities and to use an
  5278. * extensible interface.
  5279. *
  5280. * These functions return -1 if pb is NULL and 0 otherwise.
  5281. * The SLAPI_PLUGIN_INTOP_RESULT pblock parameter should be checked to
  5282. * check if the operation was successful.
  5283. *
  5284. * Helper functions are provided to set up pblock parameters currently used
  5285. * by the functions, e.g., slapi_search_internal_set_pb().
  5286. * Additional parameters may be set directly in the pblock.
  5287. */
  5288. int slapi_search_internal_pb(Slapi_PBlock *pb);
  5289. int slapi_search_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  5290. plugin_result_callback prc, plugin_search_entry_callback psec,
  5291. plugin_referral_entry_callback prec);
  5292. int slapi_add_internal_pb(Slapi_PBlock *pb);
  5293. int slapi_modify_internal_pb(Slapi_PBlock *pb);
  5294. int slapi_modrdn_internal_pb(Slapi_PBlock *pb);
  5295. int slapi_delete_internal_pb(Slapi_PBlock *pb);
  5296. int slapi_seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data,
  5297. plugin_result_callback res_callback,
  5298. plugin_search_entry_callback srch_callback,
  5299. plugin_referral_entry_callback ref_callback);
  5300. void slapi_search_internal_set_pb(Slapi_PBlock *pb, const char *base,
  5301. int scope, const char *filter, char **attrs, int attrsonly,
  5302. LDAPControl **controls, const char *uniqueid,
  5303. Slapi_ComponentId *plugin_identity, int operation_flags);
  5304. void slapi_search_internal_set_pb_ext(Slapi_PBlock *pb, Slapi_DN *sdn,
  5305. int scope, const char *filter, char **attrs, int attrsonly,
  5306. LDAPControl **controls, const char *uniqueid,
  5307. Slapi_ComponentId *plugin_identity, int operation_flags);
  5308. void slapi_add_entry_internal_set_pb(Slapi_PBlock *pb, Slapi_Entry *e,
  5309. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  5310. int operation_flags);
  5311. int slapi_add_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  5312. LDAPMod **attrs, LDAPControl **controls,
  5313. Slapi_ComponentId *plugin_identity, int operation_flags);
  5314. void slapi_modify_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  5315. LDAPMod **mods, LDAPControl **controls, const char *uniqueid,
  5316. Slapi_ComponentId *plugin_identity, int operation_flags);
  5317. void slapi_modify_internal_set_pb_ext(Slapi_PBlock *pb, const Slapi_DN *sdn,
  5318. LDAPMod **mods, LDAPControl **controls, const char *uniqueid,
  5319. Slapi_ComponentId *plugin_identity, int operation_flags);
  5320. /**
  5321. * Set \c Slapi_PBlock to perform modrdn/rename internally
  5322. *
  5323. * \param pblock - Slapi_PBlock to be set
  5324. * \param olddn - original dn to be renamed; it should have been normalized
  5325. * \param newrdn - new leaf rdn if any; it should have been normalized
  5326. * \param newsuperior - new parent dn if any; it should have been normalized
  5327. * \param deloldrdn \c 0 - keep original rdn \c non-zero - delete original rdn
  5328. * \param controls
  5329. * \param uniqueid
  5330. * \param plugin_identity
  5331. * \param operation_flags
  5332. */
  5333. void slapi_rename_internal_set_pb_ext(Slapi_PBlock *pb,
  5334. const Slapi_DN *olddn, const char *newrdn,
  5335. const Slapi_DN *newsuperior, int deloldrdn,
  5336. LDAPControl **controls, const char *uniqueid,
  5337. Slapi_ComponentId *plugin_identity, int operation_flags);
  5338. void slapi_delete_internal_set_pb(Slapi_PBlock *pb, const char *dn,
  5339. LDAPControl **controls, const char *uniqueid,
  5340. Slapi_ComponentId *plugin_identity, int operation_flags);
  5341. void slapi_seq_internal_set_pb(Slapi_PBlock *pb, char *ibase, int type,
  5342. char *attrname, char *val, char **attrs, int attrsonly,
  5343. LDAPControl **controls, Slapi_ComponentId *plugin_identity,
  5344. int operation_flags);
  5345. /*
  5346. * slapi_search_internal_get_entry() finds an entry given a dn. It returns
  5347. * an LDAP error code (LDAP_SUCCESS if all goes well).
  5348. */
  5349. int slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrlist,
  5350. Slapi_Entry **ret_entry , void *caller_identity);
  5351. /*
  5352. * interface for registering object extensions.
  5353. */
  5354. typedef void *(*slapi_extension_constructor_fnptr)(void *object, void *parent);
  5355. typedef void (*slapi_extension_destructor_fnptr)(void *extension,
  5356. void *object, void *parent);
  5357. int slapi_register_object_extension( const char *pluginname,
  5358. const char *objectname, slapi_extension_constructor_fnptr constructor,
  5359. slapi_extension_destructor_fnptr destructor, int *objecttype,
  5360. int *extensionhandle);
  5361. /* objects that can be extended (possible values for the objectname param.) */
  5362. #define SLAPI_EXT_CONNECTION "Connection"
  5363. #define SLAPI_EXT_OPERATION "Operation"
  5364. #define SLAPI_EXT_ENTRY "Entry"
  5365. #define SLAPI_EXT_MTNODE "Mapping Tree Node"
  5366. /* Module names for SLAPI_EXT_ENTRY */
  5367. #define SLAPI_EXTMOD_PWPOLICY "Password Policy"
  5368. /* Object names in SLAPI_EXT_ENTRY */
  5369. #define SLAPI_EXTOBJ_ENTRY_PW "UnhashedPW"
  5370. void *slapi_get_object_extension(int objecttype, void *object,
  5371. int extensionhandle);
  5372. void slapi_set_object_extension(int objecttype, void *object,
  5373. int extensionhandle, void *extension);
  5374. /*
  5375. * interface to allow a plugin to register additional plugins.
  5376. */
  5377. typedef int (*slapi_plugin_init_fnptr)( Slapi_PBlock *pb );
  5378. int slapi_register_plugin( const char *plugintype, int enabled,
  5379. const char *initsymbol, slapi_plugin_init_fnptr initfunc,
  5380. const char *name, char **argv, void *group_identity);
  5381. int slapi_register_plugin_ext( const char *plugintype, int enabled,
  5382. const char *initsymbol, slapi_plugin_init_fnptr initfunc,
  5383. const char *name, char **argv, void *group_identity, int precedence);
  5384. /*
  5385. * logging
  5386. */
  5387. int slapi_log_error( int severity, char *subsystem, char *fmt, ... )
  5388. #ifdef __GNUC__
  5389. __attribute__ ((format (printf, 3, 4)));
  5390. #else
  5391. ;
  5392. #endif
  5393. int slapi_log_error_ext( int severity, char *subsystem, char *fmt, va_list varg1, va_list varg2);
  5394. /* allowed values for the "severity" parameter */
  5395. #define SLAPI_LOG_FATAL 0
  5396. #define SLAPI_LOG_TRACE 1
  5397. #define SLAPI_LOG_PACKETS 2
  5398. #define SLAPI_LOG_ARGS 3
  5399. #define SLAPI_LOG_CONNS 4
  5400. #define SLAPI_LOG_BER 5
  5401. #define SLAPI_LOG_FILTER 6
  5402. #define SLAPI_LOG_CONFIG 7
  5403. #define SLAPI_LOG_ACL 8
  5404. #define SLAPI_LOG_SHELL 9
  5405. #define SLAPI_LOG_PARSE 10
  5406. #define SLAPI_LOG_HOUSE 11
  5407. #define SLAPI_LOG_REPL 12
  5408. #define SLAPI_LOG_CACHE 13
  5409. #define SLAPI_LOG_PLUGIN 14
  5410. #define SLAPI_LOG_TIMING 15
  5411. #define SLAPI_LOG_BACKLDBM 16
  5412. #define SLAPI_LOG_ACLSUMMARY 17 /* ACLSUMMARY must be the last (log.c) */
  5413. int slapi_is_loglevel_set( const int loglevel );
  5414. /*
  5415. * locks and synchronization
  5416. */
  5417. typedef struct slapi_mutex Slapi_Mutex;
  5418. typedef struct slapi_condvar Slapi_CondVar;
  5419. #ifdef USE_POSIX_RWLOCKS
  5420. typedef pthread_rwlock_t Slapi_RWLock;
  5421. #else
  5422. typedef struct slapi_rwlock Slapi_RWLock;
  5423. #endif
  5424. Slapi_Mutex *slapi_new_mutex( void );
  5425. void slapi_destroy_mutex( Slapi_Mutex *mutex );
  5426. void slapi_lock_mutex( Slapi_Mutex *mutex );
  5427. int slapi_unlock_mutex( Slapi_Mutex *mutex );
  5428. Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
  5429. void slapi_destroy_condvar( Slapi_CondVar *cvar );
  5430. int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
  5431. int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
  5432. /**
  5433. * Creates a new read/write lock.
  5434. *
  5435. * \return A pointer to a \c Slapi_RWLock
  5436. *
  5437. * \note Free the returned lock by calling slapi_destroy_rwlock() when finished
  5438. *
  5439. * \see slapi_destroy_rwlock()
  5440. * \see slapi_rwlock_rdlock()
  5441. * \see slapi_rwlock_wrlock()
  5442. * \see slapi_rwlock_unlock()
  5443. */
  5444. Slapi_RWLock *slapi_new_rwlock( void );
  5445. /**
  5446. * Free a read/write lock
  5447. *
  5448. * \see slapi_new_rwlock()
  5449. */
  5450. void slapi_destroy_rwlock( Slapi_RWLock *rwlock );
  5451. /**
  5452. * Acquires a reader lock
  5453. *
  5454. * \return 0 if successful
  5455. * \return Non-zero if an error occurred
  5456. *
  5457. * \note Release the acquired lock by calling slapi_rwlock_unlock()
  5458. * \note It is safe for a thread to hold multiple reader locks, but
  5459. * you must call slapi_rwlock_unlock() for each aquired lock.
  5460. *
  5461. * \see slapi_rwlock_unlock()
  5462. */
  5463. int slapi_rwlock_rdlock( Slapi_RWLock *rwlock );
  5464. /**
  5465. * Acquires a writer lock
  5466. *
  5467. * \return 0 if successful
  5468. * \return Non-zero if an error occurred
  5469. *
  5470. * \note Release the acquired lock by calling slapi_rwlock_unlock()
  5471. *
  5472. * \see slapi_rwlock_unlock()
  5473. */
  5474. int slapi_rwlock_wrlock( Slapi_RWLock *rwlock );
  5475. /**
  5476. * Releases a reader or writer lock
  5477. *
  5478. * \return 0 if successful
  5479. * \return Non-zero if an error occurred
  5480. *
  5481. * \see slapi_rwlock_rdlock()
  5482. * \see slapi_rwlock_wrlock()
  5483. */
  5484. int slapi_rwlock_unlock( Slapi_RWLock *rwlock );
  5485. /*
  5486. * thread-safe LDAP connections
  5487. */
  5488. /**
  5489. * Initializes an LDAP connection, and returns a handle to the connection.
  5490. *
  5491. * \param ldaphost Hostname or IP address - NOTE: for TLS or GSSAPI, should be the FQDN
  5492. * \param ldapport LDAP server port number (default 389)
  5493. * \param secure \c 0 - LDAP \c 1 - LDAPS \c 2 - startTLS
  5494. * \param shared \c 0 - single thread access \c 1 - LDAP* will be shared among multiple threads
  5495. * \return A pointer to an LDAP* handle
  5496. *
  5497. * \note Use #slapi_ldap_unbind() to close and free the handle
  5498. *
  5499. * \see slapi_ldap_unbind()
  5500. * \see slapi_ldap_init_ext()
  5501. */
  5502. LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared );
  5503. /**
  5504. * Closes an LDAP connection, and frees memory associated with the handle
  5505. *
  5506. * \param ld the LDAP connection handle
  5507. *
  5508. * \see slapi_ldap_init()
  5509. * \see slapi_ldap_init_ext()
  5510. */
  5511. void slapi_ldap_unbind( LDAP *ld );
  5512. /**
  5513. * Initializes an LDAP connection, and returns a handle to the connection.
  5514. *
  5515. * \param ldapurl A full LDAP url in the form ldap[s]://hostname:port or
  5516. * ldapi://path - if \c NULL, #hostname, #port, and #secure must be provided
  5517. * \param hostname Hostname or IP address - NOTE: for TLS or GSSAPI, should be the FQDN
  5518. * \param port LDAP server port number (default 389)
  5519. * \param secure \c 0 - LDAP \c 1 - LDAPS \c 2 - startTLS
  5520. * \param shared \c 0 - single thread access \c 1 - LDAP* will be shared among multiple threads
  5521. * \param filename - currently not supported
  5522. * \return A pointer to an LDAP* handle
  5523. *
  5524. * \note Use #slapi_ldap_unbind() to close and free the handle
  5525. *
  5526. * \see slapi_ldap_unbind()
  5527. * \see slapi_ldap_init()
  5528. */
  5529. LDAP *slapi_ldap_init_ext(
  5530. const char *ldapurl, /* full ldap url */
  5531. const char *hostname, /* can also use this to override
  5532. host in url */
  5533. int port, /* can also use this to override port in url */
  5534. int secure, /* 0 for ldap, 1 for ldaps, 2 for starttls -
  5535. override proto in url */
  5536. int shared, /* if true, LDAP* will be shared among multiple threads */
  5537. const char *filename /* for ldapi */
  5538. );
  5539. /**
  5540. * The LDAP bind request - this function handles all of the different types of mechanisms
  5541. * including simple, sasl, and external (client cert auth)
  5542. *
  5543. * \param ld the LDAP connection handle
  5544. * \param bindid Either a bind DN for simple bind or a SASL identity
  5545. * \param creds usually a password for simple bind or SASL credentials
  5546. * \param mech a valid mech that can be passed to ldap_sasl_bind (or NULL for simple)
  5547. * \param serverctrls optional controls to send (or NULL)
  5548. * \param returnedctrls optional controls returned by the server - use NULL if you just
  5549. * want to ignore them - if you pass in a variable for this, you
  5550. * are responsible for freeing the result (ldap_controls_free)
  5551. * \param timeout timeout or NULL for no timeout (wait forever)
  5552. * \param msgidp LDAP message ID \c NULL - call bind synchronously \c non-NULL -
  5553. * call bind asynchronously - you are responsible for calling ldap_result
  5554. * to read the response
  5555. * \return an LDAP error code
  5556. *
  5557. * \see ldap_sasl_bind()
  5558. * \see ldap_sasl_bind_s()
  5559. * \see ldap_controls_free()
  5560. * \see ldap_result()
  5561. */
  5562. int slapi_ldap_bind(
  5563. LDAP *ld, /* ldap connection */
  5564. const char *bindid, /* usually a bind DN for simple bind */
  5565. const char *creds, /* usually a password for simple bind */
  5566. const char *mech, /* name of mechanism */
  5567. LDAPControl **serverctrls, /* additional controls to send */
  5568. LDAPControl ***returnedctrls, /* returned controls */
  5569. struct timeval *timeout, /* timeout */
  5570. int *msgidp /* pass in non-NULL for async handling */
  5571. );
  5572. /**
  5573. * Create either a v1 Proxy Auth Control or a v2 Proxied Auth Control
  5574. *
  5575. * \param ld the LDAP connection handle
  5576. * \param dn The proxy DN
  5577. * \param creds usually a password for simple bind or SASL credentials
  5578. * \param ctl_iscritical \c 0 - not critical \c 1 - critical
  5579. * \param usev2 \c 0 - use the v1 Proxy Auth \c 1 - use the v2 Proxied Auth
  5580. * \param ctrlp the control to send - caller is responsible for freeing (ldap_control_free)
  5581. * \return an LDAP error code
  5582. *
  5583. * \see ldap_control_free()
  5584. */
  5585. int slapi_ldap_create_proxyauth_control (
  5586. LDAP *ld, /* only used to get current ber options */
  5587. const char *dn, /* proxy dn */
  5588. const char ctl_iscritical,
  5589. int usev2, /* use the v2 (.18) control instead */
  5590. LDAPControl **ctrlp /* value to return */
  5591. );
  5592. /**
  5593. * Parse a line from an LDIF record returned by ldif_getline() and return the LDAP
  5594. * attribute type and value from the line. ldif_getline() will encode the LDIF continuation
  5595. * lines, and slapi_ldif_parse_line() will take those into consideration when returning the
  5596. * value.
  5597. *
  5598. * \param line LDIF record line returned by ldif_getline()
  5599. * \param type The attribute type returned
  5600. * \param value The attribute value returned
  5601. * \param freeval \c NULL - use malloc for the value->bv_val - caller is responsible for freeing
  5602. * \c an int* - slapi_ldif_parse_line will usually return pointers into the line
  5603. * parameter that should not be freed - if slapi_ldif_parse_line needs to allocate
  5604. * memory for the value, *freeval will be set to 1 to indicate the caller must
  5605. * free value->bv_val
  5606. * \return \c 0 - success \c 1 - failure
  5607. *
  5608. * \note line is written to - you must pass in writable memory - line must be NULL terminated
  5609. *
  5610. * \see ldif_getline()
  5611. */
  5612. int slapi_ldif_parse_line(
  5613. char *line, /* line to parse */
  5614. struct berval *type, /* attribute type to return */
  5615. struct berval *value, /* attribute value to return */
  5616. int *freeval /* values will usually be returned in place as pointers into line - if the value is a url, the value will be malloced and must be freed by the caller */
  5617. );
  5618. /**
  5619. * Parse an LDAP DN string. Return an array of RDN strings, terminated by a NULL. This
  5620. * function differs from the standard openldap ldap_explode_dn, which will escape utf-8
  5621. * characters. In the directory server, we do not want to escape them. The caller
  5622. * should use slapi_ldap_value_free to free the returned memory when finished.
  5623. *
  5624. * \param dn The LDAP DN
  5625. * \param notypes set to true (1) to return only the attribute values with no attribute types
  5626. * \return \c An array of RDN strings - use slapi_ch_array_free to free
  5627. *
  5628. * \see slapi_ldap_value_free()
  5629. */
  5630. char **slapi_ldap_explode_dn(
  5631. const char *dn, /* dn to explode */
  5632. int notypes /* set to true to return only the values with no types */
  5633. );
  5634. /**
  5635. * Parse an LDAP RDN string. Return an array of AVA strings, terminated by a NULL. This
  5636. * function differs from the standard openldap ldap_explode_rdn, which will escape utf-8
  5637. * characters. In the directory server, we do not want to escape them. The caller
  5638. * should use slapi_ldap_value_free to free the returned memory when finished.
  5639. *
  5640. * \param dn The LDAP RDN
  5641. * \param notypes set to true (1) to return only the attribute values with no attribute types
  5642. * \return \c An array of AVA strings - use slapi_ch_array_free to free
  5643. *
  5644. * \see slapi_ldap_value_free()
  5645. */
  5646. char **slapi_ldap_explode_rdn(
  5647. const char *rdn, /* rdn to explode */
  5648. int notypes /* set to true to return only the values with no types */
  5649. );
  5650. /*
  5651. * computed attributes
  5652. */
  5653. struct _computed_attr_context;
  5654. typedef struct _computed_attr_context computed_attr_context;
  5655. typedef int (*slapi_compute_output_t)(computed_attr_context *c,Slapi_Attr *a , Slapi_Entry *e);
  5656. typedef int (*slapi_compute_callback_t)(computed_attr_context *c,char* type,Slapi_Entry *e,slapi_compute_output_t outputfn);
  5657. typedef int (*slapi_search_rewrite_callback_t)(Slapi_PBlock *pb);
  5658. int slapi_compute_add_evaluator(slapi_compute_callback_t function);
  5659. int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function);
  5660. int compute_rewrite_search_filter(Slapi_PBlock *pb);
  5661. /*
  5662. * routines for dealing with backends
  5663. */
  5664. Slapi_Backend *slapi_be_new( const char *type, const char *name,
  5665. int isprivate, int logchanges );
  5666. void slapi_be_free(Slapi_Backend **be);
  5667. Slapi_Backend *slapi_be_select( const Slapi_DN *sdn );
  5668. Slapi_Backend *slapi_be_select_by_instance_name( const char *name );
  5669. int slapi_be_exist(const Slapi_DN *sdn);
  5670. void slapi_be_delete_onexit(Slapi_Backend *be);
  5671. void slapi_be_set_readonly(Slapi_Backend *be, int readonly);
  5672. int slapi_be_get_readonly(Slapi_Backend *be);
  5673. int slapi_be_getentrypoint(Slapi_Backend *be, int entrypoint, void **ret_fnptr,
  5674. Slapi_PBlock *pb);
  5675. int slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr,
  5676. Slapi_PBlock *pb);
  5677. int slapi_be_logchanges(Slapi_Backend *be);
  5678. int slapi_be_issuffix(const Slapi_Backend *be, const Slapi_DN *suffix );
  5679. void slapi_be_addsuffix(Slapi_Backend *be,const Slapi_DN *suffix);
  5680. char * slapi_be_get_name(Slapi_Backend * be);
  5681. const Slapi_DN *slapi_be_getsuffix(Slapi_Backend *be, int n);
  5682. Slapi_Backend* slapi_get_first_backend(char **cookie);
  5683. Slapi_Backend* slapi_get_next_backend(char *cookie);
  5684. int slapi_be_private( Slapi_Backend *be );
  5685. void * slapi_be_get_instance_info(Slapi_Backend * be);
  5686. void slapi_be_set_instance_info(Slapi_Backend * be, void * data);
  5687. Slapi_DN * slapi_get_first_suffix(void ** node, int show_private);
  5688. Slapi_DN * slapi_get_next_suffix(void ** node, int show_private);
  5689. Slapi_DN * slapi_get_next_suffix_ext(void ** node, int show_private);
  5690. int slapi_is_root_suffix(Slapi_DN * dn);
  5691. const Slapi_DN *slapi_get_suffix_by_dn(const Slapi_DN *dn);
  5692. const char * slapi_be_gettype(Slapi_Backend *be);
  5693. /**
  5694. * Start database transaction
  5695. *
  5696. * \param pb Pblock which is supposed to set (Slapi_Backend *) to SLAPI_BACKEND
  5697. * \return 0 if successful
  5698. * \return SLAPI_BACK_TRANSACTION_NOT_SUPPORTED if transaction support is not available for this backend
  5699. * \return Non-zero if an error occurred
  5700. *
  5701. * \see slapi_back_transaction_commit
  5702. * \see slapi_back_transaction_abort
  5703. */
  5704. int slapi_back_transaction_begin(Slapi_PBlock *pb);
  5705. /**
  5706. * Commit database transaction
  5707. *
  5708. * \param pb Pblock which is used to start transaction
  5709. * \return 0 if successful
  5710. * \return Non-zero if an error occurred
  5711. *
  5712. * \see slapi_back_transaction_start
  5713. * \see slapi_back_transaction_abort
  5714. */
  5715. int slapi_back_transaction_commit(Slapi_PBlock *pb);
  5716. /**
  5717. * Abort database transaction
  5718. *
  5719. * \param pb Pblock which is used to start transaction
  5720. * \return 0 if successful
  5721. * \return Non-zero if an error occurred
  5722. *
  5723. * \see slapi_back_transaction_commit
  5724. * \see slapi_back_transaction_abort
  5725. */
  5726. int slapi_back_transaction_abort(Slapi_PBlock *pb);
  5727. /**
  5728. * Checks if the connection type is LDAPI
  5729. *
  5730. * \param pb Parameter block.
  5731. *
  5732. * \return \c 1 if connection type is LDAPI
  5733. * \return \c 0 if connection is not LDAPI
  5734. */
  5735. int slapi_is_ldapi_conn(Slapi_PBlock *pb);
  5736. int slapi_be_is_flag_set(Slapi_Backend * be, int flag);
  5737. void slapi_be_set_flag(Slapi_Backend * be, int flag);
  5738. #define SLAPI_BE_FLAG_REMOTE_DATA 0x1 /* entries held by backend are remote */
  5739. #define SLAPI_BE_FLAG_DONT_BYPASS_FILTERTEST 0x10 /* force to call filter_test (search only) */
  5740. /* These functions allow a plugin to register for callback when
  5741. * a backend state change
  5742. */
  5743. typedef void (*slapi_backend_state_change_fnptr)(void *handle, char *be_name,
  5744. int old_be_state, int new_be_state);
  5745. void slapi_register_backend_state_change(void * handle, slapi_backend_state_change_fnptr funct);
  5746. int slapi_unregister_backend_state_change(void * handle);
  5747. #define SLAPI_BE_STATE_ON 1 /* backend is ON */
  5748. #define SLAPI_BE_STATE_OFFLINE 2 /* backend is OFFLINE (import process) */
  5749. #define SLAPI_BE_STATE_DELETE 3 /* backend has been deleted */
  5750. /*
  5751. * Distribution.
  5752. */
  5753. /* SLAPI_BE_ALL_BACKENDS is a special value that is returned by
  5754. * a distribution plugin function to indicate that all backends
  5755. * should be searched (it is only used for search operations).
  5756. *
  5757. * SLAPI_BE_NO_BACKEND indicates no more backend is available or allowed
  5758. * SLAPI_BE_REMOTE_BACKEND indicates that the are not locally available
  5759. */
  5760. #define SLAPI_BE_ALL_BACKENDS -1
  5761. #define SLAPI_BE_NO_BACKEND -2
  5762. #define SLAPI_BE_REMOTE_BACKEND -3
  5763. /*
  5764. * virtual attribute service
  5765. */
  5766. /* General flags (flags parameter) */
  5767. #define SLAPI_REALATTRS_ONLY 1
  5768. #define SLAPI_VIRTUALATTRS_ONLY 2
  5769. #define SLAPI_VIRTUALATTRS_REQUEST_POINTERS 4 /* I want to receive pointers into the entry, if possible */
  5770. #define SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS 8 /* Include operational attributes in attribute lists */
  5771. #define SLAPI_VIRTUALATTRS_SUPPRESS_SUBTYPES 16 /* I want only the requested attribute */
  5772. /* Buffer disposition flags (buffer_flags parameter) */
  5773. #define SLAPI_VIRTUALATTRS_RETURNED_POINTERS 1
  5774. #define SLAPI_VIRTUALATTRS_RETURNED_COPIES 2
  5775. #define SLAPI_VIRTUALATTRS_REALATTRS_ONLY 4
  5776. #define SLAPI_VIRTUALATTRS_VALUES_CACHEABLE 8
  5777. /* Attribute type name disposition values (type_name_disposition parameter) */
  5778. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS 1
  5779. #define SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE 2
  5780. #define SLAPI_VIRTUALATTRS_NOT_FOUND -1
  5781. #define SLAPI_VIRTUALATTRS_LOOP_DETECTED -2
  5782. typedef struct _vattr_type_thang vattr_type_thang;
  5783. typedef struct _vattr_get_thang vattr_get_thang;
  5784. vattr_get_thang *slapi_vattr_getthang_first(vattr_get_thang *t);
  5785. vattr_get_thang *slapi_vattr_getthang_next(vattr_get_thang *t);
  5786. int slapi_vattr_values_type_thang_get(
  5787. /* Entry we're interested in */ Slapi_Entry *e,
  5788. /* attr type */ vattr_type_thang *type_thang,
  5789. /* pointer to result set */ Slapi_ValueSet** results,
  5790. int *type_name_disposition, char **actual_type_name, int flags,
  5791. int *buffer_flags);
  5792. int slapi_vattr_values_get(
  5793. /* Entry we're interested in */ Slapi_Entry *e,
  5794. /* attr type name */ char *type,
  5795. /* pointer to result set */ Slapi_ValueSet** results,
  5796. int *type_name_disposition, char **actual_type_name, int flags,
  5797. int *buffer_flags);
  5798. int slapi_vattr_values_get_ex(
  5799. /* Entry we're interested in */ Slapi_Entry *e,
  5800. /* attr type name */ char *type,
  5801. /* pointer to result set */ Slapi_ValueSet*** results,
  5802. int **type_name_disposition, char ***actual_type_name, int flags,
  5803. int *buffer_flags, int *subtype_count);
  5804. int slapi_vattr_namespace_values_get(
  5805. /* Entry we're interested in */ Slapi_Entry *e,
  5806. /* backend namespace dn */ Slapi_DN *namespace_dn,
  5807. /* attr type name */ char *type,
  5808. /* pointer to result set */ Slapi_ValueSet*** results,
  5809. int **type_name_disposition, char ***actual_type_name, int flags,
  5810. int *buffer_flags, int *subtype_count);
  5811. void slapi_vattr_values_free(Slapi_ValueSet **value, char **actual_type_name,
  5812. int flags);
  5813. int slapi_vattr_value_compare(
  5814. /* Entry we're interested in */ Slapi_Entry *e,
  5815. /* attr type name */ char *type,
  5816. Slapi_Value *test_this,/* pointer to result */ int *result,
  5817. int flags);
  5818. int slapi_vattr_namespace_value_compare(
  5819. /* Entry we're interested in */ Slapi_Entry *e,
  5820. /* backend namespace dn */ Slapi_DN *namespace_dn,
  5821. /* attr type name */ const char *type,
  5822. Slapi_Value *test_this,/* pointer to result */ int *result,
  5823. int flags);
  5824. int slapi_vattr_list_attrs(
  5825. /* Entry we're interested in */ Slapi_Entry *e,
  5826. /* pointer to receive the list */ vattr_type_thang **types,
  5827. int flags, int *buffer_flags);
  5828. void slapi_vattr_attrs_free(vattr_type_thang **types, int flags);
  5829. char *vattr_typethang_get_name(vattr_type_thang *t);
  5830. unsigned long vattr_typethang_get_flags(vattr_type_thang *t);
  5831. vattr_type_thang *vattr_typethang_next(vattr_type_thang *t);
  5832. vattr_type_thang *vattr_typethang_first(vattr_type_thang *t);
  5833. int slapi_vattr_schema_check_type(Slapi_Entry *e, char *type);
  5834. /* roles */
  5835. typedef int (*roles_check_fn_type)(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  5836. int slapi_role_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn, int *present);
  5837. void slapi_register_role_check(roles_check_fn_type check_fn);
  5838. /* DSE */
  5839. /* Front end configuration */
  5840. typedef int (*dseCallbackFn)(Slapi_PBlock *, Slapi_Entry *, Slapi_Entry *,
  5841. int *, char*, void *);
  5842. /*
  5843. * Note: DSE callback functions MUST return one of these three values:
  5844. *
  5845. * SLAPI_DSE_CALLBACK_OK -- no errors occurred; apply changes.
  5846. * SLAPI_DSE_CALLBACK_ERROR -- an error occurred; don't apply changes.
  5847. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY -- no error, but do not apply changes.
  5848. *
  5849. * SLAPI_DSE_CALLBACK_DO_NOT_APPLY should only be returned by modify
  5850. * callbacks (i.e., those registered with operation==SLAPI_OPERATION_MODIFY).
  5851. * A return value of SLAPI_DSE_CALLBACK_DO_NOT_APPLY is treated the same as
  5852. * SLAPI_DSE_CALLBACK_ERROR for all other operations.
  5853. */
  5854. #define SLAPI_DSE_CALLBACK_OK (1)
  5855. #define SLAPI_DSE_CALLBACK_ERROR (-1)
  5856. #define SLAPI_DSE_CALLBACK_DO_NOT_APPLY (0)
  5857. /*
  5858. * Flags for slapi_config_register_callback() and
  5859. * slapi_config_remove_callback()
  5860. */
  5861. #define DSE_FLAG_PREOP 0x0001
  5862. #define DSE_FLAG_POSTOP 0x0002
  5863. /* This is the size of the returntext parameter passed to the config callback function,
  5864. which is the "char *" argument to dseCallbackFn above */
  5865. #define SLAPI_DSE_RETURNTEXT_SIZE 512 /* for use by callback functions */
  5866. int slapi_config_register_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn, void *fn_arg);
  5867. int slapi_config_remove_callback(int operation, int flags, const char *base, int scope, const char *filter, dseCallbackFn fn);
  5868. /******************************************************************************
  5869. * Online tasks interface (to support import, export, etc)
  5870. * After some cleanup, we could consider making these public.
  5871. */
  5872. /* task states */
  5873. #define SLAPI_TASK_SETUP 0
  5874. #define SLAPI_TASK_RUNNING 1
  5875. #define SLAPI_TASK_FINISHED 2
  5876. #define SLAPI_TASK_CANCELLED 3
  5877. /* task flag (pb_task_flags)*/
  5878. #define SLAPI_TASK_RUNNING_AS_TASK 0x0
  5879. #define SLAPI_TASK_RUNNING_FROM_COMMANDLINE 0x1
  5880. /* task flags (set by the task-control code) */
  5881. #define SLAPI_TASK_DESTROYING 0x01 /* queued event for destruction */
  5882. int slapi_task_register_handler(const char *name, dseCallbackFn func);
  5883. void slapi_task_begin(Slapi_Task *task, int total_work);
  5884. void slapi_task_inc_progress(Slapi_Task *task);
  5885. void slapi_task_finish(Slapi_Task *task, int rc);
  5886. void slapi_task_cancel(Slapi_Task *task, int rc);
  5887. int slapi_task_get_state(Slapi_Task *task);
  5888. void slapi_task_set_data(Slapi_Task *task, void *data);
  5889. void * slapi_task_get_data(Slapi_Task *task);
  5890. void slapi_task_inc_refcount(Slapi_Task *task);
  5891. void slapi_task_dec_refcount(Slapi_Task *task);
  5892. int slapi_task_get_refcount(Slapi_Task *task);
  5893. void slapi_task_set_destructor_fn(Slapi_Task *task, TaskCallbackFn func);
  5894. void slapi_task_set_cancel_fn(Slapi_Task *task, TaskCallbackFn func);
  5895. void slapi_task_status_changed(Slapi_Task *task);
  5896. void slapi_task_log_status(Slapi_Task *task, char *format, ...)
  5897. #ifdef __GNUC__
  5898. __attribute__ ((format (printf, 2, 3)));
  5899. #else
  5900. ;
  5901. #endif
  5902. void slapi_task_log_notice(Slapi_Task *task, char *format, ...)
  5903. #ifdef __GNUC__
  5904. __attribute__ ((format (printf, 2, 3)));
  5905. #else
  5906. ;
  5907. #endif
  5908. void slapi_task_log_status_ext(Slapi_Task *task, char *format, va_list varg);
  5909. void slapi_task_log_notice_ext(Slapi_Task *task, char *format, va_list varg);
  5910. /*
  5911. * slapi_new_task: create new task, fill in DN, and setup modify callback
  5912. * argument:
  5913. * dn: task dn
  5914. * result:
  5915. * Success: Slapi_Task object
  5916. * Failure: NULL
  5917. */
  5918. Slapi_Task *slapi_new_task(const char *dn);
  5919. /* slapi_destroy_task: destroy a task
  5920. * argument:
  5921. * task: task to destroy
  5922. * result:
  5923. * none
  5924. */
  5925. void slapi_destroy_task(void *arg);
  5926. /* End of interface to support online tasks **********************************/
  5927. /* Slapi_Counter Interface */
  5928. Slapi_Counter *slapi_counter_new(void);
  5929. void slapi_counter_init(Slapi_Counter *counter);
  5930. void slapi_counter_destroy(Slapi_Counter **counter);
  5931. PRUint64 slapi_counter_increment(Slapi_Counter *counter);
  5932. PRUint64 slapi_counter_decrement(Slapi_Counter *counter);
  5933. PRUint64 slapi_counter_add(Slapi_Counter *counter, PRUint64 addvalue);
  5934. PRUint64 slapi_counter_subtract(Slapi_Counter *counter, PRUint64 subvalue);
  5935. PRUint64 slapi_counter_set_value(Slapi_Counter *counter, PRUint64 newvalue);
  5936. PRUint64 slapi_counter_get_value(Slapi_Counter *counter);
  5937. /* Binder-based (connection centric) resource limits */
  5938. /*
  5939. * Valid values for `type' parameter to slapi_reslimit_register().
  5940. */
  5941. #define SLAPI_RESLIMIT_TYPE_INT 0
  5942. /*
  5943. * Status codes returned by all functions.
  5944. */
  5945. #define SLAPI_RESLIMIT_STATUS_SUCCESS 0 /* goodness */
  5946. #define SLAPI_RESLIMIT_STATUS_NOVALUE 1 /* no value is available */
  5947. #define SLAPI_RESLIMIT_STATUS_INIT_FAILURE 2 /* initialization failed */
  5948. #define SLAPI_RESLIMIT_STATUS_PARAM_ERROR 3 /* bad parameter */
  5949. #define SLAPI_RESLIMIT_STATUS_UNKNOWN_HANDLE 4 /* unregistered handle */
  5950. #define SLAPI_RESLIMIT_STATUS_INTERNAL_ERROR 5 /* unexpected error */
  5951. /*
  5952. * Functions.
  5953. */
  5954. int slapi_reslimit_register( int type, const char *attrname, int *handlep );
  5955. int slapi_reslimit_get_integer_limit( Slapi_Connection *conn, int handle,
  5956. int *limitp );
  5957. /* END of Binder-based resource limits API */
  5958. /**
  5959. * Returns the current time
  5960. *
  5961. * \return The current time
  5962. */
  5963. time_t slapi_current_time( void );
  5964. /*
  5965. * Plugin and parameter block related macros (remainder of this file).
  5966. */
  5967. /*
  5968. * Plugin version. Note that the Directory Server will load version 01
  5969. * and 02 plugins, but some server features require 03 plugins.
  5970. */
  5971. #define SLAPI_PLUGIN_VERSION_01 "01"
  5972. #define SLAPI_PLUGIN_VERSION_02 "02"
  5973. #define SLAPI_PLUGIN_VERSION_03 "03"
  5974. #define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03
  5975. #define SLAPI_PLUGIN_IS_COMPAT(x) \
  5976. ((strcmp((x), SLAPI_PLUGIN_VERSION_01) == 0) || \
  5977. (strcmp((x), SLAPI_PLUGIN_VERSION_02) == 0) || \
  5978. (strcmp((x), SLAPI_PLUGIN_VERSION_03) == 0))
  5979. #define SLAPI_PLUGIN_IS_V2(x) \
  5980. ((strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_02) == 0) || \
  5981. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0))
  5982. #define SLAPI_PLUGIN_IS_V3(x) \
  5983. (strcmp((x)->plg_version, SLAPI_PLUGIN_VERSION_03) == 0)
  5984. /* this one just has to be human readable */
  5985. #define SLAPI_PLUGIN_SUPPORTED_VERSIONS "01,02,03"
  5986. /*
  5987. * types of plugin interfaces
  5988. */
  5989. #define SLAPI_PLUGIN_EXTENDEDOP 2
  5990. #define SLAPI_PLUGIN_PREOPERATION 3
  5991. #define SLAPI_PLUGIN_POSTOPERATION 4
  5992. #define SLAPI_PLUGIN_MATCHINGRULE 5
  5993. #define SLAPI_PLUGIN_SYNTAX 6
  5994. #define SLAPI_PLUGIN_ACL 7
  5995. #define SLAPI_PLUGIN_BEPREOPERATION 8
  5996. #define SLAPI_PLUGIN_BEPOSTOPERATION 9
  5997. #define SLAPI_PLUGIN_ENTRY 10
  5998. #define SLAPI_PLUGIN_TYPE_OBJECT 11
  5999. #define SLAPI_PLUGIN_INTERNAL_PREOPERATION 12
  6000. #define SLAPI_PLUGIN_INTERNAL_POSTOPERATION 13
  6001. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME 14
  6002. #define SLAPI_PLUGIN_VATTR_SP 15
  6003. #define SLAPI_PLUGIN_REVER_PWD_STORAGE_SCHEME 16
  6004. #define SLAPI_PLUGIN_LDBM_ENTRY_FETCH_STORE 17
  6005. #define SLAPI_PLUGIN_INDEX 18
  6006. #define SLAPI_PLUGIN_BETXNPREOPERATION 19
  6007. #define SLAPI_PLUGIN_BETXNPOSTOPERATION 20
  6008. /*
  6009. * special return values for extended operation plugins (zero or positive
  6010. * return values should be LDAP error codes as defined in ldap.h)
  6011. */
  6012. #define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1
  6013. #define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2
  6014. /*
  6015. * Return values of plugins:
  6016. */
  6017. #define SLAPI_PLUGIN_SUCCESS 0 /* 0 is treated as success implicitely */
  6018. #define SLAPI_PLUGIN_FAILURE -1 /* common failure */
  6019. #define SLAPI_PLUGIN_NOOP -2 /* Special in be_pre_op/be_txn_pre_op.
  6020. * Treat as SUCCESS, but skip the backend op.
  6021. * Also, return SUCCESS to the client/supplier.
  6022. * Necessary for the replication conflicts. */
  6023. /*
  6024. * the following can be used as the second argument to the
  6025. * slapi_pblock_get() and slapi_pblock_set() calls.
  6026. */
  6027. /* backend, connection, operation */
  6028. #define SLAPI_BACKEND 130
  6029. #define SLAPI_CONNECTION 131
  6030. #define SLAPI_OPERATION 132
  6031. #define SLAPI_REQUESTOR_ISROOT 133
  6032. #define SLAPI_BE_TYPE 135
  6033. #define SLAPI_BE_READONLY 136
  6034. #define SLAPI_BE_LASTMOD 137
  6035. #define SLAPI_CONN_ID 139
  6036. #define SLAPI_BACKEND_COUNT 860
  6037. /* operation */
  6038. #define SLAPI_OPINITIATED_TIME 140
  6039. #define SLAPI_REQUESTOR_DN 141
  6040. #define SLAPI_REQUESTOR_SDN 852
  6041. #define SLAPI_REQUESTOR_NDN 156
  6042. #define SLAPI_OPERATION_PARAMETERS 138
  6043. #define SLAPI_OPERATION_TYPE 590
  6044. #define SLAPI_OPERATION_AUTHTYPE 741
  6045. #define SLAPI_OPERATION_ID 744
  6046. #define SLAPI_OPERATION_SSF 750
  6047. #define SLAPI_IS_REPLICATED_OPERATION 142
  6048. #define SLAPI_IS_MMR_REPLICATED_OPERATION 153
  6049. #define SLAPI_IS_LEGACY_REPLICATED_OPERATION 154
  6050. #define SLAPI_SKIP_MODIFIED_ATTRS 155
  6051. /* connection */
  6052. #define SLAPI_CONN_DN 143
  6053. #define SLAPI_CONN_CLIENTNETADDR 850
  6054. #define SLAPI_CONN_SERVERNETADDR 851
  6055. #define SLAPI_CONN_IS_REPLICATION_SESSION 149
  6056. #define SLAPI_CONN_IS_SSL_SESSION 747
  6057. #define SLAPI_CONN_CERT 743
  6058. #define SLAPI_CONN_AUTHMETHOD 746
  6059. #define SLAPI_CONN_SASL_SSF 748
  6060. #define SLAPI_CONN_SSL_SSF 749
  6061. #define SLAPI_CONN_LOCAL_SSF 751
  6062. /*
  6063. * Types of authentication for SLAPI_CONN_AUTHMETHOD
  6064. * (and deprecated SLAPI_CONN_AUTHTYPE)
  6065. */
  6066. #define SLAPD_AUTH_NONE "none"
  6067. #define SLAPD_AUTH_SIMPLE "simple"
  6068. #define SLAPD_AUTH_SSL "SSL"
  6069. #define SLAPD_AUTH_SASL "SASL " /* followed by the mechanism name */
  6070. #define SLAPD_AUTH_OS "OS"
  6071. /* Command Line Arguments */
  6072. #define SLAPI_ARGC 147
  6073. #define SLAPI_ARGV 148
  6074. /* Slapd config file directory */
  6075. #define SLAPI_CONFIG_DIRECTORY 281
  6076. /* DSE flags */
  6077. #define SLAPI_DSE_DONT_WRITE_WHEN_ADDING 282
  6078. #define SLAPI_DSE_MERGE_WHEN_ADDING 283
  6079. #define SLAPI_DSE_DONT_CHECK_DUPS 284
  6080. #define SLAPI_DSE_REAPPLY_MODS 287
  6081. #define SLAPI_DSE_IS_PRIMARY_FILE 289
  6082. /* internal schema flags */
  6083. #define SLAPI_SCHEMA_FLAGS 285
  6084. /* urp flags */
  6085. #define SLAPI_URP_NAMING_COLLISION_DN 286
  6086. #define SLAPI_URP_TOMBSTONE_UNIQUEID 288
  6087. /* common to all plugins */
  6088. #define SLAPI_PLUGIN 3
  6089. #define SLAPI_PLUGIN_PRIVATE 4
  6090. #define SLAPI_PLUGIN_TYPE 5
  6091. #define SLAPI_PLUGIN_ARGV 6
  6092. #define SLAPI_PLUGIN_ARGC 7
  6093. #define SLAPI_PLUGIN_VERSION 8
  6094. #define SLAPI_PLUGIN_OPRETURN 9
  6095. #define SLAPI_PLUGIN_OBJECT 10
  6096. #define SLAPI_PLUGIN_DESTROY_FN 11
  6097. #define SLAPI_PLUGIN_DESCRIPTION 12
  6098. typedef struct slapi_plugindesc {
  6099. char *spd_id;
  6100. char *spd_vendor;
  6101. char *spd_version;
  6102. char *spd_description;
  6103. } Slapi_PluginDesc;
  6104. #define SLAPI_PLUGIN_IDENTITY 13
  6105. #define SLAPI_PLUGIN_PRECEDENCE 14
  6106. /* common for internal plugin_ops */
  6107. #define SLAPI_PLUGIN_INTOP_RESULT 15
  6108. #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16
  6109. #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17
  6110. /* miscellaneous plugin functions */
  6111. #define SLAPI_PLUGIN_CLOSE_FN 210
  6112. #define SLAPI_PLUGIN_START_FN 212
  6113. #define SLAPI_PLUGIN_CLEANUP_FN 232
  6114. #define SLAPI_PLUGIN_POSTSTART_FN 233
  6115. /* extendedop plugin functions */
  6116. #define SLAPI_PLUGIN_EXT_OP_FN 300
  6117. #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301
  6118. #define SLAPI_PLUGIN_EXT_OP_NAMELIST 302
  6119. /* preoperation plugin functions */
  6120. #define SLAPI_PLUGIN_PRE_BIND_FN 401
  6121. #define SLAPI_PLUGIN_PRE_UNBIND_FN 402
  6122. #define SLAPI_PLUGIN_PRE_SEARCH_FN 403
  6123. #define SLAPI_PLUGIN_PRE_COMPARE_FN 404
  6124. #define SLAPI_PLUGIN_PRE_MODIFY_FN 405
  6125. #define SLAPI_PLUGIN_PRE_MODRDN_FN 406
  6126. #define SLAPI_PLUGIN_PRE_ADD_FN 407
  6127. #define SLAPI_PLUGIN_PRE_DELETE_FN 408
  6128. #define SLAPI_PLUGIN_PRE_ABANDON_FN 409
  6129. #define SLAPI_PLUGIN_PRE_ENTRY_FN 410
  6130. #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411
  6131. #define SLAPI_PLUGIN_PRE_RESULT_FN 412
  6132. /* internal preoperation plugin functions */
  6133. #define SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN 420
  6134. #define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421
  6135. #define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422
  6136. #define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423
  6137. #define SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN 424
  6138. /* preoperation plugin to the backend */
  6139. #define SLAPI_PLUGIN_BE_PRE_ADD_FN 450
  6140. #define SLAPI_PLUGIN_BE_PRE_MODIFY_FN 451
  6141. #define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452
  6142. #define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453
  6143. #define SLAPI_PLUGIN_BE_PRE_CLOSE_FN 454
  6144. #define SLAPI_PLUGIN_BE_PRE_BACKUP_FN 455
  6145. /* preoperation plugin to the backend - just after transaction creation */
  6146. #define SLAPI_PLUGIN_BE_TXN_PRE_ADD_FN 460
  6147. #define SLAPI_PLUGIN_BE_TXN_PRE_MODIFY_FN 461
  6148. #define SLAPI_PLUGIN_BE_TXN_PRE_MODRDN_FN 462
  6149. #define SLAPI_PLUGIN_BE_TXN_PRE_DELETE_FN 463
  6150. #define SLAPI_PLUGIN_BE_TXN_PRE_DELETE_TOMBSTONE_FN 464
  6151. /* postoperation plugin functions */
  6152. #define SLAPI_PLUGIN_POST_BIND_FN 501
  6153. #define SLAPI_PLUGIN_POST_UNBIND_FN 502
  6154. #define SLAPI_PLUGIN_POST_SEARCH_FN 503
  6155. #define SLAPI_PLUGIN_POST_COMPARE_FN 504
  6156. #define SLAPI_PLUGIN_POST_MODIFY_FN 505
  6157. #define SLAPI_PLUGIN_POST_MODRDN_FN 506
  6158. #define SLAPI_PLUGIN_POST_ADD_FN 507
  6159. #define SLAPI_PLUGIN_POST_DELETE_FN 508
  6160. #define SLAPI_PLUGIN_POST_ABANDON_FN 509
  6161. #define SLAPI_PLUGIN_POST_ENTRY_FN 510
  6162. #define SLAPI_PLUGIN_POST_REFERRAL_FN 511
  6163. #define SLAPI_PLUGIN_POST_RESULT_FN 512
  6164. #define SLAPI_PLUGIN_POST_SEARCH_FAIL_FN 513
  6165. /* internal preoperation plugin functions */
  6166. #define SLAPI_PLUGIN_INTERNAL_POST_ADD_FN 520
  6167. #define SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN 521
  6168. #define SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN 522
  6169. #define SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN 523
  6170. /* postoperation plugin to the backend */
  6171. #define SLAPI_PLUGIN_BE_POST_ADD_FN 550
  6172. #define SLAPI_PLUGIN_BE_POST_MODIFY_FN 551
  6173. #define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552
  6174. #define SLAPI_PLUGIN_BE_POST_DELETE_FN 553
  6175. #define SLAPI_PLUGIN_BE_POST_OPEN_FN 554
  6176. #define SLAPI_PLUGIN_BE_POST_BACKUP_FN 555
  6177. /* postoperation plugin to the backend - just before transaction commit */
  6178. #define SLAPI_PLUGIN_BE_TXN_POST_ADD_FN 560
  6179. #define SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN 561
  6180. #define SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN 562
  6181. #define SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN 563
  6182. /* matching rule plugin functions */
  6183. #define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600
  6184. #define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601
  6185. #define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602
  6186. #define SLAPI_PLUGIN_MR_FILTER_INDEX_FN 603
  6187. #define SLAPI_PLUGIN_MR_FILTER_RESET_FN 604
  6188. #define SLAPI_PLUGIN_MR_INDEX_FN 605
  6189. #define SLAPI_PLUGIN_MR_INDEX_SV_FN 606
  6190. /* matching rule plugin arguments */
  6191. #define SLAPI_PLUGIN_MR_OID 610
  6192. #define SLAPI_PLUGIN_MR_TYPE 611
  6193. #define SLAPI_PLUGIN_MR_VALUE 612
  6194. #define SLAPI_PLUGIN_MR_VALUES 613
  6195. #define SLAPI_PLUGIN_MR_KEYS 614
  6196. #define SLAPI_PLUGIN_MR_FILTER_REUSABLE 615
  6197. #define SLAPI_PLUGIN_MR_QUERY_OPERATOR 616
  6198. #define SLAPI_PLUGIN_MR_USAGE 617
  6199. /* new style matching rule syntax plugin functions */
  6200. #define SLAPI_PLUGIN_MR_FILTER_AVA 618
  6201. #define SLAPI_PLUGIN_MR_FILTER_SUB 619
  6202. #define SLAPI_PLUGIN_MR_VALUES2KEYS 620
  6203. #define SLAPI_PLUGIN_MR_ASSERTION2KEYS_AVA 621
  6204. #define SLAPI_PLUGIN_MR_ASSERTION2KEYS_SUB 622
  6205. #define SLAPI_PLUGIN_MR_FLAGS 623
  6206. #define SLAPI_PLUGIN_MR_NAMES 624
  6207. #define SLAPI_PLUGIN_MR_COMPARE 625
  6208. #define SLAPI_PLUGIN_MR_NORMALIZE 626
  6209. /* Defined values of SLAPI_PLUGIN_MR_QUERY_OPERATOR: */
  6210. #define SLAPI_OP_LESS 1
  6211. #define SLAPI_OP_LESS_OR_EQUAL 2
  6212. #define SLAPI_OP_EQUAL 3
  6213. #define SLAPI_OP_GREATER_OR_EQUAL 4
  6214. #define SLAPI_OP_GREATER 5
  6215. #define SLAPI_OP_SUBSTRING 6
  6216. /* Defined values of SLAPI_PLUGIN_MR_USAGE: */
  6217. #define SLAPI_PLUGIN_MR_USAGE_INDEX 0
  6218. #define SLAPI_PLUGIN_MR_USAGE_SORT 1
  6219. /* Defined values for matchingRuleEntry accessor functions */
  6220. #define SLAPI_MATCHINGRULE_NAME 1
  6221. #define SLAPI_MATCHINGRULE_OID 2
  6222. #define SLAPI_MATCHINGRULE_DESC 3
  6223. #define SLAPI_MATCHINGRULE_SYNTAX 4
  6224. #define SLAPI_MATCHINGRULE_OBSOLETE 5
  6225. /* syntax plugin functions and arguments */
  6226. #define SLAPI_PLUGIN_SYNTAX_FILTER_AVA 700
  6227. #define SLAPI_PLUGIN_SYNTAX_FILTER_SUB 701
  6228. #define SLAPI_PLUGIN_SYNTAX_VALUES2KEYS 702
  6229. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA 703
  6230. #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB 704
  6231. #define SLAPI_PLUGIN_SYNTAX_NAMES 705
  6232. #define SLAPI_PLUGIN_SYNTAX_OID 706
  6233. #define SLAPI_PLUGIN_SYNTAX_FLAGS 707
  6234. #define SLAPI_PLUGIN_SYNTAX_COMPARE 708
  6235. /* user defined substrlen; not stored in slapdplugin, but pblock itself */
  6236. #define SLAPI_SYNTAX_SUBSTRLENS 709
  6237. #define SLAPI_MR_SUBSTRLENS SLAPI_SYNTAX_SUBSTRLENS /* alias */
  6238. #define SLAPI_PLUGIN_SYNTAX_VALIDATE 710
  6239. #define SLAPI_PLUGIN_SYNTAX_NORMALIZE 711
  6240. #define SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED 712
  6241. #define SLAPI_PLUGIN_SYNTAX_FILTER_DATA 713
  6242. /* ACL plugin functions and arguments */
  6243. #define SLAPI_PLUGIN_ACL_INIT 730
  6244. #define SLAPI_PLUGIN_ACL_SYNTAX_CHECK 731
  6245. #define SLAPI_PLUGIN_ACL_ALLOW_ACCESS 732
  6246. #define SLAPI_PLUGIN_ACL_MODS_ALLOWED 733
  6247. #define SLAPI_PLUGIN_ACL_MODS_UPDATE 734
  6248. #define ACLPLUGIN_ACCESS_DEFAULT 0
  6249. #define ACLPLUGIN_ACCESS_READ_ON_ENTRY 1
  6250. #define ACLPLUGIN_ACCESS_READ_ON_ATTR 2
  6251. #define ACLPLUGIN_ACCESS_READ_ON_VLV 3
  6252. #define ACLPLUGIN_ACCESS_MODRDN 4
  6253. #define ACLPLUGIN_ACCESS_GET_EFFECTIVE_RIGHTS 5
  6254. /* Authorization types */
  6255. #define SLAPI_BE_MAXNESTLEVEL 742
  6256. #define SLAPI_CLIENT_DNS 745
  6257. /* Password storage scheme functions and arguments */
  6258. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN 800
  6259. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN 801 /* only meaningfull for reversible encryption */
  6260. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN 802
  6261. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME 810 /* name of the method: SHA, SSHA... */
  6262. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_USER_PWD 811 /* value sent over LDAP */
  6263. #define SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DB_PWD 812 /* value from the DB */
  6264. /* entry fetch and entry store values */
  6265. #define SLAPI_PLUGIN_ENTRY_FETCH_FUNC 813
  6266. #define SLAPI_PLUGIN_ENTRY_STORE_FUNC 814
  6267. #define SLAPI_PLUGIN_ENABLED 815
  6268. #define SLAPI_PLUGIN_CONFIG_AREA 816
  6269. /*
  6270. * Defined values of SLAPI_PLUGIN_SYNTAX_FLAGS:
  6271. */
  6272. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1
  6273. #define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2
  6274. /* controls we know about */
  6275. #define SLAPI_MANAGEDSAIT 1000
  6276. #define SLAPI_PWPOLICY 1001
  6277. /* arguments that are common to all operation */
  6278. #define SLAPI_TARGET_ADDRESS 48 /* target address (dn + uniqueid) should be normalized */
  6279. #define SLAPI_TARGET_UNIQUEID 49 /* target uniqueid of the operation */
  6280. #define SLAPI_TARGET_DN 50 /* DEPRECATED. target dn of the operation.
  6281. It actually points DN in SLAPI_TARGET_SDN. */
  6282. #define SLAPI_TARGET_SDN 47 /* target sdn of the operation */
  6283. #define SLAPI_REQCONTROLS 51 /* request controls */
  6284. /* Copies of entry before and after add, mod, mod[r]dn operations */
  6285. #define SLAPI_ENTRY_PRE_OP 52
  6286. #define SLAPI_ENTRY_POST_OP 53
  6287. /* a PRE_ENTRY_FN may alter the entry to be returned to the client -
  6288. SLAPI_SEARCH_ORIG_ENTRY holds the original entry from
  6289. the database - this must not be changed
  6290. SLAPI_SEARCH_ENTRY_COPY holds a copy of the original entry that
  6291. has been modified by the plugin - this will be NULL by default -
  6292. if a plugin needs to modify the entry, it should first check to
  6293. see if there is already a SLAPI_SEARCH_ENTRY_COPY - if not, the
  6294. plugin must use slapi_entry_dup() or similar to make a copy, edit
  6295. the copy, then store it in SLAPI_SEARCH_ENTRY_COPY - the internal
  6296. server code will free SLAPI_SEARCH_ENTRY_COPY
  6297. */
  6298. #define SLAPI_SEARCH_ENTRY_ORIG SLAPI_ENTRY_PRE_OP
  6299. #define SLAPI_SEARCH_ENTRY_COPY SLAPI_ENTRY_POST_OP
  6300. /* for plugin init functions, this is the plugin config entry */
  6301. #define SLAPI_PLUGIN_CONFIG_ENTRY SLAPI_ENTRY_PRE_OP
  6302. /* LDAPv3 controls to be sent with the operation result */
  6303. #define SLAPI_RESCONTROLS 55
  6304. #define SLAPI_ADD_RESCONTROL 56 /* add result control */
  6305. /* Extra notes to be logged within access log RESULT lines */
  6306. #define SLAPI_OPERATION_NOTES 57
  6307. #define SLAPI_OP_NOTE_UNINDEXED 0x01
  6308. #define SLAPI_OP_NOTE_SIMPLEPAGED 0x02
  6309. #define SLAPI_OP_NOTE_FULL_UNINDEXED 0x04
  6310. /* Allows controls to be passed before operation object is created */
  6311. #define SLAPI_CONTROLS_ARG 58
  6312. /* specify whether pblock content should be destroyed when the pblock is destroyed */
  6313. #define SLAPI_DESTROY_CONTENT 59
  6314. /* add arguments */
  6315. #define SLAPI_ADD_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6316. #define SLAPI_ADD_TARGET_SDN SLAPI_TARGET_SDN
  6317. #define SLAPI_ADD_ENTRY 60
  6318. #define SLAPI_ADD_EXISTING_DN_ENTRY 61
  6319. #define SLAPI_ADD_PARENT_ENTRY 62
  6320. #define SLAPI_ADD_PARENT_UNIQUEID 63
  6321. #define SLAPI_ADD_EXISTING_UNIQUEID_ENTRY 64
  6322. /* bind arguments */
  6323. #define SLAPI_BIND_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6324. #define SLAPI_BIND_TARGET_SDN SLAPI_TARGET_SDN
  6325. #define SLAPI_BIND_METHOD 70
  6326. #define SLAPI_BIND_CREDENTIALS 71 /* v3 only */
  6327. #define SLAPI_BIND_SASLMECHANISM 72 /* v3 only */
  6328. /* bind return values */
  6329. #define SLAPI_BIND_RET_SASLCREDS 73 /* v3 only */
  6330. /* compare arguments */
  6331. #define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6332. #define SLAPI_COMPARE_TARGET_SDN SLAPI_TARGET_SDN
  6333. #define SLAPI_COMPARE_TYPE 80
  6334. #define SLAPI_COMPARE_VALUE 81
  6335. /* delete arguments */
  6336. #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6337. #define SLAPI_DELETE_TARGET_SDN SLAPI_TARGET_SDN
  6338. #define SLAPI_DELETE_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  6339. #define SLAPI_DELETE_GLUE_PARENT_ENTRY SLAPI_ADD_PARENT_ENTRY
  6340. #define SLAPI_DELETE_BEPREOP_ENTRY SLAPI_ENTRY_PRE_OP
  6341. #define SLAPI_DELETE_BEPOSTOP_ENTRY SLAPI_ENTRY_POST_OP
  6342. /* modify arguments */
  6343. #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6344. #define SLAPI_MODIFY_TARGET_SDN SLAPI_TARGET_SDN
  6345. #define SLAPI_MODIFY_MODS 90
  6346. #define SLAPI_MODIFY_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  6347. /* modrdn arguments */
  6348. #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6349. #define SLAPI_MODRDN_TARGET_SDN SLAPI_TARGET_SDN
  6350. #define SLAPI_MODRDN_NEWRDN 100
  6351. #define SLAPI_MODRDN_DELOLDRDN 101
  6352. #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */
  6353. #define SLAPI_MODRDN_NEWSUPERIOR_SDN 103 /* v3 only */
  6354. #define SLAPI_MODRDN_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY
  6355. #define SLAPI_MODRDN_PARENT_ENTRY 104
  6356. #define SLAPI_MODRDN_NEWPARENT_ENTRY 105
  6357. #define SLAPI_MODRDN_TARGET_ENTRY 106
  6358. #define SLAPI_MODRDN_NEWSUPERIOR_ADDRESS 107
  6359. /*
  6360. * unnormalized dn argument (useful for MOD, MODRDN and DEL operations to carry
  6361. * the original non-escaped dn as introduced by the client application)
  6362. */
  6363. #define SLAPI_ORIGINAL_TARGET_DN 109
  6364. #define SLAPI_ORIGINAL_TARGET SLAPI_ORIGINAL_TARGET_DN
  6365. /* search arguments */
  6366. #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN /* DEPRECATED */
  6367. #define SLAPI_SEARCH_TARGET_SDN SLAPI_TARGET_SDN
  6368. #define SLAPI_SEARCH_SCOPE 110
  6369. #define SLAPI_SEARCH_DEREF 111
  6370. #define SLAPI_SEARCH_SIZELIMIT 112
  6371. #define SLAPI_SEARCH_TIMELIMIT 113
  6372. #define SLAPI_SEARCH_FILTER 114
  6373. #define SLAPI_SEARCH_STRFILTER 115
  6374. #define SLAPI_SEARCH_ATTRS 116
  6375. #define SLAPI_SEARCH_GERATTRS 1160
  6376. #define SLAPI_SEARCH_ATTRSONLY 117
  6377. #define SLAPI_SEARCH_IS_AND 118
  6378. /* abandon arguments */
  6379. #define SLAPI_ABANDON_MSGID 120
  6380. /* seq access arguments */
  6381. #define SLAPI_SEQ_TYPE 150
  6382. #define SLAPI_SEQ_ATTRNAME 151
  6383. #define SLAPI_SEQ_VAL 152
  6384. /* extended operation arguments */
  6385. #define SLAPI_EXT_OP_REQ_OID 160 /* v3 only */
  6386. #define SLAPI_EXT_OP_REQ_VALUE 161 /* v3 only */
  6387. /* extended operation return values */
  6388. #define SLAPI_EXT_OP_RET_OID 162 /* v3 only */
  6389. #define SLAPI_EXT_OP_RET_VALUE 163 /* v3 only */
  6390. /* extended filter arguments */
  6391. #define SLAPI_MR_FILTER_ENTRY 170 /* v3 only */
  6392. #define SLAPI_MR_FILTER_TYPE 171 /* v3 only */
  6393. #define SLAPI_MR_FILTER_VALUE 172 /* v3 only */
  6394. #define SLAPI_MR_FILTER_OID 173 /* v3 only */
  6395. #define SLAPI_MR_FILTER_DNATTRS 174 /* v3 only */
  6396. /* ldif2db arguments */
  6397. /* ldif file to convert to db */
  6398. #define SLAPI_LDIF2DB_FILE 180
  6399. /* check for duplicate values or not */
  6400. #define SLAPI_LDIF2DB_REMOVEDUPVALS 185
  6401. /* index only this attribute from existing database */
  6402. #define SLAPI_DB2INDEX_ATTRS 186
  6403. /* do not generate attribute indexes */
  6404. #define SLAPI_LDIF2DB_NOATTRINDEXES 187
  6405. /* list if DNs to include */
  6406. #define SLAPI_LDIF2DB_INCLUDE 188
  6407. /* list of DNs to exclude */
  6408. #define SLAPI_LDIF2DB_EXCLUDE 189
  6409. /* generate uniqueid */
  6410. #define SLAPI_LDIF2DB_GENERATE_UNIQUEID 175
  6411. #define SLAPI_LDIF2DB_NAMESPACEID 177
  6412. #define SLAPI_LDIF2DB_ENCRYPT 303
  6413. #define SLAPI_DB2LDIF_DECRYPT 304
  6414. /* uniqueid generation options */
  6415. #define SLAPI_UNIQUEID_GENERATE_NONE 0 /* do not generate */
  6416. #define SLAPI_UNIQUEID_GENERATE_TIME_BASED 1 /* generate time based id */
  6417. #define SLAPI_UNIQUEID_GENERATE_NAME_BASED 2 /* generate name based id */
  6418. /* db2ldif arguments */
  6419. /* print keys or not in ldif */
  6420. #define SLAPI_DB2LDIF_PRINTKEY 183
  6421. /* filename to export */
  6422. #define SLAPI_DB2LDIF_FILE 184
  6423. /* dump uniqueid */
  6424. #define SLAPI_DB2LDIF_DUMP_UNIQUEID 176
  6425. #define SLAPI_DB2LDIF_SERVER_RUNNING 197
  6426. /* db2ldif/ldif2db/bak2db/db2bak arguments */
  6427. #define SLAPI_BACKEND_INSTANCE_NAME 178
  6428. #define SLAPI_BACKEND_TASK 179
  6429. #define SLAPI_TASK_FLAGS 181
  6430. /* bulk import (online wire import) */
  6431. #define SLAPI_BULK_IMPORT_ENTRY 182
  6432. #define SLAPI_BULK_IMPORT_STATE 192
  6433. /* the actual states (these are not pblock args) */
  6434. #define SLAPI_BI_STATE_START 1
  6435. #define SLAPI_BI_STATE_DONE 2
  6436. #define SLAPI_BI_STATE_ADD 3
  6437. /* possible error codes from a bulk import */
  6438. #define SLAPI_BI_ERR_BUSY -23 /* backend is busy; try later */
  6439. /* transaction arguments */
  6440. #define SLAPI_PARENT_TXN 190
  6441. #define SLAPI_TXN 191
  6442. #define SLAPI_TXN_RUV_MODS_FN 1901
  6443. #define SLAPI_BACK_TRANSACTION_NOT_SUPPORTED 1902
  6444. /*
  6445. * The following are used to pass information back and forth
  6446. * between the front end and the back end. The backend
  6447. * creates a search result set as an opaque structure and
  6448. * passes a reference to this back to the front end. The
  6449. * front end uses the backend's iterator entry point to
  6450. * step through the results. The entry, nentries, and
  6451. * referrals options, below, are set/read by both the
  6452. * front end and back end while stepping through the
  6453. * search results.
  6454. */
  6455. /* Search result set */
  6456. #define SLAPI_SEARCH_RESULT_SET 193
  6457. /* Estimated search result set size (for paged results) */
  6458. #define SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE 1930
  6459. /* Search result - next entry returned from search result set */
  6460. #define SLAPI_SEARCH_RESULT_ENTRY 194
  6461. #define SLAPI_SEARCH_RESULT_ENTRY_EXT 1944
  6462. /* Number of entries returned from search */
  6463. #define SLAPI_NENTRIES 195
  6464. /* Any referrals encountered during the search */
  6465. #define SLAPI_SEARCH_REFERRALS 196
  6466. /* for search operations, allows plugins to provide
  6467. controls to pass for each entry or referral returned
  6468. corresponds to pb_search_ctrls */
  6469. #define SLAPI_SEARCH_CTRLS 198
  6470. #define SLAPI_RESULT_CODE 881
  6471. #define SLAPI_RESULT_TEXT 882
  6472. #define SLAPI_RESULT_MATCHED 883
  6473. #define SLAPI_PB_RESULT_TEXT 885
  6474. /* Size of the database, in kilobytes */
  6475. #define SLAPI_DBSIZE 199
  6476. /* Simple paged results index */
  6477. #define SLAPI_PAGED_RESULTS_INDEX 1945
  6478. /* ACI Target Check */
  6479. #define SLAPI_ACI_TARGET_CHECK 1946
  6480. /* convenience macros for checking modify operation types */
  6481. #define SLAPI_IS_MOD_ADD(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD)
  6482. #define SLAPI_IS_MOD_DELETE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_DELETE)
  6483. #define SLAPI_IS_MOD_REPLACE(x) (((x) & ~LDAP_MOD_BVALUES) == LDAP_MOD_REPLACE)
  6484. /* regex.c */
  6485. typedef struct slapi_regex_handle Slapi_Regex;
  6486. /**
  6487. * Compiles a regular expression pattern. A thin wrapper of pcre_compile.
  6488. *
  6489. * \param pat Pattern to be compiled.
  6490. * \param error The error string is set if the compile fails.
  6491. * \return This function returns a pointer to the regex handler which stores
  6492. * the compiled pattern. NULL if the compile fails.
  6493. * \warning The regex handler should be released by slapi_re_free().
  6494. */
  6495. Slapi_Regex *slapi_re_comp( const char *pat, const char **error );
  6496. /**
  6497. * Matches a compiled regular expression pattern against a given string.
  6498. * A thin wrapper of pcre_exec.
  6499. *
  6500. * \param re_handle The regex handler returned from slapi_re_comp.
  6501. * \param subject A string to be checked against the compiled pattern.
  6502. * \param time_up If the current time is larger than the value, this function
  6503. * returns immediately. (-1) means no time limit.
  6504. * \return This function returns 0 if the string did not match.
  6505. * \return This function returns 1 if the string matched.
  6506. * \return This function returns other values if any error occurred.
  6507. * \warning The regex handler should be released by slapi_re_free().
  6508. */
  6509. int slapi_re_exec( Slapi_Regex *re_handle, const char *subject, time_t time_up );
  6510. /**
  6511. * Substitutes '&' or '\#' in the param src with the matched string.
  6512. *
  6513. * \param re_handle The regex handler returned from slapi_re_comp.
  6514. * \param subject A string checked against the compiled pattern.
  6515. * \param src A given string which could contain the substitution symbols.
  6516. * \param dst A pointer pointing to the memory which stores the output string.
  6517. * \param dstlen Size of the memory dst.
  6518. * \return This function returns 1 if the substitution was successful.
  6519. * \return This function returns 0 if the substitution failed.
  6520. * \warning The regex handler should be released by slapi_re_free().
  6521. */
  6522. int slapi_re_subs( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen );
  6523. /**
  6524. * Substitutes '&' or '\#' in the param src with the matched string. If the 'src' is a search filter
  6525. * do not remove & if it is part of a compound filter.
  6526. *
  6527. * \param re_handle The regex handler returned from slapi_re_comp.
  6528. * \param subject A string checked against the compiled pattern.
  6529. * \param src A given string which could contain the substitution symbols.
  6530. * \param dst A pointer pointing to the memory which stores the output string.
  6531. * \param dstlen Size of the memory dst.
  6532. * \param filter Set to 1 if the src is a ldap search filter
  6533. * \return This function returns 1 if the substitution was successful.
  6534. * \return This function returns 0 if the substitution failed.
  6535. * \warning The regex handler should be released by slapi_re_free().
  6536. */
  6537. int slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject, const char *src, char **dst, unsigned long dstlen, int filter );
  6538. /**
  6539. * Releases the regex handler which was returned from slapi_re_comp.
  6540. *
  6541. * \param re_handle The regex handler to be released.
  6542. * \return nothing
  6543. */
  6544. void slapi_re_free(Slapi_Regex *re_handle);
  6545. /* wrap non-portable LDAP API functions */
  6546. void slapi_ldap_value_free(char **vals);
  6547. int slapi_ldap_count_values(char **vals);
  6548. int slapi_ldap_url_parse(const char *url, LDAPURLDesc **ludpp, int require_dn, int *secure);
  6549. const char *slapi_urlparse_err2string(int err);
  6550. int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
  6551. #ifndef LDIF_OPT_NOWRAP
  6552. #define LDIF_OPT_NOWRAP 0x01UL
  6553. #endif
  6554. #ifndef LDIF_OPT_VALUE_IS_URL
  6555. #define LDIF_OPT_VALUE_IS_URL 0x02UL
  6556. #endif
  6557. #ifndef LDIF_OPT_MINIMAL_ENCODING
  6558. #define LDIF_OPT_MINIMAL_ENCODING 0x04UL
  6559. #endif
  6560. void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
  6561. /* ldif_read_record lineno argument type depends on openldap version */
  6562. #if defined(USE_OPENLDAP)
  6563. #if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
  6564. typedef unsigned long int ldif_record_lineno_t;
  6565. #else
  6566. typedef int ldif_record_lineno_t;
  6567. #endif
  6568. #endif
  6569. #if defined(USE_OPENLDAP)
  6570. /*
  6571. * UTF-8 routines (should these move into libnls?)
  6572. */
  6573. /* number of bytes in character */
  6574. int ldap_utf8len( const char* );
  6575. /* find next character */
  6576. char *ldap_utf8next( char* );
  6577. /* find previous character */
  6578. char *ldap_utf8prev( char* );
  6579. /* copy one character */
  6580. int ldap_utf8copy( char* dst, const char* src );
  6581. /* total number of characters */
  6582. size_t ldap_utf8characters( const char* );
  6583. /* get one UCS-4 character, and move *src to the next character */
  6584. unsigned long ldap_utf8getcc( const char** src );
  6585. /* UTF-8 aware strtok_r() */
  6586. char *ldap_utf8strtok_r( char* src, const char* brk, char** next);
  6587. /* like isalnum(*s) in the C locale */
  6588. int ldap_utf8isalnum( char* s );
  6589. /* like isalpha(*s) in the C locale */
  6590. int ldap_utf8isalpha( char* s );
  6591. /* like isdigit(*s) in the C locale */
  6592. int ldap_utf8isdigit( char* s );
  6593. /* like isxdigit(*s) in the C locale */
  6594. int ldap_utf8isxdigit(char* s );
  6595. /* like isspace(*s) in the C locale */
  6596. int ldap_utf8isspace( char* s );
  6597. #define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1)
  6598. #define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : ( s)+1)
  6599. #define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s)
  6600. #define LDAP_UTF8PREV(s) ldap_utf8prev(s)
  6601. #define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s))
  6602. #define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1))
  6603. #define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++)
  6604. #define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++)
  6605. #endif /* USE_OPENLDAP */
  6606. /* by default will allow dups */
  6607. char **slapi_str2charray( char *str, char *brkstr );
  6608. /*
  6609. * extended version of str2charray lets you disallow
  6610. * duplicate values into the array.
  6611. */
  6612. char **slapi_str2charray_ext( char *str, char *brkstr, int allow_dups );
  6613. #ifndef LDAP_PORT_MAX
  6614. #define LDAP_PORT_MAX 65535 /* API extension */
  6615. #endif
  6616. #ifndef LDAP_ALL_USER_ATTRS
  6617. #ifdef LDAP_ALL_USER_ATTRIBUTES
  6618. #define LDAP_ALL_USER_ATTRS LDAP_ALL_USER_ATTRIBUTES
  6619. #else
  6620. #define LDAP_ALL_USER_ATTRS "*"
  6621. #endif
  6622. #endif
  6623. #ifndef LDAP_SASL_EXTERNAL
  6624. #define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */
  6625. #endif
  6626. #ifndef LBER_SOCKET
  6627. #ifdef LBER_SOCKET_T
  6628. #define LBER_SOCKET LBER_SOCKET_T
  6629. #else
  6630. #define LBER_SOCKET int
  6631. #endif
  6632. #endif
  6633. /* Used to make unhashed passwords available to plugins. */
  6634. #define PSEUDO_ATTR_UNHASHEDUSERPASSWORD "unhashed#user#password"
  6635. /* Unhashed password */
  6636. #define SLAPD_UNHASHED_PW_OFF 0
  6637. #define SLAPD_UNHASHED_PW_ON 1
  6638. #define SLAPD_UNHASHED_PW_NOLOG 2
  6639. /**
  6640. * Set given "type: value" to the plugin default config entry
  6641. * (cn=plugin default config,cn=config) unless the same "type: value" pair
  6642. * already exists in the entry.
  6643. *
  6644. * \param type Attribute type to add to the default config entry
  6645. * \param value Attribute value to add to the default config entry
  6646. * \return \c 0 if the operation was successful
  6647. * \return non-0 if the operation was not successful
  6648. */
  6649. int slapi_set_plugin_default_config(const char *type, Slapi_Value *value);
  6650. /**
  6651. * Get attribute values of given type from the plugin default config entry
  6652. * (cn=plugin default config,cn=config).
  6653. *
  6654. * \param type Attribute type to get from the default config entry
  6655. * \param valueset Valueset holding the attribute values
  6656. * \return \c 0 if the operation was successful
  6657. * \return non-0 if the operation was not successful
  6658. * \warning Caller is responsible to free attrs by slapi_ch_array_free
  6659. */
  6660. int slapi_get_plugin_default_config(char *type, Slapi_ValueSet **valueset);
  6661. int slapi_check_account_lock( Slapi_PBlock *pb, Slapi_Entry *bind_target_entry, int pwresponse_req, int check_password_policy, int send_result);
  6662. /* backend get/set info */
  6663. /**
  6664. * Get backend info based upon cmd
  6665. *
  6666. * \param be Backend from which the infomation will be retrieved
  6667. * \param cmd macro to specify the information type
  6668. * \param info pointer to store the information
  6669. * \return \c 0 if the operation was successful
  6670. * \return non-0 if the operation was not successful
  6671. *
  6672. * \note Implemented cmd:
  6673. * BACK_INFO_DBENV - Get the dbenv
  6674. * BACK_INFO_DBENV_OPENFLAGS - Get the dbenv openflags
  6675. * BACK_INFO_INDEXPAGESIZE - Get the index page size
  6676. */
  6677. int slapi_back_get_info(Slapi_Backend *be, int cmd, void **info);
  6678. /**
  6679. * Set info to backend based upon cmd
  6680. *
  6681. * \param be Backend to which the infomation will be set
  6682. * \param cmd macro to specify the information type
  6683. * \param info pointer to the information
  6684. * \return \c 0 if the operation was successful
  6685. * \return non-0 if the operation was not successful
  6686. * \warning No cmd is defined yet.
  6687. */
  6688. int slapi_back_set_info(Slapi_Backend *be, int cmd, void *info);
  6689. /**
  6690. * Execute cmd in backend
  6691. *
  6692. * \param be Backend where the command is executed
  6693. * \param cmd macro to specify the execution type
  6694. * \param info pointer to the information
  6695. * \return \c 0 if the operation was successful
  6696. * \return non-0 if the operation was not successful
  6697. *
  6698. * \note Implemented cmd:
  6699. * BACK_INFO_CRYPT_INIT - Initialize cipher (info: back_info_crypt_init)
  6700. * BACK_INFO_CRYPT_ENCRYPT_VALUE - Encrypt the given value (info: back_info_crypt_value)
  6701. * BACK_INFO_CRYPT_DECRYPT_VALUE - Decrypt the given value (info: back_info_crypt_value)
  6702. */
  6703. int slapi_back_ctrl_info(Slapi_Backend *be, int cmd, void *info);
  6704. /* cmd */
  6705. enum
  6706. {
  6707. BACK_INFO_DBENV, /* Get the dbenv */
  6708. BACK_INFO_INDEXPAGESIZE, /* Get the index page size */
  6709. BACK_INFO_DBENV_OPENFLAGS, /* Get the dbenv openflags */
  6710. BACK_INFO_CRYPT_INIT, /* Ctrl: clcrypt_init */
  6711. BACK_INFO_CRYPT_ENCRYPT_VALUE, /* Ctrl: clcrypt_encrypt_value */
  6712. BACK_INFO_CRYPT_DECRYPT_VALUE, /* Ctrl: clcrypt_decrypt_value */
  6713. BACK_INFO_DIRECTORY, /* Get the directory path */
  6714. BACK_INFO_LOG_DIRECTORY /* Get the txn log directory */
  6715. };
  6716. struct _back_info_crypt_init {
  6717. char *dn; /* input -- entry to store nsSymmetricKey */
  6718. char *encryptionAlgorithm; /* input -- encryption althorithm */
  6719. Slapi_Backend *be; /* input -- backend to use */
  6720. void *state_priv; /* outout */
  6721. };
  6722. typedef struct _back_info_crypt_init back_info_crypt_init;
  6723. struct _back_info_crypt_value {
  6724. void *state_priv; /* input */
  6725. struct berval *in; /* input */
  6726. struct berval *out; /* output */
  6727. };
  6728. typedef struct _back_info_crypt_value back_info_crypt_value;
  6729. #define BACK_CRYPT_OUTBUFF_EXTLEN 16
  6730. /**
  6731. * Convert unsigned char (8 bit) value to a hex string. Writes to the string.
  6732. * The caller must ensure enough space to write 2 bytes. If the upper parameter
  6733. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6734. * Returns the address after the last byte written to encourage usage like this:
  6735. * \code
  6736. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6737. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6738. * ...
  6739. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6740. * *ptr = 0;
  6741. * \endcode
  6742. *
  6743. * \param val unsigned value to convert to string
  6744. * \param s string to write hex value into
  6745. * \param upper if TRUE use A-F otherwise use a-f
  6746. * \return address of next char after writing value to s
  6747. *
  6748. * \note Does not null terminate s - caller is responsible for that
  6749. */
  6750. char *slapi_u8_to_hex(uint8_t val, char *s, uint8_t upper);
  6751. /**
  6752. * Convert unsigned short (16 bit) value to a hex string. Writes to the string.
  6753. * The caller must ensure enough space to write 4 bytes. If the upper parameter
  6754. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6755. * Returns the address after the last byte written to encourage usage like this:
  6756. * \code
  6757. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6758. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6759. * ...
  6760. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6761. * *ptr = 0;
  6762. * \endcode
  6763. *
  6764. * \param val unsigned value to convert to string
  6765. * \param s string to write hex value into
  6766. * \param upper if TRUE use A-F otherwise use a-f
  6767. * \return address of next char after writing value to s
  6768. *
  6769. * \note Does not null terminate s - caller is responsible for that
  6770. */
  6771. char *slapi_u16_to_hex(uint16_t val, char *s, uint8_t upper);
  6772. /**
  6773. * Convert unsigned int (32 bit) value to a hex string. Writes to the string.
  6774. * The caller must ensure enough space to write 4 bytes. If the upper parameter
  6775. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6776. * Returns the address after the last byte written to encourage usage like this:
  6777. * \code
  6778. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6779. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6780. * ...
  6781. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6782. * *ptr = 0;
  6783. * \endcode
  6784. *
  6785. * \param val unsigned value to convert to string
  6786. * \param s string to write hex value into
  6787. * \param upper if TRUE use A-F otherwise use a-f
  6788. * \return address of next char after writing value to s
  6789. *
  6790. * \note Does not null terminate s - caller is responsible for that
  6791. */
  6792. char *slapi_u32_to_hex(uint32_t val, char *s, uint8_t upper);
  6793. /**
  6794. * Convert unsigned long long (64 bit) value to a hex string. Writes to the string.
  6795. * The caller must ensure enough space to write 4 bytes. If the upper parameter
  6796. * is TRUE, will use upper case A-F instead of lower case a-f for hex numbers.
  6797. * Returns the address after the last byte written to encourage usage like this:
  6798. * \code
  6799. * char *ptr = slapi_u_to_hex(val, buf, 0);
  6800. * ptr = slapi_u_to_hex(val2, ptr, 0);
  6801. * ...
  6802. * ptr = slapi_u_to_hex(valN, ptr, 0);
  6803. * *ptr = 0;
  6804. * \endcode
  6805. *
  6806. * \param val unsigned value to convert to string
  6807. * \param s string to write hex value into
  6808. * \param upper if TRUE use A-F otherwise use a-f
  6809. * \return address of next char after writing value to s
  6810. *
  6811. * \note Does not null terminate s - caller is responsible for that
  6812. */
  6813. char *slapi_u64_to_hex(uint64_t val, char *s, uint8_t upper);
  6814. /**
  6815. * Convert a char to its integral hex value e.g. '0' -> 0 or 'a' -> 10.
  6816. * This only works on one caller at a time. If you want to convert a string
  6817. * of decimal/hex numbers to its integral value, see slapi_str_to_u8 et. al.
  6818. * This uses a lookup table so it should be extremely fast.
  6819. *
  6820. * \param c character value to convert
  6821. * \return integral value of the given char or -1 if not a valid decimal/hex digit
  6822. */
  6823. int slapi_hexchar2int(char c);
  6824. /**
  6825. * Convert a string of 2 decimal/hex characters to a 1 byte (8-bit) unsigned value.
  6826. * This function does no checking - it assumes s is non-NULL and well-formed.
  6827. *
  6828. * \param s convert the first 2 chars of this decimal/hex char string to its integral value
  6829. * \return the integral value
  6830. */
  6831. uint8_t slapi_str_to_u8(const char *s);
  6832. /**
  6833. * Convert a string of 4 decimal/hex characters to a 2 byte (16-bit) unsigned value.
  6834. * This function does no checking - it assumes s is non-NULL and well-formed.
  6835. *
  6836. * \param s convert the first 4 chars of this decimal/hex char string to its integral value
  6837. * \return the integral value
  6838. */
  6839. uint16_t slapi_str_to_u16(const char *s);
  6840. /**
  6841. * Convert a string of 8 decimal/hex characters to a 4 byte (32-bit) unsigned value.
  6842. * This function does no checking - it assumes s is non-NULL and well-formed.
  6843. *
  6844. * \param s convert the first 8 chars of this decimal/hex char string to its integral value
  6845. * \return the integral value
  6846. */
  6847. uint32_t slapi_str_to_u32(const char *s);
  6848. /**
  6849. * Convert a string of 16 decimal/hex characters to a 8 byte (64-bit) unsigned value.
  6850. * This function does no checking - it assumes s is non-NULL and well-formed.
  6851. *
  6852. * \param s convert the first 16 chars of this decimal/hex char string to its integral value
  6853. * \return the integral value
  6854. */
  6855. uint64_t slapi_str_to_u64(const char *s);
  6856. void slapi_set_plugin_open_rootdn_bind(Slapi_PBlock *pb);
  6857. PRBool slapi_disordely_shutdown(PRBool set);
  6858. /*
  6859. * Public entry extension getter/setter functions
  6860. *
  6861. * Currently, only slapi_pw_get/set_entry_ext is implemented.
  6862. * The functions are in pw.c. Detailed usage of the factory
  6863. * is found in the comments at the top of factory.c.
  6864. *
  6865. * When you plan to add other entry extension code AND
  6866. * the type-value pair is managed via ordinary mod,
  6867. * setter, getter and copy function having the same API
  6868. * are supposed to be implemented, then add the set to
  6869. * attrs_in_extension list in entry.c. The set is called
  6870. * in slapi_entry_apply_mod_extension.
  6871. *
  6872. * Note: setter and getter are public, but copy function
  6873. * is not. (for the copy function, see pw_copy_entry_ext in pw.c)
  6874. */
  6875. /* operation used in the entry extension setter */
  6876. #define SLAPI_EXT_SET_ADD 0
  6877. #define SLAPI_EXT_SET_REPLACE 1
  6878. /**
  6879. * Get entry extension
  6880. *
  6881. * \param entry is the entry to retrieve the extension from
  6882. * \param vals is the array of (Slapi_Value *), which directly refers the extension. Caller must duplicate it to use it for other than referring.
  6883. *
  6884. * \return LDAP_SUCCESS if successful.
  6885. * \return non-zero otherwise.
  6886. */
  6887. int slapi_pw_get_entry_ext(Slapi_Entry *entry, Slapi_Value ***vals);
  6888. /**
  6889. * Set entry extension
  6890. *
  6891. * \param entry is the entry to set the extension to
  6892. * \param vals is the array of (Slapi_Value *), which is consumed in slapi_pw_set_ext if the call is successful.
  6893. * \param flags: SLAPI_EXT_SET_ADD -- add vals to the existing extension if any.
  6894. * SLAPI_EXT_SET_REPLACE -- replace vals with the existing extension if any.
  6895. * No difference if there is no extension in the entry.
  6896. *
  6897. * \return LDAP_SUCCESS if successful.
  6898. * \return non-zero otherwise.
  6899. */
  6900. int slapi_pw_set_entry_ext(Slapi_Entry *entry, Slapi_Value **vals, int flags);
  6901. /**
  6902. * Get stashed clear password.
  6903. * If multiple of them are in the extension, the first one is returned.
  6904. *
  6905. * \param entry is the entry to retrieve the extension from
  6906. *
  6907. * \return a pointer to the clear password string. Caller is responsible to free the string.
  6908. */
  6909. char *slapi_get_first_clear_text_pw(Slapi_Entry *entry);
  6910. /**
  6911. * Return the string equivalent of an NSPR error
  6912. * *
  6913. * \param a NSPR error code
  6914. *
  6915. * \return a pointer to the error code string.
  6916. */
  6917. char *slapi_pr_strerror( const PRErrorCode prerrno );
  6918. /**
  6919. * Return the string equivalent of an OS error
  6920. *
  6921. * \param a OS error code
  6922. *
  6923. * \return a pointer to the system error code string.
  6924. */
  6925. const char *slapi_system_strerror( const int syserrno );
  6926. /* event queue routines and data types */
  6927. /**
  6928. * Represents a scheduled event object.
  6929. */
  6930. typedef void* Slapi_Eq_Context;
  6931. /**
  6932. * Represents the function that will be performed when an event is triggered.
  6933. */
  6934. typedef void (*slapi_eq_fn_t)(time_t when, void *arg);
  6935. /**
  6936. * Cause an event to happen exactly once.
  6937. *
  6938. * \param fn The function to call when the event is triggered.
  6939. * \param arg An argument to pass to the called function.
  6940. * \param when The time that the function should be called.
  6941. *
  6942. * \return slapi_eq_context
  6943. */
  6944. Slapi_Eq_Context slapi_eq_once(slapi_eq_fn_t fn, void *arg, time_t when);
  6945. /**
  6946. * Cause an event to happen repeatedly.
  6947. *
  6948. * \param fn The function to call when the vent is triggered.
  6949. * \param arg An argument to pass to the called function.
  6950. * \param when The time that the function should be called.
  6951. * \param interval The amount of time (in milliseconds) between
  6952. * successive calls to the function.
  6953. *
  6954. * \return slapi_eq_context
  6955. */
  6956. Slapi_Eq_Context slapi_eq_repeat(slapi_eq_fn_t fn, void *arg, time_t when, unsigned long interval);
  6957. /**
  6958. * Cause a scheduled event to be canceled.
  6959. *
  6960. * \param ctx The event object to cancel
  6961. *
  6962. * \return 1 If event was found and canceled.
  6963. * \return 0 If event was not found in the queue.
  6964. */
  6965. int slapi_eq_cancel(Slapi_Eq_Context ctx);
  6966. /**
  6967. * Return the event's argument.
  6968. *
  6969. * \param ctx The event object
  6970. *
  6971. * \return A pointer to the event argument.
  6972. */
  6973. void *slapi_eq_get_arg (Slapi_Eq_Context ctx);
  6974. /**
  6975. * Construct a full path and name of a plugin.
  6976. *
  6977. * \param dir The Directory where the plugin is located.
  6978. * \param name The name of the plugin.
  6979. *
  6980. * \return absolute path of the plugin. Caller is responsible to free it.
  6981. */
  6982. char *slapi_get_plugin_name(const char *dir, const char *name);
  6983. #ifdef __cplusplus
  6984. }
  6985. #endif
  6986. #endif /* _SLAPIPLUGIN */