Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r3f3ee61 r9b70dd4  
    9999}
    100100
    101 char *owl_function_style_describe(void *name) {
     101char *owl_function_style_describe(char *name) {
    102102  char *desc, *s;
    103103  owl_style *style;
     
    114114}
    115115
    116 char *owl_function_cmd_describe(void *name)
     116char *owl_function_cmd_describe(char *name)
    117117{
    118118  owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    172172}
    173173
     174void 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
    174204/* Create an admin message, append it to the global list of messages
    175205 * and redisplay if necessary.
     
    602632
    603633  if (!found) {
    604     owl_function_makemsg("already at last%s message%s%s",
     634    owl_function_makemsg("already at last%s message%s%s%s",
    605635                         skip_deleted?" non-deleted":"",
    606                          filter?" in ":"", filter?filter:"");
     636                         filter?" in ":"", filter?filter:"",
     637                         owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g)) ?
     638                         ", press Enter to scroll" : "");
    607639    /* if (!skip_deleted) owl_function_beep(); */
    608640  }
     
    10191051  owl_function_debugmsg("Quitting Owl");
    10201052  exit(0);
    1021 }
    1022 
    1023 void 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   }
    11191053}
    11201054
     
    16101544        /* fix this */
    16111545        sprintf(buff, "  Checkd Ath: %i\n", n->z_checked_auth);
    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);
     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);
    16151549        owl_fmtext_append_normal(&fm, buff);
    16161550       
     
    19221856void owl_function_status()
    19231857{
    1924   char buff[5000];
     1858  char buff[MAXPATHLEN+1];
    19251859  time_t start;
    19261860  int up, days, hours, minutes;
     
    19421876
    19431877  owl_fmtext_append_normal(&fm, "  Current Directory: ");
    1944   (void) getcwd(buff, MAXPATHLEN);
    1945   owl_fmtext_append_normal(&fm, buff);
     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  }
    19461883  owl_fmtext_append_normal(&fm, "\n");
    19471884
     
    20521989        return;
    20531990      }
     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;
    20541997    }
    20551998
     
    25482491  sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass);
    25492492  if (tmpinstance) {
    2550     sprintf(argbuff, "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance);
     2493    sprintf(argbuff + strlen(argbuff), " and ( instance ^(un)*%s(\\.d)*$ )", tmpinstance);
    25512494  }
    25522495  owl_free(tmpclass);
     
    25772520{
    25782521  owl_filter *f;
    2579   char *argbuff, *longuser, *shortuser, *filtname;
     2522  char *argbuff, *longuser, *esclonguser, *shortuser, *filtname;
    25802523
    25812524  /* stick the local realm on if it's not there */
     
    25842527
    25852528  /* name for the filter */
    2586   filtname=owl_malloc(strlen(shortuser)+20);
    2587   sprintf(filtname, "user-%s", shortuser);
     2529  filtname=owl_sprintf("user-%s", shortuser);
    25882530
    25892531  /* if it already exists then go with it.  This lets users override */
     
    25952537  f=owl_malloc(sizeof(owl_filter));
    25962538
    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);
     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);
    26012545
    26022546  owl_filter_init_fromstring(f, filtname, argbuff);
     
    26082552  owl_free(argbuff);
    26092553  owl_free(longuser);
     2554  owl_free(esclonguser);
    26102555  owl_free(shortuser);
    26112556
     
    26262571
    26272572  /* name for the filter */
    2628   filtname=owl_malloc(strlen(user)+40);
    2629   sprintf(filtname, "aimuser-%s", user);
     2573  filtname=owl_sprintf("aimuser-%s", user);
    26302574
    26312575  /* if it already exists then go with it.  This lets users override */
     
    26392583  escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    26402584
    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);
     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));
    26462589
    26472590  owl_filter_init_fromstring(f, filtname, argbuff);
     
    26602603{
    26612604  owl_filter *f;
    2662   char *argbuff, *filtname;
     2605  char *argbuff, *filtname, *esctype;
    26632606
    26642607  /* name for the filter */
     
    26732616  f=owl_malloc(sizeof(owl_filter));
    26742617
    2675   argbuff = owl_sprintf("type ^%s$", type);
     2618  esctype = owl_text_quote(type, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
     2619
     2620  argbuff = owl_sprintf("type ^%s$", esctype);
    26762621
    26772622  owl_filter_init_fromstring(f, filtname, argbuff);
     
    26822627  /* free stuff */
    26832628  owl_free(argbuff);
     2629  owl_free(esctype);
    26842630
    26852631  return filtname;
     
    29552901    owl_text_tr(quoted, '\'', '.');
    29562902    owl_text_tr(quoted, '"', '.');
    2957     sprintf(buff, "%s ^(un)*%s(\\.d)*$", buff, quoted);
     2903    sprintf(buff + strlen(buff), " ^(un)*%s(\\.d)*$", quoted);
    29582904    owl_free(quoted);
    29592905  }
     
    29652911    owl_text_tr(quoted, '\'', '.');
    29662912    owl_text_tr(quoted, '"', '.');
    2967     sprintf(buff, "%s and instance ^(un)*%s(\\.d)*$", buff, quoted);
     2913    sprintf(buff + strlen(buff), " and instance ^(un)*%s(\\.d)*$", quoted);
    29682914    owl_free(quoted);
    29692915  }
     
    29732919    owl_text_tr(quoted, '\'', '.');
    29742920    owl_text_tr(quoted, '"', '.');
    2975     sprintf(buff, "%s and recipient ^%s$", buff, quoted);
     2921    sprintf(buff + strlen(buff), " and recipient ^%s$", quoted);
    29762922    owl_free(quoted);
    29772923  }
     
    30653011}
    30663012
    3067 char *owl_function_keymap_summary(void *name)
     3013char *owl_function_keymap_summary(char *name)
    30683014{
    30693015  owl_keymap *km
Note: See TracChangeset for help on using the changeset viewer.