slapi-plugin.h 298 KB

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