slapi-plugin.h 289 KB

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