NO

Author Topic: Additions to Strlib.lib  (Read 9012 times)

JohnF

  • Guest
Additions to Strlib.lib
« on: September 24, 2004, 09:53:43 am »
Because Pelle added _vsnwprintf() to his libc.lib I have been able to add the wide char functions for str_asprintf() - these functions allocate the destination buffer, also added str_ccat.

Functions added
long str_ccat(char* pszDest, size_t cchDest, int numargs, ...);
long str_ccatx(char* pszDest, size_t cchDest, size_t* pLength, int numargs, ...);
long str_asprintf(char ** pszDest, const char* pszFormat, ...);
long str_asprintfx(char ** pszDest, size_t * pLength, const char* pszFormat, ...);

WideChar equivalents
long str_wccat(wchar_t* pszDest, size_t cchDest, int numargs, ...);
long str_wccatx(wchar_t* pszDest, size_t cchDest, size_t* pLength, int numargs, ...);
long str_aswprintf(wchar_t ** pszDest, const wchar_t* pszFormat, ...);
long str_aswprintfx(wchar_t ** pszDest, size_t * pLength, const wchar_t* pszFormat, ...);
=====================

str_ccat() will concatenate any number of null terminated strings. This is more efficient than using either str_sprintf or multiple calls to str_cat.

str_asprintf() allocates the required memory from the heap for the destination buffer, the buffer must be free-ed by the user.

As with all functions in this library (except str_asprintf) the destination size is passed making buffer overruns not possible - the 'X' functions will return the final size in pLength.

[can't find the attachment feature]

http://www.btinternet.com/~john.findlay1/Strlib.zip

John

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2181
    • http://www.smorgasbordet.com
Additions to Strlib.lib
« Reply #1 on: September 24, 2004, 11:08:22 pm »
Nice! Thanks!

The attachment feature *should* be there. Vortex have had some problems too. It works for me (because I'm the Administrator?).

Pelle
/Pelle

BiMode

  • Guest
Additions to Strlib.lib
« Reply #2 on: September 25, 2004, 02:52:42 am »
Well, It disappears on my end too.  :?:

Offline Robert

  • Member
  • *
  • Posts: 216
I can't see it either
« Reply #3 on: September 25, 2004, 03:55:02 am »
I, as well, can not see the Attachments portion of the Post a Reply box. The last thing above the Preview and Submit buttons is the "Notify me when a reply is posted" checkbox.

I am logged in.

Robert Wishlaw

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2181
    • http://www.smorgasbordet.com
Additions to Strlib.lib
« Reply #4 on: September 25, 2004, 04:46:50 am »
It should work now.

Pelle
/Pelle

JohnF

  • Guest
Additions to Strlib.lib
« Reply #5 on: September 25, 2004, 08:14:21 am »
Quote from: "Pelle"
It should work now.

Pelle


Thanks, trying with strlib.zip

Seems to be ok now.


John

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2181
    • http://www.smorgasbordet.com
Additions to Strlib.lib
« Reply #6 on: September 25, 2004, 10:46:37 am »
Great. A typical case of RTFM.

Pelle
/Pelle

JohnF

  • Guest
Additions to Strlib.lib
« Reply #7 on: September 25, 2004, 11:21:08 am »
Quote from: "Pelle"
Great. A typical case of RTFM.

Pelle


:)

Images and attachments only for logged in users, is that right?

John

Offline Robert

  • Member
  • *
  • Posts: 216
Log in to win !
« Reply #8 on: September 25, 2004, 11:28:32 am »
Quote from: "JohnF"
Quote from: "Pelle"
Great. A typical case of RTFM.

Pelle


:)

Images and attachments only for logged in users, is that right?

John


On this forum, a reply can not be posted unless logged in.

The attachment dialog is now functioning as expected.

Thank you.

Robert Wishlaw

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2181
    • http://www.smorgasbordet.com
Additions to Strlib.lib
« Reply #9 on: September 25, 2004, 11:39:36 am »
The problem was with the per forum permission settings. They can be viewed in 'simple' or 'advanced' mode. The 'advanced' mode contains (in my opinion) too much information, so at one point I switched to 'simple' mode. This changed the permissions for attachments to 'administrator' (or something like that). Probably because the attachment feature is not part of the base package (add-on). Not so easy to figure out...

Pelle
/Pelle

JohnF

  • Guest
Additions to Strlib.lib
« Reply #10 on: September 25, 2004, 01:03:43 pm »
Quote from: "Pelle"
The problem was with the per forum permission settings. They can be viewed in 'simple' or 'advanced' mode. The 'advanced' mode contains (in my opinion) too much information, so at one point I switched to 'simple' mode. This changed the permissions for attachments to 'administrator' (or something like that). Probably because the attachment feature is not part of the base package (add-on). Not so easy to figure out...

Pelle


It's not important for me - I was wondering you you wanted it that way.

John

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2181
    • http://www.smorgasbordet.com
Additions to Strlib.lib
« Reply #11 on: September 25, 2004, 01:39:56 pm »
At least for 'Bug reports' and 'Feature requests' I prefer to have something other than 'guest'. Maybe I should remove the requirement to log in for the other forums...?

Pelle
/Pelle

JohnF

  • Guest
Additions to Strlib.lib
« Reply #12 on: September 25, 2004, 02:35:04 pm »
Quote from: "Pelle"
At least for 'Bug reports' and 'Feature requests' I prefer to have something other than 'guest'. Maybe I should remove the requirement to log in for the other forums...?

Pelle


Yes, that is probably the right way to go.

John

JohnF

  • Guest
Additions to Strlib.lib
« Reply #13 on: September 25, 2004, 05:19:28 pm »
Updated strlib.zip

Bug found in str_ccat and family

added code to trap another possible overrun.

Code: [Select]

// go to the end of the dest string
while(*pszDest)
{
pszDest++;
cchDest--;
if(cchDest == 0)
return STR_E_INSUFFICIENT_BUFFER;
}


John