slapi-plugin.h 298 KB

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