Changeset e4eebe8


Ignore:
Timestamp:
Jun 22, 2003, 1:58:18 PM (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:
9c4ec91
Parents:
53f421b
Message:
Reformatted util.c in new code style
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r73624b4 re4eebe8  
    88static const char fileIdent[] = "$Id$";
    99
    10 void sepbar(char *in) {
     10void sepbar(char *in)
     11{
    1112  char buff[1024];
    1213  WINDOW *sepwin;
     
    117118
    118119
    119 void pophandler_quit(int ch) {
     120void pophandler_quit(int ch)
     121{
    120122  if (ch=='q') {
    121123    owl_popwin_close(owl_global_get_popwin(&g));
     
    123125}
    124126
    125 char **atokenize(char *buffer, char *sep, int *i) {
     127char **atokenize(char *buffer, char *sep, int *i)
     128{
    126129  /* each element of return must be freed by user */
    127130  char **args;
     
    171174}
    172175
    173 void atokenize_free(char **tok, int nels) {
     176void atokenize_free(char **tok, int nels)
     177{
    174178  int i;
    175179  for (i=0; i<nels; i++) {
     
    180184
    181185
    182 void owl_parsefree(char **argv, int argc) {
     186void owl_parsefree(char **argv, int argc)
     187{
    183188  int i;
    184189
     
    191196}
    192197
    193 char **owl_parseline(char *line, int *argc) {
     198char **owl_parseline(char *line, int *argc)
     199{
    194200  /* break a command line up into argv, argc.  The caller must free
    195201     the returned values.  If there is an error argc will be set to
     
    275281
    276282
    277 
    278 int owl_util_find_trans(char *in, int len) {
    279   /* return the index of the last char before a change from the first
    280      one */
     283/* return the index of the last char before a change from the first one */
     284int owl_util_find_trans(char *in, int len)
     285{
    281286  int i;
    282287  for (i=1; i<len; i++) {
     
    287292
    288293
    289 void downstr(char *foo) {
     294/* downcase the string 'foo' */
     295void downstr(char *foo)
     296{
    290297  int i;
    291298  for (i=0; foo[i]!='\0'; i++) {
     
    294301}
    295302
    296 char *stristr(char *a, char *b) {
    297   /* exactly like strstr but it's case insensitive */
     303/* exactly like strstr but case insensitive */
     304char *stristr(char *a, char *b)
     305{
    298306  char *x, *y, *ret;
    299307
     
    314322}
    315323
    316 char *owl_util_uniq(char *A, char *B, char *prohibit) {
    317   /* Caller must free response.
    318      Takes in strings which are space-separated lists of tokens
    319      and returns a single string containing no token more than once.
    320      If prohibit is non-null, no token may start with a character
    321      in prohibit.
    322   */
     324/* Caller must free response.
     325 * Takes in strings which are space-separated lists of tokens
     326 * and returns a single string containing no token more than once.
     327 * If prohibit is non-null, no token may start with a character
     328 * in prohibit.
     329 */
     330char *owl_util_uniq(char *A, char *B, char *prohibit)
     331{
    323332 
    324333  char *cat, **tok;
     
    347356}
    348357
    349 int only_whitespace(char *s) {
    350   /* returns if a string is only whitespace */
    351 
     358/* return 1 if a string is only whitespace, otherwise 0 */
     359int only_whitespace(char *s)
     360{
    352361  int i;
    353362  for (i=0; s[i]; i++) {
     
    359368/* hooks for doing memory allocation et. al. in owl */
    360369
    361 void *owl_malloc(size_t size) {
     370void *owl_malloc(size_t size)
     371{
    362372  return(malloc(size));
    363373}
    364374
    365 void owl_free(void *ptr) {
     375void owl_free(void *ptr)
     376{
    366377  free(ptr);
    367378}
    368379
    369 char *owl_strdup(const char *s1) {
     380char *owl_strdup(const char *s1)
     381{
    370382  return(strdup(s1));
    371383}
    372384
    373 void *owl_realloc(void *ptr, size_t size) {
     385void *owl_realloc(void *ptr, size_t size)
     386{
    374387  return(realloc(ptr, size));
    375388}
    376389
    377 char *owl_sprintf(const char *fmt, ...) {
    378   /* allocates memory and returns the string or null.
    379    * caller must free the string.
    380    * from Linux sprintf man page.
    381    */
    382  
     390
     391/* allocates memory and returns the string or null.
     392 * caller must free the string.
     393 * from Linux sprintf man page.
     394 */
     395char *owl_sprintf(const char *fmt, ...)
     396{
    383397  int n, size = 100;
    384398  char *p;
     
    403417}
    404418
    405 /* the caller must free the return */
    406 char *short_zuser(char *in) {
     419/* Strip a local realm fron the zephyr user name.
     420 * The caller must free the return
     421 */
     422char *short_zuser(char *in)
     423{
    407424  char *out, *ptr;
    408425
     
    417434}
    418435
    419 /* the caller must free the return */
    420 char *long_zuser(char *in) {
     436/* Append a local realm to the zephyr user name if necessary.
     437 * The caller must free the return.
     438 */
     439char *long_zuser(char *in)
     440{
    421441  char *ptr;
    422442
     
    429449
    430450
    431 char *owl_util_smartstripped_user(char *in) {
    432   /* strip out the instance from a zsender's principal.  Preserves the
    433    * realm if present.  daemon.webzephyr is a special case.  The
    434    * caller must free the return */
    435 
     451/* strip out the instance from a zsender's principal.  Preserves the
     452 * realm if present.  daemon.webzephyr is a special case.  The
     453 * caller must free the return
     454 */
     455char *owl_util_smartstripped_user(char *in)
     456{
    436457  char *ptr, *realm, *out;
    437458
     
    452473  }
    453474
    454 
    455475  /* remove the realm from ptr, but hold on to it */
    456476  realm=strchr(out, '@');
     
    471491}
    472492
    473 char *owl_getquoting(char *line) {
     493char *owl_getquoting(char *line)
     494{
    474495  if (line[0]=='\0') return("'");
    475496  if (strchr(line, '\'')) return("\"");
     
    479500}
    480501
    481 char *owl_util_substitute(char *in, char *from, char *to) {
    482   /* Caller must free returned string.
    483    * Returns a string with any occurances of 'from' replaced with 'to'.
    484    * Does not currently handle backslash quoting, but may in the future.
    485    */
     502
     503
     504/* Return a string with any occurances of 'from' replaced with 'to'.
     505 * Does not currently handle backslash quoting, but may in the future.
     506 * Caller must free returned string.
     507 */
     508char *owl_util_substitute(char *in, char *from, char *to)
     509{
    486510 
    487511  char *out;
     
    511535}
    512536
    513 void owl_util_tr(char *buff, char a, char b) {
    514   /* replace all instances of character a in buff with the character
    515      b.  buff must be null terminated */
     537/* replace all instances of character a in buff with the character
     538 * b.  buff must be null terminated.
     539 */
     540void owl_util_tr(char *buff, char a, char b)
     541{
    516542  int i;
    517543
     
    523549}
    524550
    525 int owl_util_string_to_color(char *color) {
     551
     552/* Return the owl color associated with the named color */
     553int owl_util_string_to_color(char *color)
     554{
    526555  if (!strcasecmp(color, "black")) {
    527556    return(OWL_COLOR_BLACK);
     
    546575}
    547576
    548 char *owl_util_color_to_string(int color) {
     577/* Return a string name of the given owl color */
     578char *owl_util_color_to_string(int color)
     579{
    549580  if (color==OWL_COLOR_BLACK)   return("black");
    550581  if (color==OWL_COLOR_RED)     return("red");
     
    559590}
    560591
    561 char *owl_util_get_default_tty() {
    562   /* call must free the return */
     592/* Get the default tty name.  Caller must free the return */
     593char *owl_util_get_default_tty()
     594{
    563595  char *out, *tmp;
    564596
     
    578610
    579611
    580 void owl_hack_animate() {
     612/* Animation hack */
     613void owl_hack_animate()
     614{
    581615  owl_messagelist *ml;
    582616  owl_message *m;
     
    631665}
    632666
    633 char *owl_util_stripnewlines(char *in) {
    634   /* strip leading and trailing new lines.
    635      caller must free the return */
     667/* strip leading and trailing new lines.  Caller must free the
     668 * return.
     669 */
     670char *owl_util_stripnewlines(char *in)
     671{
    636672 
    637673  char  *tmp, *ptr1, *ptr2, *out;
     
    733769#define FAIL_UNLESS(desc,pred) printf("\t%-4s: %s\n", (pred)?"ok":(numfailed++,"FAIL"), desc)
    734770
    735 int owl_util_regtest(void) {
     771int owl_util_regtest(void)
     772{
    736773  int numfailed=0;
    737774
Note: See TracChangeset for help on using the changeset viewer.