slapi-plugin.h 222 KB

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