[BACK]Return to opt.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sndiod

Diff for /src/usr.bin/sndiod/opt.c between version 1.2 and 1.3

version 1.2, 2012/12/07 08:04:58 version 1.3, 2016/01/08 10:54:07
Line 14 
Line 14 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #include <stdio.h>  
 #include <stdlib.h>  
 #include <string.h>  #include <string.h>
   
 #include "dev.h"  #include "dev.h"
Line 32 
Line 30 
     int pmin, int pmax, int rmin, int rmax,      int pmin, int pmax, int rmin, int rmax,
     int maxweight, int mmc, int dup, unsigned int mode)      int maxweight, int mmc, int dup, unsigned int mode)
 {  {
         struct opt *o, **po;          struct opt *o;
         unsigned int len;          unsigned int len;
         char c;          char c;
   
           if (opt_byname(name, dev->num)) {
                   log_puts(name);
                   log_puts(": already defined\n");
                   return NULL;
           }
         for (len = 0; name[len] != '\0'; len++) {          for (len = 0; name[len] != '\0'; len++) {
                 if (len == OPT_NAMEMAX) {                  if (len == OPT_NAMEMAX) {
                         fprintf(stderr, "%s: name too long\n", name);                          log_puts(name);
                         exit(1);                          log_puts(": too long\n");
                           return NULL;
                 }                  }
                 c = name[len];                  c = name[len];
                 if ((c < 'a' || c > 'z') &&                  if ((c < 'a' || c > 'z') &&
                     (c < 'A' || c > 'Z')) {                      (c < 'A' || c > 'Z')) {
                         fprintf(stderr, "%s: '%c' not allowed\n", name, c);                          log_puts(name);
                         exit(1);                          log_puts(": only alphabetic chars allowed\n");
                           return NULL;
                 }                  }
         }          }
         o = xmalloc(sizeof(struct opt));          o = xmalloc(sizeof(struct opt));
Line 63 
Line 68 
         o->mode = mode;          o->mode = mode;
         o->dev = dev;          o->dev = dev;
         memcpy(o->name, name, len + 1);          memcpy(o->name, name, len + 1);
         for (po = &opt_list; *po != NULL; po = &(*po)->next) {          o->next = opt_list;
                 if (o->dev->num == (*po)->dev->num &&          opt_list = o;
                     strcmp(o->name, (*po)->name) == 0) {  
                         fprintf(stderr, "%s: already defined\n", o->name);  
                         exit(1);  
                 }  
         }  
         o->next = NULL;  
         *po = o;  
         if (log_level >= 2) {          if (log_level >= 2) {
                 dev_log(o->dev);                  dev_log(o->dev);
                 log_puts(".");                  log_puts(".");

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3