Recent content by James889

  1. James889

    Getpwnam no such file or directory

    There seems to be a similar situation with the hashed password found in master.password and the hash generated by crypt(), they are different, despite hashing being done on the same clear text password. In this case there are no trailing newlines.
  2. James889

    Getpwnam no such file or directory

    Duh, silly newbie mistake :)
  3. James889

    Getpwnam no such file or directory

    Hi, I'm trying to write a simple authentication plugin which authenticates a user against /etc/master.passwd. The problem is the call to getpwnam() which fails with 'no such file or directory' Relevant code below char username[10]; memset(username,0,sizeof(username)); /* Read the username */...
  4. James889

    What are the issues with this code for reversing a string in memory?

    Ok, so after a bit of fiddling i finally managed to come up with a version that works(not saying anything about code quality etc ;) ) char *reverse(char *buf){ /* Allocate enough memory for the string */ int length = strlen(buf); char *ptr = calloc(length,sizeof(char)); char **p2p...
  5. James889

    What are the issues with this code for reversing a string in memory?

    void reverse(char *buf){ unsigned int strlen = 0; /* Allocate memory for the reversed string */ char *ptr; ptr = (char *)malloc(100); /* Find the length of the string in the buffer */ while( *buf++ != '\0'){ strlen++; } /* Copy */ for(strlen;strlen>0;strlen--){ *ptr++ = *buf--...
  6. James889

    What are the issues with this code for reversing a string in memory?

    So why do i get different results from *buf and **bufptr ?
  7. James889

    What are the issues with this code for reversing a string in memory?

    One thing i don't understand. The statement 'char **bufptr = buf' and putchar(bufptr) whould print out the same output as putchar(buf). But it doesn't. Why? char *reverse(char *buf){ /* Allocate memory for the reversed string */ char *ptr = (char *)malloc(100); char...
  8. James889

    What are the issues with this code for reversing a string in memory?

    Hi, I'm trying to write a simple program for reversing a string stored in memory. This is what I've come up with. For some reason this code coredumps, so something is wrong. any ideas ? #include <stdio.h> #include <string.h> #include <stdlib.h> char *reverse(char *buf,unsigned...
  9. James889

    How Can I Add Support for Multiple Client Connections to my TCP Server?

    Hi, I have a simple tcp server, to which i would like to add support for multiple client connections via pthreads. This is what i had in mind, calling accept in a separate thread. I this similar to what you would do? . . . int sock = socket(PF_INET,SOCK_STREAM,0); int...
  10. James889

    What Does This Regular Expression Mean?

    Is this the same as saying 'match as much as possible up until a white space is found' ?
  11. James889

    What Does This Regular Expression Mean?

    Howdy, I came across a regular expression i couldn't get my head around. ' there \([^ ]*\)' echo "Howdy there neighbor" | sed 's/there \([^ ]*\)//' returns howdy. It's the subgroup that's a bit confusing. match any sentence which contains banana then a space and then a non-space character...
  12. James889

    Designing a Scalable C Chat Server

    Ouch, sounds difficult.
  13. James889

    Designing a Scalable C Chat Server

    Hi, I developed a simple ad-hoc client/server chat program, however the design isn't exactly scalable since the addresses are hard coded and one of the clients is also the server. So i wanted to write a dedicated server, to which multiple clients could connect and chat, like irssi.. how...
  14. James889

    C - Print connecting clients address

    Hi, I'm currently trying to implement a simple client server program in C. Needless to say i ran into troubles, and being a novice, i turned here for some advice. I have a function to print the connecting peers address. I don't even know if this is the right way of doing it. For...
  15. James889

    Calculating Interest with Recursive Function

    That's why these small exercises are so useful, you always learn something.
Back
Top