Changeset 38cf544c for functions.c


Ignore:
Timestamp:
Jun 4, 2003, 12:04:54 AM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
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
Message:
Added the 'startup' and 'unstartup' commands
The $HOME/.owl directory is created on startup if it does not exist
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    raa5f725 r38cf544c  
    28952895  printf("\033[1t");
    28962896}
     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 */
     2903void 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. */
     2920void 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
     2928void 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}
Note: See TracChangeset for help on using the changeset viewer.