slapi-plugin.h 275 KB

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