- Timestamp:
- Jul 6, 2003, 6:42:06 PM (22 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:
- 5d9c664
- Parents:
- 675ce49
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
style.c
ref56a67 rf1e629d 3 3 static const char fileIdent[] = "$Id$"; 4 4 5 void owl_style_create_internal(owl_style *s, char *name, void (*formatfunc) (owl_fmtext *fm, owl_message *m) )5 void owl_style_create_internal(owl_style *s, char *name, void (*formatfunc) (owl_fmtext *fm, owl_message *m), char *description) 6 6 { 7 7 s->type=OWL_STYLE_TYPE_INTERNAL; 8 8 s->name=owl_strdup(name); 9 if (description) { 10 s->description=owl_strdup(description); 11 } else { 12 s->description=owl_sprintf("Owl internal style %s", name); 13 } 9 14 s->perlfuncname=NULL; 10 15 s->formatfunc=formatfunc; 11 16 } 12 17 13 void owl_style_create_perl(owl_style *s, char *name, char *perlfuncname )18 void owl_style_create_perl(owl_style *s, char *name, char *perlfuncname, char *description) 14 19 { 15 20 s->type=OWL_STYLE_TYPE_PERL; 16 21 s->name=owl_strdup(name); 17 22 s->perlfuncname=owl_strdup(perlfuncname); 23 if (description) { 24 s->description=owl_strdup(description); 25 } else { 26 s->description=owl_sprintf("User-defined perl style that calls %s", 27 perlfuncname); 28 } 18 29 s->formatfunc=NULL; 19 30 } … … 30 41 } 31 42 43 char *owl_style_get_description(owl_style *s) 44 { 45 return(s->description); 46 } 47 32 48 /* Use style 's' to format message 'm' into fmtext 'fm'. 33 49 * 'fm' should already be be initialzed … … 41 57 42 58 /* run the perl function */ 43 body=owl_ config_getmsg(m, s->perlfuncname);59 body=owl_perlconfig_getmsg(m, 1, s->perlfuncname); 44 60 45 61 /* indent */ … … 55 71 } 56 72 73 int owl_style_validate(owl_style *s) { 74 if (!s) { 75 return -1; 76 } else if (s->type==OWL_STYLE_TYPE_INTERNAL) { 77 return 0; 78 } else if (s->type==OWL_STYLE_TYPE_PERL 79 && s->perlfuncname 80 && owl_perlconfig_is_function(s->perlfuncname)) { 81 return 0; 82 } else { 83 return -1; 84 } 85 } 86 57 87 void owl_style_free(owl_style *s) 58 88 { 59 89 if (s->name) owl_free(s->name); 90 if (s->description) owl_free(s->description); 60 91 if (s->type==OWL_STYLE_TYPE_PERL && s->perlfuncname) { 61 92 owl_free(s->perlfuncname);
Note: See TracChangeset
for help on using the changeset viewer.