Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r9b70dd4 r3f3ee61  
    9999}
    100100
    101 char *owl_function_style_describe(char *name) {
     101char *owl_function_style_describe(void *name) {
    102102  char *desc, *s;
    103103  owl_style *style;
     
    114114}
    115115
    116 char *owl_function_cmd_describe(char *name)
     116char *owl_function_cmd_describe(void *name)
    117117{
    118118  owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    172172}
    173173
    174 void owl_function_show_quickstart()
    175 {
    176     char *message =
    177     "Move between messages with the arrow keys, and press 'r' to reply.\n"
    178     "For more info, press 'h' or visit http://barnowl.mit.edu/\n\n"
    179 #ifdef HAVE_LIBZEPHYR
    180     "@b(Zephyr:)\n"
    181     "To send a message to a user, type ':zwrite @b(username)'. You can also\n"
    182     "press 'z' and then type the username. To subscribe to a class, type\n"
    183     "':sub @b(class)', and then type ':zwrite -c @b(class)' to send.\n\n"
    184 #endif
    185     "@b(AIM:)\n"
    186     "Log in to AIM with ':aimlogin @b(screenname)'. Use ':aimwrite @b(screenname)',\n"
    187     "or 'a' and then the screen name, to send someone a message.\n\n"
    188     ;
    189 
    190     if (owl_perlconfig_is_function("BarnOwl::Hooks::_get_quickstart")) {
    191         char *perlquickstart = owl_perlconfig_execute("BarnOwl::Hooks::_get_quickstart()");
    192         if (perlquickstart) {
    193             char *result = owl_sprintf("%s%s", message, perlquickstart);
    194             owl_function_adminmsg("BarnOwl Quickstart", result);
    195             owl_free(result);
    196             owl_free(perlquickstart);
    197             return;
    198         }
    199     }
    200     owl_function_adminmsg("BarnOwl Quickstart", message);
    201 }
    202 
    203 
    204174/* Create an admin message, append it to the global list of messages
    205175 * and redisplay if necessary.
     
    632602
    633603  if (!found) {
    634     owl_function_makemsg("already at last%s message%s%s%s",
     604    owl_function_makemsg("already at last%s message%s%s",
    635605                         skip_deleted?" non-deleted":"",
    636                          filter?" in ":"", filter?filter:"",
    637                          owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g)) ?
    638                          ", press Enter to scroll" : "");
     606                         filter?" in ":"", filter?filter:"");
    639607    /* if (!skip_deleted) owl_function_beep(); */
    640608  }
     
    10511019  owl_function_debugmsg("Quitting Owl");
    10521020  exit(0);
     1021}
     1022
     1023void owl_function_openurl()
     1024{
     1025  /* visit the first url in the current message */
     1026  owl_message *m;
     1027  owl_view *v;
     1028  char *ptr1, *ptr2, *text, url[LINE], tmpbuff[LINE];
     1029  int webbrowser;
     1030
     1031  webbrowser = owl_global_get_webbrowser(&g);
     1032
     1033  if (webbrowser < 0 || webbrowser == OWL_WEBBROWSER_NONE) {
     1034    owl_function_error("No browser selected");
     1035    return;
     1036  }
     1037
     1038  v=owl_global_get_current_view(&g);
     1039 
     1040  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
     1041
     1042  if (!m || owl_view_get_size(v)==0) {
     1043    owl_function_error("No current message selected");
     1044    return;
     1045  }
     1046
     1047  text=owl_message_get_text(m);
     1048
     1049  /* First look for a good URL */ 
     1050  if ((ptr1=strstr(text, "http://"))!=NULL) {
     1051    ptr2=strpbrk(ptr1, " \n\t");
     1052    if (ptr2) {
     1053      strncpy(url, ptr1, ptr2-ptr1+1);
     1054      url[ptr2-ptr1+1]='\0';
     1055    } else {
     1056      strcpy(url, ptr1);
     1057    }
     1058
     1059    /* if we had <http strip a trailing > */
     1060    if (ptr1>text && ptr1[-1]=='<') {
     1061      if (url[strlen(url)-1]=='>') {
     1062        url[strlen(url)-1]='\0';
     1063      }
     1064    }
     1065  } else if ((ptr1=strstr(text, "https://"))!=NULL) {
     1066    /* Look for an https URL */ 
     1067    ptr2=strpbrk(ptr1, " \n\t");
     1068    if (ptr2) {
     1069      strncpy(url, ptr1, ptr2-ptr1+1);
     1070      url[ptr2-ptr1+1]='\0';
     1071    } else {
     1072      strcpy(url, ptr1);
     1073    }
     1074   
     1075    /* if we had <http strip a trailing > */
     1076    if (ptr1>text && ptr1[-1]=='<') {
     1077      if (url[strlen(url)-1]=='>') {
     1078        url[strlen(url)-1]='\0';
     1079      }
     1080    }
     1081  } else if ((ptr1=strstr(text, "www."))!=NULL) {
     1082    /* if we can't find a real url look for www.something */
     1083    ptr2=strpbrk(ptr1, " \n\t");
     1084    if (ptr2) {
     1085      strncpy(url, ptr1, ptr2-ptr1+1);
     1086      url[ptr2-ptr1+1]='\0';
     1087    } else {
     1088      strcpy(url, ptr1);
     1089    }
     1090  } else {
     1091    owl_function_beep();
     1092    owl_function_error("Could not find URL to open.");
     1093    return;
     1094  }
     1095
     1096  /* Make sure there aren't any quotes or \'s in the url */
     1097  for (ptr1 = url; *ptr1; ptr1++) {
     1098    if (*ptr1 == '"' || *ptr1 == '\\') {
     1099      owl_function_beep();
     1100      owl_function_error("URL contains invalid characters.");
     1101      return;
     1102    }
     1103  }
     1104 
     1105  /* NOTE: There are potentially serious security issues here... */
     1106
     1107  /* open the page */
     1108  owl_function_makemsg("Opening %s", url);
     1109  if (webbrowser == OWL_WEBBROWSER_NETSCAPE) {
     1110    snprintf(tmpbuff, LINE, "netscape -remote \"openURL(%s)\" > /dev/null 2> /dev/null", url);
     1111    system(tmpbuff);
     1112  } else if (webbrowser == OWL_WEBBROWSER_GALEON) {
     1113    snprintf(tmpbuff, LINE, "galeon \"%s\" > /dev/null 2> /dev/null &", url);
     1114    system(tmpbuff);
     1115  } else if (webbrowser == OWL_WEBBROWSER_OPERA) {
     1116    snprintf(tmpbuff, LINE, "opera \"%s\" > /dev/null 2> /dev/null &", url);
     1117    system(tmpbuff);
     1118  }
    10531119}
    10541120
     
    15441610        /* fix this */
    15451611        sprintf(buff, "  Checkd Ath: %i\n", n->z_checked_auth);
    1546         sprintf(buff + strlen(buff), "  Multi notc: %s\n", n->z_multinotice);
    1547         sprintf(buff + strlen(buff), "  Num other : %i\n", n->z_num_other_fields);
    1548         sprintf(buff + strlen(buff), "  Msg Len   : %i\n", n->z_message_len);
     1612        sprintf(buff, "%s  Multi notc: %s\n", buff, n->z_multinotice);
     1613        sprintf(buff, "%s  Num other : %i\n", buff, n->z_num_other_fields);
     1614        sprintf(buff, "%s  Msg Len   : %i\n", buff, n->z_message_len);
    15491615        owl_fmtext_append_normal(&fm, buff);
    15501616       
     
    18561922void owl_function_status()
    18571923{
    1858   char buff[MAXPATHLEN+1];
     1924  char buff[5000];
    18591925  time_t start;
    18601926  int up, days, hours, minutes;
     
    18761942
    18771943  owl_fmtext_append_normal(&fm, "  Current Directory: ");
    1878   if(getcwd(buff, MAXPATHLEN) == NULL) {
    1879     owl_fmtext_append_normal(&fm, "<Error in getcwd>");
    1880   } else {
    1881     owl_fmtext_append_normal(&fm, buff);
    1882   }
     1944  (void) getcwd(buff, MAXPATHLEN);
     1945  owl_fmtext_append_normal(&fm, buff);
    18831946  owl_fmtext_append_normal(&fm, "\n");
    18841947
     
    19892052        return;
    19902053      }
    1991     }
    1992 
    1993     /* then check if it's a question and just bring up the command prompt */
    1994     if (owl_message_is_question(m)) {
    1995       owl_function_start_command("");
    1996       return;
    19972054    }
    19982055
     
    24912548  sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass);
    24922549  if (tmpinstance) {
    2493     sprintf(argbuff + strlen(argbuff), " and ( instance ^(un)*%s(\\.d)*$ )", tmpinstance);
     2550    sprintf(argbuff, "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance);
    24942551  }
    24952552  owl_free(tmpclass);
     
    25202577{
    25212578  owl_filter *f;
    2522   char *argbuff, *longuser, *esclonguser, *shortuser, *filtname;
     2579  char *argbuff, *longuser, *shortuser, *filtname;
    25232580
    25242581  /* stick the local realm on if it's not there */
     
    25272584
    25282585  /* name for the filter */
    2529   filtname=owl_sprintf("user-%s", shortuser);
     2586  filtname=owl_malloc(strlen(shortuser)+20);
     2587  sprintf(filtname, "user-%s", shortuser);
    25302588
    25312589  /* if it already exists then go with it.  This lets users override */
     
    25372595  f=owl_malloc(sizeof(owl_filter));
    25382596
    2539   esclonguser = owl_text_quote(longuser, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2540 
    2541   argbuff=owl_sprintf("( type ^zephyr$ and filter personal and "
    2542       "( ( direction ^in$ and sender ^%1$s$ ) or ( direction ^out$ and "
    2543       "recipient ^%1$s$ ) ) ) or ( ( class ^login$ ) and ( sender ^%1$s$ ) )",
    2544       esclonguser);
     2597  argbuff=owl_malloc(strlen(longuser)+1000);
     2598  sprintf(argbuff, "( type ^zephyr$ and filter personal and ");
     2599  sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser);
     2600  sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) )", argbuff, longuser);
    25452601
    25462602  owl_filter_init_fromstring(f, filtname, argbuff);
     
    25522608  owl_free(argbuff);
    25532609  owl_free(longuser);
    2554   owl_free(esclonguser);
    25552610  owl_free(shortuser);
    25562611
     
    25712626
    25722627  /* name for the filter */
    2573   filtname=owl_sprintf("aimuser-%s", user);
     2628  filtname=owl_malloc(strlen(user)+40);
     2629  sprintf(filtname, "aimuser-%s", user);
    25742630
    25752631  /* if it already exists then go with it.  This lets users override */
     
    25832639  escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    25842640
    2585   argbuff = owl_sprintf(
    2586       "( type ^aim$ and ( ( sender ^%1$s$ and recipient ^%2$s$ ) or "
    2587       "( sender ^%2$s$ and recipient ^%1$s$ ) ) )",
    2588       escuser, owl_global_get_aim_screenname_for_filters(&g));
     2641  argbuff=owl_malloc(1000);
     2642  sprintf(argbuff,
     2643          "( type ^aim$ and ( ( sender ^%s$ and recipient ^%s$ ) or ( sender ^%s$ and recipient ^%s$ ) ) )",
     2644          escuser, owl_global_get_aim_screenname_for_filters(&g),
     2645          owl_global_get_aim_screenname_for_filters(&g), escuser);
    25892646
    25902647  owl_filter_init_fromstring(f, filtname, argbuff);
     
    26032660{
    26042661  owl_filter *f;
    2605   char *argbuff, *filtname, *esctype;
     2662  char *argbuff, *filtname;
    26062663
    26072664  /* name for the filter */
     
    26162673  f=owl_malloc(sizeof(owl_filter));
    26172674
    2618   esctype = owl_text_quote(type, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2619 
    2620   argbuff = owl_sprintf("type ^%s$", esctype);
     2675  argbuff = owl_sprintf("type ^%s$", type);
    26212676
    26222677  owl_filter_init_fromstring(f, filtname, argbuff);
     
    26272682  /* free stuff */
    26282683  owl_free(argbuff);
    2629   owl_free(esctype);
    26302684
    26312685  return filtname;
     
    29012955    owl_text_tr(quoted, '\'', '.');
    29022956    owl_text_tr(quoted, '"', '.');
    2903     sprintf(buff + strlen(buff), " ^(un)*%s(\\.d)*$", quoted);
     2957    sprintf(buff, "%s ^(un)*%s(\\.d)*$", buff, quoted);
    29042958    owl_free(quoted);
    29052959  }
     
    29112965    owl_text_tr(quoted, '\'', '.');
    29122966    owl_text_tr(quoted, '"', '.');
    2913     sprintf(buff + strlen(buff), " and instance ^(un)*%s(\\.d)*$", quoted);
     2967    sprintf(buff, "%s and instance ^(un)*%s(\\.d)*$", buff, quoted);
    29142968    owl_free(quoted);
    29152969  }
     
    29192973    owl_text_tr(quoted, '\'', '.');
    29202974    owl_text_tr(quoted, '"', '.');
    2921     sprintf(buff + strlen(buff), " and recipient ^%s$", quoted);
     2975    sprintf(buff, "%s and recipient ^%s$", buff, quoted);
    29222976    owl_free(quoted);
    29232977  }
     
    30113065}
    30123066
    3013 char *owl_function_keymap_summary(char *name)
     3067char *owl_function_keymap_summary(void *name)
    30143068{
    30153069  owl_keymap *km
Note: See TracChangeset for help on using the changeset viewer.