Re: Part of const array with same value
TQ <[email protected]> Sat, 7 Dec 2019 11:31:11 -0800
| Newsgroups | gmane.comp.security.detection.bro |
|---|---|
| Message-ID | <CAM2MKSrOzhg8ES-2+qM3o1WAfqA1as5d6C62wCQxhVxtMBhzmg@mail.gmail.com> |
--===============0363300323== Content-Type: multipart/alternative; boundary="00000000000094dcca05992236f3" --00000000000094dcca05992236f3 Content-Type: text/plain; charset="UTF-8" My use case is for enumeration. This array is typically declared in consts.zeek; you would call it in main.zeek. I mean you could write a switch statement, but now main.zeek would definitely blow up quite a bit. Thanks, On Sat, Dec 7, 2019 at 6:00 AM [email protected] <[email protected]> wrote: > What's the use of this array? > > On Fri, Dec 6, 2019, 10:36 PM TQ <[email protected]> wrote: > >> Hello Zeekers, >> >> What is the best way to represent indices of an array with the same >> value? Let's say I declare a constant string array used for enumeration >> called 'test'. Values 0 and 1 has some unique value, but anything from 2 >> and 7 has a constant value of 'test2'. Is there a quicker way of >> representing this or would I need to manually set it? >> >> const test = { >> [0] = "test0", >> [1] = "test1", >> [2] = "test2", >> [3] = "test2", >> [4] = "test2", >> [5] = "test2", >> [6] = "test2", >> [7] = "test2", >> [8] = "test3", >> } &default=function(i: count):string { return fmt("test(%x)", i); } >> &redef; >> >> Thanks, >> _______________________________________________ >> Zeek mailing list >> [email protected] >> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/zeek > > --00000000000094dcca05992236f3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">My use case is for enumeration.=C2=A0 This array is typica= lly declared in consts.zeek; you would call it in main.zeek.=C2=A0 I mean y= ou could write a switch statement, but now main.zeek would definitely blow = up quite a bit.<div><br></div><div>Thanks,</div></div><br><div class=3D"gma= il_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, Dec 7, 2019 at 6:00= AM <a href=3D"mailto:[email protected]">[email protected]</a> <<a href= =3D"mailto:[email protected]">[email protected]</a>> wrote:<br></div><bl= ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef= t:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"auto">What's= the use of this array?</div><br><div class=3D"gmail_quote"><div dir=3D"ltr= " class=3D"gmail_attr">On Fri, Dec 6, 2019, 10:36 PM TQ <<a href=3D"mail= to:[email protected]" target=3D"_blank">[email protected]</a>>= wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px = 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir= =3D"ltr">Hello Zeekers,<br><div><br></div><div>What is the best way to repr= esent indices of an array with the same value?=C2=A0 Let's say I declar= e a constant string array used for enumeration called 'test'.=C2=A0= Values 0 and 1 has some unique value, but anything from 2 and 7 has a cons= tant value of 'test2'.=C2=A0 Is there a quicker way of representing= this or would I need to manually set it?</div><div><br></div><div>const te= st =3D {<br>=C2=A0 =C2=A0 [0] =3D "test0",<br>=C2=A0 =C2=A0 [1] = =3D "test1",</div><div><div>=C2=A0 =C2=A0 [2] =3D "test2&quo= t;,<br>=C2=A0 =C2=A0 [3] =3D "test2",</div><div><div>=C2=A0 =C2= =A0 [4] =3D "test2",<br>=C2=A0 =C2=A0 [5] =3D "test2",<= /div><div></div></div><div></div><div><div>=C2=A0 =C2=A0 [6] =3D "test= 2",<br>=C2=A0 =C2=A0 [7] =3D "test2",</div><div> =C2=A0 =C2=A0 [8] =3D "test3", <br></div><div></div></div>=C2=A0 =C2=A0 } &default=3Dfunction(i: count= ):string { return fmt("test(%x)", i); } &redef;<br></div><div= ><br></div><div>Thanks,</div></div> _______________________________________________<br> Zeek mailing list<br> <a href=3D"mailto:[email protected]" rel=3D"noreferrer" target=3D"_blank">zeek@= zeek.org</a><br> <a href=3D"http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/zeek" rel=3D"n= oreferrer noreferrer" target=3D"_blank">http://mailman.ICSI.Berkeley.EDU/ma= ilman/listinfo/zeek</a></blockquote></div> </blockquote></div> --00000000000094dcca05992236f3-- --===============0363300323== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Zeek mailing list [email protected] http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/zeek --===============0363300323==--