well ive allocated some memory to receive some information. the information im getting is in there but im confused on how i would check to see if a single period is on a line by itself.

the inforamtion ill be working with will always contain more than one line. so let say the allocated memory holds these lines:

alt.personals.test0 0000074573 0000074539 y
alt.personals.test1 0000074573 0000074539 y
alt.personals.test223 0000074573 0000074539 y
. ;<---single line with a period.. this line should be the last line in memory.


according to the rfc for nntp the period indicates that it is the end of the newsgroup listing.

any ideas how i check for the period?
Posted on 2002-01-07 22:13:03 by smurf
Should the period not be preceded and followed by a CRLF (0x0D, 0x0A), or have a terminating NULL at the end? Also, is it unicode or ascii?
Posted on 2002-01-07 22:24:08 by sluggy
this is what information i got from the nntp rfc

2.2. Character Codes

Commands and replies are composed of characters from the ASCII
character set. When the transport service provides an 8-bit byte
(octet) transmission channel, each 7-bit character is transmitted
right justified in an octet with the high order bit cleared to zero.

2.4.1. Text Responses

Text is sent only after a numeric status response line has been sent
that indicates that text will follow. Text is sent as a series of
successive lines of textual matter, each terminated with CR-LF pair.
A single line containing only a period (.) is sent to indicate the
end of the text (i.e., the server will send a CR-LF pair at the end
of the last line of text, a period, and another CR-LF pair).

If the text contained a period as the first character of the text
line in the original, that first period is doubled. Therefore, the
client must examine the first character of each line received, and
for those beginning with a period, determine either that this is the
end of the text or whether to collapse the doubled period to a single
one.

The intention is that text messages will usually be displayed on the
user's terminal whereas command/status responses will be interpreted
by the client program before any possible display is done.


so it appears the info im searching through is acsii.
also the last line with only a period should be CR-LF CR-LF
Posted on 2002-01-07 22:38:39 by smurf
so it appears the info im searching through is acsii.
also the last line with only a period should be CR-LF CR-LF

Okay, i would say that you need to search for the byte pattern:

0D 0A 2E 0D 0A

which is hex for:

CR LF . CR LF

as this is sitting in a buffer, and they are only single bytes, i am not sure if there is going to be any little-endian swapping around on them.
Posted on 2002-01-07 23:02:55 by sluggy
hi sluggy one thing i have a pretty good understanding is the windows api and how i can make it work to create an asm program. my problem is that i struggle with the actual asm coding. so now im hoping someone can give me an example of how i would search in a memory block for what im looking for.

so if my memory contains:

alt.personals.test0 0000074573 0000074539 y
alt.personals.test1 0000074573 0000074539 y
alt.personals.test223 0000074573 0000074539 y
. ;<-- the CR-LF . CR-LF im looking for

and i want to try and locate CR-LF . CR-LF

how would i go about this?
Posted on 2002-01-08 12:36:40 by smurf
For faster testing, you might want to load more than a byte at a time from memory?
         00 01 02 03 00 ; Alignment

---------------
?? ?? ?? 0D 0A 2E 0D 0A
?? ?? 0D 0A 2E 0D 0A xx
?? 0D 0A 2E 0D 0A xx xx
0D 0A 2E 0D 0A xx xx xx
Posted on 2002-01-08 13:34:37 by bitRAKE
no habla asm BitRAKE :confused:

hi bitrake im sure that would mean alot to someone who has half a brain cell but unfortunatly i only have a quarter of one left.

you wouldnt happen to have a some code up your sleeve would ya?
Posted on 2002-01-08 13:45:55 by smurf
Use scasd ito scan a dword in a buffer. For example :


BUFFER_SIZE = 256 ; buffer size
PATTERN = 0Dh OR (0Ah SHL 8) OR (2Eh SHL 16) OR (0Dh SHL 24)
; pattern to match CR CL . CR

.CODE
mov ecx, BUFFER_SIZE
mov eax, PATTERN
mov edi, offset buffer
repne scasd
or ecx, ecx
jz NotFound

; test last byte
cmp BYTE PTR [edi], 0Ah
jz NotFound

; Found...

NotFound :

; not found...
Posted on 2002-01-08 15:48:51 by Dr. Manhattan
Q. What if the search string isn't dword aligned?

A. That algo doesn't work.
Posted on 2002-01-08 16:04:03 by bitRAKE
This might not even work. Composed on my break in a couple minutes, never assembled before. It's many times slower than much fast ways - too many branches. I'll test it when I get home:
xLoop:

mov eax,[edx]
add edx,4
cmp ax,0a0dh
je A_case
bswap eax
cmp ax,0d0ah
je B_case
XX_case:
sub ecx,4
jg xloop
xor eax,eax ; error
ret

A_case:
cmp eax,0d2e0a0d
je AA_case
cmp WORD PTR [edx-6],2e0ah
jne XX_case
cmp BYTE PTR [edx-7],0dh
jne XX_case
lea eax,[edx-7]
ret
AA_case:
cmp BYTE PTR [edx],0ah
jne XX_case
lea eax,[edx-4]
ret

B_case:
cmp eax,0a2e0d0a
je BB_case
cmp WORD PTR [edx],0d2eh
jne XX_case
cmp BYTE PTR [edx+2],0ah
jne XX_case
lea eax,[edx-2]
ret
BB_case:
cmp BYTE PTR [edx-5],0dh
jne XX_case
lea eax,[edx-5]
ret
Posted on 2002-01-08 17:14:10 by bitRAKE
There are number of search algos in the MASM32 library that should give you an idea of how to search for the terminator you want. It sounds like a period followed by a CR/LF so just search for the three bytes and it should do the job for you.

Regards,

hutch@movsd.com
Posted on 2002-01-08 19:12:15 by hutch--