1
0

slapi-plugin.h 238 KB

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