Changeset 38cf544c
- Timestamp:
- Jun 4, 2003, 12:04:54 AM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 96f8e5b
- Parents:
- fd93b41
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rfd93b41 r38cf544c 82 82 WORK yet 83 83 Removed a bit of faim code that allowed commands to be executed. 84 84 The 'B' key is now bound to 'alist' 85 Added the 'startup' and 'unstartup' commands 86 The $HOME/.owl directory is created on startup if it does not exist 85 87 86 88 1.2.8 -
buddylist.c
raa5f725 r38cf544c 72 72 73 73 void owl_buddylist_clear(owl_buddylist *b) { 74 int i, j;75 76 74 owl_list_free_all(&(b->buddies), owl_free); 77 75 owl_list_create(&(b->buddies)); -
commands.c
rfd93b41 r38cf544c 159 159 "are used print the value of all variables.\n"), 160 160 161 OWLCMD_ARGS("startup", owl_command_startup, OWL_CTX_ANY, 162 "run a command and set it to be run at every Owl startup", 163 "startup <commands> ...", 164 "Everything on the command line after the startup command\n" 165 "is executed as a normal owl command and is also placed in\n" 166 "a file so that the command is executed every time owl\n" 167 "is started"), 168 169 OWLCMD_ARGS("unstartup", owl_command_unstartup, OWL_CTX_ANY, 170 "remove a command from the list of those to be run at Owl startup", 171 "unstartup <commands> ...", 172 ""), 173 161 174 OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY, 162 175 "print the version of the running owl", "", ""), … … 201 214 "add a buddy to a buddylist", 202 215 "addbuddy aim <screenname>", 203 "Add the named buddy to your buddylist. Eventually other protocols, "204 "such as zephyr, will also be able to use this command. For now the "216 "Add the named buddy to your buddylist. Eventually other protocols,\n" 217 "such as zephyr, will also be able to use this command. For now the\n" 205 218 "only available protocol is 'aim', specified as the first argument."), 206 219 … … 208 221 "delete a buddy from a buddylist", 209 222 "delbuddy aim <screenname>", 210 "Delete the named buddy to your buddylist. Eventually other protocols, "211 "such as zephyr, will also be able to use this command. For now the "212 "only available protocol is 'aim', specified as the first argument. "),223 "Delete the named buddy to your buddylist. Eventually other protocols,\n" 224 "such as zephyr, will also be able to use this command. For now the\n" 225 "only available protocol is 'aim', specified as the first argument.\n"), 213 226 214 227 OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE, … … 909 922 owl_aim_delbuddy(argv[2]); 910 923 owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g)); 924 925 return(NULL); 926 } 927 928 char *owl_command_startup(int argc, char **argv, char *buff) 929 { 930 char *ptr; 931 932 if (argc<2) { 933 owl_function_makemsg("usage: %s <commands> ...", argv[0]); 934 return(NULL); 935 } 936 937 /* we'll be pedantic here, just in case this command gets another name 938 * (or is aliased) start after the first space on the line 939 */ 940 ptr=strchr(buff, ' '); 941 if (!ptr) { 942 owl_function_makemsg("Parse error finding command for startup"); 943 return(NULL); 944 } 945 946 owl_function_command(ptr+1); 947 owl_function_addstartup(ptr+1); 948 949 return(NULL); 950 } 951 952 char *owl_command_unstartup(int argc, char **argv, char *buff) 953 { 954 char *ptr; 955 956 if (argc<2) { 957 owl_function_makemsg("usage: %s <commands> ...", argv[0]); 958 return(NULL); 959 } 960 961 /* we'll be pedantic here, just in case this command gets another name 962 * (or is aliased) start after the first space on the line 963 */ 964 ptr=strchr(buff, ' '); 965 if (!ptr) { 966 owl_function_makemsg("Parse error finding command for unstartup"); 967 return(NULL); 968 } 969 970 owl_function_delstartup(ptr+1); 911 971 912 972 return(NULL); -
functions.c
raa5f725 r38cf544c 2895 2895 printf("\033[1t"); 2896 2896 } 2897 2898 /* Add the specified command to the startup file. Eventually this 2899 * should be clever, and rewriting settings that will obviosly 2900 * override earlier settings with 'set' 'bindkey' and 'alias' 2901 * commands. For now though we just append to the startupfile. 2902 */ 2903 void owl_function_addstartup(char *buff) 2904 { 2905 FILE *file; 2906 char *filename; 2907 2908 filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE); 2909 file=fopen(filename, "a"); 2910 owl_free(filename); 2911 if (!file) { 2912 owl_function_makemsg("Error opening startupfile for new command"); 2913 return; 2914 } 2915 fprintf(file, "%s\n", buff); 2916 fclose(file); 2917 } 2918 2919 /* Remove the specified command from the startup file. */ 2920 void owl_function_delstartup(char *buff) 2921 { 2922 char *filename; 2923 filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE); 2924 owl_util_file_deleteline(filename, buff, 1); 2925 owl_free(filename); 2926 } 2927 2928 void owl_function_execstartup(void) 2929 { 2930 FILE *file; 2931 char *filename; 2932 char buff[LINE]; 2933 2934 filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE); 2935 file=fopen(filename, "r"); 2936 owl_free(filename); 2937 if (!file) { 2938 /* just fail silently if it doesn't exist */ 2939 return; 2940 } 2941 while (fgets(buff, LINE, file)!=NULL) { 2942 buff[strlen(buff)-1]='\0'; 2943 owl_function_command(buff); 2944 } 2945 fclose(file); 2946 } -
keys.c
raa5f725 r38cf544c 242 242 BIND_CMD("i", "info", ""); 243 243 BIND_CMD("l", "blist", ""); 244 BIND_CMD("B", "alist", ""); 244 245 BIND_CMD("M", "pop-message", ""); 245 246 BIND_CMD("T", "delete trash", "mark all 'trash' messages for deletion"); -
owl.c
r3abf28b r38cf544c 22 22 #include <sys/param.h> 23 23 #include <sys/types.h> 24 #include <sys/stat.h> 24 25 #include "owl.h" 25 26 … … 37 38 time_t nexttime, now; 38 39 struct tm *today; 40 char *dir; 39 41 40 42 argcsave=argc; … … 123 125 init_pair(OWL_COLOR_WHITE, COLOR_WHITE, -1); 124 126 } 127 125 128 126 129 /* owl init */ … … 128 131 if (debug) owl_global_set_debug_on(&g); 129 132 owl_global_set_startupargs(&g, argcsave, argvsave); 130 owl_context_set_readconfig(owl_global_get_context(&g)); 133 134 /* create the owl directory, in case it does not exist */ 135 dir=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_CONFIG_DIR); 136 mkdir(dir, S_IRWXU); 137 owl_free(dir); 131 138 132 139 /* set the tty, either from the command line, or by figuring it out */ … … 138 145 139 146 /* setup the default filters */ 140 141 147 /* the personal filter will need to change again when AIM chat's are 142 148 * included. Also, there should be an %aimme% */ … … 191 197 owl_view_create(owl_global_get_current_view(&g), f); 192 198 199 /* process the startup file */ 200 owl_function_execstartup(); 201 202 193 203 /* read the config file */ 204 owl_context_set_readconfig(owl_global_get_context(&g)); 194 205 ret=owl_readconfig(configfile); 195 206 if (ret) { -
owl.h
raa5f725 r38cf544c 19 19 #define OWL_DEBUG 0 20 20 #define OWL_DEBUG_FILE "/var/tmp/owldebug" 21 22 #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ 23 #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */ 21 24 22 25 #define OWL_FMTEXT_ATTR_NONE 0 -
owl_prototypes.h
rfd93b41 r38cf544c 61 61 extern char *owl_command_addbuddy(int argc, char **argv, char *buff); 62 62 extern char *owl_command_delbuddy(int argc, char **argv, char *buff); 63 extern char *owl_command_startup(int argc, char **argv, char *buff); 64 extern char *owl_command_unstartup(int argc, char **argv, char *buff); 63 65 extern char *owl_command_dump(int argc, char **argv, char *buff); 64 66 extern char *owl_command_next(int argc, char **argv, char *buff); … … 395 397 extern void owl_function_xterm_raise(void); 396 398 extern void owl_function_xterm_deiconify(void); 399 extern void owl_function_addstartup(char *buff); 400 extern void owl_function_delstartup(char *buff); 401 extern void owl_function_execstartup(void); 397 402 398 403 /* -------------------------------- global.c -------------------------------- */ … … 740 745 extern void owl_hack_animate(); 741 746 extern char *owl_util_stripnewlines(char *in); 747 extern void owl_util_file_deleteline(char *filename, char *line, int backup); 742 748 extern int owl_util_regtest(void); 743 749 -
util.c
r7c8060d0 r38cf544c 648 648 } 649 649 650 /* Delete the line matching "line" from the named file. If no such 651 * line is found the file is left intact. If backup==1 then create a 652 * backupfile containing the original contents. This is an 653 * inefficient impelementation which reads the entire file into 654 * memory. 655 */ 656 void owl_util_file_deleteline(char *filename, char *line, int backup) 657 { 658 char buff[LINE], *text; 659 char *backupfilename; 660 FILE *file, *backupfile; 661 int size, newline; 662 663 /* open the file for reading */ 664 file=fopen(filename, "r"); 665 if (!file) { 666 owl_function_makemsg("Error opening file %s", filename); 667 return; 668 } 669 670 /* open the backup file for writing */ 671 if (backup) { 672 backupfilename=owl_sprintf("%s.backup", filename); 673 backupfile=fopen(backupfilename, "w"); 674 owl_free(backupfilename); 675 if (!backupfile) { 676 owl_function_makemsg("Error opening file %s for writing", backupfilename); 677 return; 678 } 679 } 680 681 /* we'll read the entire file into memory, minus the line we don't want and 682 * and at the same time create the backup file if necessary 683 */ 684 text=owl_malloc(LINE); 685 strcpy(text, ""); 686 size=LINE; 687 while (fgets(buff, LINE, file)!=NULL) { 688 /* strip the newline */ 689 newline=0; 690 if (buff[strlen(buff)-1]=='\n') { 691 buff[strlen(buff)-1]='\0'; 692 newline=1; 693 } 694 695 /* if we don't match the line, add to saved text in memory */ 696 if (strcasecmp(buff, line)) { 697 size+=LINE; 698 text=owl_realloc(text, size); 699 strcat(text, buff); 700 if (newline) strcat(text, "\n"); 701 } 702 703 /* write to backupfile if necessary */ 704 if (backup) fputs(buff, backupfile); 705 } 706 fclose(backupfile); 707 fclose(file); 708 709 /* now rewrite the original file from memory */ 710 file=fopen(filename, "w"); 711 if (!file) { 712 owl_function_makemsg("WARNING: Error opening %s for writing. Use %s to restore.", filename, backupfilename); 713 owl_function_beep(); 714 owl_free(line); 715 return; 716 } 717 718 fputs(text, file); 719 fclose(file); 720 } 721 650 722 /**************************************************************************/ 651 723 /************************* REGRESSION TESTS *******************************/
Note: See TracChangeset
for help on using the changeset viewer.