Changeset 895 for trunk


Ignore:
Timestamp:
Dec 30, 2007, 12:46:11 AM (18 years ago)
Author:
Gregg Young
Message:

Added remove_first_occurence_of_character to strip.c; Refined mailrun to use <mailto:> syntax;

Location:
trunk/dll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/fm3dll.h

    r892 r895  
    6666  22 Nov 07 GKY Use CopyPresParams in CheckMenu to fix presparam inconsistencies in menus
    6767  17 Dec 07 GKY Add variables for using WPURLDEFAULTSETTINGS as the fall back for ftphttprun
     68  29 Dec 07 GKY Add remove_first_occurence_of_character
    6869
    6970***********************************************************************/
     
    832833void strip_lead_char(char *pszStripChars, char *pszSrc);
    833834void strip_trail_char(char *pszStripChars, char *pszSrc);
     835VOID remove_first_occurence_of_character(char *pszRemoveChar, char *pszSrc);
    834836
    835837#define lstrip(s)         strip_lead_char(" \t",(s))
  • trunk/dll/newview.c

    r894 r895  
    2828  17 Dec 07 GKY Make WPURLDEFAULTSETTINGS the fall back for ftp/httprun
    2929  28 Dec 07 GKY Add mailrun to allow mailto by clicking on an email address in the viewer
     30  29 Dec 07 GKY Formated email address using "<mailto:"
    3031
    3132***********************************************************************/
     
    7879#define COLORS_MAILFORE              13
    7980
    80 static LONG Colors[COLORS_MAX] = { COLR_WHITE, COLR_DARKGRAY,
     81static LONG Colors[COLORS_MAX] = {
     82  COLR_WHITE, COLR_DARKGRAY,
    8183  COLR_PALEGRAY, COLR_BLACK,
    8284  COLR_BLACK, COLR_RED,
     
    9193typedef struct
    9294{
    93   USHORT size;
    94   USHORT flags;
    95   USHORT cliptype;
    96   CHAR filename[CCHMAXPATH];
     95  FATTRS fattrs;
     96  LONG colors[COLORS_MAX];
    9797  CHAR *text;
    9898  CHAR **lines, *markedlines;
     
    100100  ULONG textsize, numlines, topline, cursored, selected, numalloc, multiplier,
    101101    lastselected, found;
    102   CHAR stopflag, busy;
    103102  LONG oldwidth, lastdirection, lMaxAscender, lMaxDescender, lMaxHeight,
    104103    maxx, horzscroll;
    105   BOOL hex, mousecaptured, sensitive, dummy, literalsearch, clientfocused,
    106     alsoselect, wrapon, relining, httpin, ftpin, mailin, ignorehttp, ignoreftp,
    107     ignoremail, needrefreshing;
    108104  HMTX ScanSem;
    109105  HWND hvscroll, hwndMenu, hwndStatus1, hwndStatus2, hwndStatus3, hwndRestore,
    110106    hwndPopup, hwndListbox, hwndFrame, hwndDrag, hwndParent, hhscroll;
    111107  HPS hps;
    112   FATTRS fattrs;
    113   LONG colors[COLORS_MAX];
     108  USHORT size;
     109  USHORT flags;
     110  USHORT cliptype;
     111  CHAR filename[CCHMAXPATH];
     112  CHAR stopflag, busy;
     113  BOOL hex, mousecaptured, sensitive, dummy, literalsearch, clientfocused,
     114    alsoselect, wrapon, relining, httpin, ftpin, mailin, ignorehttp, ignoreftp,
     115    ignoremail, needrefreshing;
    114116}
    115117VIEWDATA;
     
    117119typedef struct
    118120{
     121  ULONG len;
     122  CHAR *line;
    119123  USHORT size;
    120124  USHORT dummy;
    121   ULONG len;
    122   CHAR *line;
    123125  CHAR url[SEARCHSTRINGLEN];
    124126}
     
    137139
    138140// mailstr checks for a designated character in a string then cuts the string
    139 //to the first word that contains the character
    140 
    141 CHAR *mailstr(CHAR *t, CHAR *s, LONG lens)
     141//to the first word that contains the character then prepends <mailto: and appends >
     142
     143CHAR *mailstr(CHAR *pszSrc, CHAR *pszFindChar, LONG StrLens)
    142144{
    143   CHAR *pp;
    144   CHAR *test = t;
    145 
    146   if (!strnstr(test, s, lens))
     145  CHAR *pszCharCounter;
     146  CHAR *pszTestStr = pszSrc;
     147  CHAR szMailTo[1024] = "<mailto:";
     148  CHAR szMailEnd[] = ">";
     149
     150  if (!strnstr(pszTestStr, pszFindChar, StrLens))
    147151    return NULL;
    148   bstripcr(t);
    149   if (!strstr(t, " "))
    150     return t;
    151   while (strchr(t, ' ') < strchr(t, (CHAR) s)){
    152     pp = t;
    153     while (*pp && *pp != ' '){
    154       *pp = ' ';
    155       pp++;
    156     }
    157       lstrip(t);
     152  bstripcr(pszSrc);
     153  remove_first_occurence_of_character("\r", pszSrc);
     154  remove_first_occurence_of_character("\n", pszSrc);
     155  if (!strstr(pszSrc, " ")){
     156    if (!stristr(pszSrc, "<mailto:")) {
     157      strip_lead_char("<", pszSrc);
     158      strip_trail_char(">", pszSrc);
     159      strcat(szMailTo, pszSrc);
     160      strcat(szMailTo, szMailEnd);
     161      pszSrc = szMailTo;
     162      return pszSrc;
     163    }
     164    else {
     165      return pszSrc;
     166    }
    158167  }
    159   pp = t;
    160   while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' &&
    161          *pp != '\"')
    162     pp++;
    163   *pp = 0;
    164   strip_lead_char(t, "<");
    165   strip_trail_char(t, ">");
    166   return t;
     168  while (strchr(pszSrc, ' ') < strchr(pszSrc, *pszFindChar)){
     169    pszCharCounter = pszSrc;
     170    while (*pszCharCounter && *pszCharCounter != ' '){
     171      *pszCharCounter = ' ';
     172      pszCharCounter++;
     173    }
     174    lstrip(pszSrc);
     175  }
     176  pszCharCounter = pszSrc;
     177  while (*pszCharCounter && *pszCharCounter != ' ' && *pszCharCounter != '\r' &&
     178         *pszCharCounter != '\n' && *pszCharCounter != '\"')
     179    pszCharCounter++;
     180  *pszCharCounter = 0;
     181  if (!stristr(pszSrc, "<mailto:")) {
     182    strip_lead_char("<", pszSrc);
     183    strip_trail_char(">", pszSrc);
     184    strcat(szMailTo, pszSrc);
     185    strcat(szMailTo, szMailEnd);
     186    pszSrc = szMailTo;
     187    return pszSrc;
     188    }
     189  else {
     190    return pszSrc;
     191  }
    167192}
    168193
     
    216241      p = urld->line;
    217242      if (mailstr(p, "@", e - p)) {
    218         strcpy(urld->url, p);
     243        pp = mailstr(p, "@", e - p);
     244        strcpy(urld->url, pp);
    219245        WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM,
    220246                          MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url));
  • trunk/dll/strips.c

    r793 r895  
    1212  26 Jul 06 SHL Add chop_at_crnl
    1313  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
     14  29 Dec 07 GKY Add remove_first_occurence_of_character
    1415
    1516***********************************************************************/
     
    7172}
    7273
     74VOID remove_first_occurence_of_character(char *pszRemoveChar, char *pszSrc)
     75{
     76  PSZ pszStrLocation;
     77
     78  pszStrLocation = strchr(pszSrc, *pszRemoveChar);
     79  if (pszStrLocation)
     80    memmove(pszStrLocation, pszStrLocation + 1, strlen(pszStrLocation) + 1);
     81}
     82
    7383#pragma alloc_text(MISC8,chop_at_crnl,convert_nl_to_nul,strip_trail_char,strip_lead_char)
Note: See TracChangeset for help on using the changeset viewer.