slapi-plugin.h 210 KB

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