From 8e2d9de658662d5cad666626ee507755519459d8 Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Fri, 29 Jul 2005 06:25:58 +0000 Subject: [PATCH] - whitespace changes --- abook.c | 2 +- edit.c | 31 +++++----- ldif.c | 187 ++++++++++++++++++++++++++++---------------------------- 3 files changed, 110 insertions(+), 110 deletions(-) diff --git a/abook.c b/abook.c index 52b7f42..24d9f52 100644 --- a/abook.c +++ b/abook.c @@ -555,7 +555,7 @@ launch_mutt(int item) #ifdef DEBUG fprintf(stderr, "cmd: %s\n", cmd); #endif - system(cmd); + system(cmd); free(cmd); /* diff --git a/edit.c b/edit.c index ebabf1a..cb42326 100644 --- a/edit.c +++ b/edit.c @@ -47,13 +47,13 @@ editor_tab(const int tab) "CUSTOM " }; - mvwhline(editw, TABLINE+1, 0, UI_HLINE_CHAR, EDITW_COLS); - for(i=0; i < TABS; i++) { + mvwhline(editw, TABLINE + 1, 0, UI_HLINE_CHAR, EDITW_COLS); + for(i = 0; i < TABS; i++) { mvwaddch(editw, TABLINE+1, spacing * i + 2, UI_TEE_CHAR); mvwaddch(editw, TABLINE+1, spacing * i + 12, UI_TEE_CHAR); } - for(i=0; i < TABS; i++) { + for(i = 0; i < TABS; i++) { mvwaddch(editw, TABLINE, spacing * i + 2, UI_ULCORNER_CHAR); mvwaddch(editw, TABLINE, spacing * i + 3, UI_LBOXLINE_CHAR); mvwaddstr(editw, TABLINE, spacing * i + 4, tab_names[i]); @@ -136,12 +136,12 @@ print_editor_header(int item) char *header; char email[MAX_EMAIL_LEN]; - if( (header = xmalloc(EDITW_COLS)) == NULL ) + if((header = xmalloc(EDITW_COLS)) == NULL) return; get_first_email(email, item); - if( *database[item][EMAIL] ) + if(*database[item][EMAIL]) snprintf(header, EDITW_COLS, "%s <%s>", database[item][NAME], email); @@ -164,7 +164,7 @@ editor_print_data(int tab, int item) if(abook_fields[i].tab != tab) continue; - if(i==EMAIL) { /* special field */ + if(i == EMAIL) { /* special field */ int k; char emails[MAX_EMAILS][MAX_EMAIL_LEN]; split_emailstr(item, emails); @@ -182,7 +182,8 @@ editor_print_data(int tab, int item) } if(j > 1) { - getyx(editw, y, x); y++; + getyx(editw, y, x); + y++; } else y = FIELDS_START_Y; @@ -219,7 +220,7 @@ change_field(char *msg, char **field) char *old; int ret = 0; - if( !strncmp("E-mail", msg, 6) ) + if(!strncmp("E-mail", msg, 6)) max_len = MAX_EMAIL_LEN; old = *field; @@ -249,7 +250,7 @@ change_name_field(char **field) tmp = strdup(*field); change_field("Name: ", field); - if( *field == NULL || ! **field ) { + if(*field == NULL || ! **field) { xfree(*field); *field = strdup(tmp); } @@ -260,7 +261,7 @@ change_name_field(char **field) static void fix_email_str(char *str) { - for(; *str; str++ ) + for(; *str; str++) *str = *str == ',' ? '_' : *str; } @@ -326,14 +327,14 @@ edit_field(int tab, char c, int item) return 1; } - for(i=0, j=0; i< ITEM_FIELDS; i++) { + for(i = 0, j = 0; i< ITEM_FIELDS; i++) { if(abook_fields[i].tab == tab) j++; if(j==n) break; } - if(j!=n) + if(j != n) return 0; str = mkstr("%s: ", abook_fields[i].name); @@ -395,7 +396,7 @@ edit_loop(int item) refresh(); wrefresh(editw); - switch( (c = getch()) ) { + switch((c = getch())) { case 'c': tab = TAB_CONTACT; break; case 'a': tab = TAB_ADDRESS; break; case 'p': tab = TAB_PHONE; break; @@ -412,7 +413,7 @@ edit_loop(int item) case 'k': if(is_valid_item(item-1)) item--; break; case KEY_DOWN: case '>': - case 'j': if(is_valid_item(item+1)) item++; break; + case 'j': if(is_valid_item(item + 1)) item++; break; case 'r': roll_emails(item); break; case '?': display_help(HELP_EDITOR); break; case 'u': edit_undo(item, RESTORE_ITEM); break; @@ -437,7 +438,7 @@ edit_item(int item) init_editor(); - while( (item = edit_loop(item)) >= 0 ) + while((item = edit_loop(item)) >= 0) curitem = item; /* hmm, this is not very clean way to go */ close_editor(); diff --git a/ldif.c b/ldif.c index 617cefc..ab74cdf 100644 --- a/ldif.c +++ b/ldif.c @@ -1,5 +1,6 @@ /* + * $Id$ * adapted to use with abook by JH */ @@ -29,7 +30,7 @@ #define LDAP_DEBUG_PARSE 0x800 #define LDAP_DEBUG_ANY 0xffff -#define LDIF_LINE_WIDTH 76 /* maximum length of LDIF lines */ +#define LDIF_LINE_WIDTH 76 /* maximum length of LDIF lines */ #define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3) #define LDIF_SIZE_NEEDED(tlen,vlen) \ @@ -44,7 +45,7 @@ #define CONTINUED_LINE_MARKER '\001' static char nib2b64[0x40f] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static unsigned char b642nib[0x80] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -73,110 +74,107 @@ static unsigned char b642nib[0x80] = { */ int -str_parse_line( - char *line, - char **type, - char **value, - int *vlen -) +str_parse_line(char *line, char **type, char **value, int *vlen) { - char *p, *s, *d, *byte, *stop; - char nib; - int i, b64; + char *p, *s, *d, *byte, *stop; + char nib; + int i, b64; /* skip any leading space */ - while ( ISSPACE( *line ) ) { + while(ISSPACE(*line)) { line++; } *type = line; - for ( s = line; *s && *s != ':'; s++ ) - ; /* NULL */ - if ( *s == '\0' ) { - Debug( LDAP_DEBUG_PARSE, "parse_line missing ':'\n", 0, 0, 0 ); - return( -1 ); + for(s = line; *s && *s != ':'; s++); /* NULL */ + if(*s == '\0') { + Debug(LDAP_DEBUG_PARSE, "parse_line missing ':'\n", 0, 0, + 0); + return (-1); } /* trim any space between type and : */ - for ( p = s - 1; p > line && ISSPACE( *p ); p-- ) { + for(p = s - 1; p > line && ISSPACE(*p); p--) { *p = '\0'; } *s++ = '\0'; /* check for double : - indicates base 64 encoded value */ - if ( *s == ':' ) { + if(*s == ':') { s++; b64 = 1; - /* single : - normally encoded value */ + /* single : - normally encoded value */ } else { b64 = 0; } /* skip space between : and value */ - while ( ISSPACE( *s ) ) { + while(ISSPACE(*s)) { s++; } /* if no value is present, error out */ - if ( *s == '\0' ) { - Debug( LDAP_DEBUG_PARSE, "parse_line missing value\n", 0,0,0 ); - return( -1 ); + if(*s == '\0') { + Debug(LDAP_DEBUG_PARSE, "parse_line missing value\n", 0, 0, + 0); + return (-1); } /* check for continued line markers that should be deleted */ - for ( p = s, d = s; *p; p++ ) { - if ( *p != CONTINUED_LINE_MARKER ) + for(p = s, d = s; *p; p++) { + if(*p != CONTINUED_LINE_MARKER) *d++ = *p; } *d = '\0'; *value = s; - if ( b64 ) { - stop = strchr( s, '\0' ); + if(b64) { + stop = strchr(s, '\0'); byte = s; - for ( p = s, *vlen = 0; p < stop; p += 4, *vlen += 3 ) { - for ( i = 0; i < 3; i++ ) { - if ( p[i] != '=' && (p[i] & 0x80 || - b642nib[ p[i] & 0x7f ] > 0x3f) ) { - Debug( LDAP_DEBUG_ANY, - "invalid base 64 encoding char (%c) 0x%x\n", - p[i], p[i], 0 ); - return( -1 ); + for(p = s, *vlen = 0; p < stop; p += 4, *vlen += 3) { + for(i = 0; i < 3; i++) { + if(p[i] != '=' && (p[i] & 0x80 || + b642nib[p[i] & 0x7f] > + 0x3f)) { + Debug(LDAP_DEBUG_ANY, + "invalid base 64 encoding char (%c) 0x%x\n", + p[i], p[i], 0); + return (-1); } } /* first digit */ - nib = b642nib[ p[0] & 0x7f ]; + nib = b642nib[p[0] & 0x7f]; byte[0] = nib << 2; /* second digit */ - nib = b642nib[ p[1] & 0x7f ]; + nib = b642nib[p[1] & 0x7f]; byte[0] |= nib >> 4; byte[1] = (nib & RIGHT4) << 4; /* third digit */ - if ( p[2] == '=' ) { + if(p[2] == '=') { *vlen += 1; break; } - nib = b642nib[ p[2] & 0x7f ]; + nib = b642nib[p[2] & 0x7f]; byte[1] |= nib >> 2; byte[2] = (nib & RIGHT2) << 6; /* fourth digit */ - if ( p[3] == '=' ) { + if(p[3] == '=') { *vlen += 2; break; } - nib = b642nib[ p[3] & 0x7f ]; + nib = b642nib[p[3] & 0x7f]; byte[2] |= nib; byte += 3; } - s[ *vlen ] = '\0'; + s[*vlen] = '\0'; } else { *vlen = (int) (d - s); } - return( 0 ); + return (0); } #if 0 @@ -196,21 +194,21 @@ str_parse_line( */ char * -str_getline( char **next ) +str_getline(char **next) { - char *l; - char c; + char *l; + char c; - if ( *next == NULL || **next == '\n' || **next == '\0' ) { - return( NULL ); + if(*next == NULL || **next == '\n' || **next == '\0') { + return (NULL); } l = *next; - while ( (*next = strchr( *next, '\n' )) != NULL ) { + while((*next = strchr(*next, '\n')) != NULL) { c = *(*next + 1); - if ( ISSPACE( c ) && c != '\n' ) { + if(ISSPACE(c) && c != '\n') { **next = CONTINUED_LINE_MARKER; - *(*next+1) = CONTINUED_LINE_MARKER; + *(*next + 1) = CONTINUED_LINE_MARKER; } else { *(*next)++ = '\0'; break; @@ -218,23 +216,23 @@ str_getline( char **next ) (*next)++; } - return( l ); + return (l); } #endif void -put_type_and_value( char **out, char *t, char *val, int vlen ) +put_type_and_value(char **out, char *t, char *val, int vlen) { - unsigned char *byte, *p, *stop; - unsigned char buf[3]; - unsigned long bits; - char *save; - int i, b64, pad, len, savelen; + unsigned char *byte, *p, *stop; + unsigned char buf[3]; + unsigned long bits; + char *save; + int i, b64, pad, len, savelen; len = 0; /* put the type + ": " */ - for ( p = (unsigned char *) t; *p; p++, len++ ) { + for(p = (unsigned char *) t; *p; p++, len++) { *(*out)++ = *p; } *(*out)++ = ':'; @@ -245,16 +243,16 @@ put_type_and_value( char **out, char *t, char *val, int vlen ) b64 = 0; stop = (unsigned char *) (val + vlen); - if ( isascii( val[0] ) && (ISSPACE( val[0] ) || val[0] == ':') ) { + if(isascii(val[0]) && (ISSPACE(val[0]) || val[0] == ':')) { b64 = 1; } else { - for ( byte = (unsigned char *) val; byte < stop; - byte++, len++ ) { - if ( !isascii( *byte ) || !isprint( *byte ) ) { + for(byte = (unsigned char *) val; byte < stop; + byte++, len++) { + if(!isascii(*byte) || !isprint(*byte)) { b64 = 1; break; } - if ( len > LDIF_LINE_WIDTH ) { + if(len > LDIF_LINE_WIDTH) { *(*out)++ = '\n'; *(*out)++ = ' '; len = 1; @@ -262,36 +260,37 @@ put_type_and_value( char **out, char *t, char *val, int vlen ) *(*out)++ = *byte; } } - if ( b64 ) { + if(b64) { *out = save; *(*out)++ = ':'; *(*out)++ = ' '; len = savelen + 2; /* convert to base 64 (3 bytes => 4 base 64 digits) */ - for ( byte = (unsigned char *) val; byte < stop - 2; - byte += 3 ) { + for(byte = (unsigned char *) val; byte < stop - 2; + byte += 3) { bits = (byte[0] & 0xff) << 16; bits |= (byte[1] & 0xff) << 8; bits |= (byte[2] & 0xff); - for ( i = 0; i < 4; i++, len++, bits <<= 6 ) { - if ( len > LDIF_LINE_WIDTH ) { + for(i = 0; i < 4; i++, len++, bits <<= 6) { + if(len > LDIF_LINE_WIDTH) { *(*out)++ = '\n'; *(*out)++ = ' '; len = 1; } /* get b64 digit from high order 6 bits */ - *(*out)++ = nib2b64[ (bits & 0xfc0000L) >> 18 ]; + *(*out)++ = + nib2b64[(bits & 0xfc0000L) >> 18]; } } /* add padding if necessary */ - if ( byte < stop ) { - for ( i = 0; byte + i < stop; i++ ) { + if(byte < stop) { + for(i = 0; byte + i < stop; i++) { buf[i] = byte[i]; } - for ( pad = 0; i < 3; i++, pad++ ) { + for(pad = 0; i < 3; i++, pad++) { buf[i] = '\0'; } byte = buf; @@ -299,18 +298,19 @@ put_type_and_value( char **out, char *t, char *val, int vlen ) bits |= (byte[1] & 0xff) << 8; bits |= (byte[2] & 0xff); - for ( i = 0; i < 4; i++, len++, bits <<= 6 ) { - if ( len > LDIF_LINE_WIDTH ) { + for(i = 0; i < 4; i++, len++, bits <<= 6) { + if(len > LDIF_LINE_WIDTH) { *(*out)++ = '\n'; *(*out)++ = ' '; len = 1; } /* get b64 digit from low order 6 bits */ - *(*out)++ = nib2b64[ (bits & 0xfc0000L) >> 18 ]; + *(*out)++ = + nib2b64[(bits & 0xfc0000L) >> 18]; } - for ( ; pad > 0; pad-- ) { + for(; pad > 0; pad--) { *(*out - pad) = '='; } } @@ -320,29 +320,28 @@ put_type_and_value( char **out, char *t, char *val, int vlen ) char * -ldif_type_and_value( char *type, char *val, int vlen ) +ldif_type_and_value(char *type, char *val, int vlen) /* * return malloc'd, zero-terminated LDIF line */ { - char *buf, *p; - int tlen; - size_t bufsize, t; + char *buf, *p; + int tlen; + size_t bufsize, t; - tlen = strlen( type ); + tlen = strlen(type); - t = LDIF_SIZE_NEEDED( tlen, vlen ); - if((bufsize = t + 1) <= t) - return NULL; + t = LDIF_SIZE_NEEDED(tlen, vlen); + if((bufsize = t + 1) <= t) + return NULL; - if (( buf = (char *)malloc( bufsize )) == NULL ) { - return NULL; - } + if((buf = (char *) malloc(bufsize)) == NULL) { + return NULL; + } - p = buf; - put_type_and_value( &p, type, val, vlen ); - *p = '\0'; + p = buf; + put_type_and_value(&p, type, val, vlen); + *p = '\0'; - return( buf ); + return (buf); } - -- 2.39.2