Re: GLU in DerelictOrg

2015-07-21 Thread Spacen Jasset via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 15:17:13 UTC, Alex Parrill wrote:

On Tuesday, 21 July 2015 at 14:51:47 UTC, John Colvin wrote:
Isn't glu considered legacy these days? I think it's entirely 
OpenGL 2.x. For the maths stuff see 
http://code.dlang.org/packages/gl3n


Yep. It still uses immediate mode, GL matrix functions, and all 
sorts of other stuff removed in OpenGL 3.1+ core.


Yes, thanks John. I will be using the legacy mode though :-) Not 
got around to the wizz bang stuff yet.





Re: GLU in DerelictOrg

2015-07-21 Thread Alex Parrill via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 14:51:47 UTC, John Colvin wrote:
Isn't glu considered legacy these days? I think it's entirely 
OpenGL 2.x. For the maths stuff see 
http://code.dlang.org/packages/gl3n


Yep. It still uses immediate mode, GL matrix functions, and all 
sorts of other stuff removed in OpenGL 3.1+ core.


Re: C bindings: typedef struct conflicts with method

2015-07-21 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-07-21 14:24, yawniek wrote:


done, https://github.com/jacob-carlborg/dstep/issues/40
i was under the impression that there is already a ticked as
https://github.com/jacob-carlborg/dstep/issues/8
looks very similar (but was closed).


Yeah, looks very similar. Issue 8 i still open and has never been closed.

--
/Jacob Carlborg


Re: GLU in DerelictOrg

2015-07-21 Thread John Colvin via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 12:26:30 UTC, Spacen Jasset wrote:
It seems that Derelict3 contains GLUT whereas derelict2 
containss GLU.


It appears I need GLU but I am somewhat confused as to what the 
diffrence is.


Whoops, yes you are right, my mistake.

Isn't glu considered legacy these days? I think it's entirely 
OpenGL 2.x. For the maths stuff see 
http://code.dlang.org/packages/gl3n


Code Coverage Analysis, how do I skip (ignore) a line?

2015-07-21 Thread antropod via Digitalmars-d-learn

I want my coverage analysis to be 100%, how do I skip lines like
assert(0);
from being counted?


Passing struct and struct[] into a template

2015-07-21 Thread Taylor Gronka via Digitalmars-d-learn

Hi,

I have a template function, and I want it to do something if the 
input variable is a list of structs, and something else if the 
input is a struct.


1) What's the best way to test this? I suppose I can call 
__traits(identifier, results) and look at the last two characters.
2) If `T` is a list of structs, how can I initialize a new struct 
so that I can append to `T`?


This is sort of how it might be done in python. I haven't 
implemented question 2 yet since I'm not sure how atm:


template Uks(T) {
T query(string q) {
T result;
try {
ulong test = result.length; // won't compile for 
non-list structs

// append to a struct list
T.subtype newResult; // is there a function like this?
result ~= newResult;
} catch {
// assign the struct members directly
}
return result;
}
}

I would like to call it like either of the following, depending 
on if I want 1 result or X results:

auto res = Uks!(U_Struct).query(email);
auto res = Uks!(U_Struct[]).query(email);

I'd be happy to hear better design methods.

Thanks


Re: How do i sanitize a string for database query?

2015-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote:

How do i sanitize a string for database query?


You generally shouldn't even try, instead use the database 
functions that bind parameters to the procedure.



Is there some builtin function?



It is different for each database target.


How do i sanitize a string for database query?

2015-07-21 Thread ddos via Digitalmars-d-learn

How do i sanitize a string for database query?
Is there some builtin function?

thx :)


Re: How do i sanitize a string for database query?

2015-07-21 Thread Gary Willoughby via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote:

How do i sanitize a string for database query?
Is there some builtin function?

thx :)


Use prepared statements instead.

https://en.wikipedia.org/wiki/Prepared_statement


Re: GLU in DerelictOrg

2015-07-21 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 16:34:35 UTC, Spacen Jasset wrote:

On Tuesday, 21 July 2015 at 15:17:13 UTC, Alex Parrill wrote:

On Tuesday, 21 July 2015 at 14:51:47 UTC, John Colvin wrote:
Isn't glu considered legacy these days? I think it's entirely 
OpenGL 2.x. For the maths stuff see 
http://code.dlang.org/packages/gl3n


Yep. It still uses immediate mode, GL matrix functions, and 
all sorts of other stuff removed in OpenGL 3.1+ core.


Yes, thanks John. I will be using the legacy mode though :-) 
Not got around to the wizz bang stuff yet.


I intentionally did not port the Derelict3 GLU binding to 
DerelictOrg because it uses parts of the deprecated OGL API and 
is considered legacy these days. Initially, I didn't include 
support for the deprecated OGL API either, but there were enough 
requests for it that I finally added it. I have no intention of 
adding GLU, though. It's easily replaceable.


Re: Passing struct and struct[] into a template

2015-07-21 Thread Timon Gehr via Digitalmars-d-learn

On 07/22/2015 06:29 AM, Taylor Gronka wrote:

Hi,

I have a template function, and I want it to do something if the input
variable is a list of structs, and something else if the input is a struct.

1) What's the best way to test this? I suppose I can call
__traits(identifier, results) and look at the last two characters.
2) If `T` is a list of structs, how can I initialize a new struct so
that I can append to `T`?

This is sort of how it might be done in python. I haven't implemented
question 2 yet since I'm not sure how atm:

template Uks(T) {
 T query(string q) {
 T result;
 try {
 ulong test = result.length; // won't compile for non-list
structs
 // append to a struct list
 T.subtype newResult; // is there a function like this?
 result ~= newResult;
 } catch {
 // assign the struct members directly
 }
 return result;
 }
}

I would like to call it like either of the following, depending on if I
want 1 result or X results:
auto res = Uks!(U_Struct).query(email);
auto res = Uks!(U_Struct[]).query(email);

I'd be happy to hear better design methods.

Thanks


template Uks(T){
T query(string q){
T result;
static if(is(T==S[],S)){
ulong test=result.length;
// append
S newResult;
result~=newResult;
}else{
// assign
}
return result;
}
}

void main(){
struct U_Struct{}
auto res1=Uks!(U_Struct).query(email);
auto res2=Uks!(U_Struct[]).query(email);
}



Re: Passing struct and struct[] into a template

2015-07-21 Thread Taylor Gronka via Digitalmars-d-learn

On Wednesday, 22 July 2015 at 05:02:59 UTC, Timon Gehr wrote:

template Uks(T){
T query(string q){
T result;
static if(is(T==S[],S)){
ulong test=result.length;
// append
S newResult;
result~=newResult;
}else{
// assign
}
return result;
}
}

void main(){
struct U_Struct{}
auto res1=Uks!(U_Struct).query(email);
auto res2=Uks!(U_Struct[]).query(email);
}


Oh that's phenomenal. Thanks!

For reference, the is() function can accept template parameters. 
More here, under isExpression

http://dlang.org/expression.html


Re: How do i sanitize a string for database query?

2015-07-21 Thread Gary Willoughby via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 18:55:53 UTC, ddos wrote:

On Tuesday, 21 July 2015 at 17:58:55 UTC, Gary Willoughby wrote:

On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote:

How do i sanitize a string for database query?
Is there some builtin function?

thx :)


Use prepared statements instead.

https://en.wikipedia.org/wiki/Prepared_statement


thx for reminding me of prepared statements
this is ok for preventing an sql injection i guess, but still 
my insert would fail.

maybe i should have specified what i want to achieve:

i have a plugin for a call of duty gameserver, this plugin is 
able to ban players from the server by inserting name/ip/etc.. 
into a sql database. it is priority that the insert never 
fails. e.g. name could contain a ' which lets my insert fail.


Prepared statements handle this just fine. In fact that's why 
they exist, to handle this case.




Re: How do i sanitize a string for database query?

2015-07-21 Thread ddos via Digitalmars-d-learn

thx


Re: How do i sanitize a string for database query?

2015-07-21 Thread ddos via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 17:58:55 UTC, Gary Willoughby wrote:

On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote:

How do i sanitize a string for database query?
Is there some builtin function?

thx :)


Use prepared statements instead.

https://en.wikipedia.org/wiki/Prepared_statement


thx for reminding me of prepared statements
this is ok for preventing an sql injection i guess, but still my 
insert would fail.

maybe i should have specified what i want to achieve:

i have a plugin for a call of duty gameserver, this plugin is 
able to ban players from the server by inserting name/ip/etc.. 
into a sql database. it is priority that the insert never fails. 
e.g. name could contain a ' which lets my insert fail.





Re: How do i sanitize a string for database query?

2015-07-21 Thread Alex Parrill via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 18:55:53 UTC, ddos wrote:

On Tuesday, 21 July 2015 at 17:58:55 UTC, Gary Willoughby wrote:

On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote:

How do i sanitize a string for database query?
Is there some builtin function?

thx :)


Use prepared statements instead.

https://en.wikipedia.org/wiki/Prepared_statement


thx for reminding me of prepared statements
this is ok for preventing an sql injection i guess, but still 
my insert would fail.

maybe i should have specified what i want to achieve:

i have a plugin for a call of duty gameserver, this plugin is 
able to ban players from the server by inserting name/ip/etc.. 
into a sql database. it is priority that the insert never 
fails. e.g. name could contain a ' which lets my insert fail.


No it won't. The actual contents of your query parameters are 
irrelevant and are stored as-is; that's the entire point of using 
query parameters.


Example using d2sqlite3:

auto db = Database(:memory:);
auto stmt = db.prepare(INSERT INTO banned VALUES (?);)
stmt.bindAll(O'chucks);
stmt.execute(); // works fine



Re: Sending an immutable object to a thread

2015-07-21 Thread rsw0x via Digitalmars-d-learn

On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote:

On Sunday, 19 July 2015 at 17:04:07 UTC, Frank Pagliughi wrote:

[...]


Oh, yes, pointer. Ha! I didn't even think of that. Thanks.

I'm not familiar with how garbage collection works in D. If 
the initial reference goes out of scope, and you just have a 
pointer - in another thread, no less - then are you still 
guaranteed that the object will not disappear while the 
pointer exists?


[...]


a pointer to a pointer(or in this case, a reference) does not 
keep it alive.


wow, I don't even remember posting this.

This is (mostly) wrong, but I'm unsure if a pointer to another 
pointer on the stack would correctly keep its object alive(but, I 
believe this would just be a bug I think,) If the pointer was 
pointing to a pointer on the heap, then AFAICT it would keep it 
alive.


Re: Sending an immutable object to a thread

2015-07-21 Thread rsw0x via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 21:44:07 UTC, rsw0x wrote:

On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote:

[...]


wow, I don't even remember posting this.

This is (mostly) wrong, but I'm unsure if a pointer to another 
pointer on the stack would correctly keep its object alive(but, 
I believe this would just be a bug I think,) If the pointer was 
pointing to a pointer on the heap, then AFAICT it would keep it 
alive.


addendum:
http://dlang.org/garbage.html

Pointers in D can be broadly divided into two categories: Those 
that point to garbage collected memory, and those that do not. 
Examples of the latter are pointers created by calls to C's 
malloc(), pointers received from C library routines, pointers to 
static data, pointers to objects on the stack, etc.



and those that do not ... pointers to objects on the stack, etc.


I believe this implies that it would *not* keep the object alive.

Sorry for the confusion/noise.


Re: Sending an immutable object to a thread

2015-07-21 Thread Frank Pagliughi via Digitalmars-d-learn

On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote:


a pointer to a pointer(or in this case, a reference) does not 
keep it alive.


Interesting. If you de-reference the pointer and assign it back, 
do you get back the keep-alive? Like, in the receiving thread:


void threadFunc()
{
receive((Tid cli, immutable(Message) *m) {
immutable(Message) msg = *m;   // ---
int retCode = do_something_with(msg);
send(cli, retCode);
});
}

I assume that even if so, there is a race condition there. You 
would need to keep the original reference alive until at least 
the msg = *m assignment happened, right?


Or... could you tell the GC to leave the memory alone until the 
thread gets it?  Like in the sending thread:


  Tid tid = spawn(threadFunc);
  auto p = cast(void*) msg;
  GC.addRoot(p);
  GC.setAttr(p, GC.BlkAttr.NO_MOVE);
  send(tid, thisTid(), msg);
  //...

Is that possible? Is it efficient enough to do if you're sending 
lots and lots of messages?


Thanks.



Re: C bindings: typedef struct conflicts with method

2015-07-21 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-07-21 07:53, yawniek wrote:

i tried to automagically create bindings for librdkafka
(https://github.com/edenhill/librdkafka)
with dstep.

now the code contains typedefs structs with the same name as methods:

```
typedef struct rd_kafka_metadata {
 int broker_cnt; /* Number of brokers in 'brokers' */
 struct rd_kafka_metadata_broker *brokers;  /* Brokers */

 int topic_cnt;  /* Number of topics in 'topics' */
 struct rd_kafka_metadata_topic *topics;/* Topics */

 int32_t orig_broker_id; /* Broker originating this metadata */
 char   *orig_broker_name; /* Name of originating broker */
} rd_kafka_metadata_t;


rd_kafka_metadata (rd_kafka_t *rk, int all_topics,
rd_kafka_topic_t *only_rkt,
const struct rd_kafka_metadata **metadatap,
int timeout_ms);
```

what the correct way to bind these?


Please report an issue for this. In this case rd_kafka_metadata_t 
should be used for the struct name.


--
/Jacob Carlborg


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 10:28:27 UTC, Rikki Cattermole wrote:

On 21/07/2015 10:14 p.m., Baz wrote:

---
import std.process;
import core.thread;
import std.random;

void main(string[] args)
{
 string on = netsh interface set interface \Connexion au 
réseau

local\ Enable;
 string off = netsh interface set interface \Connexion 
au réseau

local\ Disable;

 while(true)
 {
 executeShell(on);
 Thread.sleep(dur!(msecs)(uniform(2000, 5000)));
 executeShell(off);
 Thread.sleep(dur!(msecs)(2000));
 }
}
---

It's stable if i remove the random time after connecting, 
otherwise in
the current shape it crashes Windows. Don't know why. Any idea 
?


Note that you can test by replacing the name of my interface 
by yours

('Connexion au réseau local').


This shouldn't be a D bug, it's reasonable D code.
Can you give us the BSOD text?
Also OS version + platform would be nice.

I've asked a friend who knows Windows better then anybody 
should and basically relaying this to him FYI.


- Window 7 64 bit (up to date) but the program is running in 32 
bit, compiled with latest DMD 2.067.1.
- involved hardware is onboard REALTEK on Gigabyte H97-HD3, 
driver up to date.


I have not the BSOD error code because I ran this script while 
away.


Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn

---
import std.process;
import core.thread;
import std.random;

void main(string[] args)
{
string on = netsh interface set interface \Connexion au 
réseau local\ Enable;
string off = netsh interface set interface \Connexion au 
réseau local\ Disable;


while(true)
{
executeShell(on);
Thread.sleep(dur!(msecs)(uniform(2000, 5000)));
executeShell(off);
Thread.sleep(dur!(msecs)(2000));
}
}
---

It's stable if i remove the random time after connecting, 
otherwise in the current shape it crashes Windows. Don't know 
why. Any idea ?


Note that you can test by replacing the name of my interface by 
yours ('Connexion au réseau local').


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Rikki Cattermole via Digitalmars-d-learn

On 21/07/2015 10:14 p.m., Baz wrote:

---
import std.process;
import core.thread;
import std.random;

void main(string[] args)
{
 string on = netsh interface set interface \Connexion au réseau
local\ Enable;
 string off = netsh interface set interface \Connexion au réseau
local\ Disable;

 while(true)
 {
 executeShell(on);
 Thread.sleep(dur!(msecs)(uniform(2000, 5000)));
 executeShell(off);
 Thread.sleep(dur!(msecs)(2000));
 }
}
---

It's stable if i remove the random time after connecting, otherwise in
the current shape it crashes Windows. Don't know why. Any idea ?

Note that you can test by replacing the name of my interface by yours
('Connexion au réseau local').


This shouldn't be a D bug, it's reasonable D code.
Can you give us the BSOD text?
Also OS version + platform would be nice.

I've asked a friend who knows Windows better then anybody should and 
basically relaying this to him FYI.


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Kagamin via Digitalmars-d-learn

try this:

import std.process, std.stdio;
import core.thread;
import std.random;

void main(string[] args)
{
string on = netsh interface set interface \Connexion au 
réseau local\ Enable;
string off = netsh interface set interface \Connexion au 
réseau local\ Disable;


while(true)
{
executeShell(on);
const t=uniform(2000, 5000);
writeln(timeout: ,t);
readln();
Thread.sleep(dur!(msecs)(t));
executeShell(off);
Thread.sleep(dur!(msecs)(2000));
}
}


Re: C bindings: typedef struct conflicts with method

2015-07-21 Thread Rikki Cattermole via Digitalmars-d-learn

On 21/07/2015 5:53 p.m., yawniek wrote:

i tried to automagically create bindings for librdkafka
(https://github.com/edenhill/librdkafka)
with dstep.

now the code contains typedefs structs with the same name as methods:

```
typedef struct rd_kafka_metadata {
 int broker_cnt; /* Number of brokers in 'brokers' */
 struct rd_kafka_metadata_broker *brokers;  /* Brokers */

 int topic_cnt;  /* Number of topics in 'topics' */
 struct rd_kafka_metadata_topic *topics;/* Topics */

 int32_t orig_broker_id; /* Broker originating this metadata */
 char   *orig_broker_name; /* Name of originating broker */
} rd_kafka_metadata_t;


rd_kafka_metadata (rd_kafka_t *rk, int all_topics,
rd_kafka_topic_t *only_rkt,
const struct rd_kafka_metadata **metadatap,
int timeout_ms);
```

what the correct way to bind these?


The c function matters. The struct's two names do not. Just use the 
struct's _t name.


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 10:41:54 UTC, Kagamin wrote:

try this:

import std.process, std.stdio;
import core.thread;
import std.random;

void main(string[] args)
{
string on = netsh interface set interface \Connexion au 
réseau local\ Enable;
string off = netsh interface set interface \Connexion au 
réseau local\ Disable;


while(true)
{
executeShell(on);
const t=uniform(2000, 5000);
writeln(timeout: ,t);
readln();
Thread.sleep(dur!(msecs)(t));
executeShell(off);
Thread.sleep(dur!(msecs)(2000));
}
}


Mmmmh i see, you think that t will be on TLS like this ?
But i'll test later, actually the crash happens after a few 
iterations, eg i run the script, i check it works, i go away, 
then when i come back and windows restarted and i got 
unexepected  blue screen message.


GLU in DerelictOrg

2015-07-21 Thread Spacen Jasset via Digitalmars-d-learn

Hello,

Can anyone tell me if the GLU functions, gluSpehere etc are 
availble in DerelictOrg or have they been removed. I can replace 
these with my own versions, but was hoping to do a quick port to 
DerelictOrg


Re: GLU in DerelictOrg

2015-07-21 Thread John Colvin via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 11:08:13 UTC, Spacen Jasset wrote:

Hello,

Can anyone tell me if the GLU functions, gluSpehere etc are 
availble in DerelictOrg or have they been removed. I can 
replace these with my own versions, but was hoping to do a 
quick port to DerelictOrg


They are not available. See 
http://dblog.aldacron.net/2014/10/derelict-3-removed-from-dub-repository/


I'm not sure why they aren't part of the DerelictOrg. I'm sure it 
wouldn't be hard to take 
https://github.com/aldacron/Derelict3/tree/master/import/derelict/freeglut and make a dub package out of it yourself, maybe even add it to code.dlang.org as derelict_extras-freeglut


Re: GLU in DerelictOrg

2015-07-21 Thread Spacen Jasset via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 11:23:23 UTC, John Colvin wrote:

On Tuesday, 21 July 2015 at 11:08:13 UTC, Spacen Jasset wrote:

Hello,

Can anyone tell me if the GLU functions, gluSpehere etc are 
availble in DerelictOrg or have they been removed. I can 
replace these with my own versions, but was hoping to do a 
quick port to DerelictOrg


They are not available. See 
http://dblog.aldacron.net/2014/10/derelict-3-removed-from-dub-repository/


I'm not sure why they aren't part of the DerelictOrg. I'm sure 
it wouldn't be hard to take 
https://github.com/aldacron/Derelict3/tree/master/import/derelict/freeglut and make a dub package out of it yourself, maybe even add it to code.dlang.org as derelict_extras-freeglut


Thanks John, it looks really simple. I'll see if I can get round 
to making a proper package from it.


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Kagamin via Digitalmars-d-learn
http://forum.dlang.org/post/oyzgbvdzyjmupkduz...@forum.dlang.org 
- maybe related


On Tuesday, 21 July 2015 at 11:03:47 UTC, Baz wrote:

Mmmmh i see, you think that t will be on TLS like this ?


I thought it passes some weird value, that sleep doesn't like.

But i'll test later, actually the crash happens after a few 
iterations, eg i run the script, i check it works, i go away


Is the system trying to go to sleep mode? At least XP didn't like 
unexpected hardware events when going to sleep.


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Rikki Cattermole via Digitalmars-d-learn

On 21/07/2015 10:36 p.m., Baz wrote:

On Tuesday, 21 July 2015 at 10:28:27 UTC, Rikki Cattermole wrote:

On 21/07/2015 10:14 p.m., Baz wrote:

---
import std.process;
import core.thread;
import std.random;

void main(string[] args)
{
 string on = netsh interface set interface \Connexion au réseau
local\ Enable;
 string off = netsh interface set interface \Connexion au réseau
local\ Disable;

 while(true)
 {
 executeShell(on);
 Thread.sleep(dur!(msecs)(uniform(2000, 5000)));
 executeShell(off);
 Thread.sleep(dur!(msecs)(2000));
 }
}
---

It's stable if i remove the random time after connecting, otherwise in
the current shape it crashes Windows. Don't know why. Any idea ?

Note that you can test by replacing the name of my interface by yours
('Connexion au réseau local').


This shouldn't be a D bug, it's reasonable D code.
Can you give us the BSOD text?
Also OS version + platform would be nice.

I've asked a friend who knows Windows better then anybody should and
basically relaying this to him FYI.


- Window 7 64 bit (up to date) but the program is running in 32 bit,
compiled with latest DMD 2.067.1.
- involved hardware is onboard REALTEK on Gigabyte H97-HD3, driver up to
date.

I have not the BSOD error code because I ran this script while away.


I'll summarize what my friend is saying.

netsh is potentially going away. Don't use it if you can.
Since you are using a localized system it, it may be causing issues for 
the interface name.

Internally to Windows, it does not use the interface names. It uses id's.

Oh and most importantly use Windows API not netsh.

You should instead be using ConvertInterfaceAliasToLuid[0] to get the UID.
There does not appear to be a c-function to disable/enable an interface. 
Supposedly[1] could be used to enable/disable the card which provides 
it. Although I would recommend against it.


Lastly, this is half good news and half bad news. We have found a way[2] 
through WMI/COM to enable/disable them. Although I've never gone the 
path of COM let alone WMI which could be a rather mess to deal with in 
D. May be easier to use PowerShell for this.


Either way, my current theory revolves around Windows kernel + 
subsystems not liking it toggling so frequently. Friend is a little more 
conservative on it.


[0] 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365821(v=vs.85).aspx
[1] 
https://msdn.microsoft.com/en-us/library/windows/hardware/ff552169(v=vs.85).aspx

[2] https://msdn.microsoft.com/en-us/library/hh968170(v=vs.85).aspx


Re: GLU in DerelictOrg

2015-07-21 Thread Rikki Cattermole via Digitalmars-d-learn

On 21/07/2015 11:08 p.m., Spacen Jasset wrote:

Hello,

Can anyone tell me if the GLU functions, gluSpehere etc are availble in
DerelictOrg or have they been removed. I can replace these with my own
versions, but was hoping to do a quick port to DerelictOrg


https://github.com/DerelictOrg?utf8=%E2%9C%93query=+only%3Asources+glu


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Kagamin via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 11:08:00 UTC, Rikki Cattermole wrote:
Lastly, this is half good news and half bad news. We have found 
a way[2] through WMI/COM to enable/disable them. Although I've 
never gone the path of COM let alone WMI which could be a 
rather mess to deal with in D. May be easier to use PowerShell 
for this.


WMI is accessible through javascript, e.g.:

var Wmi = 
WScript.CreateObject(WbemScripting.SWbemLocator).ConnectServer(., root/cimv2);

var processes = Wmi.ExecQuery(select * from win32_process);


Re: C bindings: typedef struct conflicts with method

2015-07-21 Thread yawniek via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 06:12:53 UTC, Jacob Carlborg wrote:

what the correct way to bind these?


Please report an issue for this. In this case 
rd_kafka_metadata_t should be used for the struct name.


done, https://github.com/jacob-carlborg/dstep/issues/40
i was under the impression that there is already a ticked as
https://github.com/jacob-carlborg/dstep/issues/8
looks very similar (but was closed).

thanks rikki, thats what i ended up doing, compiles so far.


Re: idiom for C error strings

2015-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 12:40:37 UTC, Daniel Kozák wrote:

static:

char[size] buf;


somefun(param1, buf.ptr, buf.length);

still works there too. That's the form I prefer to use.


idiom for C error strings

2015-07-21 Thread yawniek via Digitalmars-d-learn
whats the proper way to use/wrap C functions  that expect a error 
string buffer

e.g.:
somefun(T param1, char* errstr, size_t errstr_size)
 in D ?



Re: GLU in DerelictOrg

2015-07-21 Thread Spacen Jasset via Digitalmars-d-learn
It seems that Derelict3 contains GLUT whereas derelict2 containss 
GLU.


It appears I need GLU but I am somewhat confused as to what the 
diffrence is.


Re: Why does this script BSOD-ize windows ?

2015-07-21 Thread Baz via Digitalmars-d-learn

On Tuesday, 21 July 2015 at 11:08:00 UTC, Rikki Cattermole wrote:

On 21/07/2015 10:36 p.m., Baz wrote:

[...]


I'll summarize what my friend is saying.

netsh is potentially going away. Don't use it if you can.
Since you are using a localized system it, it may be causing 
issues for the interface name.
Internally to Windows, it does not use the interface names. It 
uses id's.


Oh and most importantly use Windows API not netsh.

You should instead be using ConvertInterfaceAliasToLuid[0] to 
get the UID.
There does not appear to be a c-function to disable/enable an 
interface. Supposedly[1] could be used to enable/disable the 
card which provides it. Although I would recommend against it.


Lastly, this is half good news and half bad news. We have found 
a way[2] through WMI/COM to enable/disable them. Although I've 
never gone the path of COM let alone WMI which could be a 
rather mess to deal with in D. May be easier to use PowerShell 
for this.


Either way, my current theory revolves around Windows kernel + 
subsystems not liking it toggling so frequently. Friend is a 
little more conservative on it.


[0] 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365821(v=vs.85).aspx
[1] 
https://msdn.microsoft.com/en-us/library/windows/hardware/ff552169(v=vs.85).aspx
[2] 
https://msdn.microsoft.com/en-us/library/hh968170(v=vs.85).aspx


That's an excellent expertise. However, I'd like to put the 
emphasis on the fact that it looks like a deterministic way to 
crash windows, even if to run the script, admin rights are 
necessary.


Now there is also other questions in background: DHCP server, 
network interface driver even if nowadays they are all in 'user 
mode', (versus kernel mode).


Re: idiom for C error strings

2015-07-21 Thread Daniel Kozák via Digitalmars-d-learn

On Tue, 21 Jul 2015 12:27:55 +
yawniek dl...@srtnwz.com wrote:

 whats the proper way to use/wrap C functions  that expect a error 
 string buffer
 e.g.:
 somefun(T param1, char* errstr, size_t errstr_size)
   in D ?
 

dynamic:

auto buf = new char[size];
somefun(param1, buf.ptr, buf.length);
or
somefun(param1, buf.ptr, size);

static:

char[size] buf;
somefun(param1, buf, size);