On 2/9/2015 7:57 PM, Frantisek Hanzlik wrote:
> Hi Eric,
> thanks for help,
>
> Eric Auer wrote:
>> Hi Franta,
>>
>>>          struct dosemu_detect {
>>>              char magic[8];
>>>              unsigned char ver[4];
>>>          };
>>>          static struct dosemu_detect far *p = (void far*) 0xF000FFE0;
>> Note that the way how you create far pointers can differ
>> between compilers. In particular, with any 32 bit memory
>> model, things would look quite differently. Just saying.
> Pointers and things around them are for me still a little
> incomprehensible ;)
If you want to program in C, then there is no way around it. For almost 
everything, and in particular when working with strings, you need to 
know what you are doing, as the C compiler is doing exactly what you are 
telling it to do, which in turn might not be what you want it to do...;-)
>
>>>          char magicexp[]="$DOSEMU$";          // expected string when on 
>>> DOSEMU
>>>
>>>          if (strcmp(p->magic, magicexp))      // p->magic == "$DOSEMU$" ?
>> You cannot strcmp this because the string is no C style
>> string with a NUL character at the end. You could use
>> strncmp(string1, string2, 8) to compare only the first
>> eight bytes, which will probably work fine for you :-)
> But 'magicexp' is null-terminated string, yes?
No.
>   Then comparison
> should stop at its length (or before, when p->magic is different
> or has null-byte before strlen(magicexp) ), I suppose that.
> And I tried to use some as
>    strncmp(p->magic, magicexp, strlen(magicexp))
> too and it also was not working.
That's not working because strlen() expects (like all C string 
functions) a NULL-terminated string. That's why Eric put a fixed 8 for 
the length to compare in his example...



---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to