"Fossies" - the Fresh Open Source Software Archive

Member "smslink-0.56b-3/server/gsmdevices.c" (15 Nov 2005, 21736 Bytes) of package /linux/misc/old/smslink-0.56b-3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gsmdevices.c" see the Fossies "Dox" file reference documentation.

    1 /*==========================================================
    2  * Program : gsmdevices.c                  Project : smslink
    3  * Author  : Philippe Andersson.
    4  * Date    : 12/01/05
    5  * Version : 0.17b
    6  * Notice  : Shamelessly copied from Riccardo Facchetti's modems.c
    7  *           in libmodem-1.0.0 (c) 1997 Riccardo Facchetti under GNU GPL.
    8  *           (c) Les Ateliers du Heron, 1998 for Scitex Europe, S.A.
    9  * Comment : Handling routines for /etc/gsmdevices database.
   10  *
   11  * Modification History :
   12  * - 0.01a (13/08/98) : Initial release.
   13  * ++++ Switched to Beta ++++
   14  * - 0.02b (29/03/00) : Modified /etc/gsmdevices record structure
   15  *   to hold the default sending mode. Adapted demangle_gsmdev_entry()
   16  *   accordingly.
   17  * - 0.03b (20/05/00) : Added translatemodname() function to
   18  *   handle to pseudo-driver file, and adapted demangle_gsmdev_entry()
   19  *   accordingly. Cosmetics.
   20  * - 0.04b (21/06/00) : Adapted translatemodname() and
   21  *   demangle_gsmdev_entry() to handle the new capmatrix structure.
   22  * - 0.05b (18/02/01) : Modified demangle_gsmdev_entry() to take
   23  *   the <flags> field into account (contributed by Andrew Worsley 
   24  *   <epaanwo@asac.ericsson.se>).
   25  * - 0.06b (20/02/01) : Modified demangle_gsmdev_entry() to support
   26  *   the "fast" flag. Cosmetics. Contributed by Andrew Worsley 
   27  *   <epaanwo@asac.ericsson.se>.
   28  * - 0.07b (03/03/01) : Replaced control of all debug info by 
   29  *   global flags.
   30  * - 0.08b (06/03/01) : Modified demangle_gsmdev_entry() to support
   31  *   the "r4" flag.
   32  * - 0.09b (31/03/01) : Modified translatemodname() to support
   33  *   the new modem_okay field + fixed a bug in processing the
   34  *   date format field.
   35  * - 0.10b (03/04/01) : Fixed a bug in the way the special
   36  *   characters were handled in the modem_okay field.
   37  * - 0.11b (04/04/01) : Modified translatemodname() to support
   38  *   the new line_sep field.
   39  * - 0.12b (20/03/01) : Modified demangle_gsmdev_entry() to support
   40  *   the "db" flag. 
   41  * - 0.13b (16/05/01) : Adapted demangle_gsmdev_entry() and
   42  *   translatemodname() to handle the new "model" field in
   43  *   struct gsms_def.
   44  * - 0.14b (02/03/02) : Modified translatemodname() to return
   45  *   -1 in case the requested model is not found in the driver
   46  *   file. Should have been that way all along.
   47  * - 0.15b (07/11/02) : Added support for "init" mode (contributed
   48  *   by Ing. Andrea Vettori <a.vettori@inetronics.com>).
   49  *   Improved dependencies handling in device-level flags.
   50  *   Moved gsmdevcpy() from serv_stuff.c to this file. Added
   51  *   handling of "PINpause" field. Added dd_busy field handling.
   52  * - 0.16b (12/09/04) : Corrected a string sizing bug in
   53  *   translatemodname().
   54  * - 0.17b (12/01/05) : Added support for 'skip' flag.
   55  *========================================================*/
   56 
   57 #include <stdio.h>
   58 #include <stdlib.h>
   59 #include <string.h>
   60 #include <sys/types.h>
   61 
   62 #include <dial/modems.h>
   63 #include <dial/mdmerrno.h>
   64 #include <termios.h>
   65 
   66 #include "sms_serv.h"
   67 #include "gsmdev.h"
   68 
   69 #define BUFSIZE     128
   70 
   71 /*========================================================*/
   72 /* For debugging purposes only - comment out for normal compile */
   73 /* #define INCL_DEBUG_CODE */
   74 
   75 /*========================================================*/
   76 /**********           GLOBAL VARIABLES             ********/
   77 /*========================================================*/
   78 extern int debug;                    /* debug level/flags */
   79 extern char *gsmdevfile;
   80 static int gsmdeventry = 0;
   81 static FILE *gsmdevfp;
   82 
   83 /*========================================================*/
   84 /**********               FUNCTIONS                ********/
   85 /*========================================================*/
   86 /*========================================================*/
   87 /*################# struct gsms_def handling #############*/
   88 /*========================================================*/
   89 int gsmdevcpy (struct gsms_def *dest, struct gsms_def *src)
   90 {
   91   if ((src != NULL) && (dest != NULL)) {
   92     dest->free = src->free;
   93     dest->owner = src->owner;
   94     dest->dd_busy = src->dd_busy;
   95     strcpy (dest->device, src->device);
   96     strcpy (dest->PIN, src->PIN);
   97     strcpy (dest->PUK, src->PUK);
   98     strcpy (dest->addr, src->addr);
   99     strcpy (dest->defsca, src->defsca);
  100     dest->PINpause = src->PINpause;
  101     strcpy (dest->provider, src->provider);
  102     strcpy (dest->model, src->model);
  103     dest->capmatrix.capflags = src->capmatrix.capflags;
  104     strcpy (dest->capmatrix.datefmt, src->capmatrix.datefmt);
  105     strcpy (dest->capmatrix.modem_okay, src->capmatrix.modem_okay);
  106     strcpy (dest->capmatrix.line_sep, src->capmatrix.line_sep);
  107     dest->defmode = src->defmode;
  108     dest->flags = src->flags;
  109     /* stats counter fields */
  110     dest->in_ok = src->in_ok;
  111     dest->in_fail = src->in_fail;
  112     dest->out_ok = src->out_ok;
  113     dest->out_fail = src->out_fail;
  114     dest->unlocked = src->unlocked;
  115     return (0);
  116   }
  117   else {
  118     return (-1);
  119   }
  120 }                                         /* gsmdevcpy () */
  121 /*========================================================*/
  122 int translatemodname (struct gsms_def *mdm, char *driverfilename)
  123 {
  124   FILE *driverfile;
  125   int found;
  126   int l;
  127   char *line;
  128   char *token;
  129   
  130   /*---------------------------------------Initialization */
  131   line = (char *) malloc ((BUFFSIZE + 1) * sizeof (char));
  132   if (! line) {
  133     fprintf (stderr, "sms_serv: in translatemodname(): can't malloc()\n");
  134     return (-1);
  135   }
  136   line[0] = '\0';
  137   found = FALSE;
  138   /*-------------------------------------Open driver file */
  139   if ((driverfile = fopen (driverfilename, "r")) == NULL) {
  140     fprintf (stderr, "sms_serv: in translatemodname(): can't fopen() %s\n",
  141             driverfilename);
  142     return (-1);
  143   }
  144   /*--------------------------------------Loop and search */
  145   while ((! found) && (fgets (line, BUFFSIZE, driverfile) != NULL)) {
  146     if ((line[0] != '#') && (line[0] != '\n') && (line[0] != '\0')){
  147       /* line is not a comment or a blank */
  148       if ((token = strtok (line, ":")) == NULL) {
  149         return (-1);
  150       }
  151       if (strcmp (token, mdm->model) == 0) {
  152         /* we've found it - let's extract the cap. matrix items */
  153         /*.......................................capflags */
  154     if ((token = strtok (NULL, ":")) == NULL) {
  155           return (-1);
  156         }
  157     mdm->capmatrix.capflags = atoi (token);
  158         if (debug & DEBUG_PRINTF) {
  159           fprintf (stderr, "GSM Model %s has cap. flags : [%d]\n", mdm->model,
  160               mdm->capmatrix.capflags);
  161         }
  162         /*....................................date format */
  163     if ((token = strtok (NULL, ":")) == NULL) {
  164           return (-1);
  165         }
  166     l = strlen (token);
  167     if (l) {
  168       if (l > 3) {
  169         strncpy (mdm->capmatrix.datefmt, token, 3);
  170       }
  171       else {
  172         strcpy (mdm->capmatrix.datefmt, token);
  173       }
  174     }
  175     else {
  176       /* empty field - let's default to 'dmy' */
  177       strcpy (mdm->capmatrix.datefmt, "dmy");
  178     }
  179         if (debug & DEBUG_PRINTF) {
  180           fprintf (stderr, "GSM Model %s has date format : [%s]\n", mdm->model,
  181               mdm->capmatrix.datefmt);
  182         }
  183         /*......................................OK string */
  184     if ((token = strtok (NULL, ":")) == NULL) {
  185           return (-1);
  186         }
  187     l = strlen (token);
  188     if (l) {
  189       spchar_pp (token);
  190       if (l > TINYBUFF) {
  191         strncpy (mdm->capmatrix.modem_okay, token, TINYBUFF);
  192         mdm->capmatrix.modem_okay[TINYBUFF] = '\0';
  193       }
  194       else {
  195         strcpy (mdm->capmatrix.modem_okay, token);
  196       }
  197     }
  198     else {
  199       /* empty field - let's default to MODEM_OKAY */
  200       strcpy (mdm->capmatrix.modem_okay, MODEM_OKAY);
  201     }
  202         if (debug & DEBUG_PRINTF) {
  203           fprintf (stderr, "GSM Model %s has OK string : [%s]\n", mdm->model,
  204               mdm->capmatrix.modem_okay);
  205       if (debug & DEBUG_HEXDUMP) {
  206         fprintf (stderr, "Hexdump of modem OK string:\n");
  207         dump_string (mdm->capmatrix.modem_okay);
  208       }
  209         }
  210         /*.................................line separator */
  211     if ((token = strtok (NULL, ":")) == NULL) {
  212           return (-1);
  213         }
  214     l = strlen (token);
  215     if (l) {
  216       spchar_pp (token);
  217       if (l > 2) {
  218         strncpy (mdm->capmatrix.line_sep, token, 2);
  219         mdm->capmatrix.line_sep[2] = '\0';
  220       }
  221       else {
  222         strcpy (mdm->capmatrix.line_sep, token);
  223       }
  224     }
  225     else {
  226       /* empty field - let's default to CRLF */
  227       strcpy (mdm->capmatrix.modem_okay, "\r\n");
  228     }
  229         if (debug & DEBUG_PRINTF) {
  230           fprintf (stderr, "GSM Model %s has line separator string : [%s]\n",
  231               mdm->model, mdm->capmatrix.line_sep);
  232       if (debug & DEBUG_HEXDUMP) {
  233         fprintf (stderr, "Hexdump of modem line_sep string:\n");
  234         dump_string (mdm->capmatrix.line_sep);
  235       }
  236         }
  237     /*................................................*/
  238         /* last field (model name) is ignored */
  239     /*................................................*/
  240     found = TRUE;
  241       }
  242     }                              /* if (line[0] != '#') */
  243   }                                    /* while (fgets... */
  244   /*------------------------------------------Conclusions */
  245   fclose (driverfile);
  246   free (line);
  247   if (found) {
  248     return (0);
  249   }
  250   else {
  251     return (-1);
  252   }
  253 }                                  /* translatemodname () */
  254 /*========================================================*/
  255 static int open_gsmdevs (void)
  256 /*
  257  * open/close_gsmdevs: open and close the /etc/gsmdevices file
  258  */
  259 {
  260     if ((gsmdevfp = fopen (gsmdevfile, "r")) == NULL)
  261         return FAILURE;
  262     return SUCCESS;
  263 }                                      /* open_gsmdevs () */
  264 /*========================================================*/
  265 static void close_gsmdevs (void)
  266 {
  267     fclose (gsmdevfp);
  268 }                                     /* close_gsmdevs () */
  269 /*========================================================*/
  270 struct gsms_def *getgsmdevbynam (char *line)
  271 /*
  272  * getgsmdevbynam: returns a pointer to the gsmdev entry named
  273  *            (char *) line, NULL if line is not present in
  274  *            /etc/gsmdevices.
  275  */
  276 {
  277     static struct gsms_def mdm;
  278     char *buffer;
  279 
  280     buffer = mdmalloc(BUFSIZE);
  281 
  282     if (!buffer) {
  283     mdmerrno = -EMDMEM;
  284     return NULL;
  285     }
  286 
  287     mdmerrno = 0;
  288 
  289     if (open_gsmdevs() == FAILURE) {
  290     mdmfree (buffer);
  291         mdmerrno = -ENOMDMFILE;
  292         return NULL;
  293     }
  294 
  295     while (fgets (buffer, BUFSIZE, gsmdevfp) != NULL) {
  296         buffer[strlen (buffer) - 1] = '\0';
  297 
  298         if (buffer[0] == '#' || buffer[0] == '\0' || buffer[0] == '\n')
  299             continue;
  300 
  301         if (demangle_gsmdev_entry (&mdm, buffer) == FAILURE) {
  302             mdmerrno = -EMDMBADCONF;
  303             continue;
  304         }
  305         if (!strcmp (mdm.device, line)) {
  306             close_gsmdevs ();
  307         mdmfree (buffer);
  308             return (&mdm);
  309         }
  310     }
  311     close_gsmdevs ();
  312     mdmerrno = -ENOMDMLINE;
  313     return NULL;
  314 }                                    /* getgsmdevbynam () */
  315 /*========================================================*/
  316 int getgsmdevscount (int validation)
  317 /*
  318  * getgsmdevscount: count the number of valid (?) entries in
  319  *            /etc/gsmdevices.
  320  */
  321 {
  322     static struct gsms_def mdm;
  323     char *buffer;
  324     int nvalidentries = 0;
  325 
  326     buffer = mdmalloc(BUFSIZE);
  327 
  328     if (!buffer) {
  329     mdmerrno = -EMDMEM;
  330     return (0);
  331     }
  332 
  333     mdmerrno = 0;
  334 
  335     if (open_gsmdevs() == FAILURE) {
  336     mdmfree (buffer);
  337         mdmerrno = -ENOMDMFILE;
  338         return (0);
  339     }
  340 
  341     while (fgets (buffer, BUFSIZE, gsmdevfp) != NULL) {
  342         buffer[strlen (buffer) - 1] = '\0';
  343 
  344         if (buffer[0] == '#' || buffer[0] == '\0' || buffer[0] == '\n')
  345             continue;
  346 
  347         if (validation && (demangle_gsmdev_entry (&mdm, buffer) == FAILURE)) {
  348             mdmerrno = -EMDMBADCONF;
  349             continue;
  350         }
  351     nvalidentries++;
  352     }
  353     close_gsmdevs ();
  354     return (nvalidentries);
  355 }                                   /* getgsmdevscount () */
  356 /*========================================================*/
  357 void setgsmdevs (void)
  358 /*
  359  * setgsmdevs: set the library for modem sequential search from the first to the
  360  *          end. See getnextgsmdev ().
  361  */
  362 {
  363     gsmdeventry = 0;
  364 }                                        /* setgsmdevs () */
  365 /*========================================================*/
  366 struct gsms_def *getnextgsmdev (void)
  367 /*
  368  * getnextgsmdev: get the next modem entry in /etc/gsmdevices
  369  *             file returns NULL if we are over the last entry.
  370  */
  371 {
  372     static struct gsms_def mdm;
  373     int i = 0;
  374     char *buffer;
  375 
  376     buffer = mdmalloc (BUFSIZE);
  377 
  378     if (!buffer) {
  379     mdmerrno = -EMDMEM;
  380     return NULL;
  381     }
  382 
  383 
  384     mdmerrno = 0;
  385 
  386     if (open_gsmdevs () == FAILURE) {
  387     mdmfree (buffer);
  388         mdmerrno = -ENOMDMFILE;
  389         return NULL;
  390     }
  391 
  392     while (fgets (buffer, BUFSIZE, gsmdevfp) != NULL) {
  393         buffer[strlen (buffer) - 1] = '\0';
  394 
  395         if (buffer[0] == '#' || buffer[0] == '\0' || buffer[0] == '\n')
  396             continue;
  397 
  398         if (i == gsmdeventry) {
  399             if (demangle_gsmdev_entry (&mdm, buffer) == FAILURE) {
  400                 mdmerrno = -EMDMBADCONF;
  401                 continue;
  402             }
  403             gsmdeventry++;
  404             close_gsmdevs ();
  405         mdmfree (buffer);
  406             return (&mdm);
  407         }
  408         i++;
  409     }
  410     close_gsmdevs ();
  411     mdmfree(buffer);
  412     return NULL;
  413 }                                     /* getnextgsmdev () */
  414 /*========================================================*/
  415 static int demangle_gsmdev_entry (struct gsms_def *mdm, char *mdmstr)
  416 /*
  417  * demangle_gsmdev_entry: get a gsmdev pointer that point to an existing
  418  * gsm_def structure and a string to demangle. Returns FAILURE or SUCCESS.
  419  * The buffer pointed to by mdmstr is modified in the process.
  420  */
  421 {
  422     char *ptr, *pptr, *errptr;
  423     int more = 0;
  424 
  425     if (debug & DEBUG_PRINTF) {
  426       fprintf (stderr, "raw gsmdev entry: '%s'\n", mdmstr);
  427     }
  428     /*------------------------------------Initialisations */
  429     /*.........................................mdm->flags */
  430     /* set default value for flags: (poll mode | inbox) */
  431     mdm->flags = SMS_INBOX;
  432 
  433     /*....................................mdm->free (int) */
  434     /* is left uninitialized - dynamic data */
  435     
  436     /*-----------------------------------------Processing */
  437     /*...............................mdm->device (char *) */
  438     if ((ptr = strchr (mdmstr, ':')) == NULL)
  439         return (FAILURE);
  440     *ptr = '\0';
  441     if ((strlen (mdmstr) == 0) || (strlen (mdmstr) > MAXDEVLEN))
  442         return (FAILURE);
  443     strcpy (mdm->device, mdmstr);
  444     ptr++;
  445 
  446     /*..................................mdm->PIN (char *) */
  447     if (*ptr == ':') {
  448         /* empty field */
  449         mdm->PIN[0] = '\0';
  450         *ptr = '\0';
  451         ptr++;
  452     }
  453     else {
  454         if ((pptr = strchr (ptr, ':')) == NULL)
  455             return (FAILURE);
  456         *pptr = '\0';
  457         if (strlen (ptr) > PINLEN)
  458             return (FAILURE);
  459     strcpy (mdm->PIN, ptr);
  460         ptr = pptr + 1;
  461     }
  462 
  463     /*..................................mdm->PUK (char *) */
  464     if (*ptr == ':') {
  465         /* empty field */
  466         mdm->PUK[0] = '\0';
  467         *ptr = '\0';
  468         ptr++;
  469     }
  470     else {
  471         if ((pptr = strchr (ptr, ':')) == NULL)
  472             return (FAILURE);
  473         *pptr = '\0';
  474         if (strlen (ptr) > PUKLEN)
  475             return (FAILURE);
  476         strcpy (mdm->PUK, ptr);
  477         ptr = pptr + 1;
  478     }
  479 
  480     /*.................................mdm->addr (char *) */
  481     if (*ptr == ':') {
  482         /* empty field */
  483         mdm->addr[0] = '\0';
  484         *ptr = '\0';
  485         ptr++;
  486     }
  487     else {
  488         if ((pptr = strchr (ptr, ':')) == NULL)
  489             return (FAILURE);
  490         *pptr = '\0';
  491         if (strlen (ptr) > MAXPHNUMLEN)
  492             return (FAILURE);
  493         strcpy (mdm->addr, ptr);
  494         ptr = pptr + 1;
  495     }
  496 
  497     /*...............................mdm->defsca (char *) */
  498     if (*ptr == ':') {
  499         /* empty field */
  500         mdm->defsca[0] = '\0';
  501         *ptr = '\0';
  502         ptr++;
  503     }
  504     else {
  505         if ((pptr = strchr (ptr, ':')) == NULL)
  506             return (FAILURE);
  507         *pptr = '\0';
  508         if (strlen (ptr) > MAXPHNUMLEN)
  509             return (FAILURE);
  510         strcpy (mdm->defsca, ptr);
  511         ptr = pptr + 1;
  512     }
  513 
  514     /*.................................mdm->defmode (int) */
  515     if (*ptr == ':') {
  516         /* empty field */
  517         mdm->defmode = SMS_MODE_DEFAULT;
  518         *ptr = '\0';
  519         ptr++;
  520     }
  521     else {
  522         if ((pptr = strchr (ptr, ':')) == NULL)
  523             return (FAILURE);
  524         *pptr = '\0';
  525         if (strlen (ptr) == 0)
  526             return (FAILURE);
  527         mdm->defmode = strtol (ptr, &errptr, 0);
  528     if (*errptr != '\0')
  529             return (FAILURE);
  530         ptr = pptr + 1;
  531     }
  532 
  533     /*................................mdm->PINpause (int) */
  534     if (*ptr == ':') {
  535         /* empty field */
  536         mdm->PINpause = SMS_PINPAUSE_DEFAULT;
  537         *ptr = '\0';
  538         ptr++;
  539     }
  540     else {
  541         if ((pptr = strchr (ptr, ':')) == NULL)
  542             return (FAILURE);
  543         *pptr = '\0';
  544         if (strlen (ptr) == 0)
  545             return (FAILURE);
  546         mdm->PINpause = strtol (ptr, &errptr, 0);
  547     if (*errptr != '\0')
  548             return (FAILURE);
  549         ptr = pptr + 1;
  550     }
  551 
  552     /*.....................................mdm->capmatrix */
  553     if (*ptr == ':') {
  554         /* empty field */
  555         mdm->capmatrix.capflags = 0;
  556     mdm->capmatrix.datefmt[0] = '\0';
  557         *ptr = '\0';
  558         ptr++;
  559     }
  560     else {
  561         if ((pptr = strchr (ptr, ':')) == NULL)
  562             return (FAILURE);
  563         *pptr = '\0';
  564         if (strlen (ptr) > MAXMODLEN)
  565             return (FAILURE);
  566         strcpy (mdm->model, ptr);
  567     /* Now translate model into capacity matrix */
  568     if ((translatemodname (mdm, GSMCAPS_FILE)) == -1) {
  569       return (FAILURE);
  570     }
  571         ptr = pptr + 1;
  572     }
  573 
  574     /*.............................mdm->provider (char *) */
  575     /*                   !!! Last field when no flags !!! */
  576     if (*ptr == '\n' || *ptr == '\0' || *ptr == ':') {
  577         mdm->provider[0] = '\0';
  578     if (*ptr != ':') {
  579         /* was the last field - no flags */
  580         return (SUCCESS);
  581     }
  582     ptr++;                    /* go on to flags field */
  583     }
  584     else {
  585         if (pptr = strchr (ptr, ':'))
  586         *pptr = '\0';
  587         if (strlen (ptr) > MAXDEVLEN)
  588             return (FAILURE);
  589         strcpy (mdm->provider, ptr);
  590         if (debug & DEBUG_PRINTF) {
  591           fprintf (stderr, "Provider : [%s]\n", mdm->provider);
  592         }
  593     if (pptr)
  594         ptr = pptr + 1;
  595     else
  596         ptr = 0;
  597     }
  598 
  599     /*...................................mdm->flags (int) */
  600     if (ptr != 0 && *ptr != '\n' && *ptr != '\0' && *ptr != ':') {
  601       if (debug & DEBUG_PRINTF) {
  602         fprintf (stderr, "GSM Model %s has flags field : [%s]\n",
  603             mdm->model, ptr);
  604       }
  605       mdm->flags = 0; /* explicitly specifying flags so zero all flags */
  606       do {
  607     size_t i = strcspn (ptr, ":,\n");
  608     more = 0;
  609     if (i > 0) {
  610       pptr = ptr + i;
  611       if (*pptr == ',') /* more flags */
  612         more = 1;
  613       *pptr = '\0';
  614     }
  615         if (debug & DEBUG_PRINTF) {
  616           fprintf (stderr, "processing flag=%s flags = [%d]\n", ptr, mdm->flags);
  617         }
  618     /* could use a table in the future here for future options */
  619     /* could use strncasecmp(), and check for optional '=' character
  620      * which could be used to specify extra info such as program to
  621      * run for SMS_PROG or mail box file for SMS_INBOX et cetera 
  622      */
  623     if (strcasecmp (ptr, "dd") == 0) {
  624       /* dd mode excludes init mode */
  625       if (mdm->flags & SMS_INIT) {
  626         mdm->flags &= ~SMS_INIT;
  627         fprintf (stderr, "Warning: dd mode conflicts with init mode, overrides it\n");
  628       }
  629       mdm->flags |= DEDICATED_DAEMON;
  630     }
  631     else if (strcasecmp (ptr, "init") == 0) {
  632       /* init mode excludes dd mode */
  633       if (mdm->flags & DEDICATED_DAEMON) {
  634         mdm->flags &= ~DEDICATED_DAEMON;
  635         fprintf (stderr, "Warning: init mode conflicts with dd mode, overrides it\n");
  636       }
  637       mdm->flags |= SMS_INIT;
  638     }
  639     else if (strcasecmp (ptr, "poll") == 0) {
  640       /* poll mode excludes dd mode */
  641       if (mdm->flags & DEDICATED_DAEMON) {
  642         mdm->flags &= ~DEDICATED_DAEMON;
  643         fprintf (stderr, "Warning: poll mode conflicts with dd mode, overrides it\n");
  644       }
  645       /* poll mode excludes init mode */
  646       if (mdm->flags & SMS_INIT) {
  647         mdm->flags &= ~SMS_INIT;
  648         fprintf (stderr, "Warning: poll mode conflicts with init mode, overrides it\n");
  649       }
  650       mdm->flags |= POLL_DEVICE;
  651     }
  652     else if (strcasecmp (ptr, "inbox") == 0) {
  653       mdm->flags |= SMS_INBOX;
  654     }
  655     else if (strcasecmp (ptr, "prog") == 0) {
  656       mdm->flags |= SMS_PROG;
  657     }
  658     else if (strcasecmp (ptr, "db") == 0) {
  659       mdm->flags |= SMS_DB;
  660     }
  661     else if (strcasecmp (ptr, "fast") == 0) {
  662       mdm->flags |= FAST_RESPONSE;
  663     }
  664     else if (strcasecmp (ptr, "r4") == 0) {
  665       mdm->flags |= SMS_READ_ALL;
  666     }
  667     else if (strcasecmp (ptr, "skip") == 0) {
  668       /* skip option excludes inbox mode */
  669       if (mdm->flags & SMS_INBOX) {
  670         mdm->flags &= ~SMS_INBOX;
  671         fprintf (stderr, "Warning: skip option conflicts with inbox mode, overrides it\n");
  672       }
  673       /* skip option excludes db mode */
  674       if (mdm->flags & SMS_DB) {
  675         mdm->flags &= ~SMS_DB;
  676         fprintf (stderr, "Warning: skip option conflicts with db mode, overrides it\n");
  677       }
  678       /* skip option excludes prog mode */
  679       if (mdm->flags & SMS_PROG) {
  680         mdm->flags &= ~SMS_PROG;
  681         fprintf (stderr, "Warning: skip option conflicts with prog mode, overrides it\n");
  682       }
  683       mdm->flags |= SMS_SKIP;
  684     }
  685     else {
  686       return (FAILURE);
  687     }
  688 
  689     ptr = pptr + 1;
  690 
  691       } while (more);
  692     }
  693     if (debug & DEBUG_PRINTF) {
  694       fprintf (stderr, "flags are now: [%d]\n", mdm->flags);
  695     }
  696 
  697     /*----------------------------------------Conclusions */
  698     return (SUCCESS);
  699 }                             /* demangle_gsmdev_entry () */
  700 /*==========================================================
  701  * EOF : gsmdevices.c
  702  *===================*/