Annotation of researchv10no/ipc/libipc/ipcbuf.c, revision 1.1.1.1

1.1       root        1: #include "defs.h"
                      2: /*
                      3:  *     stretching buffers
                      4:  */
                      5: _strinit(sp)
                      6:        stretch *sp;
                      7: {
                      8:        sp->ptr = NULL;
                      9:        sp->len = 0;
                     10: }
                     11: 
                     12: _strcat(sp, p1, p2, p3)
                     13:        stretch *sp;
                     14:        char *p1, *p2, *p3;
                     15: {
                     16:        char buf[2048];
                     17:        int len=0;
                     18:        char *malloc();
                     19: 
                     20:        if (p1) {
                     21:                len += strlen(p1);
                     22:                if (p2) {
                     23:                        len += strlen(p2);
                     24:                        if (p3)
                     25:                                len += strlen(p3);
                     26:                }
                     27:        }
                     28:        if (len<sizeof(buf)) {
                     29:                buf[0] = '\0';
                     30:                if (p1) {
                     31:                        strcat(buf, p1);
                     32:                        if (p2) {
                     33:                                strcat(buf, p2);
                     34:                                if (p3)
                     35:                                        strcat(buf, p3);
                     36:                        }
                     37:                }
                     38:        } else {
                     39:                strcpy(buf, "string_too_long");
                     40:                len = strlen(buf);
                     41:        }
                     42:        if (sp->len<=len) {
                     43:                if(sp->ptr)
                     44:                        free(sp->ptr);
                     45:                sp->ptr = malloc(len+1);
                     46:                sp->len = len+1;
                     47:        }
                     48:        strcpy(sp->ptr, buf);
                     49: }
                     50: 
                     51: _strkill(sp)
                     52:        stretch *sp;
                     53: {
                     54:        if (sp->ptr)
                     55:                free(sp->ptr);
                     56: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.