slapi-plugin.h 227 KB

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