OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
enqueue.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "PGS_SMF.h"
3 #include "PGS_MODIS_35005.h"
4 #include "FP_failed_pkt_queue.h"
5 
6 
7 PGSt_SMF_status enqueue ( char *item, FP_QUEUE_t Q )
8 
9 /*
10 !C************************************************************************
11 
12 !Description: Puts the item on the end of the queue.
13 
14 !Input Parameters:
15  char *item ** The item to put on the **
16  ** end of the queue **
17 
18 !Output Parameters:
19  None
20 
21 !Input/Output Parameters:
22  FP_QUEUE_t Q ** The FIFO queue on which **
23  ** to put the item **
24 
25 Return Values:
26  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
27  MODIS_E_MALLOC_FAILED (PGS_MODIS_35005.h)
28 
29 Externally Defined:
30  PGSt_SMF_status (PGS_SMF.h)
31  FP_QUEUE_t (FP_failed_pkt_queue.h)
32 
33 Called By:
34  accumulate_failed_packets
35 
36 Routines Called:
37  log_fmt_msg
38 
39 !Revision History:
40  Revision 1.0 1997/09/15 10:35
41  Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov)
42  Original code.
43 
44 !Team-unique Header:
45  This software is developed by the MODIS Science
46  Data Support Team (SDST) for the National Aeronautics
47  and Space Administration (NASA), Goddard Space Flight
48  Center (GSFC), under contract NAS5-32373.
49 
50 !References and Credits:
51  None
52 
53 !Design Notes:
54  None
55 
56 !END************************************************************************
57 */
58 
59 {
60 
61  /***************************************************************************/
62  /* Declare and Initialize Local Variables */
63  /***************************************************************************/
64 
65  PGSt_SMF_status returnStatus; /* SMF-style message returned by function */
66  char *routine = "enqueue";
67  node_ptr tmp_cell;
68 
69  /***************************************************************************/
70 
71 
72  /***************************************************************************/
73  /* */
74  /* set routine to "enqueue" (done during declaration) */
75  /* set returnStatus to MODIS_S_SUCCESS */
76  /* */
77  /***************************************************************************/
78 
79  returnStatus = MODIS_S_SUCCESS;
80 
81 
82  /***************************************************************************/
83  /* */
84  /* Dynamically allocate memory for the next item (tmp_cell) in the queue */
85  /* */
86  /* IF unable to allocate memory */
87  /* THEN */
88  /* Set msg to "unable to allocate memory" */
89  /* Set returnStatus to MODIS_E_MALLOC_FAILED */
90  /* CALL log_fmt_msg to report the memory allocation error */
91  /* INPUTS: logStatus, routine, msg */
92  /* OUTPUTS: None */
93  /* RETURN: None */
94  /* */
95  /* ELSE */
96  /* Set tmp_cell.element to item */
97  /* Set tmp_cell.prev to Q.tail.prev */
98  /* Set Q.tail.prev.next to tmp_cell */
99  /* Set Q.tail.prev to tmp_cell */
100  /* Set tmp_cell.next to Q.tail */
101  /* */
102  /* ENDIF */
103  /* */
104  /***************************************************************************/
105 
106  tmp_cell = (node_ptr) malloc( sizeof ( struct node ) );
107  if (tmp_cell == NULL)
108  {
109  returnStatus = MODIS_E_MALLOC_FAILED;
111  "Unable to allocate the failed packets linked list node");
112  }
113 
114  else
115  {
116  tmp_cell->element = item;
117  tmp_cell->prev = Q->tail->prev;
118  Q->tail->prev->next = tmp_cell;
119  Q->tail->prev = tmp_cell;
120  tmp_cell->next = Q->tail;
121  }
122 
123 
124  /***************************************************************************/
125  /* */
126  /* RETURN returnStatus */
127  /* */
128  /***************************************************************************/
129 
130  return (returnStatus);
131 
132 }
#define NULL
Definition: decode_rs.h:63
#define MODIS_E_MALLOC_FAILED
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
PGSt_SMF_status enqueue(char *item, FP_QUEUE_t Q)
Definition: enqueue.c:7
#define MODIS_S_SUCCESS