Beispiel #1
0
int main(void)
{
    char s[MAXSIZE] = "abc";
    char t[MAXSIZE] = "abracadabra";
    mystrncpy(s, t, 6);
    printf("%s\n", s);

    strncpy(t, "", MAXSIZE);
    mystrncpy(s, t, 6);
    printf("%s\n", s);

    strncpy(s, "foo", MAXSIZE);
    strncpy(t, "bar", MAXSIZE);
    mystrncat(s, t, 5);
    printf("%s\n", s);

    strncpy(s, "foobar", MAXSIZE);
    strncpy(t, "foobar", MAXSIZE);
    printf("%d\n", mystrncmp(s, t, 10));
    printf("%d\n", mystrncmp(s, t, 4));

    strncpy(t, "fooby", MAXSIZE);
    printf("%d\n", mystrncmp(s, t, 10));
    printf("%d\n", mystrncmp(s, t, 4));
    printf("%d\n", mystrncmp(s, t, 5));
    return 0;
}
Beispiel #2
0
//-------------------------------------------------------------------------
void reply_ps(uint8_t * receivebuffer)
{
    uint8_t i, len;

    //reply[0] = 15;
    reply[1] = 171;
    reply[2] = nodeid;
    for (i = 0; i < LITE_MAX_THREADS; i++)
    {
        if (thread_table[i].state != STATE_NULL)
        {
            len = mystrlen((char *)thread_table[i].threadName);
            reply[0] = len + 4;
            reply[3] = thread_table[i].state;
            //if this is a break thread, then fetch the real number
            if (reply[3] == STATE_BREAK)
            {
                uint8_t *tempptr = (uint8_t *) thread_table[i].sp + 47;
                uint16_t addr =
                    (((uint16_t) (*tempptr)) * 256 + *(tempptr + 1) - 3);
                reply[4] = addr / 256;
                reply[5] = addr % 256;
                reply[0] += 2;
                mystrncpy((char *)&reply[6],
                          (char *)thread_table[i].threadName, len);
            }
            else
            {
                mystrncpy((char *)&reply[4],
                          (char *)thread_table[i].threadName, len);
            }
            StandardSocketSend(0xefef, 0xffff, 32, reply);
        }
    }
}
Beispiel #3
0
int picolCondition(picolInterp *i, char* str)
{
    if(str) {
        char buf[MAXSTR], buf2[MAXSTR];
        int rc;
        rc = picolSubst(i,str);
        if(rc != PICOL_OK) return rc;
        //mysnprintf(buf, MAXSTR, "Condi: (%s) ->(%s)\n",str,i->result);
        //dbg_send_str3(buf, 1);
        mystrncpy(buf2,i->result, MAXSTR);
        /* ------- try whether the format suits [expr]... */
        mystrncpy(buf,"llength ", MAXSTR); LAPPEND(buf,i->result);
        //dbg_send_str3(buf, 1);
        rc = picolEval(i,buf);
        if(rc != PICOL_OK) return rc;
#if 0
        if(EQ(i->result,"3")) {
            FOREACH(buf,cp,buf2) argv[a++] = mystrdup(buf);
            if(picolGetCmd(i,argv[1])) { /* defined operator in center */
                mystrncpy(buf,argv[1], MAXSTR);       /* translate to Polish :) */
                LAPPEND(buf,argv[0]);      /* e.g. {1 > 2} -> {> 1 2} */
                LAPPEND(buf,argv[2]);
                rc = picolEval(i, buf);
                return rc;
            }
        } /* .. otherwise, check for inequality to zero */
#endif
        if(*str == '!') {mystrncpy(buf, "== 0 ", MAXSTR); str++;} /* allow !$x */
        else             mystrncpy(buf, "!= 0 ", MAXSTR);
        mystrncat(buf, str, MAXSTR);
        return picolEval(i, buf); // todo: compare without eval
    }
    else
        return picolErr(i, "NULL condition");
}
Beispiel #4
0
bool matchcharset(uchar *pat,uchar *chrs,uchar *codepage)
{
   uchar buf[20],buf2[20];

   if(strchr(pat,','))
   {
      /* Match chrs and codepage */
      
      mystrncpy(buf,pat,20);
      
      if(strchr(buf,','))
         *strchr(buf,',')=0;
         
      mystrncpy(buf2,strchr(pat,',')+1,20);

      if(matchpattern(buf,chrs) && matchpattern(buf2,codepage))
         return(TRUE);

      return(FALSE);
   }
   else
   {
      /* Match chrs only */

      return matchpattern(pat,chrs);
   }
}
Beispiel #5
0
char *GetTimeonStringsTrans( short lp ) 
{
	strcpy( TimeonStringsTrans[lp], TimeonStrings[lp] );
	long len = strlen( TimeonStringsTrans[lp] );
	if ( lp == 0 ) // For 1 min
		mystrncpy( &TimeonStringsTrans[lp][len], TranslateID( TIME_MIN ), BUF16-len );
	else // For >1 min
		mystrncpy( &TimeonStringsTrans[lp][len], TranslateID( TIME_MINS ), BUF16-len );
	TimeonStringsTrans[lp][BUF16-1] = 0;
	return TimeonStringsTrans[lp];
}
int main()
{
	char *current = "helloworld";
	char destination [12];

	printf ("strcpy of helloworld %s \n", mystrcpy (current, destination));
	printf ("%s \n", mystrncpy (current, destination, 1));
	printf ("%s \n", mystrncpy (current, destination, 0));
	printf ("length of helloworld = %d", mystrlen ("helloworld"));
	return 0;
}
Beispiel #7
0
 void f(char *z) /*@requires MaxRead(z) >= 2; @*/
{
char x[3];
char y[3];

mystrncpy (x, z, 3);
mystrncpy (y, z, 3);

x[(sizeof x)] = 'i';
y[((sizeof y) - 1)] = '0';

}
Beispiel #8
0
struct xlat *findreadxlat(struct var *var,struct group *group,uchar *ichrs,uchar *icodepage,uchar *destpat)
{
   uchar chrs[20],codepage[20];
   struct xlat *xlat;
   struct xlatalias *xlatalias;
   
   mystrncpy(chrs,ichrs,20);
   mystrncpy(codepage,icodepage,20);
   
   /* Do override */
   
   if(group->defaultchrs[0] == '!') 
      setchrscodepage(chrs,codepage,&group->defaultchrs[1]);
   
   else if(var->defaultreadchrs[0] == '!')
      setchrscodepage(chrs,codepage,&var->defaultreadchrs[1]);
   
   /* Set charset if missing */
   
   if(chrs[0] == 0 && group->defaultchrs[0] != 0 && group->defaultchrs[0] != '!') 
      setchrscodepage(chrs,codepage,group->defaultchrs);
      
   if(chrs[0] == 0 && var->defaultreadchrs[0] != 0 && var->defaultreadchrs[0] != '!')
      setchrscodepage(chrs,codepage,var->defaultreadchrs);      

   /* Replace if an alias */      
                  
   for(xlatalias=var->firstreadalias;xlatalias;xlatalias=xlatalias->next)
      if(matchcharset(xlatalias->pattern,chrs,codepage)) break;
      
   if(xlatalias)
      setchrscodepage(chrs,codepage,xlatalias->replace);
   
   /* Find in list */
      
   if(destpat)
   {
      for(xlat=var->firstreadxlat;xlat;xlat=xlat->next)
         if(matchcharset(xlat->fromchrs,chrs,codepage) && matchpattern(destpat,xlat->tochrs)) break;
   }
   else
   {
      for(xlat=var->firstreadxlat;xlat;xlat=xlat->next)
         if(matchcharset(xlat->fromchrs,chrs,codepage)) break;
   }
   
   return(xlat);
}
Beispiel #9
0
/* - returns pointer to last field in addr		 	*/
char *ReverseAddressARPA(char *srcDomain, char *dst)
{
	char	*pt, *pt2, *src;
	char	*last_field = 0;
	char	tempSrc[512];
	int		count=0;

	if ( srcDomain==dst ) {
		mystrncpy( tempSrc, srcDomain, 512 );
		src = tempSrc;
	} else
		src = srcDomain;
		
	dst[0] = 0;
	while( ((pt=strrchr(src,'.')) || (pt2=strrchr(src,'/'))) && count<=4 ) {
		if ( !pt ) pt = pt2;
		if ( !last_field ) last_field = pt + 1;
		if ( count<4 ){
			strcat( dst,pt+1 );
			if ( count<3 ) strcat( dst,"." );
			count++;
		}
		*pt = 0;
	}
	if ( count < 4 ){
		if ( !last_field ) last_field = src;
		strcat( dst,src );
	}
	return( last_field );
}
Beispiel #10
0
//-------------------------------------------------------------------------
//Note that this function should consider splitting a message into multiple pieces, if the requested memory chunk is too large 
void reply_debugging_print(uint8_t * receivebuffer)
{
    //This is the reply for the print command 
    uint16_t addr;
    uint16_t size;
    uint8_t chunkindex;
    uint8_t numOfChunks;

    addr = ((uint16_t) receivebuffer[3]) * 256 + (receivebuffer[4]);
    size = (uint16_t) receivebuffer[5] * 256 + receivebuffer[6];
    numOfChunks = size / 24 + 1;
    for (chunkindex = 0; chunkindex < numOfChunks; chunkindex++)
    {
        reply[0] = 24 + 6;
        reply[1] = 91;
        reply[2] = nodeid;
        reply[3] = chunkindex;
        reply[4] = size / 256;
        reply[5] = size % 256;
        //Note that this expose some piece of memory that is NOT part of the requested data 
        mystrncpy((char *)&reply[6], (char *)addr, 24);
        addr = addr + 24;
        StandardSocketSend(0xefef, 0xffff, 32, reply);
    }
    //printStringN(reply,32); 
}
Beispiel #11
0
//-------------------------------------------------------------------------
void reply_cp_fromPCtoNode_type1(uint8_t * receivebuffer)
{
    uint8_t blockid;
    char filename[13];
    int fid;
    uint8_t newblockid;
      
    releaseAllFid();
    blockid = receivebuffer[3];
    mystrncpy(filename, (char *)&receivebuffer[4], receivebuffer[0] - 4);
    filename[receivebuffer[0] - 4] = '\0';
    newblockid = createFileFromDirectory(filename, (int)blockid);
    chunksequencenum = 0;
    expectNextNum = 1;
    reply[0] = 4;
    reply[1] = 121;
    reply[2] = nodeid;
    reply[3] = newblockid;
    fid = getFreeFid();
    openFile(newblockid, fid, 2);
    openedfile = &fidtable[fid];
	 sleepThread(20);
    // printStringN(reply,32);      
    StandardSocketSend(0xefef, 0xffff, 32, reply);
}
Beispiel #12
0
int     picolSetVar2(picolInterp *i, char *name, char *val,int glob) {
    picolVar       *v = picolGetVar(i,name);
    picolCallFrame *c = i->callframe, *localc = c;
    int             global = COLONED(name);
    if(glob||global) v = picolGetGlobalVar(i,name);
    if(!v) {           /* non-existing variable */
        if(glob || global) {
            if(global) name += 2;
            while(c->parent) c = c->parent;
        } else {
            v       = mymalloc(sizeof(*v));
            v->name = mystrdup(name);
            v->next = c->vars;
            c->vars = v;
            i->callframe = localc;
        }
    }
    if(v)
    {
        if(glob || global)
            mystrncpy(v->val, val, mystrnlen(v->val, MAXSTR));
        else
            v->val = mystrdup(val);
    }
    return PICOL_OK;
}
Beispiel #13
0
bool chsgetword(uchar *line, ulong *pos, uchar *dest, ulong destlen)
{
   ulong begin;

   while(isspace(line[*pos]) && line[*pos]!=0)
      (*pos)++;

   if(line[*pos] == 0)
      return(FALSE);

   begin=*pos;

   while(line[*pos]!=0 && !isspace(line[*pos]))
      (*pos)++;

   if(line[*pos] != 0)
   {
      line[*pos]=0;
      (*pos)++;
   }

   mystrncpy(dest,&line[begin],destlen);

   return(TRUE);
}
Beispiel #14
0
	void Print(int ident)
	{
		if (text&&length)
		{
			PrintIdent(ident);
			static char mess[10000];
			static char str[10000];
			mystrncpy(str,text,length);
			sprintf(mess,"|%s|\n",str);
			OutputDebugString(mess);
		}
		if (child)
		{
			PrintIdent(ident);
			OutputDebugString("{\n");
			TxtNode *sib=child;
			while (sib)
			{
				sib->Print(ident+1);
				sib=sib->sibling;
			}

			PrintIdent(ident);
			OutputDebugString("}\n");
		}
	}
Beispiel #15
0
void send_task()
{
    struct msgData *dataPayloadPtr_currentMsg;



    dataPayloadPtr_currentMsg = (struct msgData *)currentMsg.data;
    if (radiosocketdata.socket_msg_len == 0)
    {
        radiosocketdata.socket_msg_len = mystrlen((char *)radiosocketdata.socket_msg);
    }
    mystrncpy((char *)dataPayloadPtr_currentMsg, (char *)radiosocketdata.socket_msg,
              radiosocketdata.socket_msg_len);



    if (radiosocketdata.socket_addr != 0)
    {
        AMStandard_SendMsg_send(radiosocketdata.socket_port, radiosocketdata.socket_addr, radiosocketdata.socket_msg_len, &currentMsg);
    }
    else
    {
        currentMsg.length = radiosocketdata.socket_msg_len;
        currentMsg.addr = radiosocketdata.socket_addr;
        currentMsg.port = radiosocketdata.socket_port;
        currentMsg.strength = 0;
        currentMsg.lqi = 0;
        Standard_Receive_Packet(radiosocketdata.socket_port, &currentMsg);
    }
//#endif
}
Beispiel #16
0
void setchrscodepage(uchar *chrs,uchar *codepage,uchar *str)
{
   if(strchr(str,','))
   {
      mystrncpy(chrs,str,20);
      
      if(strchr(chrs,','))
         *strchr(chrs,',')=0;

      mystrncpy(codepage,strchr(str,',')+1,20);
   }
   else
   {
      mystrncpy(chrs,str,20);
      codepage[0]=0;
   }
}
Beispiel #17
0
void bftpd_stat(char *name, FILE * client)
{
    struct stat statbuf;
	char temp[MAXCMD + 3], linktarget[MAXCMD + 5], perm[11], timestr[17],
		uid[USERLEN + 1], gid[USERLEN + 1];
    struct tm filetime;
    time_t t;
    if (lstat(name, (struct stat *) &statbuf) == -1) { // used for command_stat
        fprintf(client, "213-Error: %s.\n", strerror(errno));
        return;
    }
#ifdef S_ISLNK
	if (S_ISLNK(statbuf.st_mode)) {
		strcpy(perm, "lrwxrwxrwx");
		temp[readlink(name, temp, sizeof(temp) - 1)] = '\0';
		sprintf(linktarget, " -> %s", temp);
	} else {
#endif
		strcpy(perm, "----------");
		if (S_ISDIR(statbuf.st_mode))
			perm[0] = 'd';
		if (statbuf.st_mode & S_IRUSR)
			perm[1] = 'r';
		if (statbuf.st_mode & S_IWUSR)
			perm[2] = 'w';
		if (statbuf.st_mode & S_IXUSR)
			perm[3] = 'x';
		if (statbuf.st_mode & S_IRGRP)
			perm[4] = 'r';
		if (statbuf.st_mode & S_IWGRP)
			perm[5] = 'w';
		if (statbuf.st_mode & S_IXGRP)
			perm[6] = 'x';
		if (statbuf.st_mode & S_IROTH)
			perm[7] = 'r';
		if (statbuf.st_mode & S_IWOTH)
			perm[8] = 'w';
		if (statbuf.st_mode & S_IXOTH)
			perm[9] = 'x';
		linktarget[0] = '\0';
#ifdef S_ISLNK
	}
#endif
    memcpy(&filetime, localtime(&(statbuf.st_mtime)), sizeof(struct tm));
    time(&t);
    if (filetime.tm_year == localtime(&t)->tm_year)
    	mystrncpy(timestr, ctime(&(statbuf.st_mtime)) + 4, 12);
    else
        strftime(timestr, sizeof(timestr), "%b %d  %G", &filetime);
    mygetpwuid(statbuf.st_uid, passwdfile, uid)[8] = 0;
    mygetpwuid(statbuf.st_gid, groupfile, gid)[8] = 0;
	fprintf(client, "%s %3i %-8s %-8s %8lu %s %s%s\r\n", perm,
			(int) statbuf.st_nlink, uid, gid,
			(unsigned long) statbuf.st_size,
			timestr, name, linktarget);
}
Beispiel #18
0
size_t	GetReportPath(VDinfoP VDptr, char* szDestPath, size_t nLength)
{
	size_t nPos(0);

	if ( totalDomains>0 && VDptr ) 
	{
		nPos += PathFromFullPath( MyPrefStruct.outfile, szDestPath);	// not safe - oh well.
		nPos += mystrncpy(szDestPath+nPos, GetDomainPath(VDptr), (nLength-nPos));
		nPos += mystrncpy(szDestPath+nPos, PATHSEPSTR,			 (nLength-nPos));
		if (nPos >= nLength)	// if there is no space left in the string.
			return nPos;
		ReplacePathFromHost( GetDomainPath(VDptr), szDestPath );
	}
	else
	{
		nPos += PathFromFullPath( MyPrefStruct.outfile, szDestPath);
	}

	return nPos;
}
Beispiel #19
0
int main(void)
{
	char s[MAX];
	char t[MAX];

	gets(t);

	mystrncpy(s, t, N);
	
	printf("%s\n", s);
}
Beispiel #20
0
char* mystrdup(char *str)
{
    size_t len = mystrnlen(str, MAXSTR);
    char *ptr = mymalloc(len + 1);
    if(ptr)
    {
        mystrncpy(ptr, str, MAXSTR);
        return ptr;
    }
    return 0;
}
Beispiel #21
0
char *mystrncat(char *s1, const char *s2, size_t n){

   char * res = s1;
   
   /* go to the end of the first string */
   while(*s1 != '\0') s1++;
   /* then copy */
   mystrncpy(s1, s2, n);
   
   return res;

}
Beispiel #22
0
char *ReadToken(char *at,char *end,int &len,char **out)
{
	char *ret=0;
	len=0;
	while (at<end&&(isspace(*at)||*at==';'||*at==','))
		at++;
	if (at==end)
	{
		*out=end;
		return 0;
	}
	if ((*at=='\"'||*at=='<')&&at+1<end)
	{
		char endchar='\"';
		if (*at=='<')
			endchar='>';
		at++;
		ret=at;
		while (at<end&&*at!=endchar)
		{
			at++;
			len++;
		}
		if (at<end)
			at++;
	}
	else if ((*at=='{'||*at=='}')&&at+1<end)
	{
		ret=at;
		len=1;
		at++;
	}
	else
	{
		ret=at;
		while (at<end&&!(isspace(*at)||*at==';'||*at==','||*at=='}'||*at=='>'||*at=='{'||*at=='<'||*at=='\"'))
		{
			len++;
			at++;
		}
	}
	*out=at;
#if 0
	static char mess[10000];
	static char str[10000];
	mystrncpy(str,ret,len);
	sprintf(mess,"Token |%s|\n",str);
	OutputDebugString(mess);
#endif
	return ret;
}
Beispiel #23
0
void MakeFullPath(char *path,char *file,char *dest,uint32_t destsize)
{
   int d;
   char *chr;

   chr=OS_PATH_CHARS;

   mystrncpy(dest,path,destsize);
   d=strlen(dest);

   if(d != 0)
   {
      if(!strchr(chr,dest[d-1]))
         if(d+1 < destsize)
         {
            dest[d++]=(char)chr[0];
            dest[d]=0;
         }
   }

   if(destsize-d-1 > 0)
      mystrncpy(&dest[d],file,destsize-d-1);
}
Beispiel #24
0
void fcurrentdir(char *buffer, int size)
{


    int currentP;
    char *p;
    int len;
    char namebuffer[13];
    int i;
    char *q;
    p = buffer + size -1;
    *p = '\0';
    p--;


    currentP = getPwd();

    while (1)
    {


        getName(namebuffer, currentP);

        len = strlen(namebuffer);

        mystrncpy(p-len, namebuffer, len);

        *p = '/';

        p = p-len-1;

        currentP = read8uint(currentP, 31);

        if (currentP == 0)
            break;
    }

    *p = '/';

    len = buffer+size-1-p;

    q = buffer;
    for (i=0; i<len; i++)
        *q++ = *p++;
    q--;
    *q = '\0';

    return;
}
Beispiel #25
0
struct xlat *findpostxlat(struct var *var,uchar *ichrs,uchar *destpat)
{
   uchar chrs[20];
   struct xlat *xlat;
   struct xlatalias *xlatalias;
   
   mystrncpy(chrs,ichrs,20);
   
   /* Set charset if missing */
   
   if(chrs[0] == 0 && var->defaultpostchrs[0] != 0)
      mystrncpy(chrs,var->defaultpostchrs,20);
   
   /* Replace if an alias */      
                  
   for(xlatalias=var->firstpostalias;xlatalias;xlatalias=xlatalias->next)
      if(matchpattern(xlatalias->pattern,chrs)) break;
      
   if(xlatalias)
      mystrncpy(chrs,xlatalias->replace,20);
      
   /* Find in list */
      
   if(destpat)
   {
      for(xlat=var->firstpostxlat;xlat;xlat=xlat->next)
         if(matchpattern(xlat->fromchrs,chrs) && matchpattern(destpat,xlat->tochrs)) break;
   }
   else
   {
      for(xlat=var->firstpostxlat;xlat;xlat=xlat->next)
         if(matchpattern(xlat->fromchrs,chrs)) break;
   }
         
   return(xlat);
}
Beispiel #26
0
void command_user(char *username)
{

//printf("In command_user username=%s\n", username); // brcm

	// brcm char *alias;
	if (state) {
		control_printf(SL_FAILURE, "503 Username already given.");
		return;
	}
	mystrncpy(user, username, sizeof(user) - 1);
    userinfo_set = 1; /* Dirty! */
#if 0 // brcm 	
    alias = (char *) config_getoption("ALIAS");
    userinfo_set = 0;
	if (alias[0] != '\0')
		mystrncpy(user, alias, sizeof(user) - 1);
#endif //brcm
    init_userinfo();
#ifdef DEBUG
//	bftpd_log("Trying to log in as %s.\n", user);
#endif
#if 0 //brcm
    expand_groups();
	if (!strcasecmp(config_getoption("ANONYMOUS_USER"), "yes"))
		bftpd_login("");
	else {
		state = STATE_USER;
		control_printf(SL_SUCCESS, "331 Password please.");
	}
#endif //brcm
    state = STATE_USER; //brcm
	control_printf(SL_SUCCESS, "331 Password please."); //brcm

//printf("Done command_user username=%s\n", username); // brcm
}
Beispiel #27
0
//-------------------------------------------------------------------------
void reply_touch(uint8_t * receivebuffer)
{
    uint8_t blockid;
    char filename[13];
    uint8_t newblockid;

    blockid = receivebuffer[3];
    mystrncpy(filename, (char *)&receivebuffer[4], receivebuffer[0] - 4);
    filename[receivebuffer[0] - 4] = '\0';
    newblockid = createFileFromDirectory(filename, (int)blockid);
    reply[0] = 4;
    reply[1] = 151;
    reply[2] = nodeid;
    reply[3] = newblockid;
    StandardSocketSend(0xefef, 0xffff, 32, reply);
    //printStringN(reply,32);       
}
Beispiel #28
0
//-------------------------------------------------------------------------
void reply_mkdir(uint8_t * receivebuffer)
{
    uint8_t blockid;
    char dirname[13];
    uint8_t newblockid;

    blockid = receivebuffer[3];
    mystrncpy(dirname, (char *)&receivebuffer[4], receivebuffer[0] - 4);
    dirname[receivebuffer[0] - 4] = '\0';
    newblockid = createDir(dirname, (int)blockid);
    reply[0] = 4;
    reply[1] = 141;
    reply[2] = nodeid;
    reply[3] = newblockid;
	 sleepThread(20);
    StandardSocketSend(0xefef, 0xffff, 32, reply);
    // printStringN(reply,32);      
}
Beispiel #29
0
//-------------------------------------------------------------------------
void reply_ls_nodename(uint8_t * receivebuffer)
{
    uint8_t temp = receivebuffer[0] - 3;
    uint16_t randomsleep;

    if (mystrncmp((char *)receivebuffer, 3, (char *)networkid, 0, temp) == 0)
    {
        temp = mystrlen(filenameid);
        reply[0] = temp + 3;
        reply[1] = 102;
        reply[2] = nodeid;
        mystrncpy((char *)&reply[3], filenameid, temp);
        randomsleep = getRandomNumber() % 400;
        sleepThread(randomsleep);
        StandardSocketSend(0xefef, 0xffff, 32, reply);
        //printStringN(reply,32); 
    }
}
static void
test_strncpy (void)
{
  /* Testing is a bit different because of odd semantics.  */
  it = "strncpy";
  check (mystrncpy (one, "abc", 4) == one, 1);    /* Returned value. */
  equal (one, "abc", 2);                        /* Did the copy go right? */

  (void) strcpy (one, "abcdefgh");
  (void) mystrncpy (one, "xyz", 2);
  equal (one, "xycdefgh", 3);                   /* Copy cut by count. */

  (void) strcpy (one, "abcdefgh");
  (void) mystrncpy (one, "xyz", 3);               /* Copy cut just before NUL. */
  equal (one, "xyzdefgh", 4);

  (void) strcpy (one, "abcdefgh");
  (void) mystrncpy (one, "xyz", 4);               /* Copy just includes NUL. */
  equal (one, "xyz", 5);
  equal (one+4, "efgh", 6);                     /* Wrote too much? */

  (void) strcpy (one, "abcdefgh");
  (void) mystrncpy (one, "xyz", 5);               /* Copy includes padding. */
  equal (one, "xyz", 7);
  equal (one+4, "", 8);
  equal (one+5, "fgh", 9);

  (void) strcpy (one, "abc");
  (void) mystrncpy (one, "xyz", 0);               /* Zero-length copy. */
  equal (one, "abc", 10);

  (void) mystrncpy (one, "", 2);          /* Zero-length source. */
  equal (one, "", 11);
  equal (one+1, "", 12);
  equal (one+2, "c", 13);

  (void) strcpy (one, "hi there");
  (void) mystrncpy (two, one, 9);
  equal (two, "hi there", 14);          /* Just paranoia. */
  equal (one, "hi there", 15);          /* Stomped on source? */
}